Skip to content

Commit acec855

Browse files
authored
fix energy equation and change convection term in dfHighSpeedFoam, add new example for dfHighSpeedFoam (#287)
* fix energy equation and change convection term in dfHighSpeedFoam, add new example for dfHighSpeedFoam * Update dfLowMachFoam.C * fix dfLowMachFoam and dfSprayFoam * fix df0DFoam and dfSprayFoam * fix df0DFoam and dfSprayFoam * Update CanteraMixture.C, fix name * fix dfLowMachFoam, df0DFoam and dfSprayFoam
1 parent 9492e60 commit acec855

41 files changed

Lines changed: 1671 additions & 58 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

applications/solvers/df0DFoam/createFields.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Info<< "Reading thermophysical properties\n" << endl;
66
fluidThermo* pThermo = new heRhoThermo<rhoThermo, CanteraMixture>(mesh, word::null);
77
fluidThermo& thermo = *pThermo;
88

9-
thermo.validate(args.executable(), "ha");
9+
// thermo.validate(args.executable(), "ha");
1010

1111
volScalarField& p = thermo.p();
1212

@@ -94,6 +94,8 @@ dfChemistryModel<basicThermo> chemistry(thermo);
9494
PtrList<volScalarField>& Y = chemistry.Y();
9595
const word inertSpecie(chemistry.lookup("inertSpecie"));
9696
const label inertIndex(chemistry.species()[inertSpecie]);
97+
chemistry.setEnergyName("ha");
98+
chemistry.updateEnergy();
9799

98100
forAll(Y, i)
99101
{

applications/solvers/dfHighSpeedFoam/createFields.H

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dictionary thermoDict
2929
)
3030
);
3131

32-
bool inviscid(thermoDict.lookup("inviscid"));
32+
bool inviscid(thermoDict.lookupOrDefault("inviscid",false));
3333

3434
Info<< "Reading field U\n" << endl;
3535
volVectorField U
@@ -58,9 +58,6 @@ volScalarField rho
5858
thermo.rho()
5959
);
6060

61-
volScalarField e = thermo.he() - p/rho;
62-
volScalarField& ha = thermo.he();
63-
6461
volVectorField rhoU
6562
(
6663
IOobject
@@ -74,19 +71,6 @@ volVectorField rhoU
7471
rho*U
7572
);
7673

77-
volScalarField rhoE
78-
(
79-
IOobject
80-
(
81-
"rhoE",
82-
runTime.timeName(),
83-
mesh,
84-
IOobject::NO_READ,
85-
IOobject::NO_WRITE
86-
),
87-
rho*(e + 0.5*magSqr(U))
88-
);
89-
9074
surfaceScalarField pos
9175
(
9276
IOobject
@@ -140,6 +124,22 @@ const label inertIndex(chemistry->species()[inertSpecie]);
140124
chemistry->setEnergyName("ea");
141125
chemistry->updateEnergy();
142126

127+
volScalarField& ea = thermo.he();
128+
volScalarField ha = ea + p/rho;
129+
130+
volScalarField rhoE
131+
(
132+
IOobject
133+
(
134+
"rhoE",
135+
runTime.timeName(),
136+
mesh,
137+
IOobject::NO_READ,
138+
IOobject::NO_WRITE
139+
),
140+
rho*(ea + 0.5*magSqr(U))
141+
);
142+
143143
chemistry->correctThermo();
144144
Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl;
145145

@@ -149,6 +149,28 @@ forAll(Y, i)
149149
}
150150
fields.add(thermo.he());
151151

