Cantera  3.1.0a2
Loading...
Searching...
No Matches
Arrhenius.h
Go to the documentation of this file.
1/**
2 * @file Arrhenius.h
3 * Header for reaction rates that involve Arrhenius-type kinetics.
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
9#ifndef CT_ARRHENIUS_H
10#define CT_ARRHENIUS_H
11
13#include "cantera/base/Units.h"
15#include "ReactionRate.h"
16#include "MultiRate.h"
17
18namespace Cantera
19{
20
21class AnyValue;
22class AnyMap;
23
24//! Data container holding shared data specific to ArrheniusRate
25/**
26 * The data container `ArrheniusData` holds precalculated data common to
27 * all `ArrheniusRate` objects.
28 */
30{
31 bool update(const ThermoPhase& phase, const Kinetics& kin) override;
33};
34
35
36//! Base class for Arrhenius-type Parameterizations
37/*!
38 * This base class provides a minimally functional interface that allows for parameter
39 * access from derived classes as well as classes that use Arrhenius-type expressions
40 * internally, for example FalloffRate and PlogRate.
41 * @ingroup arrheniusGroup
42 */
44{
45public:
46 //! Default constructor.
48
49 //! Constructor.
50 /*!
51 * @param A Pre-exponential factor. The unit system is (kmol, m, s); actual units
52 * depend on the reaction order and the dimensionality (surface or bulk).
53 * @param b Temperature exponent (non-dimensional)
54 * @param Ea Activation energy in energy units [J/kmol]
55 */
56 ArrheniusBase(double A, double b, double Ea);
57
58 //! Constructor based on AnyValue content
59 ArrheniusBase(const AnyValue& rate, const UnitSystem& units,
60 const UnitStack& rate_units);
61
62 explicit ArrheniusBase(const AnyMap& node, const UnitStack& rate_units={});
63
64 //! Perform object setup based on AnyValue node information
65 /*!
66 * Used to set parameters from a child of the reaction node, which may have
67 * different names for different rate parameterizations, such as falloff rates.
68 *
69 * @param rate Child of the reaction node containing Arrhenius rate parameters.
70 * For example, the `rate-coefficient` node for a standard Arrhenius reaction.
71 * @param units Unit system
72 * @param rate_units Unit definitions specific to rate information
73 */
74 void setRateParameters(const AnyValue& rate,
75 const UnitSystem& units,
76 const UnitStack& rate_units);
77
78 //! Get Arrhenius parameters used to populate the `rate-coefficient` or
79 //! equivalent field
80 void getRateParameters(AnyMap& node) const;
81
82 void setParameters(const AnyMap& node, const UnitStack& rate_units) override;
83
84 void getParameters(AnyMap& node) const override;
85
86 //! Check rate expression
87 void check(const string& equation) override;
88
89 void validate(const string& equation, const Kinetics& kin) override;
90
91 //! Return the pre-exponential factor *A* (in m, kmol, s to powers depending
92 //! on the reaction order)
93 /*!
94 * Class specializations may provide alternate definitions that describe
95 * an effective pre-exponential factor that depends on the thermodynamic state.
96 */
97 virtual double preExponentialFactor() const {
98 return m_A;
99 }
100
101 //! Return the temperature exponent *b*
102 /*!
103 * Class specializations may provide alternate definitions that describe
104 * an effective temperature exponent that depends on the thermodynamic state.
105 */
106 virtual double temperatureExponent() const {
107 return m_b;
108 }
109
110 //! Return the activation energy *Ea* [J/kmol]
111 //! The value corresponds to the constant specified by input parameters;
112 /*!
113 * Class specializations may provide alternate definitions that describe
114 * an effective activation energy that depends on the thermodynamic state.
115 */
116 virtual double activationEnergy() const {
117 return m_Ea_R * GasConstant;
118 }
119
120 //! Return reaction order associated with the reaction rate
121 double order() const {
122 return m_order;
123 }
124
125 //! Set units of the reaction rate expression
126 void setRateUnits(const UnitStack& rate_units) override {
127 ReactionRate::setRateUnits(rate_units);
128 if (rate_units.size() > 1) {
129 m_order = 1 - rate_units.product().dimension("quantity");
130 } else {
131 m_order = NAN;
132 }
133 }
134
135 //! Get flag indicating whether negative A values are permitted
137 return m_negativeA_ok;
138 }
139
140 //! Set flag indicating whether negative A values are permitted
142 m_negativeA_ok = value;
143 }
144
145protected:
146 bool m_negativeA_ok = false; //!< Permissible negative A values
147 double m_A = NAN; //!< Pre-exponential factor
148 double m_b = NAN; //!< Temperature exponent
149 double m_Ea_R = 0.; //!< Activation energy (in temperature units)
150 double m_E4_R = 0.; //!< Optional 4th energy parameter (in temperature units)
151 double m_logA = NAN; //!< Logarithm of pre-exponential factor
152 double m_order = NAN; //!< Reaction order
153 string m_A_str = "A"; //!< The string for the pre-exponential factor
154 string m_b_str = "b"; //!< The string for temperature exponent
155 string m_Ea_str = "Ea"; //!< The string for activation energy
156 string m_E4_str = ""; //!< The string for an optional 4th parameter
157};
158
159//! Arrhenius reaction rate type depends only on temperature
160/*!
161 * A reaction rate coefficient of the following form.
162 *
163 * @f[
164 * k_f = A T^b \exp (-Ea/RT)
165 * @f]
166 *
167 * @ingroup arrheniusGroup
168 */
170{
171public:
172 using ArrheniusBase::ArrheniusBase; // inherit constructors
173
174 unique_ptr<MultiRateBase> newMultiRate() const override {
175 return make_unique<MultiRate<ArrheniusRate, ArrheniusData>>();
176 }
177
178 const string type() const override {
179 return "Arrhenius";
180 }
181
182 //! Evaluate reaction rate
183 double evalRate(double logT, double recipT) const {
184 return m_A * std::exp(m_b * logT - m_Ea_R * recipT);
185 }
186
187 //! Evaluate natural logarithm of the rate constant.
188 double evalLog(double logT, double recipT) const {
189 return m_logA + m_b * logT - m_Ea_R * recipT;
190 }
191
192 //! Evaluate reaction rate
193 /*!
194 * @param shared_data data shared by all reactions of a given type
195 */
196 double evalFromStruct(const ArrheniusData& shared_data) const {
197 return m_A * std::exp(m_b * shared_data.logT - m_Ea_R * shared_data.recipT);
198 }
199
200 //! Evaluate derivative of reaction rate with respect to temperature
201 //! divided by reaction rate
202 /*!
203 * @param shared_data data shared by all reactions of a given type
204 */
205 double ddTScaledFromStruct(const ArrheniusData& shared_data) const {
206 return (m_Ea_R * shared_data.recipT + m_b) * shared_data.recipT;
207 }
208};
209
210}
211
212#endif
Header for unit conversion utilities, which are used to translate user input from input files (See In...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
A wrapper for a variable whose type is determined at runtime.
Definition AnyMap.h:86
Base class for Arrhenius-type Parameterizations.
Definition Arrhenius.h:44
void setAllowNegativePreExponentialFactor(bool value)
Set flag indicating whether negative A values are permitted.
Definition Arrhenius.h:141
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
string m_b_str
The string for temperature exponent.
Definition Arrhenius.h:154
virtual double temperatureExponent() const
Return the temperature exponent b
Definition Arrhenius.h:106
string m_E4_str
The string for an optional 4th parameter.
Definition Arrhenius.h:156
double m_E4_R
Optional 4th energy parameter (in temperature units)
Definition Arrhenius.h:150
void getRateParameters(AnyMap &node) const
Get Arrhenius parameters used to populate the rate-coefficient or equivalent field.
Definition Arrhenius.cpp:76
void validate(const string &equation, const Kinetics &kin) override
Validate the reaction rate expression.
virtual double activationEnergy() const
Return the activation energy Ea [J/kmol] The value corresponds to the constant specified by input par...
Definition Arrhenius.h:116
string m_Ea_str
The string for activation energy.
Definition Arrhenius.h:155
void getParameters(AnyMap &node) const override
Get parameters.
double m_A
Pre-exponential factor.
Definition Arrhenius.h:147
void setRateParameters(const AnyValue &rate, const UnitSystem &units, const UnitStack &rate_units)
Perform object setup based on AnyValue node information.
Definition Arrhenius.cpp:35
double m_order
Reaction order.
Definition Arrhenius.h:152
bool allowNegativePreExponentialFactor() const
Get flag indicating whether negative A values are permitted.
Definition Arrhenius.h:136
bool m_negativeA_ok
Permissible negative A values.
Definition Arrhenius.h:146
string m_A_str
The string for the pre-exponential factor.
Definition Arrhenius.h:153
double m_b
Temperature exponent.
Definition Arrhenius.h:148
virtual double preExponentialFactor() const
Return the pre-exponential factor A (in m, kmol, s to powers depending on the reaction order)
Definition Arrhenius.h:97
void check(const string &equation) override
Check rate expression.
void setRateUnits(const UnitStack &rate_units) override
Set units of the reaction rate expression.
Definition Arrhenius.h:126
ArrheniusBase()
Default constructor.
Definition Arrhenius.h:47
double order() const
Return reaction order associated with the reaction rate.
Definition Arrhenius.h:121
double m_logA
Logarithm of pre-exponential factor.
Definition Arrhenius.h:151
double m_Ea_R
Activation energy (in temperature units)
Definition Arrhenius.h:149
Arrhenius reaction rate type depends only on temperature.
Definition Arrhenius.h:170
unique_ptr< MultiRateBase > newMultiRate() const override
Create a rate evaluator for reactions of a particular derived type.
Definition Arrhenius.h:174
double evalRate(double logT, double recipT) const
Evaluate reaction rate.
Definition Arrhenius.h:183
double evalLog(double logT, double recipT) const
Evaluate natural logarithm of the rate constant.
Definition Arrhenius.h:188
double ddTScaledFromStruct(const ArrheniusData &shared_data) const
Evaluate derivative of reaction rate with respect to temperature divided by reaction rate.
Definition Arrhenius.h:205
const string type() const override
String identifying reaction rate specialization.
Definition Arrhenius.h:178
double evalFromStruct(const ArrheniusData &shared_data) const
Evaluate reaction rate.
Definition Arrhenius.h:196
Public interface for kinetics managers.
Definition Kinetics.h:125
Abstract base class for reaction rate definitions; this base class is used by user-facing APIs to acc...
virtual void setRateUnits(const UnitStack &rate_units)
Set the units of the reaction rate expression.
Base class for a phase with thermodynamic properties.
Unit conversion utility.
Definition Units.h:169
double dimension(const string &primary) const
Return dimension of primary unit component ("mass", "length", "time", "temperature",...
Definition Units.cpp:303
This file contains definitions of constants, types and terms that are used in internal routines and a...
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:120
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Data container holding shared data specific to ArrheniusRate.
Definition Arrhenius.h:30
bool update(const ThermoPhase &phase, const Kinetics &kin) override
Update data container based on thermodynamic phase state.
Data container holding shared data used for ReactionRate calculation.
double recipT
inverse of temperature
virtual void update(double T)
Update data container based on temperature T
double logT
logarithm of temperature
Unit aggregation utility.
Definition Units.h:105
size_t size() const
Size of UnitStack.
Definition Units.h:118
Units product() const
Calculate product of units-exponent stack.
Definition Units.cpp:377