chemistryModel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2017 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::chemistryModel
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  chemistryModelI.H
34  chemistryModel.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef chemistryModel_H
39 #define chemistryModel_H
40 
41 #include "Reaction.H"
42 #include "ODESystem.H"
43 #include "volFields.H"
44 #include "simpleMatrix.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of classes
52 class fvMesh;
53 
54 /*---------------------------------------------------------------------------*\
55  Class chemistryModel Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class CompType, class ThermoType>
59 class chemistryModel
60 :
61  public CompType,
62  public ODESystem
63 {
64  // Private Member Functions
65 
66  //- Solve the reaction system for the given time step
67  // of given type and return the characteristic time
68  template<class DeltaTType>
69  scalar solve(const DeltaTType& deltaT);
70 
71  //- Disallow copy constructor
73 
74  //- Disallow default bitwise assignment
75  void operator=(const chemistryModel&);
76 
77 
78 protected:
79 
80  typedef ThermoType thermoType;
81 
82  // Protected data
83 
84  //- Reference to the field of specie mass fractions
86 
87  //- Reactions
89 
90  //- Thermodynamic data of the species
92 
93  //- Number of species
95 
96  //- Number of reactions
98 
99  //- Temperature below which the reaction rates are assumed 0
100  scalar Treact_;
101 
102  //- List of reaction rate per specie [kg/m3/s]
104 
105  //- Temporary concentration field
106  mutable scalarField c_;
107 
108  //- Temporary rate-of-change of concentration field
109  mutable scalarField dcdt_;
110 
111 
112  // Protected Member Functions
113 
114  //- Write access to chemical source terms
115  // (e.g. for multi-chemistry model)
117 
118 
119 public:
120 
121  //- Runtime type information
122  TypeName("chemistryModel");
123 
124 
125  // Constructors
126 
127  //- Construct from mesh
128  chemistryModel(const fvMesh& mesh, const word& phaseName);
129 
130 
131  //- Destructor
132  virtual ~chemistryModel();
133 
134 
135  // Member Functions
136 
137  //- The reactions
138  inline const PtrList<Reaction<ThermoType>>& reactions() const;
139 
140  //- Thermodynamic data of the species
141  inline const PtrList<ThermoType>& specieThermo() const;
142 
143  //- The number of species
144  virtual inline label nSpecie() const;
145 
146  //- The number of reactions
147  virtual inline label nReaction() const;
148 
149  //- Temperature below which the reaction rates are assumed 0
150  inline scalar Treact() const;
151 
152  //- Temperature below which the reaction rates are assumed 0
153  inline scalar& Treact();
154 
155  //- dc/dt = omega, rate of change in concentration, for each species
156  virtual void omega
157  (
158  const scalarField& c,
159  const scalar T,
160  const scalar p,
161  scalarField& dcdt
162  ) const;
163 
164  //- Return the reaction rate for reaction r and the reference
165  // species and charateristic times
166  virtual scalar omega
167  (
168  const Reaction<ThermoType>& r,
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 
181  //- Return the reaction rate for iReaction and the reference
182  // species and charateristic times
183  virtual scalar omegaI
184  (
185  label iReaction,
186  const scalarField& c,
187  const scalar T,
188  const scalar p,
189  scalar& pf,
190  scalar& cf,
191  label& lRef,
192  scalar& pr,
193  scalar& cr,
194  label& rRef
195  ) const;
196 
197  //- Calculates the reaction rates
198  virtual void calculate();
199 
200 
201  // Chemistry model functions (overriding abstract functions in
202  // basicChemistryModel.H)
203 
204  //- Return const access to the chemical source terms for specie, i
205  inline const volScalarField::Internal& RR
206  (
207  const label i
208  ) const;
209 
210  //- Return non const access to chemical source terms [kg/m3/s]
212  (
213  const label i
214  );
215 
216  //- Return reaction rate of the speciei in reactionI
218  (
219  const label reactionI,
220  const label speciei
221  ) const;
222 
223  //- Solve the reaction system for the given time step
224  // and return the characteristic time
225  virtual scalar solve(const scalar deltaT);
226 
227  //- Solve the reaction system for the given time step
228  // and return the characteristic time
229  virtual scalar solve(const scalarField& deltaT);
230 
231  //- Return the chemical time scale
232  virtual tmp<volScalarField> tc() const;
233 
234  //- Return the heat release rate [kg/m/s3]
235  virtual tmp<volScalarField> Qdot() const;
236 
237 
238  // ODE functions (overriding abstract functions in ODE.H)
239 
240  //- Number of ODE's to solve
241  inline virtual label nEqns() const;
242 
243  virtual void derivatives
244  (
245  const scalar t,
246  const scalarField& c,
247  scalarField& dcdt
248  ) const;
249 
250  virtual void jacobian
251  (
252  const scalar t,
253  const scalarField& c,
254  scalarField& dcdt,
255  scalarSquareMatrix& dfdc
256  ) const;
257 
258  virtual void solve
259  (
260  scalarField &c,
261  scalar& T,
262  scalar& p,
263  scalar& deltaT,
264  scalar& subDeltaT
265  ) const = 0;
266 };
267 
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 } // End namespace Foam
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 #include "chemistryModelI.H"
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #ifdef NoRepository
280  #include "chemistryModel.C"
281 #endif
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #endif
286 
287 // ************************************************************************* //
virtual tmp< volScalarField::Internal > calculateRR(const label reactionI, const label speciei) const
Return reaction rate of the speciei in reactionI.
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.
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
PtrList< volScalarField > & Y_
Reference to the field of specie mass fractions.
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:46
virtual tmp< volScalarField > tc() const
Return the chemical time scale.
scalar Treact_
Temperature below which the reaction rates are assumed 0.
virtual void jacobian(const scalar t, const scalarField &c, scalarField &dcdt, scalarSquareMatrix &dfdc) const
Calculate the Jacobian of the system.
PtrList< volScalarField::Internal > & RR()
Write access to chemical source terms.
const PtrList< ThermoType > & specieThermo() const
Thermodynamic data of the species.
virtual ~chemistryModel()
Destructor.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:53
scalarField dcdt_
Temporary rate-of-change of concentration field.
virtual label nSpecie() const
The number of species.
label nReaction_
Number of reactions.
label nSpecie_
Number of species.
dynamicFvMesh & mesh
A class for handling words, derived from string.
Definition: word.H:59
scalarField c_
Temporary concentration field.
scalar Treact() const
Temperature below which the reaction rates are assumed 0.
TypeName("chemistryModel")
Runtime type information.
virtual label nEqns() const
Number of ODE&#39;s to solve.
const PtrList< ThermoType > & specieThermo_
Thermodynamic data of the species.
virtual label nReaction() const
The number of reactions.
PtrList< volScalarField::Internal > RR_
List of reaction rate per specie [kg/m3/s].
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual void calculate()
Calculates the reaction rates.
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
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...
virtual void derivatives(const scalar t, const scalarField &c, scalarField &dcdt) const
Calculate the derivatives in dydx.
virtual tmp< volScalarField > Qdot() const
Return the heat release rate [kg/m/s3].
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
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
const PtrList< Reaction< ThermoType > > & reactions() const
The reactions.
const PtrList< Reaction< ThermoType > > & reactions_
Reactions.
Namespace for OpenFOAM.