152+
const label nspecies(chemistry->species().size());
153+
PtrList<volScalarField> rhoYi(nspecies);
154+
forAll(rhoYi,i)
155+
{
156+
rhoYi.set
157+
(
158+
i,
159+
new volScalarField
160+
(
161+
IOobject
162+
(
163+
"rhoYi" + Y[i].name(),
164+
runTime.timeName(),
165+
mesh,
166+
IOobject::NO_READ,
167+
IOobject::NO_WRITE
168+
),
169+
rho*Y[i]
170+
)
171+
);
172+
}
173+
152174
const scalar Sct = chemistry->lookupOrDefault("Sct", 1.);
153175
volScalarField diffAlphaD
154176
(

applications/solvers/dfHighSpeedFoam/dfHighSpeedFoam.C

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,57 @@ int main(int argc, char *argv[])
132132
surfaceScalarField rho_pos(interpolate(rho, pos));
133133
surfaceScalarField rho_neg(interpolate(rho, neg));
134134

135+
PtrList<surfaceScalarField> rhoYi_pos(nspecies);
136+
PtrList<surfaceScalarField> rhoYi_neg(nspecies);
137+
forAll(rhoYi_pos,i)
138+
{
139+
rhoYi_pos.set
140+
(
141+
i,
142+
new surfaceScalarField
143+
(
144+
IOobject
145+
(
146+
"rhoYi_pos" + Y[i].name(),
147+
runTime.timeName(),
148+
mesh,
149+
IOobject::NO_READ,
150+
IOobject::NO_WRITE
151+
),
152+
interpolate(rhoYi[i], pos,"Yi")
153+
)
154+
);
155+
}
156+
157+
forAll(rhoYi_neg,i)
158+
{
159+
rhoYi_neg.set
160+
(
161+
i,
162+
new surfaceScalarField
163+
(
164+
IOobject
165+
(
166+
"rhoYi_neg" + Y[i].name(),
167+
runTime.timeName(),
168+
mesh,
169+
IOobject::NO_READ,
170+
IOobject::NO_WRITE
171+
),
172+
interpolate(rhoYi[i], neg,"Yi")
173+
)
174+
);
175+
}
176+
135177
surfaceVectorField rhoU_pos(interpolate(rhoU, pos, U.name()));
136178
surfaceVectorField rhoU_neg(interpolate(rhoU, neg, U.name()));
137179

138180
volScalarField rPsi("rPsi", 1.0/psi);
139181
surfaceScalarField rPsi_pos(interpolate(rPsi, pos, T.name()));
140182
surfaceScalarField rPsi_neg(interpolate(rPsi, neg, T.name()));
141183

142-
surfaceScalarField e_pos(interpolate(e, pos, T.name()));
143-
surfaceScalarField e_neg(interpolate(e, neg, T.name()));
184+
surfaceScalarField ea_pos(interpolate(ea, pos, T.name()));
185+
surfaceScalarField ea_neg(interpolate(ea, neg, T.name()));
144186

145187
surfaceVectorField U_pos("U_pos", rhoU_pos/rho_pos);
146188
surfaceVectorField U_neg("U_neg", rhoU_neg/rho_neg);
@@ -217,6 +259,27 @@ int main(int argc, char *argv[])
217259

218260
phi = aphiv_pos*rho_pos + aphiv_neg*rho_neg;
219261

262+
PtrList<surfaceScalarField> phiYi(nspecies);
263+
forAll(phiYi,i)
264+
{
265+
phiYi.set
266+
(
267+
i,
268+
new surfaceScalarField
269+
(
270+
IOobject
271+
(
272+
"phiYi_" + Y[i].name(),
273+
runTime.timeName(),
274+
mesh,
275+
IOobject::NO_READ,
276+
IOobject::NO_WRITE
277+
),
278+
aphiv_pos*rhoYi_pos[i] + aphiv_neg*rhoYi_neg[i]
279+
)
280+
);
281+
}
282+
220283
surfaceVectorField phiUp
221284
(
222285
(aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg)
@@ -226,8 +289,8 @@ int main(int argc, char *argv[])
226289
surfaceScalarField phiEp
227290
(
228291
"phiEp",
229-
aphiv_pos*(rho_pos*(e_pos + 0.5*magSqr(U_pos)) + p_pos)
230-
+ aphiv_neg*(rho_neg*(e_neg + 0.5*magSqr(U_neg)) + p_neg)
292+
aphiv_pos*(rho_pos*(ea_pos + 0.5*magSqr(U_pos)) + p_pos)
293+
+ aphiv_neg*(rho_neg*(ea_neg + 0.5*magSqr(U_neg)) + p_neg)
231294
+ aSf*p_pos - aSf*p_neg
232295
);
233296

applications/solvers/dfHighSpeedFoam/rhoEEqn.H

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ solve
1515
- fvc::div(sigmaDotU)
1616
);
1717

18-
e = rhoE/rho - 0.5*magSqr(U);
19-
e.correctBoundaryConditions();
18+
ea = rhoE/rho - 0.5*magSqr(U);
19+
ea.correctBoundaryConditions();
2020

21-
ha = e + p/rho;
21+
ha = ea + p/rho;
2222
chemistry->correctThermo(); // before this, we must update ha = e + p/rho
2323

24-
rhoE.boundaryFieldRef() == rho.boundaryField()*(e.boundaryField() + 0.5*magSqr(U.boundaryField()));
24+
rhoE.boundaryFieldRef() == rho.boundaryField()*(ea.boundaryField() + 0.5*magSqr(U.boundaryField()));
2525

2626
if (!inviscid)
2727
{
2828
fvScalarMatrix eEqn
2929
(
30-
fvm::ddt(rho, e) - fvc::ddt(rho, e)
30+
fvm::ddt(rho, ea) - fvc::ddt(rho, ea)
3131
// alpha in deepflame is considered to calculate h by default (kappa/Cp), so multiply gamma to correct alpha
32-
- fvm::laplacian(turbulence->alphaEff()*thermo.gamma(), e)
32+
- fvm::laplacian(turbulence->alphaEff()*thermo.gamma(), ea)
3333
+ diffAlphaD
3434
==
3535
fvc::div(hDiffCorrFlux)
3636
);
3737

38-
eEqn.solve("e");
38+
eEqn.solve("ea");
3939

40-
ha = e + p/rho;
40+
ha = ea + p/rho;
4141
chemistry->correctThermo();
42-
rhoE = rho*(e + 0.5*magSqr(U));
42+
rhoE = rho*(ea + 0.5*magSqr(U));
4343
}
4444

4545
Info<< "min/max(T) = "

applications/solvers/dfHighSpeedFoam/rhoYEqn.H

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,63 @@ tmp<fv::convectionScheme<scalar>> mvConvection
3737
{
3838
volScalarField& Yi = Y[i];
3939

40+
if (!inviscid)
41+
{
42+
hDiffCorrFlux += chemistry->hai(i)*(chemistry->rhoD(i)*fvc::grad(Yi) - Yi*sumYDiffError);
43+
diffAlphaD += fvc::laplacian(thermo.alpha()*chemistry->hai(i), Yi);
44+
}
45+
4046
if (i != inertIndex)
4147
{
42-
fvScalarMatrix YiEqn
48+
// original convection term
49+
// fvScalarMatrix YiEqn
50+
// (
51+
// fvm::ddt(rho, Yi)
52+
// + mvConvection->fvmDiv(phi, Yi)
53+
// ==
54+
// combustion->R(Yi)
55+
// );
56+
57+
solve
4358
(
44-
fvm::ddt(rho, Yi)
45-
+ mvConvection->fvmDiv(phi, Yi)
46-
==
47-
combustion->R(Yi)
59+
fvm::ddt(rhoYi[i])
60+
+ fvc::div(phiYi[i])
61+
==
62+
chemistry->RR(i)
4863
);
4964

65+
Yi=rhoYi[i]/rho;
66+
Yi.max(0.0);
67+
5068
if (!inviscid)
5169
{
5270
const surfaceScalarField phiUc = linearInterpolate(sumYDiffError) & mesh.Sf();
53-
54-
hDiffCorrFlux += chemistry->hai(i)*(chemistry->rhoD(i)*fvc::grad(Yi) - Yi*sumYDiffError);
55-
diffAlphaD += fvc::laplacian(thermo.alpha()*chemistry->hai(i), Yi);
5671
tmp<volScalarField> DEff = chemistry->rhoD(i) + turbulence->mut()/Sct;
5772

58-
YiEqn -= fvm::laplacian(DEff(), Yi) - mvConvection->fvmDiv(phiUc, Yi);
59-
}
73+
// original term
74+
// YiEqn -= fvm::laplacian(DEff(), Yi) - mvConvection->fvmDiv(phiUc, Yi);
6075

61-
YiEqn.relax();
76+
fvScalarMatrix YiEqn
77+
(
78+
fvm::ddt(rho, Yi) - fvc::ddt(rho, Yi)
79+
- fvm::laplacian(DEff(), Yi)
80+
+ mvConvection->fvmDiv(phiUc, Yi)
81+
);
6282

63-
YiEqn.solve("Yi");
83+
YiEqn.relax();
6484

65-
Yi.max(0.0);
85+
YiEqn.solve("Yi");
86+
87+
Yi.max(0.0);
88+
89+
}
90+
91+
// original term
92+
// YiEqn.relax();
93+
// YiEqn.solve("Yi");
94+
// Yi.max(0.0);
95+
96+
rhoYi[i] = rho*Yi;
6697
Yt += Yi;
6798
}
6899
}

