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-2018 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  //- Disallow copy constructor
74 
75  //- Disallow default bitwise assignment
76  void operator=(const StandardChemistryModel&);
77 
78 
79 protected:
80 
81  typedef ThermoType thermoType;
82 
83 
84  // Protected data
85 
86  //- Reference to the field of specie mass fractions
88 
89  //- Reactions
91 
92  //- Thermodynamic data of the species
94 
95  //- Number of species
97 
98  //- Number of reactions
100 
101  //- Temperature below which the reaction rates are assumed 0
102  scalar Treact_;
103 
104  //- List of reaction rate per specie [kg/m3/s]
106 
107  //- Temporary concentration field
108  mutable scalarField c_;
109 
110  //- Temporary rate-of-change of concentration field
111  mutable scalarField dcdt_;
112 
113 
114  // Protected Member Functions
115 
116  //- Write access to chemical source terms
117  // (e.g. for multi-chemistry model)
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("standard");
125 
126 
127  // Constructors
128 
129  //- Construct from thermo
130  StandardChemistryModel(ReactionThermo& thermo);
131 
132 
133  //- Destructor
134  virtual ~StandardChemistryModel();
135 
136 
137  // Member Functions
138 
139  //- The reactions
140  inline const PtrList<Reaction<ThermoType>>& reactions() const;
141 
142  //- Thermodynamic data of the species
143  inline const PtrList<ThermoType>& specieThermo() const;
144 
145  //- The number of species
146  virtual inline label nSpecie() const;
147 
148  //- The number of reactions
149  virtual inline label nReaction() const;
150 
151  //- Temperature below which the reaction rates are assumed 0
152  inline scalar Treact() const;
153 
154  //- Temperature below which the reaction rates are assumed 0
155  inline scalar& Treact();
156 
157  //- dc/dt = omega, rate of change in concentration, for each species
158  virtual void omega
159  (
160  const scalarField& c,
161  const scalar T,
162  const scalar p,
163  scalarField& dcdt
164  ) const;
165 
166 
167  //- Return the reaction rate for iReaction and the reference
168  // species and charateristic times
169  virtual scalar omegaI
170  (
171  label iReaction,
172  const scalarField& c,
173  const scalar T,
174  const scalar p,
175  scalar& pf,
176  scalar& cf,
177  label& lRef,
178  scalar& pr,
179  scalar& cr,
180  label& rRef
181  ) const;
182 
183  //- Calculates the reaction rates
184  virtual void calculate();
185 
186 
187  // Chemistry model functions (overriding abstract functions in
188  // basicChemistryModel.H)
189 
190  //- Return const access to the chemical source terms for specie, i
191  inline const volScalarField::Internal& RR
192  (
193  const label i
194  ) const;
195 
196  //- Return non const access to chemical source terms [kg/m3/s]
198  (
199  const label i
200  );
201 
202  //- Return reaction rate of the speciei in reactionI
204  (
205  const label reactionI,
206  const label speciei
207  ) const;
208 
209  //- Solve the reaction system for the given time step
210  // and return the characteristic time
211  virtual scalar solve(const scalar deltaT);
212 
213  //- Solve the reaction system for the given time step
214  // and return the characteristic time
215  virtual scalar solve(const scalarField& deltaT);
216 
217  //- Return the chemical time scale
218  virtual tmp<volScalarField> tc() const;
219 
220  //- Return the heat release rate [kg/m/s3]
221  virtual tmp<volScalarField> Qdot() const;
222 
223 
224  // ODE functions (overriding abstract functions in ODE.H)
225 
226  //- Number of ODE's to solve
227  inline virtual label nEqns() const;
228 
229  virtual void derivatives
230  (
231  const scalar t,
232  const scalarField& c,
233  scalarField& dcdt
234  ) const;
235 
236  virtual void jacobian
237  (
238  const scalar t,
239  const scalarField& c,
240  scalarField& dcdt,
242  ) const;
243 
244  virtual void solve
245  (
246  scalarField &c,
247  scalar& T,
248  scalar& p,
249  scalar& deltaT,
250  scalar& subDeltaT
251  ) const = 0;
252 };
253 
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #include "StandardChemistryModelI.H"
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 #ifdef NoRepository
266  #include "StandardChemistryModel.C"
267 #endif
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 #endif
272 
273 // ************************************************************************* //
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/s3].
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/m3/s].
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
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.
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:63
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