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-2021 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 ReactionThermo to handle reaction kinetics in addition
29  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 ReactionThermo>
56 class Reaction;
57 
58 template<class ReactionThermo>
59 inline Ostream& operator<<(Ostream&, const Reaction<ReactionThermo>&);
60 
61 class objectRegistry;
62 
63 
64 /*---------------------------------------------------------------------------*\
65  Class Reaction Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 template<class ReactionThermo>
69 class Reaction
70 :
71  public reaction,
72  public ReactionThermo::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 HashPtrTable<ReactionThermo>& thermoDatabase);
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 HashPtrTable<ReactionThermo>& thermoDatabase,
113  const dictionary& dict
114  ),
115  (species, thermoDatabase, dict)
116  );
117 
119  (
120  autoPtr,
121  Reaction,
123  (
124  const speciesTable& species,
125  const HashPtrTable<ReactionThermo>& thermoDatabase,
126  const objectRegistry& ob,
127  const dictionary& dict
128  ),
129  (species, thermoDatabase, ob, dict)
130  );
131 
132 
133  // Constructors
134 
135  //- Construct from components
136  Reaction
137  (
138  const speciesTable& species,
139  const List<specieCoeffs>& lhs,
140  const List<specieCoeffs>& rhs,
141  const HashPtrTable<ReactionThermo>& thermoDatabase
142  );
143 
144  //- Construct as copy given new speciesTable
145  Reaction(const Reaction<ReactionThermo>&, const speciesTable& species);
146 
147  //- Construct from dictionary
148  Reaction
149  (
150  const speciesTable& species,
151  const HashPtrTable<ReactionThermo>& thermoDatabase,
152  const dictionary& dict
153  );
154 
155  //- Construct and return a clone
156  virtual autoPtr<Reaction<ReactionThermo>> clone() const = 0;
157 
158  //- Construct and return a clone with new speciesTable
160  (
161  const speciesTable& species
162  ) const = 0;
163 
164 
165  // Selectors
166 
167  //- Return a pointer to new patchField created on freestore
168  // from dictionary
170  (
171  const speciesTable& species,
172  const HashPtrTable<ReactionThermo>& thermoDatabase,
173  const dictionary& dict
174  );
175 
176  //- Return a pointer to new patchField created on freestore
177  // from objectRegistry and dictionary
179  (
180  const speciesTable& species,
181  const HashPtrTable<ReactionThermo>& thermoDatabase,
182  const objectRegistry& ob,
183  const dictionary& dict
184  );
185 
186  //- Return a pointer to new patchField created on freestore from dict.
187  // This is used to construct a single reaction given a speciesThermo
188  // list from which a temporary thermoDatabase is created.
190  (
191  const speciesTable& species,
192  const PtrList<ReactionThermo>& speciesThermo,
193  const dictionary& dict
194  );
195 
196 
197  //- Destructor
198  virtual ~Reaction()
199  {}
200 
201 
202  // Member Functions
203 
204  // Access
205 
206  //- Return the name of the reaction
207  using reaction::name;
208 
209  //- Return the lower temperature limit for the reaction
210  inline scalar Tlow() const;
211 
212  //- Return the upper temperature limit for the reaction
213  inline scalar Thigh() const;
214 
215 
216  // Hooks
217 
218  //- Pre-evaluation hook
219  virtual void preEvaluate() const = 0;
220 
221  //- Post-evaluation hook
222  virtual void postEvaluate() const = 0;
223 
224 
225  // Reaction rate coefficients
226 
227  //- Net reaction rate for individual species
228  void omega
229  (
230  const scalar p,
231  const scalar T,
232  const scalarField& c,
233  const label li,
234  scalarField& dcdt
235  ) const;
236 
237  //- Net reaction rate
238  scalar omega
239  (
240  const scalar p,
241  const scalar T,
242  const scalarField& c,
243  const label li,
244  scalar& omegaf,
245  scalar& omegar
246  ) const;
247 
248  // Reaction rate coefficients
249 
250  //- Forward rate constant
251  virtual scalar kf
252  (
253  const scalar p,
254  const scalar T,
255  const scalarField& c,
256  const label li
257  ) const = 0;
258 
259  //- Reverse rate constant from the given forward rate constant
260  virtual scalar kr
261  (
262  const scalar kfwd,
263  const scalar p,
264  const scalar T,
265  const scalarField& c,
266  const label li
267  ) const = 0;
268 
269  //- Reverse rate constant
270  virtual scalar kr
271  (
272  const scalar p,
273  const scalar T,
274  const scalarField& c,
275  const label li
276  ) const = 0;
277 
278 
279  // Jacobian coefficients
280 
281  //- Derivative of the net reaction rate for each species involved
282  // w.r.t. the species concentration
283  void dwdc
284  (
285  const scalar p,
286  const scalar T,
287  const scalarField& c,
288  const label li,
290  scalarField& dcdt,
291  scalar& omegaI,
292  scalar& kfwd,
293  scalar& kbwd,
294  const bool reduced,
295  const List<label>& c2s
296  ) const;
297 
298  //- Derivative of the net reaction rate for each species involved
299  // w.r.t. the temperature
300  void dwdT
301  (
302  const scalar p,
303  const scalar T,
304  const scalarField& c,
305  const label li,
306  const scalar omegaI,
307  const scalar kfwd,
308  const scalar kbwd,
310  const bool reduced,
311  const List<label>& c2s,
312  const label indexT
313  ) const;
314 
315  //- Temperature derivative of forward rate
316  virtual scalar dkfdT
317  (
318  const scalar p,
319  const scalar T,
320  const scalarField& c,
321  const label li
322  ) const = 0;
323 
324  //- Temperature derivative of reverse rate
325  virtual scalar dkrdT
326  (
327  const scalar p,
328  const scalar T,
329  const scalarField& c,
330  const label li,
331  const scalar dkfdT,
332  const scalar kr
333  ) const = 0;
334 
335  //- Third-body efficiencies (beta = 1-alpha)
336  // non-empty only for third-body reactions
337  // with enhanced molecularity (alpha != 1)
338  virtual const List<Tuple2<label, scalar>>& beta() const = 0;
339 
340  //- Species concentration derivative of the pressure dependent term
341  virtual void dcidc
342  (
343  const scalar p,
344  const scalar T,
345  const scalarField& c,
346  const label li,
348  ) const = 0;
349 
350  //- Temperature derivative of the pressure dependent term
351  virtual scalar dcidT
352  (
353  const scalar p,
354  const scalar T,
355  const scalarField& c,
356  const label li
357  ) const = 0;
358 
359 
360  //- Write
361  virtual void write(Ostream&) const;
362 
363 
364  // Member Operators
365 
366  //- Disallow default bitwise assignment
367  void operator=(const Reaction<ReactionThermo>&) = delete;
368 
369 
370  // Ostream Operator
371 
372  friend Ostream& operator<< <ReactionThermo>
373  (
374  Ostream&,
376  );
377 };
378 
379 
380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381 
382 } // End namespace Foam
383 
384 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
385 
386 #include "ReactionI.H"
387 
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 
390 #ifdef NoRepository
391  #include "Reaction.C"
392 #endif
393 
394 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
395 
396 #endif
397 
398 // ************************************************************************* //
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
virtual scalar dkfdT(const scalar p, const scalar T, const scalarField &c, const label li) const =0
Temperature derivative of forward rate.
virtual void dcidc(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dcidc) const =0
Species concentration derivative of the pressure dependent term.
virtual ~Reaction()
Destructor.
Definition: Reaction.H:197
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
void dwdc(const scalar p, const scalar T, const scalarField &c, const label li, scalarSquareMatrix &J, scalarField &dcdt, scalar &omegaI, scalar &kfwd, scalar &kbwd, const bool reduced, const List< label > &c2s) const
Derivative of the net reaction rate for each species involved.
Definition: Reaction.C:352
virtual void write(Ostream &) const
Write.
Definition: Reaction.C:282
TypeName("Reaction")
Runtime type information.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:50
const List< specieCoeffs > & lhs() const
Return the components of the left hand side.
Definition: reactionI.H:36
virtual void postEvaluate() const =0
Post-evaluation hook.
const dimensionedScalar c
Speed of light in a vacuum.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:55
virtual void preEvaluate() const =0
Pre-evaluation hook.
Reaction base-class holding the specie names and coefficients.
Definition: reaction.H:56
void omega(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dcdt) const
Net reaction rate for individual species.
Definition: Reaction.C:290
static scalar TlowDefault
Default temperature limits of applicability of reaction rates.
Definition: Reaction.H:79
virtual scalar dcidT(const scalar p, const scalar T, const scalarField &c, const label li) const =0
Temperature derivative of the pressure dependent term.
scalar Tlow() const
Return the lower temperature limit for the reaction.
Definition: ReactionI.H:31
virtual scalar kr(const scalar kfwd, const scalar p, const scalar T, const scalarField &c, const label li) const =0
Reverse rate constant from the given forward rate constant.
virtual const List< Tuple2< label, scalar > > & beta() const =0
Third-body efficiencies (beta = 1-alpha)
scalar Thigh() const
Return the upper temperature limit for the reaction.
Definition: ReactionI.H:38
static scalar ThighDefault
Definition: Reaction.H:79
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual autoPtr< Reaction< ReactionThermo > > clone() const =0
Construct and return a clone.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void operator=(const Reaction< ReactionThermo > &)=delete
Disallow default bitwise assignment.
Reaction(const speciesTable &species, const List< specieCoeffs > &lhs, const List< specieCoeffs > &rhs, const HashPtrTable< ReactionThermo > &thermoDatabase)
Construct from components.
Definition: Reaction.C:95
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
Definition: reactionI.H:42
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.
A wordList with hashed indices for faster lookup by name.
static autoPtr< Reaction< ReactionThermo > > New(const speciesTable &species, const HashPtrTable< ReactionThermo > &thermoDatabase, const dictionary &dict)
Return a pointer to new patchField created on freestore.
Definition: Reaction.C:147
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 word & name() const
Return the name of the reaction.
Definition: reactionI.H:30
declareRunTimeSelectionTable(autoPtr, Reaction, dictionary,(const speciesTable &species, const HashPtrTable< ReactionThermo > &thermoDatabase, const dictionary &dict),(species, thermoDatabase, dict))
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Macros to ease declaration of run-time selection tables.
void dwdT(const scalar p, const scalar T, const scalarField &c, const label li, const scalar omegaI, const scalar kfwd, const scalar kbwd, scalarSquareMatrix &J, const bool reduced, const List< label > &c2s, const label indexT) const
Derivative of the net reaction rate for each species involved.
Definition: Reaction.C:499
volScalarField & p
Registry of regIOobjects.
virtual scalar kf(const scalar p, const scalar T, const scalarField &c, const label li) const =0
Forward rate constant.
Namespace for OpenFOAM.