applications/solvers/dfLowMachFoam/EEqn.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
EEqn.relax();
2727

28-
EEqn.solve();
28+
EEqn.solve("ha");
2929

3030

3131
}

applications/solvers/dfLowMachFoam/createFields.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Info<< "Reading thermophysical properties\n" << endl;
55
// fluidThermo* pThermo = new hePsiThermo<psiThermo, CanteraMixture>(mesh, word::null);
66
fluidThermo* pThermo = new heRhoThermo<rhoThermo, CanteraMixture>(mesh, word::null);
77
fluidThermo& thermo = *pThermo;
8-
thermo.validate(args.executable(), "ha");
8+
// thermo.validate(args.executable(), "ha");
99

1010
const volScalarField& psi = thermo.psi();
1111
volScalarField& p = thermo.p();
@@ -89,6 +89,8 @@ dfChemistryModel<basicThermo>* chemistry = combustion->chemistry();
8989
PtrList<volScalarField>& Y = chemistry->Y();
9090
const word inertSpecie(chemistry->lookup("inertSpecie"));
9191
const label inertIndex(chemistry->species()[inertSpecie]);
92+
chemistry->setEnergyName("ha");
93+
chemistry->updateEnergy();
9294

9395

9496
chemistry->correctThermo();

applications/solvers/dfLowMachFoam/dfLowMachFoam.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int main(int argc, char *argv[])
196196
rho = thermo.rho();
197197

