Cantera  2.5.1
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 
6 // This file is part of Cantera. See License.txt in the top-level directory or
7 // at https://cantera.org/license.txt for license and copyright information.
8 
11 #include "cantera/base/global.h"
12 #include "cantera/kinetics/Falloff.h"
13 
14 namespace Cantera
15 {
16 
17 void Falloff::init(const vector_fp& c)
18 {
19  if (c.size() != 0) {
20  throw CanteraError("Falloff::init",
21  "Incorrect number of parameters. 0 required. Received {}.",
22  c.size());
23  }
24 }
25 
26 void Troe::init(const vector_fp& c)
27 {
28  if (c.size() != 3 && c.size() != 4) {
29  throw CanteraError("Troe::init",
30  "Incorrect number of parameters. 3 or 4 required. Received {}.",
31  c.size());
32  }
33  m_a = c[0];
34  if (std::abs(c[1]) < SmallNumber) {
35  m_rt3 = std::numeric_limits<double>::infinity();
36  } else {
37  m_rt3 = 1.0 / c[1];
38  }
39 
40  if (std::abs(c[2]) < SmallNumber) {
41  m_rt1 = std::numeric_limits<double>::infinity();
42  } else {
43  m_rt1 = 1.0 / c[2];
44  }
45 
46  if (c.size() == 4) {
47  if (std::abs(c[3]) < SmallNumber) {
48  warn_user("Troe::init",
49  "Unexpected parameter value T2=0. Omitting exp(T2/T) term from "
50  "falloff expression. To suppress this warning, remove value "
51  "for T2 from the input file. In the unlikely case that the "
52  "exp(T2/T) term should be included with T2 effectively equal "
53  "to 0, set T2 to a sufficiently small value "
54  "(i.e. T2 < 1e-16).");
55  }
56  m_t2 = c[3];
57  }
58 }
59 
60 void Troe::updateTemp(double T, double* work) const
61 {
62  double Fcent = (1.0 - m_a) * exp(-T*m_rt3) + m_a * exp(-T*m_rt1);
63  if (m_t2) {
64  Fcent += exp(- m_t2 / T);
65  }
66  *work = log10(std::max(Fcent, SmallNumber));
67 }
68 
69 double Troe::F(double pr, const double* work) const
70 {
71  double lpr = log10(std::max(pr,SmallNumber));
72  double cc = -0.4 - 0.67 * (*work);
73  double nn = 0.75 - 1.27 * (*work);
74  double f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
75  double lgf = (*work) / (1.0 + f1 * f1);
76  return pow(10.0, lgf);
77 }
78 
79 void Troe::getParameters(double* params) const {
80  params[0] = m_a;
81  params[1] = 1.0/m_rt3;
82  params[2] = 1.0/m_rt1;
83  params[3] = m_t2;
84 }
85 
86 void SRI::init(const vector_fp& c)
87 {
88  if (c.size() != 3 && c.size() != 5) {
89  throw CanteraError("SRI::init",
90  "Incorrect number of parameters. 3 or 5 required. Received {}.",
91  c.size());
92  }
93 
94  if (c[2] < 0.0) {
95  throw CanteraError("SRI::init()",
96  "m_c parameter is less than zero: {}", c[2]);
97  }
98  m_a = c[0];
99  m_b = c[1];
100  m_c = c[2];
101 
102  if (c.size() == 5) {
103  if (c[3] < 0.0) {
104  throw CanteraError("SRI::init()",
105  "m_d parameter is less than zero: {}", c[3]);
106  }
107  m_d = c[3];
108  m_e = c[4];
109  } else {
110  m_d = 1.0;
111  m_e = 0.0;
112  }
113 }
114 
115 void SRI::updateTemp(double T, double* work) const
116 {
117  *work = m_a * exp(- m_b / T);
118  if (m_c != 0.0) {
119  *work += exp(- T/m_c);
120  }
121  work[1] = m_d * pow(T,m_e);
122 }
123 
124 double SRI::F(double pr, const double* work) const
125 {
126  double lpr = log10(std::max(pr,SmallNumber));
127  double xx = 1.0/(1.0 + lpr*lpr);
128  return pow(*work, xx) * work[1];
129 }
130 
131 void SRI::getParameters(double* params) const
132 {
133  params[0] = m_a;
134  params[1] = m_b;
135  params[2] = m_c;
136  params[3] = m_d;
137  params[4] = m_e;
138 }
139 
140 }
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
virtual void init(const vector_fp &c)
Initialize.
Definition: Falloff.cpp:17
doublereal m_c
parameter c in the 5-parameter SRI falloff function. [K]
Definition: Falloff.h:265
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
Definition: Falloff.cpp:115
doublereal m_b
parameter b in the 5-parameter SRI falloff function. [K]
Definition: Falloff.h:262
doublereal m_d
parameter d in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:268
virtual void getParameters(double *params) const
Sets params to contain, in order,.
Definition: Falloff.cpp:131
virtual void init(const vector_fp &c)
Initialization of the object.
Definition: Falloff.cpp:86
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
Definition: Falloff.cpp:124
doublereal m_e
parameter d in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:271
doublereal m_a
parameter a in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:259
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
Definition: Falloff.cpp:60
virtual void getParameters(double *params) const
Sets params to contain, in order,.
Definition: Falloff.cpp:79
virtual void init(const vector_fp &c)
Initialization of the object.
Definition: Falloff.cpp:26
doublereal m_t2
parameter T_2 in the 4-parameter Troe falloff function. [K]
Definition: Falloff.h:188
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
Definition: Falloff.cpp:69
doublereal m_rt3
parameter 1/T_3 in the 4-parameter Troe falloff function. [K^-1]
Definition: Falloff.h:182
doublereal m_rt1
parameter 1/T_1 in the 4-parameter Troe falloff function. [K^-1]
Definition: Falloff.h:185
doublereal m_a
parameter a in the 4-parameter Troe falloff function. Dimensionless
Definition: Falloff.h:179
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles,...
void warn_user(const std::string &method, const std::string &msg, const Args &... args)
Definition: global.h:206
const double SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:149
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:180
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
Contains declarations for string manipulation functions within Cantera.