Reaction.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-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 Class
25  Foam::Reaction
26 
27 Description
28  Simple extension of ThermoType to handle reaction kinetics in
29  addition to the equilibrium thermodynamics already handled.
30 
31 SourceFiles
32  ReactionI.H
33  Reaction.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Reaction_H
38 #define Reaction_H
39 
40 #include "reaction.H"
41 #include "HashPtrTable.H"
42 #include "scalarField.H"
43 #include "simpleMatrix.H"
44 #include "Tuple2.H"
45 #include "typeInfo.H"
46 #include "runTimeSelectionTables.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of friend functions and operators
54 
55 template<class ThermoType>
56 class Reaction;
57 
58 template<class ThermoType>
60 
61 class objectRegistry;
62 
63 
64 /*---------------------------------------------------------------------------*\
65  Class Reaction Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 template<class ThermoType>
69 class Reaction
70 :
71  public reaction,
72  public ThermoType::thermoType
73 {
74 
75 public:
76 
77  // Static data
78 
79  //- Default temperature limits of applicability of reaction rates
80  static scalar TlowDefault, ThighDefault;
81 
82 
83 private:
84 
85  // Private Data
86 
87  //- Temperature limits of applicability of reaction rates
88  scalar Tlow_, Thigh_;
89 
90 
91  // Private Member Functions
92 
93  //- Construct reaction thermo
94  void setThermo(const PtrList<ThermoType>& speciesThermo);
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("Reaction");
101 
102 
103  // Declare run-time constructor selection tables
104 
106  (
107  autoPtr,
108  Reaction,
109  dictionary,
110  (
111  const speciesTable& species,
112  const PtrList<ThermoType>& speciesThermo,
113  const dictionary& dict
114  ),
115  (species, speciesThermo, dict)
116  );
117 
119  (
120  autoPtr,
121  Reaction,
123  (
124  const speciesTable& species,
125  const PtrList<ThermoType>& speciesThermo,
126  const objectRegistry& ob,
127  const dictionary& dict
128  ),
129  (species, speciesThermo, ob, dict)
130  );
131 
132 
133  // Constructors
134 
135  //- Construct from components
136  Reaction
137  (
138  const speciesTable& species,
139  const PtrList<ThermoType>& speciesThermo,
140  const List<specieCoeffs>& lhs,
141  const List<specieCoeffs>& rhs
142  );
143 
144  //- Construct as copy given new speciesTable
145  Reaction
146  (
147  const Reaction<ThermoType>&,
148  const speciesTable& species
149  );
150 
151  //- Construct from dictionary
152  Reaction
153  (
154  const speciesTable& species,
155  const PtrList<ThermoType>& speciesThermo,
156  const dictionary& dict
157  );
158 
159  //- Construct and return a clone
160  virtual autoPtr<Reaction<ThermoType>> clone() const = 0;
161 
162  //- Construct and return a clone with new speciesTable
164  (
165  const speciesTable& species
166  ) const = 0;
167 
168 
169  // Selectors
170 
171  //- Return a pointer to new reaction created from a dictionary
173  (
174  const speciesTable& species,
175  const PtrList<ThermoType>& speciesThermo,
176  const dictionary& dict
177  );
178 
179  //- Return a pointer to new reaction created from an objectRegistry and
180  // a dictionary
182  (
183  const speciesTable& species,
184  const PtrList<ThermoType>& speciesThermo,
185  const objectRegistry& ob,
186  const dictionary& dict
187  );
188 
189 
190  //- Destructor
191  virtual ~Reaction()
192  {}
193 
194 
195  // Member Functions
196 
197  // Access
198 
199  //- Return the name of the reaction
200  using reaction::name;
201 
202  //- Return the lower temperature limit for the reaction
203  inline scalar Tlow() const;
204 
205  //- Return the upper temperature limit for the reaction
206  inline scalar Thigh() const;
207 
208 
209  // Hooks
210 
211  //- Pre-evaluation hook
212  virtual void preEvaluate() const = 0;
213 
214  //- Post-evaluation hook
215  virtual void postEvaluate() const = 0;
216 
217 
218  // Dimensions
219 
220  //- Dimensions of the forward rate
221  dimensionSet kfDims() const;
222 
223  //- Dimensions of the reverse rate
224  dimensionSet krDims() const;
225 
226 
227  // Reaction rate coefficients
228 
229  //- Concentration powers
230  void C
231  (
232  const scalar p,
233  const scalar T,
234  const scalarField& c,
235  const label li,
236  scalar& Cf,
237  scalar& Cr
238  ) const;
239 
240  //- Net reaction rate
241  scalar omega
242  (
243  const scalar p,
244  const scalar T,
245  const scalarField& c,
246  const label li,
247  scalar& omegaf,
248  scalar& omegar
249  ) const;
250 
251  //- The net reaction rate for each species involved
252  void dNdtByV
253  (
254  const scalar p,
255  const scalar T,
256  const scalarField& c,
257  const label li,
259  const bool reduced,
260  const List<label>& c2s,
261  const label Nsi0
262  ) const;
263 
264 
265  // Reaction rate coefficients
266 
267  //- Forward rate constant
268  virtual scalar kf
269  (
270  const scalar p,
271  const scalar T,
272  const scalarField& c,
273  const label li
274  ) const = 0;
275 
276  //- Reverse rate constant from the given forward rate constant
277  virtual scalar kr
278  (
279  const scalar kf,
280  const scalar p,
281  const scalar T,
282  const scalarField& c,
283  const label li
284  ) const = 0;
285 
286  //- Reverse rate constant
287  virtual scalar kr
288  (
289  const scalar p,
290  const scalar T,
291  const scalarField& c,
292  const label li
293  ) const = 0;
294 
295 
296  // Jacobian coefficients
297 
298  //- Temperature derivative of forward rate
299  virtual scalar dkfdT
300  (
301  const scalar p,
302  const scalar T,
303  const scalarField& c,
304  const label li
305  ) const = 0;
306 
307  //- Temperature derivative of reverse rate
308  virtual scalar dkrdT
309  (
310  const scalar p,
311  const scalar T,
312  const scalarField& c,
313  const label li,
314  const scalar dkfdT,
315  const scalar kr
316  ) const = 0;
317 
318  //- Does this reaction have concentration-dependent rate constants?
319  virtual bool hasDkdc() const = 0;
320 
321  //- Concentration derivative of forward rate
322  virtual void dkfdc
323  (
324  const scalar p,
325  const scalar T,
326  const scalarField& c,
327  const label li,
329  ) const = 0;
330 
331  //- Concentration derivative of reverse rate
332  virtual void dkrdc
333  (
334  const scalar p,
335  const scalar T,
336  const scalarField& c,
337  const label li,
338  const scalarField& dkfdc,
339  const scalar kr,
341  ) const = 0;
342 
343  //- Derivative of the net reaction rate for each species involved
344  // w.r.t. the concentration and temperature
345  void ddNdtByVdcTp
346  (
347  const scalar p,
348  const scalar T,
349  const scalarField& c,
350  const label li,
353  const bool reduced,
354  const List<label>& c2s,
355  const label csi0,
356  const label Tsi,
357  scalarField& cTpWork0,
358  scalarField& cTpWork1
359  ) const;
360 
361 
362  //- Write
363  virtual void write(Ostream&) const;
364 
365 
366  // Member Operators
367 
368  //- Disallow default bitwise assignment
369  void operator=(const Reaction<ThermoType>&) = delete;
370 
371 
372  // Ostream Operator
373 
374  friend Ostream& operator<< <ThermoType>
375  (
376  Ostream&,
377  const Reaction<ThermoType>&
378  );
379 };
380 
381 
382 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 
384 } // End namespace Foam
385 
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 
388 #include "ReactionI.H"
389 
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391 
392 #ifdef NoRepository
393  #include "Reaction.C"
394 #endif
395 
396 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
397 
398 #endif
399 
400 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Simple extension of ThermoType to handle reaction kinetics in addition to the equilibrium thermodynam...
Definition: Reaction.H:72
virtual scalar kf(const scalar p, const scalar T, const scalarField &c, const label li) const =0
Forward rate constant.
virtual void postEvaluate() const =0
Post-evaluation hook.
virtual void write(Ostream &) const
Write.
Definition: Reaction.C:550
static scalar TlowDefault
Default temperature limits of applicability of reaction rates.
Definition: Reaction.H:79
virtual scalar kr(const scalar kf, const scalar p, const scalar T, const scalarField &c, const label li) const =0
Reverse rate constant from the given forward rate constant.
declareRunTimeSelectionTable(autoPtr, Reaction, dictionary,(const speciesTable &species, const PtrList< ThermoType > &speciesThermo, const dictionary &dict),(species, speciesThermo, dict))
virtual scalar dkrdT(const scalar p, const scalar T, const scalarField &c, const label li, const scalar dkfdT, const scalar kr) const =0
Temperature derivative of reverse rate.
static scalar ThighDefault
Definition: Reaction.H:79
virtual void preEvaluate() const =0
Pre-evaluation hook.
scalar Tlow() const
Return the lower temperature limit for the reaction.
Definition: ReactionI.H:31
void ddNdtByVdcTp(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dNdtByV, scalarSquareMatrix &ddNdtByVdcTp, const bool reduced, const List< label > &c2s, const label csi0, const label Tsi, scalarField &cTpWork0, scalarField &cTpWork1) const
Derivative of the net reaction rate for each species involved.
Definition: Reaction.C:372
void C(const scalar p, const scalar T, const scalarField &c, const label li, scalar &Cf, scalar &Cr) const
Concentration powers.
Definition: Reaction.C:284
virtual scalar dkfdT(const scalar p, const scalar T, const scalarField &c, const label li) const =0
Temperature derivative of forward rate.
dimensionSet kfDims() const
Dimensions of the forward rate.
Definition: Reaction.C:259
dimensionSet krDims() const
Dimensions of the reverse rate.
Definition: Reaction.C:271
TypeName("Reaction")
Runtime type information.
virtual void dkfdc(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dkfdc) const =0
Concentration derivative of forward rate.
scalar Thigh() const
Return the upper temperature limit for the reaction.
Definition: ReactionI.H:38
virtual void dkrdc(const scalar p, const scalar T, const scalarField &c, const label li, const scalarField &dkfdc, const scalar kr, scalarField &dkrdc) const =0
Concentration derivative of reverse rate.
void dNdtByV(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dNdtByV, const bool reduced, const List< label > &c2s, const label Nsi0) const
The net reaction rate for each species involved.
Definition: Reaction.C:341
static autoPtr< Reaction< ThermoType > > New(const speciesTable &species, const PtrList< ThermoType > &speciesThermo, const dictionary &dict)
Return a pointer to new reaction created from a dictionary.
Definition: Reaction.C:146
scalar omega(const scalar p, const scalar T, const scalarField &c, const label li, scalar &omegaf, scalar &omegar) const
Net reaction rate.
Definition: Reaction.C:313
void operator=(const Reaction< ThermoType > &)=delete
Disallow default bitwise assignment.
virtual ~Reaction()
Destructor.
Definition: Reaction.H:190
virtual autoPtr< Reaction< ThermoType > > clone() const =0
Construct and return a clone.
Reaction(const speciesTable &species, const PtrList< ThermoType > &speciesThermo, const List< specieCoeffs > &lhs, const List< specieCoeffs > &rhs)
Construct from components.
Definition: Reaction.C:94
virtual bool hasDkdc() const =0
Does this reaction have concentration-dependent rate constants?
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Dimension set for the base types.
Definition: dimensionSet.H:125
A wordList with hashed indices for faster lookup by name.
Registry of regIOobjects.
Reaction base-class holding the specie names and coefficients.
Definition: reaction.H:57
const speciesTable & species() const
Return the specie list.
Definition: reactionI.H:48
const List< specieCoeffs > & lhs() const
Return the components of the left hand side.
Definition: reactionI.H:36
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
Definition: reactionI.H:42
const word & name() const
Return the name of the reaction.
Definition: reactionI.H:30
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
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
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Macros to ease declaration of run-time selection tables.
dictionary dict
volScalarField & p
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...