inhomogeneousEGRMixture.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class ThermoType>
32 (
33  const dictionary& dict
34 )
35 :
36  stoicRatio_("stoichiometricAirFuelMassRatio", dimless, dict),
37  fuel_("fuel", dict.subDict("fuel")),
38  oxidant_("oxidant", dict.subDict("oxidant")),
39  products_("burntProducts", dict.subDict("burntProducts")),
40  mixture_("mixture", fuel_)
41 {}
42 
43 
44 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
45 
46 template<class ThermoType>
48 (
49  const scalarFieldListSlice& Y
50 ) const
51 {
52  return max(Y[FT] - (1 - Y[FT] - Y[EGR])/stoicRatio_.value(), 0);
53 }
54 
55 
56 template<class ThermoType>
58 (
59  const scalar ft,
60  const scalar fu,
61  const scalar egr
62 ) const
63 {
64  if (ft < 0.0001 && egr < 0.0001)
65  {
66  return oxidant_;
67  }
68  else
69  {
70  const scalar ox = 1 - ft - egr - (ft - fu)*stoicRatio_.value();
71  const scalar pr = 1 - fu - ox;
72 
73  mixture_ = fu*fuel_;
74  mixture_ += ox*oxidant_;
75  mixture_ += pr*products_;
76 
77  return mixture_;
78  }
79 }
80 
81 
82 template<class ThermoType>
85 (
86  const scalarFieldListSlice& Y
87 ) const
88 {
89  return mixture(Y[FT], Y[FU], Y[EGR]);
90 }
91 
92 
93 template<class ThermoType>
96 (
97  const scalarFieldListSlice& Y
98 ) const
99 {
100  return mixture(Y[FT], Y[FU], Y[EGR]);
101 }
102 
103 
104 template<class ThermoType>
107 (
108  const scalarFieldListSlice&,
110 ) const
111 {
112  return mixture;
113 }
114 
115 
116 template<class ThermoType>
119 (
120  const scalarFieldListSlice& Y
121 ) const
122 {
123  return mixture(Y[FT], Y[FT], Y[EGR]);
124 }
125 
126 
127 template<class ThermoType>
130 (
131  const scalarFieldListSlice& Y
132 ) const
133 {
134  return mixture(Y[FT], fres(Y), Y[EGR]);
135 }
136 
137 
138 template<class ThermoType>
140 (
142 ) const
143 {
144  const volScalarField& fu = Y[FU];
145  volScalarField& ft = Y[FT];
146  volScalarField& b = Y[B];
147  volScalarField& egr = Y[EGR];
148 
149  for (label i=0; i<=fu.nOldTimes(); i++)
150  {
151  egr.oldTimeRef(i) += (ft.oldTime(i) - fu.oldTime(i))*(1 + stoicRatio_);
152  ft.oldTimeRef(i) = fu.oldTime(i);
153  b.oldTimeRef(i) = 1;
154  }
155 }
156 
157 
158 template<class ThermoType>
160 {
161  stoicRatio_ =
162  dimensionedScalar("stoichiometricAirFuelMassRatio", dimless, dict);
163 
164  fuel_ = ThermoType("fuel", dict.subDict("fuel"));
165  oxidant_ = ThermoType("oxidant", dict.subDict("oxidant"));
166  products_ = ThermoType("burntProducts", dict.subDict("burntProducts"));
167 }
168 
169 
170 // ************************************************************************* //
Generic GeometricField class.
label nOldTimes(const bool includeNull=true) const
Return the number of old-time fields stored.
Definition: OldTimeField.C:298
const Field0Type & oldTime() const
Return the old-time field.
Definition: OldTimeField.C:322
Field0Type & oldTimeRef()
Return a non-const reference to the old-time field.
Definition: OldTimeField.C:362
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:849
const thermoType & products(const scalarFieldListSlice &) const
Return the product mixture.
const thermoType & reactants(const scalarFieldListSlice &) const
Return the reactant mixture.
const thermoMixtureType & thermoMixture(const scalarFieldListSlice &) const
Return the mixture for thermodynamic properties.
ThermoType thermoType
The type of thermodynamics this mixture is instantiated for.
inhomogeneousEGRMixture(const dictionary &)
Construct from a dictionary.
ThermoType transportMixtureType
Mixing type for transport properties.
scalar fres(const scalarFieldListSlice &Y) const
Return the residual fraction of fuel in the burnt mixture.
ThermoType thermoMixtureType
Mixing type for thermodynamic properties.
const transportMixtureType & transportMixture(const scalarFieldListSlice &) const
Return the mixture for transport properties.
void read(const dictionary &)
Read dictionary.
void reset(PtrList< volScalarField > &Y) const
Reset the mixture to an unburnt state and update EGR.
const thermoType & mixture(const scalar ft, const scalar fu, const scalar egr) const
Return the mixture for the given composition.
volScalarField & b
Definition: createFields.H:27
static const coefficient B("B", dimless, 18.678)
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:59
const dimensionSet dimless
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict
PtrList< volScalarField > & Y