StandardChemistryModel.H
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) 2011-2019 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 Class
25  Foam::StandardChemistryModel
26 
27 Description
28  Extends base chemistry model by adding a thermo package, and ODE functions.
29  Introduces chemistry equation system and evaluation of chemical source
30  terms.
31 
32 SourceFiles
33  StandardChemistryModelI.H
34  StandardChemistryModel.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef StandardChemistryModel_H
39 #define StandardChemistryModel_H
40 
41 #include "BasicChemistryModel.H"
42 #include "Reaction.H"
43 #include "ODESystem.H"
44 #include "volFields.H"
45 #include "simpleMatrix.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward declaration of classes
53 class fvMesh;
54 
55 /*---------------------------------------------------------------------------*\
56  Class StandardChemistryModel Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 template<class ReactionThermo, class ThermoType>
61 :
62  public BasicChemistryModel<ReactionThermo>,
63  public ODESystem
64 {
65  // Private Member Functions
66 
67  //- Solve the reaction system for the given time step
68  // of given type and return the characteristic time
69  template<class DeltaTType>
70  scalar solve(const DeltaTType& deltaT);
71 
72 
73 protected:
74 
75  typedef ThermoType thermoType;
76 
77 
78  // Protected data
79 
80  //- Reference to the field of specie mass fractions
82 
83  //- Reactions
85 
86  //- Thermodynamic data of the species
88 
89  //- Number of species
91 
92  //- Number of reactions
94 
95  //- Temperature below which the reaction rates are assumed 0
96  scalar Treact_;
97 
98  //- List of reaction rate per specie [kg/m^3/s]
100 
101  //- Temporary concentration field
102  mutable scalarField c_;
103 
104  //- Temporary rate-of-change of concentration field
105  mutable scalarField dcdt_;
106 
107 
108  // Protected Member Functions
109 
110  //- Write access to chemical source terms
111  // (e.g. for multi-chemistry model)
113 
114 
115 public:
116 
117  //- Runtime type information
118  TypeName("standard");
119 
120 
121  // Constructors
122 
123  //- Construct from thermo
124  StandardChemistryModel(ReactionThermo& thermo);
125 
126  //- Disallow default bitwise copy construction
128 
129 
130  //- Destructor
131  virtual ~StandardChemistryModel();
132 
133 
134  // Member Functions
135 
136  //- The reactions
137  inline const PtrList<Reaction<ThermoType>>& reactions() const;
138 
139  //- Thermodynamic data of the species
140  inline const PtrList<ThermoType>& specieThermo() const;
141 
142  //- The number of species
143  virtual inline label nSpecie() const;
144 
145  //- The number of reactions
146  virtual inline label nReaction() const;
147 
148  //- Temperature below which the reaction rates are assumed 0
149  inline scalar Treact() const;
150 
151  //- Temperature below which the reaction rates are assumed 0
152  inline scalar& Treact();
153 
154  //- dc/dt = omega, rate of change in concentration, for each species
155  virtual void omega
156  (
157  const scalarField& c,
158  const scalar T,
159  const scalar p,
160  scalarField& dcdt
161  ) const;
162 
163 
164  //- Return the reaction rate for iReaction and the reference
165  // species and charateristic times
166  virtual scalar omegaI
167  (
168  label iReaction,
169  const scalarField& c,
170  const scalar T,
171  const scalar p,
172  scalar& pf,
173  scalar& cf,
174  label& lRef,
175  scalar& pr,
176  scalar& cr,
177  label& rRef
178  ) const;
179 
180  //- Calculates the reaction rates
181  virtual void calculate();
182 
183 
184  // Chemistry model functions (overriding abstract functions in
185  // basicChemistryModel.H)
186 
187  //- Return const access to the chemical source terms for specie, i
188  inline const volScalarField::Internal& RR
189  (
190  const label i
191  ) const;
192 
193  //- Return non const access to chemical source terms [kg/m^3/s]
195  (
196  const label i
197  );
198 
199  //- Return reaction rate of the speciei in reactionI
201  (
202  const label reactionI,
203  const label speciei
204  ) const;
205 
206  //- Solve the reaction system for the given time step
207  // and return the characteristic time
208  virtual scalar solve(const scalar deltaT);
209 
210  //- Solve the reaction system for the given time step
211  // and return the characteristic time
212  virtual scalar solve(const scalarField& deltaT);
213 
214  //- Return the chemical time scale
215  virtual tmp<volScalarField> tc() const;
216 
217  //- Return the heat release rate [kg/m/s^3]
218  virtual tmp<volScalarField> Qdot() const;
219 
220 
221  // ODE functions (overriding abstract functions in ODE.H)
222 
223  //- Number of ODE's to solve
224  inline virtual label nEqns() const;
225 
226  virtual void derivatives
227  (
228  const scalar t,
229  const scalarField& c,
230  scalarField& dcdt
231  ) const;
232 
233  virtual void jacobian
234  (
235  const scalar t,
236  const scalarField& c,
237  scalarField& dcdt,
239  ) const;
240 
241  virtual void solve
242  (
243  scalarField &c,
244  scalar& T,
245  scalar& p,
246  scalar& deltaT,
247  scalar& subDeltaT
248  ) const = 0;
249 
250 
251  // Member Operators
252 
253  //- Disallow default bitwise assignment
254  void operator=(const StandardChemistryModel&) = delete;
255 };
256 
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 } // End namespace Foam
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #include "StandardChemistryModelI.H"
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #ifdef NoRepository
269  #include "StandardChemistryModel.C"
270 #endif
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 #endif
275 
276 // ************************************************************************* //
virtual label nSpecie() const
The number of species.
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
Basic chemistry model templated on thermodynamics.
virtual tmp< volScalarField > Qdot() const
Return the heat release rate [kg/m/s^3].
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
ReactionThermo & thermo()
Return access to the thermo package.
virtual scalar omegaI(label iReaction, const scalarField &c, const scalar T, const scalar p, scalar &pf, scalar &cf, label &lRef, scalar &pr, scalar &cr, label &rRef) const
Return the reaction rate for iReaction and the reference.
scalarField dcdt_
Temporary rate-of-change of concentration field.
const PtrList< ThermoType > & specieThermo() const
Thermodynamic data of the species.
label nSpecie_
Number of species.
PtrList< volScalarField::Internal > RR_
List of reaction rate per specie [kg/m^3/s].
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
void operator=(const StandardChemistryModel &)=delete
Disallow default bitwise assignment.
const PtrList< Reaction< ThermoType > > & reactions() const
The reactions.
virtual void calculate()
Calculates the reaction rates.
virtual void jacobian(const scalar t, const scalarField &c, scalarField &dcdt, scalarSquareMatrix &J) const
Calculate the Jacobian of the system.
scalar Treact() const
Temperature below which the reaction rates are assumed 0.
scalar Treact_
Temperature below which the reaction rates are assumed 0.
virtual ~StandardChemistryModel()
Destructor.
scalarField c_
Temporary concentration field.
StandardChemistryModel(ReactionThermo &thermo)
Construct from thermo.
virtual void derivatives(const scalar t, const scalarField &c, scalarField &dcdt) const
Calculate the derivatives in dydx.
PtrList< volScalarField > & Y_
Reference to the field of specie mass fractions.
label nReaction_
Number of reactions.
const PtrList< ThermoType > & specieThermo_
Thermodynamic data of the species.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
PtrList< volScalarField::Internal > & RR()
Write access to chemical source terms.
virtual tmp< volScalarField::Internal > calculateRR(const label reactionI, const label speciei) const
Return reaction rate of the speciei in reactionI.
const PtrList< Reaction< ThermoType > > & reactions_
Reactions.
virtual tmp< volScalarField > tc() const
Return the chemical time scale.
virtual label nEqns() const
Number of ODE&#39;s to solve.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
const dimensionedScalar c
Speed of light in a vacuum.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
TypeName("standard")
Runtime type information.
virtual label nReaction() const
The number of reactions.
Namespace for OpenFOAM.
virtual void omega(const scalarField &c, const scalar T, const scalar p, scalarField &dcdt) const
dc/dt = omega, rate of change in concentration, for each species