Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Falloff.cpp
Go to the documentation of this file.
1 /**
2  * @file Falloff.cpp Definitions for member functions of classes derived from
3  * Falloff
4  */
5 
8 #include "cantera/kinetics/Falloff.h"
9 
10 namespace Cantera
11 {
12 
13 void Falloff::init(const vector_fp& c)
14 {
15  if (c.size() != 0) {
16  throw CanteraError("Falloff::init",
17  "Incorrect number of parameters. 0 required. Received " +
18  int2str(c.size()) + ".");
19  }
20 }
21 
22 void Troe::init(const vector_fp& c)
23 {
24  if (c.size() != 3 && c.size() != 4) {
25  throw CanteraError("Troe::init",
26  "Incorrect number of parameters. 3 or 4 required. Received " +
27  int2str(c.size()) + ".");
28  }
29  m_a = c[0];
30  if (c[1] == 0.0) {
31  m_rt3 = 1000.;
32  } else {
33  m_rt3 = 1.0/c[1];
34  }
35  if (c[2] == 0.0) {
36  m_rt1 = 1000.;
37  } else {
38  m_rt1 = 1.0/c[2];
39  }
40  if (c.size() == 4) {
41  m_t2 = c[3];
42  }
43 }
44 
45 void Troe::updateTemp(double T, double* work) const
46 {
47  double Fcent = (1.0 - m_a) * exp(-T*m_rt3) + m_a * exp(-T*m_rt1);
48  if (m_t2) {
49  Fcent += exp(- m_t2 / T);
50  }
51  *work = log10(std::max(Fcent, SmallNumber));
52 }
53 
54 double Troe::F(double pr, const double* work) const
55 {
56  double lpr,f1,lgf, cc, nn;
57  lpr = log10(std::max(pr,SmallNumber));
58  cc = -0.4 - 0.67 * (*work);
59  nn = 0.75 - 1.27 * (*work);
60  f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
61  lgf = (*work) / (1.0 + f1 * f1);
62  return pow(10.0, lgf);
63 }
64 
65 void Troe::getParameters(double* params) const {
66  params[0] = m_a;
67  params[1] = 1.0/m_rt3;
68  params[2] = 1.0/m_rt1;
69  params[3] = m_t2;
70 }
71 
72 void SRI::init(const vector_fp& c)
73 {
74  if (c.size() != 3 && c.size() != 5) {
75  throw CanteraError("SRI::init",
76  "Incorrect number of parameters. 3 or 5 required. Received " +
77  int2str(c.size()) + ".");
78  }
79 
80  if (c[2] < 0.0) {
81  throw CanteraError("SRI::init()",
82  "m_c parameter is less than zero: " + fp2str(c[2]));
83  }
84  m_a = c[0];
85  m_b = c[1];
86  m_c = c[2];
87 
88  if (c.size() == 5) {
89  if (c[3] < 0.0) {
90  throw CanteraError("SRI::init()",
91  "m_d parameter is less than zero: " + fp2str(c[3]));
92  }
93  m_d = c[3];
94  m_e = c[4];
95  } else {
96  m_d = 1.0;
97  m_e = 0.0;
98  }
99 }
100 
101 void SRI::updateTemp(double T, double* work) const
102 {
103  *work = m_a * exp(- m_b / T);
104  if (m_c != 0.0) {
105  *work += exp(- T/m_c);
106  }
107  work[1] = m_d * pow(T,m_e);
108 }
109 
110 double SRI::F(double pr, const double* work) const
111 {
112  double lpr = log10(std::max(pr,SmallNumber));
113  double xx = 1.0/(1.0 + lpr*lpr);
114  return pow(*work, xx) * work[1];
115 }
116 
117 void SRI::getParameters(double* params) const
118 {
119  params[0] = m_a;
120  params[1] = m_b;
121  params[2] = m_c;
122  params[3] = m_d;
123  params[4] = m_e;
124 }
125 
126 }
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
Definition: Falloff.cpp:45
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:39
virtual void init(const vector_fp &c)
Initialization of the object.
Definition: Falloff.cpp:72
virtual void getParameters(double *params) const
Sets params to contain, in order, .
Definition: Falloff.cpp:65
doublereal m_c
parameter c in the 5-parameter SRI falloff function. [K]
Definition: Falloff.h:238
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
Definition: Falloff.cpp:54
doublereal m_rt1
parameter 1/T_1 in the 4-parameter Troe falloff function. [K^-1]
Definition: Falloff.h:164
virtual void init(const vector_fp &c)
Initialization of the object.
Definition: Falloff.cpp:22
virtual void getParameters(double *params) const
Sets params to contain, in order, .
Definition: Falloff.cpp:117
doublereal m_t2
parameter T_2 in the 4-parameter Troe falloff function. [K]
Definition: Falloff.h:167
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
Definition: Falloff.cpp:101
doublereal m_rt3
parameter 1/T_3 in the 4-parameter Troe falloff function. [K^-1]
Definition: Falloff.h:161
virtual void init(const vector_fp &c)
Initialize.
Definition: Falloff.cpp:13
doublereal m_e
parameter d in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:244
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:28
doublereal m_d
parameter d in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:241
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
doublereal m_b
parameter b in the 5-parameter SRI falloff function. [K]
Definition: Falloff.h:235
const doublereal SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:126
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:157
doublereal m_a
parameter a in the 4-parameter Troe falloff function. Dimensionless
Definition: Falloff.h:158
Contains declarations for string manipulation functions within Cantera.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
Definition: Falloff.cpp:110
doublereal m_a
parameter a in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:232