readInitialConditions.H
Go to the documentation of this file.
1  word constProp(initialConditions.get<word>("constantProperty"));
2  if (constProp != "pressure" && constProp != "volume")
3  {
4  FatalError << "in initialConditions, unknown constantProperty type "
5  << constProp << nl << " Valid types are: pressure volume."
6  << abort(FatalError);
7  }
8 
9  word fractionBasis(initialConditions.get<word>("fractionBasis"));
10  if (fractionBasis != "mass" && fractionBasis != "mole")
11  {
12  FatalError << "in initialConditions, unknown fractionBasis type " << nl
13  << "Valid types are: mass or mole."
15  }
16 
17  label nSpecie = Y.size();
18  PtrList<gasHThermoPhysics> specieData(Y.size());
20  {
21  specieData.set
22  (
23  i,
25  (
26  dynamic_cast<const reactingMixture<gasHThermoPhysics>&>
27  (thermo).speciesData()[i]
28  )
29  );
30  }
31 
34 
35  dictionary fractions(initialConditions.subDict("fractions"));
36  if (fractionBasis == "mole")
37  {
38  forAll(Y, i)
39  {
40  fractions.readIfPresent(Y[i].name(), X0[i]);
41  }
42 
43  scalar mw = 0.0;
44  const scalar mTot = sum(X0);
45  forAll(Y, i)
46  {
47  X0[i] /= mTot;
48  mw += specieData[i].W()*X0[i];
49  }
50 
51  forAll(Y, i)
52  {
53  Y0[i] = X0[i]*specieData[i].W()/mw;
54  }
55  }
56  else // mass fraction
57  {
58  forAll(Y, i)
59  {
60  fractions.readIfPresent(Y[i].name(), Y0[i]);
61  }
62 
63  scalar invW = 0.0;
64  const scalar mTot = sum(Y0);
65  forAll(Y, i)
66  {
67  Y0[i] /= mTot;
68  invW += Y0[i]/specieData[i].W();
69  }
70  const scalar mw = 1.0/invW;
71 
72  forAll(Y, i)
73  {
74  X0[i] = Y0[i]*mw/specieData[i].W();
75  }
76  }
77 
78  scalar h0 = 0.0;
79  forAll(Y, i)
80  {
81  Y[i] = Y0[i];
82  h0 += Y0[i]*specieData[i].Hs(p[0], T0);
83  }
84 
86  thermo.correct();
87 
88  rho = thermo.rho();
89  scalar rho0 = rho[0];
90  scalar u0 = h0 - p0/rho0;
91  scalar R0 = p0/(rho0*T0);
92  Rspecific[0] = R0;
93 
94  scalar integratedHeat = 0.0;
95 
96  Info << constProp << " will be held constant." << nl
97  << " p = " << p[0] << " [Pa]" << nl
98  << " T = " << thermo.T()[0] << " [K] " << nl
99  << " rho = " << rho[0] << " [kg/m3]" << nl
100  << endl;
List< scalar > scalarList
List of scalar.
Definition: scalarList.H:32
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
scalarList Y0(nSpecie, Zero)
const scalar mTot
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
forAll(specieData, i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
scalar rho0
scalar integratedHeat
const scalar mw
psiReactionThermo & thermo
Definition: createFields.H:28
label nSpecie
scalar u0
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
word fractionBasis(initialConditions.get< word >("fractionBasis"))
errorManip< error > abort(error &err)
Definition: errorManip.H:139
word constProp(initialConditions.get< word >("constantProperty"))
const dimensionSet dimEnergy
scalarList X0(nSpecie, Zero)
PtrList< gasHThermoPhysics > specieData(Y.size())
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
PtrList< volScalarField > & Y
scalar R0
messageStream Info
Information stream (stdout output on master, null elsewhere)
dictionary fractions(initialConditions.subDict("fractions"))
Rspecific[0]
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
volScalarField & p
scalar h0
const volScalarField & p0
Definition: EEqn.H:36
scalar T0
Definition: createFields.H:22
sutherlandTransport< species::thermo< janafThermo< perfectGas< specie > >, sensibleEnthalpy > > gasHThermoPhysics
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127