| Cantera 3.0.0

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
12#include "cantera/base/ct_defs.h"
13#include "cantera/base/Units.h"
14#include "cantera/kinetics/ReactionData.h"
15#include "ReactionRate.h"
16#include "MultiRate.h"
17
18 namespace Cantera
19{
20
21 class AnyValue;
22 class 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 */
29 struct ArrheniusData : public ReactionData
30{
31 bool update(const ThermoPhase& phase, const Kinetics& kin) override;
32 using ReactionData::update;
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 */
43 class ArrheniusBase : public ReactionRate
44{
45 public:
46 //! Default constructor.
47 ArrheniusBase() {}
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
136 bool allowNegativePreExponentialFactor() const {
137 return m_negativeA_ok;
138 }
139
140 //! Set flag indicating whether negative A values are permitted
141 void setAllowNegativePreExponentialFactor(bool value) {
142 m_negativeA_ok = value;
143 }
144
145 protected:
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 */
169 class ArrheniusRate : public ArrheniusBase
170{
171 public:
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
MultiRate.h
ReactionData.h
ReactionRate.h
Units.h
Header for unit conversion utilities, which are used to translate user input from input files (See In...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::AnyValue
A wrapper for a variable whose type is determined at runtime.
Definition AnyMap.h:86
Cantera::ArrheniusBase
Base class for Arrhenius-type Parameterizations.
Definition Arrhenius.h:44
Cantera::ArrheniusBase::setAllowNegativePreExponentialFactor
void setAllowNegativePreExponentialFactor(bool value)
Set flag indicating whether negative A values are permitted.
Definition Arrhenius.h:141
Cantera::ArrheniusBase::setParameters
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
Definition Arrhenius.cpp:100
Cantera::ArrheniusBase::m_b_str
string m_b_str
The string for temperature exponent.
Definition Arrhenius.h:154
Cantera::ArrheniusBase::temperatureExponent
virtual double temperatureExponent() const
Return the temperature exponent b
Definition Arrhenius.h:106
Cantera::ArrheniusBase::m_E4_str
string m_E4_str
The string for an optional 4th parameter.
Definition Arrhenius.h:156
Cantera::ArrheniusBase::m_E4_R
double m_E4_R
Optional 4th energy parameter (in temperature units)
Definition Arrhenius.h:150
Cantera::ArrheniusBase::getRateParameters
void getRateParameters(AnyMap &node) const
Get Arrhenius parameters used to populate the rate-coefficient or equivalent field.
Definition Arrhenius.cpp:76
Cantera::ArrheniusBase::validate
void validate(const string &equation, const Kinetics &kin) override
Validate the reaction rate expression.
Definition Arrhenius.cpp:138
Cantera::ArrheniusBase::activationEnergy
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
Cantera::ArrheniusBase::m_Ea_str
string m_Ea_str
The string for activation energy.
Definition Arrhenius.h:155
Cantera::ArrheniusBase::getParameters
void getParameters(AnyMap &node) const override
Get parameters.
Definition Arrhenius.cpp:111
Cantera::ArrheniusBase::m_A
double m_A
Pre-exponential factor.
Definition Arrhenius.h:147
Cantera::ArrheniusBase::setRateParameters
void setRateParameters(const AnyValue &rate, const UnitSystem &units, const UnitStack &rate_units)
Perform object setup based on AnyValue node information.
Definition Arrhenius.cpp:35
Cantera::ArrheniusBase::m_order
double m_order
Reaction order.
Definition Arrhenius.h:152
Cantera::ArrheniusBase::allowNegativePreExponentialFactor
bool allowNegativePreExponentialFactor() const
Get flag indicating whether negative A values are permitted.
Definition Arrhenius.h:136
Cantera::ArrheniusBase::m_negativeA_ok
bool m_negativeA_ok
Permissible negative A values.
Definition Arrhenius.h:146
Cantera::ArrheniusBase::m_A_str
string m_A_str
The string for the pre-exponential factor.
Definition Arrhenius.h:153
Cantera::ArrheniusBase::m_b
double m_b
Temperature exponent.
Definition Arrhenius.h:148
Cantera::ArrheniusBase::preExponentialFactor
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
Cantera::ArrheniusBase::check
void check(const string &equation) override
Check rate expression.
Definition Arrhenius.cpp:123
Cantera::ArrheniusBase::setRateUnits
void setRateUnits(const UnitStack &rate_units) override
Set units of the reaction rate expression.
Definition Arrhenius.h:126
Cantera::ArrheniusBase::ArrheniusBase
ArrheniusBase()
Default constructor.
Definition Arrhenius.h:47
Cantera::ArrheniusBase::order
double order() const
Return reaction order associated with the reaction rate.
Definition Arrhenius.h:121
Cantera::ArrheniusBase::m_logA
double m_logA
Logarithm of pre-exponential factor.
Definition Arrhenius.h:151
Cantera::ArrheniusBase::m_Ea_R
double m_Ea_R
Activation energy (in temperature units)
Definition Arrhenius.h:149
Cantera::ArrheniusRate
Arrhenius reaction rate type depends only on temperature.
Definition Arrhenius.h:170
Cantera::ArrheniusRate::newMultiRate
unique_ptr< MultiRateBase > newMultiRate() const override
Create a rate evaluator for reactions of a particular derived type.
Definition Arrhenius.h:174
Cantera::ArrheniusRate::evalRate
double evalRate(double logT, double recipT) const
Evaluate reaction rate.
Definition Arrhenius.h:183
Cantera::ArrheniusRate::evalLog
double evalLog(double logT, double recipT) const
Evaluate natural logarithm of the rate constant.
Definition Arrhenius.h:188
Cantera::ArrheniusRate::ddTScaledFromStruct
double ddTScaledFromStruct(const ArrheniusData &shared_data) const
Evaluate derivative of reaction rate with respect to temperature divided by reaction rate.
Definition Arrhenius.h:205
Cantera::ArrheniusRate::type
const string type() const override
String identifying reaction rate specialization.
Definition Arrhenius.h:178
Cantera::ArrheniusRate::evalFromStruct
double evalFromStruct(const ArrheniusData &shared_data) const
Evaluate reaction rate.
Definition Arrhenius.h:196
Cantera::Kinetics
Public interface for kinetics managers.
Definition Kinetics.h:126
Cantera::ReactionRate
Abstract base class for reaction rate definitions; this base class is used by user-facing APIs to acc...
Definition ReactionRate.h:49
Cantera::ReactionRate::setRateUnits
virtual void setRateUnits(const UnitStack &rate_units)
Set the units of the reaction rate expression.
Definition ReactionRate.h:132
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition ThermoPhase.h:390
Cantera::UnitSystem
Unit conversion utility.
Definition Units.h:169
Cantera::Units::dimension
double dimension(const string &primary) const
Return dimension of primary unit component ("mass", "length", "time", "temperature",...
Definition Units.cpp:303
ct_defs.h
This file contains definitions of constants, types and terms that are used in internal routines and a...
Cantera::GasConstant
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:120
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::ArrheniusData
Data container holding shared data specific to ArrheniusRate.
Definition Arrhenius.h:30
Cantera::ArrheniusData::update
bool update(const ThermoPhase &phase, const Kinetics &kin) override
Update data container based on thermodynamic phase state.
Definition Arrhenius.cpp:146
Cantera::ReactionData
Data container holding shared data used for ReactionRate calculation.
Definition ReactionData.h:27
Cantera::ReactionData::recipT
double recipT
inverse of temperature
Definition ReactionData.h:112
Cantera::ReactionData::update
virtual void update(double T)
Update data container based on temperature T
Definition ReactionData.h:36
Cantera::ReactionData::logT
double logT
logarithm of temperature
Definition ReactionData.h:111
Cantera::UnitStack
Unit aggregation utility.
Definition Units.h:105
Cantera::UnitStack::size
size_t size() const
Size of UnitStack.
Definition Units.h:118
Cantera::UnitStack::product
Units product() const
Calculate product of units-exponent stack.
Definition Units.cpp:377