fluxLimitedLangmuirHinshelwoodReactionRateI.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) 2019-2020 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 #include "volFields.H"
27 #include "mathematicalConstants.H"
28 #include "thermodynamicConstants.H"
29 
30 using namespace Foam::constant::mathematical;
31 using namespace Foam::constant::thermodynamic;
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 inline Foam::scalar Foam::fluxLimitedLangmuirHinshelwoodReactionRate::Av
36 (
37  const label li
38 ) const
39 {
40  if (AvUniform_)
41  {
42  return Av_;
43  }
44  else
45  {
46  return AvField_[li];
47  }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
55 (
56  const speciesTable& st,
57  const objectRegistry& ob,
58  const dictionary& dict
59 )
60 :
61  additionalAdsorbableSpecieNames_
62  (
63  dict.lookupOrDefault
64  (
65  "additionalAdsorbableSpecies",
66  wordList()
67  )
68  ),
69  a_(dict.lookupOrDefault("a", scalar(1))),
70  A_(dict.lookup("A")),
71  Ta_(dict.lookup("Ta")),
72  limited_(dict.found("s")),
73  AvUniform_
74  (
75  limited_
76  ? dict.lookup("Av")[0].isNumber()
77  : true
78  ),
79  Av_
80  (
81  limited_ && AvUniform_
82  ? dict.lookup<scalar>("Av")
83  : 0
84  ),
85  AvName_
86  (
87  limited_ && !AvUniform_
88  ? dict.lookup("Av")
89  : word::null
90  ),
91  AvField_
92  (
93  limited_ && !AvUniform_
96  )
97 {
101  (
102  IStringStream(dict.lookup("reaction"))(),
103  st,
104  lhs,
105  rhs
106  );
107 
108  nReactants_ = lhs.size();
109 
110  ra_.setSize(nReactants_ + additionalAdsorbableSpecieNames_.size());
111  nu_.setSize(nReactants_);
112  exp_.setSize(nReactants_);
113 
114  forAll(lhs, i)
115  {
116  ra_[i] = lhs[i].index;
117  nu_[i] = lhs[i].stoichCoeff;
118  exp_[i] = lhs[i].exponent;
119  }
120 
121  forAll(additionalAdsorbableSpecieNames_, i)
122  {
123  ra_[nReactants_ + i] = st[additionalAdsorbableSpecieNames_[i]];
124  }
125 
126  beta_ =
127  dict.lookupOrDefault
128  (
129  "beta",
130  scalarList
131  (
132  1 + nReactants_ + additionalAdsorbableSpecieNames_.size(),
133  scalar(0)
134  )
135  );
136 
137  m_ =
138  dict.lookupOrDefault
139  (
140  "m",
141  scalarList
142  (
143  1 + nReactants_ + additionalAdsorbableSpecieNames_.size(),
144  scalar(1)
145  )
146  );
147 
148  if (!dict.found("m"))
149  {
150  m_[0] = 2;
151  }
152 
153  s_ = dict.lookupOrDefault("s", scalarList(nReactants_, scalar(0)));
154 
155  W_ =
156  limited_
157  ? scalarList(dict.lookup("W"))
158  : scalarList(nReactants_, scalar(0));
159 
160  const scalar nCoeffs =
161  1 + nReactants_ + additionalAdsorbableSpecieNames_.size();
162 
163  if (A_.size() != nCoeffs)
164  {
166  << "Number of A coefficients != " << nCoeffs
167  << exit(FatalIOError);
168  }
169 
170  if (Ta_.size() != nCoeffs)
171  {
173  << "Number of Ta coefficients != " << nCoeffs
174  << exit(FatalIOError);
175  }
176 
177  if (beta_.size() != nCoeffs)
178  {
180  << "Number of beta coefficients != " << nCoeffs
181  << exit(FatalIOError);
182  }
183 
184  if (m_.size() != nCoeffs)
185  {
187  << "Number of m coefficients != " << nCoeffs
188  << exit(FatalIOError);
189  }
190 
191  if (s_.size() != nReactants_)
192  {
194  << "Number of s coefficients != "
195  << nReactants_ << exit(FatalIOError);
196  }
197 
198  if (W_.size() != nReactants_)
199  {
201  << "Number of W coefficients != "
202  << nReactants_ << exit(FatalIOError);
203  }
204 }
205 
206 
207 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
208 
209 inline Foam::scalar
210 Foam::fluxLimitedLangmuirHinshelwoodReactionRate::operator()
211 (
212  const scalar p,
213  const scalar T,
214  const scalarField& c,
215  const label li
216 ) const
217 {
218  scalar sumkc = 0;
219  forAll(ra_, i)
220  {
221  const label ip1 = i + 1;
222 
223  const scalar kc =
224  A_[ip1]*pow(T, beta_[ip1])*exp(-Ta_[ip1]/T)
225  *pow(c[ra_[i]], m_[ip1]);
226 
227  sumkc += kc;
228  }
229 
230  const scalar TaByT0 = Ta_[0]/T;
231  const scalar k0 = A_[0]*pow(T, beta_[0])*exp(-TaByT0);
232 
233  scalar r = k0/pow(a_ + sumkc, m_[0]);
234 
235  if (limited_)
236  {
237  scalar rc = 1;
238  forAll(ra_, i)
239  {
240  rc *= pow(c[ra_[i]], exp_[i]);
241  }
242 
243  const scalar Av = this->Av(li);
244 
245  if (rc > rootSmall)
246  {
247  forAll(s_, i)
248  {
249  r = min
250  (
251  r,
252  (Av*s_[i]*c[ra_[i]]/(nu_[i]*rc))*sqrt(RR*T/(twoPi*W_[i]))
253  );
254  }
255  }
256  }
257 
258  return r;
259 }
260 
261 
263 (
264  const scalar p,
265  const scalar T,
266  const scalarField& c,
267  const label li
268 ) const
269 {
270  scalar sumkc = 0;
271  scalar sumBetaKc = 0;
272  forAll(ra_, i)
273  {
274  const label ip1 = i + 1;
275 
276  const scalar kc =
277  A_[ip1]*pow(T, beta_[ip1])*exp(-Ta_[ip1]/T)
278  *pow(c[ra_[i]], m_[ip1]);
279 
280  sumkc += kc;
281  sumBetaKc += (beta_[ip1] + Ta_[ip1]/T)*kc;
282  }
283 
284  const scalar TaByT0 = Ta_[0]/T;
285  const scalar k0 = A_[0]*pow(T, beta_[0])*exp(-TaByT0);
286 
287  scalar ddT =
288  ((beta_[0] + TaByT0)*k0 - m_[0]*k0*sumBetaKc/(a_ + sumkc))
289  /(pow(a_ + sumkc, m_[0])*T);
290 
291  if (limited_)
292  {
293  scalar rc = 1;
294  forAll(ra_, i)
295  {
296  rc *= pow(c[ra_[i]], exp_[i]);
297  }
298 
299  scalar r = k0/pow(a_ + sumkc, m_[0]);
300 
301  if (rc > rootSmall)
302  {
303  label l = -1;
304 
305  const scalar Av = this->Av(li);
306 
307  forAll(s_, i)
308  {
309  const scalar rl =
310  (Av*s_[i]*c[ra_[i]]/(nu_[i]*rc))*sqrt(RR*T/(twoPi*W_[i]));
311 
312  if (rl < r)
313  {
314  l = i;
315  r = rl;
316  }
317  }
318 
319  if (l != -1)
320  {
321  ddT =
322  (Av*s_[l]*c[ra_[l]]/(nu_[l]*rc))
323  *0.5*sqrt(RR/(twoPi*W_[l]*T));
324  }
325  }
326  }
327 
328  return ddT;
329 }
330 
331 
334 {
335  return NullObjectRef<List<Tuple2<label, scalar>>>();
336 }
337 
338 
340 (
341  const scalar p,
342  const scalar T,
343  const scalarField& c,
344  const label li,
345  scalarField& dcidc
346 ) const
347 {}
348 
349 
351 (
352  const scalar p,
353  const scalar T,
354  const scalarField& c,
355  const label li
356 ) const
357 {
358  return 0;
359 }
360 
361 
363 (
364  Ostream& os
365 ) const
366 {
367  writeEntry
368  (
369  os,
370  "additionalAdsorbableSpecies",
371  additionalAdsorbableSpecieNames_
372  );
373  writeEntry(os, "a", a_);
374  writeEntry(os, "A", A_);
375  writeEntry(os, "Ta", Ta_);
376  writeEntry(os, "beta", beta_);
377  writeEntry(os, "m", m_);
378  if (limited_)
379  {
380  writeEntry(os, "s", s_);
381  writeEntry(os, "W", W_);
382  }
383 }
384 
385 
386 inline Foam::Ostream& Foam::operator<<
387 (
388  Ostream& os,
390 )
391 {
392  lhrr.write(os);
393  return os;
394 }
395 
396 
397 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual Ostream & write(const char)=0
Write character.
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
scalar ddT(const scalar p, const scalar T, const scalarField &c, const label li) const
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
dimensionedScalar sqrt(const dimensionedScalar &ds)
Thermodynamic scalar constants.
const dimensionedScalar & c
Speed of light in a vacuum.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
fluxLimitedLangmuirHinshelwoodReactionRate(const speciesTable &species, const objectRegistry &ob, const dictionary &dict)
Construct from dictionary.
dimensionedScalar exp(const dimensionedScalar &ds)
mathematical constants.
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:50
static const word null
An empty word.
Definition: word.H:77
const List< Tuple2< label, scalar > > & beta() const
Third-body efficiencies (beta = 1-alpha)
Langmuir-Hinshelwood reaction rate for gaseous reactions on surfaces including the optional flux limi...
void dcidc(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dcidc) const
Species concentration derivative of the pressure dependent term.
const scalar twoPi(2 *pi)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
scalar dcidT(const scalar p, const scalar T, const scalarField &c, const label li) const
Temperature derivative of the pressure dependent term.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
static const GeometricField< scalar, fvPatchField, volMesh > & null()
Return a null geometric field.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
static void setLRhs(Istream &, const speciesTable &, List< specieCoeffs > &lhs, List< specieCoeffs > &rhs)
Construct the left- and right-hand-side reaction coefficients.
Definition: specieCoeffs.C:95
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
A wordList with hashed indices for faster lookup by name.
Input from memory buffer stream.
Definition: IStringStream.H:49
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const scalar RR
Universal gas constant (default in [J/kmol/K])
volScalarField & p
Registry of regIOobjects.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812
IOerror FatalIOError