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  const word& name = Y[i].name();
41  if (fractions.found(name))
42  {
43  X0[i] = fractions.get<scalar>(name);
44  }
45  }
46 
47  scalar mw = 0.0;
48  const scalar mTot = sum(X0);
49  forAll(Y, i)
50  {
51  X0[i] /= mTot;
52  mw += specieData[i].W()*X0[i];
53  }
54 
55  forAll(Y, i)
56  {
57  Y0[i] = X0[i]*specieData[i].W()/mw;
58  }
59  }
60  else // mass fraction
61  {
62  forAll(Y, i)
63  {
64  const word& name = Y[i].name();
65  if (fractions.found(name))
66  {
67  Y0[i] = fractions.get<scalar>(name);
68  }
69  }
70 
71  scalar invW = 0.0;
72  const scalar mTot = sum(Y0);
73  forAll(Y, i)
74  {
75  Y0[i] /= mTot;
76  invW += Y0[i]/specieData[i].W();
77  }
78  const scalar mw = 1.0/invW;
79 
80  forAll(Y, i)
81  {
82  X0[i] = Y0[i]*mw/specieData[i].W();
83  }
84  }
85 
86  scalar h0 = 0.0;
87  forAll(Y, i)
88  {
89  Y[i] = Y0[i];
90  h0 += Y0[i]*specieData[i].Hs(p[0], T0);
91  }
92 
94  thermo.correct();
95 
96  rho = thermo.rho();
97  scalar rho0 = rho[0];
98  scalar u0 = h0 - p0/rho0;
99  scalar R0 = p0/(rho0*T0);
100  Rspecific[0] = R0;
101 
102  scalar integratedHeat = 0.0;
103 
104  Info << constProp << " will be held constant." << nl
105  << " p = " << p[0] << " [Pa]" << nl
106  << " T = " << thermo.T()[0] << " [K] " << nl
107  << " rho = " << rho[0] << " [kg/m3]" << nl
108  << endl;
Foam::scalarList
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:64
mw
const scalar mw
Definition: readInitialConditions.H:78
p
volScalarField & p
Definition: createFieldRefs.H:8
Rspecific
Rspecific[0]
Definition: readInitialConditions.H:100
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::dimEnergy
const dimensionSet dimEnergy
X0
scalarList X0(nSpecie, Zero)
forAll
forAll(specieData, i)
Definition: readInitialConditions.H:19
h0
scalar h0
Definition: readInitialConditions.H:86
fractions
dictionary fractions(initialConditions.subDict("fractions"))
fractionBasis
word fractionBasis(initialConditions.get< word >("fractionBasis"))
nSpecie
label nSpecie
Definition: readInitialConditions.H:17
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
specieData
PtrList< gasHThermoPhysics > specieData(Y.size())
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
rho
rho
Definition: readInitialConditions.H:96
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
Foam::FatalError
error FatalError
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
Foam::gasHThermoPhysics
sutherlandTransport< species::thermo< janafThermo< perfectGas< specie > >, sensibleEnthalpy > > gasHThermoPhysics
Definition: thermoPhysicsTypes.H:88
rho0
scalar rho0
Definition: readInitialConditions.H:97
integratedHeat
scalar integratedHeat
Definition: readInitialConditions.H:102
Foam::nl
constexpr char nl
Definition: Ostream.H:372
u0
scalar u0
Definition: readInitialConditions.H:98
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:327
constProp
word constProp(initialConditions.get< word >("constantProperty"))
Y0
scalarList Y0(nSpecie, Zero)
p0
const volScalarField & p0
Definition: EEqn.H:36
mTot
const scalar mTot
Definition: readInitialConditions.H:72
T0
scalar T0
Definition: createFields.H:22
R0
scalar R0
Definition: readInitialConditions.H:99