ReversibleReaction.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-2023 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::ReversibleReaction
26 
27 Description
28  Extension of Reaction to handle reversible reactions using equilibrium
29  thermodynamics
30 
31 SourceFiles
32  ReversibleReaction.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef ReversibleReaction_H
37 #define ReversibleReaction_H
38 
39 #include "Reaction.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class ReversibleReaction Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 template<class ThermoType, class ReactionRate>
52 :
53  public Reaction<ThermoType>
54 {
55  // Private Data
56 
57  ReactionRate k_;
58 
59 
60 public:
61 
62  //- Runtime type information
63  TypeName("reversible");
64 
65 
66  // Constructors
67 
68  //- Construct from components
70  (
72  const ReactionRate& k
73  );
74 
75  //- Construct as copy given new speciesTable
77  (
79  const speciesTable& species
80  );
81 
82  //- Construct from dictionary
84  (
85  const speciesTable& species,
86  const PtrList<ThermoType>& speciesThermo,
87  const dictionary& dict
88  );
89 
90  //- Construct from objectRegistry and dictionary
92  (
93  const speciesTable& species,
94  const PtrList<ThermoType>& speciesThermo,
95  const objectRegistry& ob,
96  const dictionary& dict
97  );
98 
99  //- Construct and return a clone
100  virtual autoPtr<Reaction<ThermoType>> clone() const
101  {
103  (
105  (
106  *this
107  )
108  );
109  }
110 
111  //- Construct and return a clone with new speciesTable
113  (
114  const speciesTable& species
115  ) const
116  {
118  (
120  (
121  *this,
122  species
123  )
124  );
125  }
126 
127 
128  //- Destructor
129  virtual ~ReversibleReaction()
130  {}
131 
132 
133  // Member Functions
134 
135  // Hooks
136 
137  //- Pre-evaluation hook
138  virtual void preEvaluate() const;
139 
140  //- Post-evaluation hook
141  virtual void postEvaluate() const;
142 
143 
144  // ReversibleReaction rate coefficients
145 
146  //- Forward rate constant
147  virtual scalar kf
148  (
149  const scalar p,
150  const scalar T,
151  const scalarField& c,
152  const label li
153  ) const;
154 
155  //- Reverse rate constant from the given forward rate constant
156  virtual scalar kr
157  (
158  const scalar kfwd,
159  const scalar p,
160  const scalar T,
161  const scalarField& c,
162  const label li
163  ) const;
164 
165  //- Reverse rate constant.
166  // Note this evaluates the forward rate constant and divides by
167  // the equilibrium constant
168  virtual scalar kr
169  (
170  const scalar p,
171  const scalar T,
172  const scalarField& c,
173  const label li
174  ) const;
175 
176 
177  // ReversibleReaction Jacobian functions
178 
179  //- Temperature derivative of forward rate
180  virtual scalar dkfdT
181  (
182  const scalar p,
183  const scalar T,
184  const scalarField& c,
185  const label li
186  ) const;
187 
188  //- Temperature derivative of backward rate
189  virtual scalar dkrdT
190  (
191  const scalar p,
192  const scalar T,
193  const scalarField& c,
194  const label li,
195  const scalar dkfdT,
196  const scalar kr
197  ) const;
198 
199  //- Does this reaction have concentration-dependent rate constants?
200  virtual bool hasDkdc() const;
201 
202  //- Concentration derivative of forward rate
203  void dkfdc
204  (
205  const scalar p,
206  const scalar T,
207  const scalarField& c,
208  const label li,
210  ) const;
211 
212  //- Concentration derivative of reverse rate
213  void dkrdc
214  (
215  const scalar p,
216  const scalar T,
217  const scalarField& c,
218  const label li,
219  const scalarField& dkfdc,
220  const scalar kr,
222  ) const;
223 
224 
225  //- Write
226  virtual void write(Ostream&) const;
227 
228 
229  // Member Operators
230 
231  //- Disallow default bitwise assignment
232  void operator=
233  (
235  ) = delete;
236 };
237 
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #ifdef NoRepository
246  #include "ReversibleReaction.C"
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
label k
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
Extension of Reaction to handle reversible reactions using equilibrium thermodynamics.
TypeName("reversible")
Runtime type information.
virtual scalar kr(const scalar kfwd, const scalar p, const scalar T, const scalarField &c, const label li) const
Reverse rate constant from the given forward rate constant.
virtual scalar dkfdT(const scalar p, const scalar T, const scalarField &c, const label li) const
Temperature derivative of forward rate.
virtual void write(Ostream &) const
Write.
virtual void preEvaluate() const
Pre-evaluation hook.
virtual ~ReversibleReaction()
Destructor.
virtual void postEvaluate() const
Post-evaluation hook.
virtual autoPtr< Reaction< ThermoType > > clone() const
Construct and return a clone.
virtual scalar dkrdT(const scalar p, const scalar T, const scalarField &c, const label li, const scalar dkfdT, const scalar kr) const
Temperature derivative of backward rate.
void dkfdc(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dkfdc) const
Concentration derivative of forward rate.
virtual bool hasDkdc() const
Does this reaction have concentration-dependent rate constants?
virtual scalar kf(const scalar p, const scalar T, const scalarField &c, const label li) const
Forward rate constant.
void dkrdc(const scalar p, const scalar T, const scalarField &c, const label li, const scalarField &dkfdc, const scalar kr, scalarField &dkrdc) const
Concentration derivative of reverse rate.
ReversibleReaction(const Reaction< ThermoType > &reaction, const ReactionRate &k)
Construct from components.
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:160
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 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
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict
volScalarField & p