Cantera  2.1.2
FalloffFactory.cpp
Go to the documentation of this file.
1 /**
2  * @file FalloffFactory.cpp
3  */
4 // Copyright 2001 California Institute of Technology
5 
9 #include "cantera/base/global.h"
10 
11 namespace Cantera
12 {
13 
14 FalloffFactory* FalloffFactory::s_factory = 0;
16 
17 //! The 3-parameter Troe falloff parameterization.
18 /*!
19  * The falloff function defines the value of \f$ F \f$ in the following
20  * rate expression
21  *
22  * \f[ k = k_{\infty} \left( \frac{P_r}{1 + P_r} \right) F \f]
23  * where
24  * \f[ P_r = \frac{k_0 [M]}{k_{\infty}} \f]
25  *
26  * This parameterization is defined by
27  * \f[ F = F_{cent}^{1/(1 + f_1^2)} \f]
28  * where
29  * \f[ F_{cent} = (1 - A)\exp(-T/T_3) + A \exp(-T/T_1) \f]
30  *
31  * \f[ f_1 = (\log_{10} P_r + C) / \left(N - 0.14
32  * (\log_{10} P_r + C)\right) \f]
33  *
34  * \f[ C = -0.4 - 0.67 \log_{10} F_{cent} \f]
35  *
36  * \f[ N = 0.75 - 1.27 \log_{10} F_{cent} \f]
37  *
38  * - If \f$ T_3 \f$ is zero, then the corresponding term is set to zero.
39  * - If \f$ T_1 \f$ is zero, then the corresponding term is set to zero.
40  *
41  * @ingroup falloffGroup
42  */
43 class Troe3 : public Falloff
44 {
45 public:
46  //! Default constructor.
47  Troe3() : m_a(0.0), m_rt3(0.0), m_rt1(0.0) {}
48 
49  /**
50  * Initialize.
51  * @param c Coefficient vector of length 3,
52  * with entries \f$ (A, T_3, T_1) \f$
53  */
54  virtual void init(const vector_fp& c) {
55  m_a = c[0];
56 
57  if (c[1] == 0.0) {
58  m_rt3 = 1000.;
59  } else {
60  m_rt3 = 1.0/c[1];
61  }
62  if (c[2] == 0.0) {
63  m_rt1 = 1000.;
64  } else {
65  m_rt1 = 1.0/c[2];
66  }
67  }
68 
69  //! Update the temperature parameters in the representation
70  /*!
71  * The workspace has a length of one
72  *
73  * @param T Temperature (Kelvin)
74  * @param work Vector of working space representing
75  * the temperature dependent part of the
76  * parameterization.
77  */
78  virtual void updateTemp(doublereal T, doublereal* work) const {
79  doublereal Fcent = (1.0 - m_a) * exp(- T * m_rt3)
80  + m_a * exp(- T * m_rt1);
81  *work = log10(std::max(Fcent, SmallNumber));
82  }
83 
84  virtual doublereal F(doublereal pr, const doublereal* work) const {
85  doublereal lpr,f1,lgf, cc, nn;
86  lpr = log10(std::max(pr,SmallNumber));
87  cc = -0.4 - 0.67 * (*work);
88  nn = 0.75 - 1.27 * (*work);
89  f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
90  lgf = (*work) / (1.0 + f1 * f1);
91  return pow(10.0, lgf);
92  }
93 
94  virtual size_t workSize() {
95  return 1;
96  }
97 
98 protected:
99  //! parameter a in the 4-parameter Troe falloff function. This is
100  //! unitless.
101  doublereal m_a;
102 
103  //! parameter 1/T_3 in the 4-parameter Troe falloff function. This has
104  //! units of Kelvin-1
105  doublereal m_rt3;
106 
107  //! parameter 1/T_1 in the 4-parameter Troe falloff function. This has
108  //! units of Kelvin-1.
109  doublereal m_rt1;
110 };
111 
112 //! The 4-parameter Troe falloff parameterization.
113 /*!
114  * The falloff function defines the value of \f$ F \f$ in the following
115  * rate expression
116  *
117  * \f[ k = k_{\infty} \left( \frac{P_r}{1 + P_r} \right) F \f]
118  * where
119  * \f[ P_r = \frac{k_0 [M]}{k_{\infty}} \f]
120  *
121  * This parameterization is defined by
122  *
123  * \f[ F = F_{cent}^{1/(1 + f_1^2)} \f]
124  * where
125  * \f[ F_{cent} = (1 - A)\exp(-T/T_3) + A \exp(-T/T_1) + \exp(-T_2/T) \f]
126  *
127  * \f[ f_1 = (\log_{10} P_r + C) /
128  * \left(N - 0.14 (\log_{10} P_r + C)\right) \f]
129  *
130  * \f[ C = -0.4 - 0.67 \log_{10} F_{cent} \f]
131  *
132  * \f[ N = 0.75 - 1.27 \log_{10} F_{cent} \f]
133  *
134  * - If \f$ T_3 \f$ is zero, then the corresponding term is set to zero.
135  * - If \f$ T_1 \f$ is zero, then the corresponding term is set to zero.
136  *
137  * @ingroup falloffGroup
138  */
139 class Troe4 : public Falloff
140 {
141 public:
142  //! Constructor
143  Troe4() : m_a(0.0), m_rt3(0.0), m_rt1(0.0),
144  m_t2(0.0) {}
145 
146  //! Initialization of the object
147  /*!
148  * @param c Vector of four doubles: The doubles are the parameters,
149  * a,, T_3, T_1, and T_2 of the Troe parameterization
150  */
151  virtual void init(const vector_fp& c) {
152  m_a = c[0];
153  if (c[1] == 0.0) {
154  m_rt3 = 1000.;
155  } else {
156  m_rt3 = 1.0/c[1];
157  }
158  if (c[2] == 0.0) {
159  m_rt1 = 1000.;
160  } else {
161  m_rt1 = 1.0/c[2];
162  }
163  m_t2 = c[3];
164  }
165 
166  //! Update the temperature parameters in the representation
167  /*!
168  * The workspace has a length of one
169  *
170  * @param T Temperature (Kelvin)
171  * @param work Vector of working space representing
172  * the temperature dependent part of the
173  * parameterization.
174  */
175  virtual void updateTemp(doublereal T, doublereal* work) const {
176  doublereal Fcent = (1.0 - m_a) * exp(- T * m_rt3)
177  + m_a * exp(- T * m_rt1)
178  + exp(- m_t2 / T);
179  *work = log10(std::max(Fcent, SmallNumber));
180  }
181 
182  virtual doublereal F(doublereal pr, const doublereal* work) const {
183  doublereal lpr,f1,lgf, cc, nn;
184  lpr = log10(std::max(pr,SmallNumber));
185  cc = -0.4 - 0.67 * (*work);
186  nn = 0.75 - 1.27 * (*work);
187  f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
188  lgf = (*work) / (1.0 + f1 * f1);
189  return pow(10.0, lgf);
190  }
191 
192  virtual size_t workSize() {
193  return 1;
194  }
195 
196 protected:
197  //! parameter a in the 4-parameter Troe falloff function. This is
198  //! unitless.
199  doublereal m_a;
200 
201  //! parameter 1/T_3 in the 4-parameter Troe falloff function. This has
202  //! units of Kelvin-1.
203  doublereal m_rt3;
204 
205  //! parameter 1/T_1 in the 4-parameter Troe falloff function. This has
206  //! units of Kelvin-1.
207  doublereal m_rt1;
208 
209  //! parameter T_2 in the 4-parameter Troe falloff function. This has
210  //! units of Kelvin.
211  doublereal m_t2;
212 };
213 
214 //! The 3-parameter SRI falloff function for <I>F</I>
215 /*!
216  * The falloff function defines the value of \f$ F \f$ in the following
217  * rate expression
218  *
219  * \f[ k = k_{\infty} \left( \frac{P_r}{1 + P_r} \right) F \f]
220  * where
221  * \f[ P_r = \frac{k_0 [M]}{k_{\infty}} \f]
222  *
223  * \f[ F = {\left( a \; exp(\frac{-b}{T}) + exp(\frac{-T}{c})\right)}^n \f]
224  * where
225  * \f[ n = \frac{1.0}{1.0 + {\log_{10} P_r}^2} \f]
226  *
227  * \f$ c \f$ s required to greater than or equal to zero. If it is zero,
228  * then the corresponding term is set to zero.
229  *
230  * @ingroup falloffGroup
231  */
232 class SRI3 : public Falloff
233 {
234 public:
235  //! Constructor
236  SRI3() {}
237 
238  //! Initialization of the object
239  /*!
240  * @param c Vector of three doubles: The doubles are the parameters,
241  * a, b, and c of the SRI parameterization
242  */
243  virtual void init(const vector_fp& c) {
244  if (c[2] < 0.0) {
245  throw CanteraError("SRI3::init()",
246  "m_c parameter is less than zero: " + fp2str(c[2]));
247  }
248  m_a = c[0];
249  m_b = c[1];
250  m_c = c[2];
251  }
252 
253  //! Update the temperature parameters in the representation
254  /*!
255  * The workspace has a length of one
256  *
257  * @param T Temperature (Kelvin)
258  * @param work Vector of working space representing
259  * the temperature dependent part of the
260  * parameterization.
261  */
262  virtual void updateTemp(doublereal T, doublereal* work) const {
263  *work = m_a * exp(- m_b / T);
264  if (m_c != 0.0) {
265  *work += exp(- T/m_c);
266  }
267  }
268 
269  virtual doublereal F(doublereal pr, const doublereal* work) const {
270  doublereal lpr = log10(std::max(pr,SmallNumber));
271  doublereal xx = 1.0/(1.0 + lpr*lpr);
272  return pow(*work , xx);
273  }
274 
275  virtual size_t workSize() {
276  return 1;
277  }
278 
279 protected:
280  //! parameter a in the 3-parameter SRI falloff function. This is
281  //! unitless.
282  doublereal m_a;
283 
284  //! parameter b in the 3-parameter SRI falloff function. This has units
285  //! of Kelvin.
286  doublereal m_b;
287 
288  //! parameter c in the 3-parameter SRI falloff function. This has units
289  //! of Kelvin.
290  doublereal m_c;
291 };
292 
293 //! The 5-parameter SRI falloff function.
294 /*!
295  * The falloff function defines the value of \f$ F \f$ in the following
296  * rate expression
297  *
298  * \f[ k = k_{\infty} \left( \frac{P_r}{1 + P_r} \right) F \f]
299  * where
300  * \f[ P_r = \frac{k_0 [M]}{k_{\infty}} \f]
301  *
302  * \f[ F = {\left( a \; exp(\frac{-b}{T}) + exp(\frac{-T}{c})\right)}^n
303  * \; d \; exp(\frac{-e}{T}) \f]
304  * where
305  * \f[ n = \frac{1.0}{1.0 + {\log_{10} P_r}^2} \f]
306  *
307  * \f$ c \f$ s required to greater than or equal to zero. If it is zero, then
308  * the corresponding term is set to zero.
309  *
310  * m_c is required to greater than or equal to zero. If it is zero, then the
311  * corresponding term is set to zero.
312  *
313  * m_d is required to be greater than zero.
314  *
315  * @ingroup falloffGroup
316  */
317 class SRI5 : public Falloff
318 {
319 public:
320  //! Constructor
321  SRI5() {}
322 
323  //! Initialization of the object
324  /*!
325  * @param c Vector of five doubles: The doubles are the parameters,
326  * a, b, c, d, and e of the SRI parameterization
327  */
328  virtual void init(const vector_fp& c) {
329  if (c[2] < 0.0) {
330  throw CanteraError("SRI5::init()",
331  "m_c parameter is less than zero: " + fp2str(c[2]));
332  }
333  if (c[3] < 0.0) {
334  throw CanteraError("SRI5::init()",
335  "m_d parameter is less than zero: " + fp2str(c[3]));
336  }
337  m_a = c[0];
338  m_b = c[1];
339  m_c = c[2];
340  m_d = c[3];
341  m_e = c[4];
342  }
343 
344  //! Update the temperature parameters in the representation
345  /*!
346  * The workspace has a length of two
347  *
348  * @param T Temperature (Kelvin)
349  * @param work Vector of working space representing
350  * the temperature dependent part of the
351  * parameterization.
352  */
353  virtual void updateTemp(doublereal T, doublereal* work) const {
354  *work = m_a * exp(- m_b / T);
355  if (m_c != 0.0) {
356  *work += exp(- T/m_c);
357  }
358  work[1] = m_d * pow(T,m_e);
359  }
360 
361  virtual doublereal F(doublereal pr, const doublereal* work) const {
362  doublereal lpr = log10(std::max(pr,SmallNumber));
363  doublereal xx = 1.0/(1.0 + lpr*lpr);
364  return pow(*work, xx) * work[1];
365  }
366 
367  virtual size_t workSize() {
368  return 2;
369  }
370 
371 protected:
372  //! parameter a in the 5-parameter SRI falloff function. This is unitless.
373  doublereal m_a;
374 
375  //! parameter b in the 5-parameter SRI falloff function. This has units of
376  //! Kelvin.
377  doublereal m_b;
378 
379  //! parameter c in the 5-parameter SRI falloff function. This has units of
380  //! Kelvin.
381  doublereal m_c;
382 
383  //! parameter d in the 5-parameter SRI falloff function. This is unitless.
384  doublereal m_d;
385 
386  //! parameter d in the 5-parameter SRI falloff function. This is unitless.
387  doublereal m_e;
388 };
389 
390 //! Wang-Frenklach falloff function.
391 /*!
392  * The falloff function defines the value of \f$ F \f$ in the following
393  * rate expression
394  *
395  * \f[ k = k_{\infty} \left( \frac{P_r}{1 + P_r} \right) F \f]
396  * where
397  * \f[ P_r = \frac{k_0 [M]}{k_{\infty}} \f]
398  *
399  * \f[ F = 10.0^{Flog} \f]
400  * where
401  * \f[ Flog = \frac{\log_{10} F_{cent}}{\exp{(\frac{\log_{10} P_r - \alpha}{\sigma})^2}} \f]
402  * where
403  * \f[ F_{cent} = (1 - A)\exp(-T/T_3) + A \exp(-T/T_1) + \exp(-T/T_2) \f]
404  *
405  * \f[ \alpha = \alpha_0 + \alpha_1 T + \alpha_2 T^2 \f]
406  *
407  * \f[ \sigma = \sigma_0 + \sigma_1 T + \sigma_2 T^2 \f]
408  *
409  * Reference: Wang, H., and Frenklach, M., Chem. Phys. Lett. vol. 205, 271 (1993).
410  *
411  * @ingroup falloffGroup
412  * @deprecated
413  */
414 class WF93 : public Falloff
415 {
416 public:
417  //! Default constructor
418  WF93() {
419  warn_deprecated("class WF93", "To be removed in Cantera 2.2.");
420  }
421 
422  //! Initialization routine
423  /*!
424  * @param c Vector of 10 doubles with the following ordering: a, T_1,
425  * T_2, T_3, alpha0, alpha1, alpha2 sigma0, sigma1, sigma2
426  */
427  virtual void init(const vector_fp& c) {
428  m_a = c[0];
429  m_rt1 = 1.0/c[1];
430  m_t2 = c[2];
431  m_rt3 = 1.0/c[3];
432  m_alpha0 = c[4];
433  m_alpha1 = c[5];
434  m_alpha2 = c[6];
435  m_sigma0 = c[7];
436  m_sigma1 = c[8];
437  m_sigma2 = c[9];
438  }
439 
440  //! Update the temperature parameters in the representation
441  /*!
442  * The workspace has a length of three
443  *
444  * @param T Temperature (Kelvin)
445  * @param work Vector of working space representing
446  * the temperature dependent part of the
447  * parameterization.
448  */
449  virtual void updateTemp(doublereal T, doublereal* work) const {
450  work[0] = m_alpha0 + (m_alpha1 + m_alpha2*T)*T; // alpha
451  work[1] = m_sigma0 + (m_sigma1 + m_sigma2*T)*T; // sigma
452  doublereal Fcent = (1.0 - m_a) * exp(- T * m_rt3)
453  + m_a * exp(- T * m_rt1) + exp(-m_t2/T);
454  work[2] = log10(Fcent);
455  }
456 
457  virtual doublereal F(doublereal pr, const doublereal* work) const {
458  doublereal lpr = log10(std::max(pr, SmallNumber));
459  doublereal x = (lpr - work[0])/work[1];
460  doublereal flog = work[2]/exp(x*x);
461  return pow(10.0, flog);
462  }
463 
464  virtual size_t workSize() {
465  return 3;
466  }
467 
468 protected:
469  //! Value of the \f$ \alpha_0 \f$ coefficient. This is the fifth
470  //! coefficient in the xml list.
471  doublereal m_alpha0;
472 
473  //! Value of the \f$ \alpha_1 \f$ coefficient. This is the 6th coefficient
474  //! in the xml list.
475  doublereal m_alpha1;
476 
477  //! Value of the \f$ \alpha_2 \f$ coefficient. This is the 7th coefficient
478  //! in the xml list.
479  doublereal m_alpha2;
480 
481  //! Value of the \f$ \sigma_0 \f$ coefficient. This is the 8th coefficient
482  //! in the xml list.
483  doublereal m_sigma0;
484 
485  //! Value of the \f$ \sigma_1 \f$ coefficient. This is the 9th coefficient
486  //! in the xml list.
487  doublereal m_sigma1;
488 
489  //! Value of the \f$ \sigma_2 \f$ coefficient. This is the 10th
490  //! coefficient in the xml list.
491  doublereal m_sigma2;
492 
493  //! Value of the \f$ a \f$ coefficient. This is the first coefficient in
494  //! the xml list.
495  doublereal m_a;
496 
497  //! Value of inverse of the \f$ t1 \f$ coefficient. This is the second
498  //! coefficient in the xml list.
499  doublereal m_rt1;
500 
501  //! Value of the \f$ t2 \f$ coefficient. This is the third coefficient in
502  //! the xml list.
503  doublereal m_t2;
504 
505  //! Value of the inverse of the \f$ t3 \f$ coefficient. This is the 4th
506  //! coefficient in the xml list.
507  doublereal m_rt3;
508 };
509 
511 {
512  Falloff* f;
513  switch (type) {
514  case SIMPLE_FALLOFF:
515  f = new Falloff();
516  break;
517  case TROE3_FALLOFF:
518  f = new Troe3();
519  break;
520  case TROE4_FALLOFF:
521  f = new Troe4();
522  break;
523  case SRI3_FALLOFF:
524  f = new SRI3();
525  break;
526  case SRI5_FALLOFF:
527  f = new SRI5();
528  break;
529  case WF_FALLOFF:
530  f = new WF93();
531  break;
532  default:
533  return 0;
534  }
535  f->init(c);
536  return f;
537 }
538 
539 }
doublereal m_alpha2
Value of the coefficient.
The 3-parameter Troe falloff parameterization.
doublereal m_d
parameter d in the 5-parameter SRI falloff function. This is unitless.
virtual Falloff * newFalloff(int type, const vector_fp &c)
Return a pointer to a new falloff function calculator.
doublereal m_alpha1
Value of the coefficient.
WF93()
Default constructor.
doublereal m_rt3
parameter 1/T_3 in the 4-parameter Troe falloff function.
virtual size_t workSize()
The size of the work array required.
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
doublereal m_rt1
parameter 1/T_1 in the 4-parameter Troe falloff function.
virtual void init(const vector_fp &c)
Initialization of the object.
doublereal m_a
parameter a in the 4-parameter Troe falloff function.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:76
doublereal m_c
parameter c in the 5-parameter SRI falloff function.
Parameterizations for reaction falloff functions.
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, HTML_logs (see Input File Handling, Diagnostic Output, Writing messages to the screen and Writing HTML Logfiles).
doublereal m_sigma1
Value of the coefficient.
doublereal m_alpha0
Value of the coefficient.
The 5-parameter SRI falloff function.
static mutex_t falloff_mutex
Mutex for use when calling the factory.
doublereal m_t2
parameter T_2 in the 4-parameter Troe falloff function.
doublereal m_rt1
Value of inverse of the coefficient.
Troe3()
Default constructor.
doublereal m_sigma2
Value of the coefficient.
SRI3()
Constructor.
virtual size_t workSize()
The size of the work array required.
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
doublereal m_rt3
Value of the inverse of the coefficient.
doublereal m_c
parameter c in the 3-parameter SRI falloff function.
Troe4()
Constructor.
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:29
doublereal m_e
parameter d in the 5-parameter SRI falloff function. This is unitless.
virtual size_t workSize()
The size of the work array required.
doublereal m_a
parameter a in the 5-parameter SRI falloff function. This is unitless.
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
virtual void init(const vector_fp &c)
Initialization routine.
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
doublereal m_t2
Value of the coefficient.
virtual void init(const vector_fp &c)
Initialize.
virtual void init(const vector_fp &c)
Initialization of the object.
static FalloffFactory * s_factory
Pointer to the single instance of the factory.
Base class for falloff function calculators.
doublereal m_a
parameter a in the 4-parameter Troe falloff function.
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
virtual size_t workSize()
The size of the work array required.
doublereal m_a
parameter a in the 3-parameter SRI falloff function.
doublereal m_rt3
parameter 1/T_3 in the 4-parameter Troe falloff function.
const doublereal SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:139
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
SRI5()
Constructor.
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
virtual void init(const vector_fp &c)
Initialization of the object.
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
doublereal m_b
parameter b in the 5-parameter SRI falloff function.
Contains declarations for string manipulation functions within Cantera.
The 4-parameter Troe falloff parameterization.
virtual void init(const vector_fp &c)
Initialize.
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
The 3-parameter SRI falloff function for F
Wang-Frenklach falloff function.
doublereal m_sigma0
Value of the coefficient.
virtual size_t workSize()
The size of the work array required.
doublereal m_a
Value of the coefficient.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
doublereal m_rt1
parameter 1/T_1 in the 4-parameter Troe falloff function.
doublereal m_b
parameter b in the 3-parameter SRI falloff function.