198198
runTime.write();
199-
199+
200200
Info<< "========Time Spent in diffenet parts========"<< endl;
201201
Info<< "Chemical sources = " << time_monitor_chem << " s" << endl;
202202
Info<< "Species Equations = " << time_monitor_Y << " s" << endl;

applications/solvers/dfSprayFoam/EEqn.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
//fvOptions.constrain(EEqn);
5050

51-
EEqn.solve();
51+
EEqn.solve("ha");
5252

5353
//fvOptions.correct(he);
5454

applications/solvers/dfSprayFoam/createFields.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Info<< "Reading thermophysical properties\n" << endl;
44
// fluidThermo* pThermo = new hePsiThermo<psiThermo, CanteraMixture>(mesh, word::null);
55
fluidThermo* pThermo = new heRhoThermo<rhoThermo, CanteraMixture>(mesh, word::null);
66
fluidThermo& thermo = *pThermo;
7-
thermo.validate(args.executable(), "ha");
7+
// thermo.validate(args.executable(), "ha");
88

99
SLGThermo slgThermo(mesh, thermo);
1010

@@ -88,6 +88,8 @@ dfChemistryModel<basicThermo>* chemistry = combustion->chemistry();
8888
PtrList<volScalarField>& Y = chemistry->Y();
8989
const word inertSpecie(chemistry->lookup("inertSpecie"));
9090
const label inertIndex(chemistry->species()[inertSpecie]);
91+
chemistry->setEnergyName("ha");
92+
chemistry->updateEnergy();
9193

9294

9395
chemistry->correctThermo();

0 commit comments

Comments
 (0)