FallOffReactionRateI.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 \*---------------------------------------------------------------------------*/
25 
26 #define FALL_OFF_FUNCTION_JACOBIAN false
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class ReactionRate, class FallOffFunction>
33 (
34  const ReactionRate& k0,
35  const ReactionRate& kInf,
36  const FallOffFunction& F,
37  const thirdBodyEfficiencies& tbes
38 )
39 :
40  k0_(k0),
41  kInf_(kInf),
42  F_(F),
43  thirdBodyEfficiencies_(tbes)
44 {}
45 
46 
47 template<class ReactionRate, class FallOffFunction>
50 (
51  const speciesTable& species,
52  const dictionary& dict
53 )
54 :
55  k0_(species, dict.subDict("k0")),
56  kInf_(species, dict.subDict("kInf")),
57  F_(dict.subDict("F")),
58  thirdBodyEfficiencies_(species, dict.subDict("thirdBodyEfficiencies"))
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
64 template<class ReactionRate, class FallOffFunction>
65 inline void
67 {
68  k0_.preEvaluate();
69  kInf_.preEvaluate();
70 }
71 
72 
73 template<class ReactionRate, class FallOffFunction>
74 inline void
76 {
77  k0_.postEvaluate();
78  kInf_.postEvaluate();
79 }
80 
81 
82 template<class ReactionRate, class FallOffFunction>
83 inline Foam::scalar
85 (
86  const scalar p,
87  const scalar T,
88  const scalarField& c,
89  const label li
90 ) const
91 {
92  const scalar k0 = k0_(p, T, c, li);
93  const scalar kInf = kInf_(p, T, c, li);
94  const scalar M = thirdBodyEfficiencies_.M(c);
95  const scalar Pr = k0/kInf*M;
96  const scalar F = F_(T, Pr);
97 
98  return kInf*(Pr/(1 + Pr))*F;
99 }
100 
101 
102 template<class ReactionRate, class FallOffFunction>
103 inline Foam::scalar
105 (
106  const scalar p,
107  const scalar T,
108  const scalarField& c,
109  const label li
110 ) const
111 {
112  const scalar k0 = k0_(p, T, c, li);
113  const scalar kInf = kInf_(p, T, c, li);
114  const scalar M = thirdBodyEfficiencies_.M(c);
115  const scalar Pr = k0/kInf*M;
116  const scalar F = F_(T, Pr);
117 
118  const scalar dkInfdT = kInf_.ddT(p, T, c, li);
119 
120  #if FALL_OFF_FUNCTION_JACOBIAN
121 
122  const scalar dk0dT = k0_.ddT(p, T, c, li);
123  const scalar dPrdT = (M*dk0dT - Pr*dkInfdT)/kInf;
124  const scalar dFdT = F_.ddT(T, Pr, F) + F_.ddPr(T, Pr, F)*dPrdT;
125 
126  return
127  dkInfdT*(Pr/(1 + Pr))*F
128  + kInf*dPrdT/sqr(1 + Pr)*F
129  + kInf*(Pr/(1 + Pr))*dFdT;
130 
131  #else
132 
133  return dkInfdT*(Pr/(1 + Pr))*F;
134 
135  #endif
136 }
137 
138 
139 template<class ReactionRate, class FallOffFunction>
140 inline bool
142 {
143  return true;
144 }
145 
146 
147 template<class ReactionRate, class FallOffFunction>
149 (
150  const scalar p,
151  const scalar T,
152  const scalarField& c,
153  const label li,
154  scalarField& ddc
155 ) const
156 {
157  const scalar k0 = k0_(p, T, c, li);
158  const scalar kInf = kInf_(p, T, c, li);
159  const scalar M = thirdBodyEfficiencies_.M(c);
160  const scalar Pr = k0/kInf*M;
161  const scalar F = F_(T, Pr);
162 
163  #if FALL_OFF_FUNCTION_JACOBIAN
164 
165  scalarField dk0dc(c.size(), 0);
166  k0_.ddc(p, T, c, li, dk0dc);
167  scalarField dkInfdc(c.size(), 0);
168  kInf_.ddc(p, T, c, li, dkInfdc);
169  tmp<scalarField> tdMdc = thirdBodyEfficiencies_.dMdc(c);
170  const scalarField& dMdc = tdMdc();
171  scalarField dPrdc((M*dk0dc - Pr*dkInfdc + k0*dMdc)/kInf);
172  const scalar dFdPr = F_.ddPr(T, Pr, F);
173 
174  ddc =
175  dkInfdc*(Pr/(1 + Pr))*F
176  + kInf*dPrdc/sqr(1 + Pr)*F
177  + kInf*(Pr/(1 + Pr))*dFdPr*dPrdc;
178 
179  #else
180 
181  kInf_.ddc(p, T, c, li, ddc);
182 
183  ddc *= (Pr/(1 + Pr))*F;
184 
185  #endif
186 }
187 
188 
189 template<class ReactionRate, class FallOffFunction>
191 (
192  Ostream& os
193 ) const
194 {
195  os << indent << "k0" << nl;
196  os << indent << token::BEGIN_BLOCK << nl;
197  os << incrIndent;
198  k0_.write(os);
199  os << decrIndent;
200  os << indent << token::END_BLOCK << nl;
201 
202  os << indent << "kInf" << nl;
203  os << indent << token::BEGIN_BLOCK << nl;
204  os << incrIndent;
205  kInf_.write(os);
206  os << decrIndent;
207  os << indent << token::END_BLOCK << nl;
208 
209  os << indent << "F" << nl;
210  os << indent << token::BEGIN_BLOCK << nl;
211  os << incrIndent;
212  F_.write(os);
213  os << decrIndent;
214  os << indent << token::END_BLOCK << nl;
215 
216  os << indent << "thirdBodyEfficiencies" << nl;
217  os << indent << token::BEGIN_BLOCK << nl;
218  os << incrIndent;
219  thirdBodyEfficiencies_.write(os);
220  os << decrIndent;
221  os << indent << token::END_BLOCK << nl;
222 }
223 
224 
225 template<class ReactionRate, class FallOffFunction>
226 inline Foam::Ostream& Foam::operator<<
227 (
228  Ostream& os,
230 )
231 {
232  forr.write(os);
233  return os;
234 }
235 
236 
237 // ************************************************************************* //
virtual Ostream & write(const char)=0
Write character.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
const dimensionedScalar F
Faraday constant: default SI units: [C/mol].
void postEvaluate() const
Post-evaluation hook.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
General class for handling unimolecular/recombination fall-off reactions.
const dimensionedScalar c
Speed of light in a vacuum.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:1002
bool hasDdc() const
Is the rate a function of concentration?
scalar ddT(const scalar p, const scalar T, const scalarField &c, const label li) const
The derivative of the rate w.r.t. temperature.
void write(Ostream &os) const
Write to stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
void ddc(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &ddc) const
The derivative of the rate w.r.t. concentration.
FallOffReactionRate(const ReactionRate &k0, const ReactionRate &kInf, const FallOffFunction &F, const thirdBodyEfficiencies &tbes)
Construct from components.
friend Ostream & operator(Ostream &, const FallOffReactionRate< ReactionRate, FallOffFunction > &)
const volScalarField & T
void preEvaluate() const
Pre-evaluation hook.
A wordList with hashed indices for faster lookup by name.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
Third body efficiencies.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
#define M(I)