Cantera  2.4.0
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 http://www.cantera.org/license.txt for license and copyright information.
8 
11 #include "cantera/kinetics/Falloff.h"
12 
13 namespace Cantera
14 {
15 
16 void Falloff::init(const vector_fp& c)
17 {
18  if (c.size() != 0) {
19  throw CanteraError("Falloff::init",
20  "Incorrect number of parameters. 0 required. Received {}.",
21  c.size());
22  }
23 }
24 
25 void Troe::init(const vector_fp& c)
26 {
27  if (c.size() != 3 && c.size() != 4) {
28  throw CanteraError("Troe::init",
29  "Incorrect number of parameters. 3 or 4 required. Received {}.",
30  c.size());
31  }
32  m_a = c[0];
33  m_rt3 = 1.0/c[1];
34  m_rt1 = 1.0/c[2];
35  if (c.size() == 4) {
36  m_t2 = c[3];
37  }
38 }
39 
40 void Troe::updateTemp(double T, double* work) const
41 {
42  double Fcent = (1.0 - m_a) * exp(-T*m_rt3) + m_a * exp(-T*m_rt1);
43  if (m_t2) {
44  Fcent += exp(- m_t2 / T);
45  }
46  *work = log10(std::max(Fcent, SmallNumber));
47 }
48 
49 double Troe::F(double pr, const double* work) const
50 {
51  double lpr = log10(std::max(pr,SmallNumber));
52  double cc = -0.4 - 0.67 * (*work);
53  double nn = 0.75 - 1.27 * (*work);
54  double f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
55  double lgf = (*work) / (1.0 + f1 * f1);
56  return pow(10.0, lgf);
57 }
58 
59 void Troe::getParameters(double* params) const {
60  params[0] = m_a;
61  params[1] = 1.0/m_rt3;
62  params[2] = 1.0/m_rt1;
63  params[3] = m_t2;
64 }
65 
66 void SRI::init(const vector_fp& c)
67 {
68  if (c.size() != 3 && c.size() != 5) {
69  throw CanteraError("SRI::init",
70  "Incorrect number of parameters. 3 or 5 required. Received {}.",
71  c.size());
72  }
73 
74  if (c[2] < 0.0) {
75  throw CanteraError("SRI::init()",
76  "m_c parameter is less than zero: {}", c[2]);
77  }
78  m_a = c[0];
79  m_b = c[1];
80  m_c = c[2];
81 
82  if (c.size() == 5) {
83  if (c[3] < 0.0) {
84  throw CanteraError("SRI::init()",
85  "m_d parameter is less than zero: {}", c[3]);
86  }
87  m_d = c[3];
88  m_e = c[4];
89  } else {
90  m_d = 1.0;
91  m_e = 0.0;
92  }
93 }
94 
95 void SRI::updateTemp(double T, double* work) const
96 {
97  *work = m_a * exp(- m_b / T);
98  if (m_c != 0.0) {
99  *work += exp(- T/m_c);
100  }
101  work[1] = m_d * pow(T,m_e);
102 }
103 
104 double SRI::F(double pr, const double* work) const
105 {
106  double lpr = log10(std::max(pr,SmallNumber));
107  double xx = 1.0/(1.0 + lpr*lpr);
108  return pow(*work, xx) * work[1];
109 }
110 
111 void SRI::getParameters(double* params) const
112 {
113  params[0] = m_a;
114  params[1] = m_b;
115  params[2] = m_c;
116  params[3] = m_d;
117  params[4] = m_e;
118 }
119 
120 }
virtual void init(const vector_fp &c)
Initialization of the object.
Definition: Falloff.cpp:66
doublereal m_c
parameter c in the 5-parameter SRI falloff function. [K]
Definition: Falloff.h:242
doublereal m_rt1
parameter 1/T_1 in the 4-parameter Troe falloff function. [K^-1]
Definition: Falloff.h:168
virtual void init(const vector_fp &c)
Initialization of the object.
Definition: Falloff.cpp:25
virtual void getParameters(double *params) const
Sets params to contain, in order, .
Definition: Falloff.cpp:59
doublereal m_t2
parameter T_2 in the 4-parameter Troe falloff function. [K]
Definition: Falloff.h:171
virtual void getParameters(double *params) const
Sets params to contain, in order, .
Definition: Falloff.cpp:111
doublereal m_rt3
parameter 1/T_3 in the 4-parameter Troe falloff function. [K^-1]
Definition: Falloff.h:165
virtual void init(const vector_fp &c)
Initialize.
Definition: Falloff.cpp:16
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
Definition: Falloff.cpp:49
doublereal m_e
parameter d in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:248
doublereal m_d
parameter d in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:245
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
Definition: Falloff.cpp:40
doublereal m_b
parameter b in the 5-parameter SRI falloff function. [K]
Definition: Falloff.h:239
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
virtual void updateTemp(doublereal T, doublereal *work) const
Update the temperature parameters in the representation.
Definition: Falloff.cpp:95
doublereal m_a
parameter a in the 4-parameter Troe falloff function. Dimensionless
Definition: Falloff.h:162
Contains declarations for string manipulation functions within Cantera.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
virtual doublereal F(doublereal pr, const doublereal *work) const
The falloff function.
Definition: Falloff.cpp:104
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
doublereal m_a
parameter a in the 5-parameter SRI falloff function. Dimensionless.
Definition: Falloff.h:236