Cantera 2.6.0

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 virtual bool update(const ThermoPhase& phase, const Kinetics& kin);
32 using ReactionData::update;
33};
34
35
36/**
37 * @defgroup arrheniusGroup Arrhenius-type Parameterizations
38 *
39 * This section describes the parameterizations used to describe the standard
40 * Arrhenius rate parameterization and derived models.
41 *
42 * @ingroup chemkinetics
43 */
44
45//! Base class for Arrhenius-type Parameterizations
46/*!
47 * This base class provides a minimally functional interface that allows for parameter
48 * access from derived classes as well as classes that use Arrhenius-type expressions
49 * internally, for example FalloffRate and PlogRate.
50 */
51 class ArrheniusBase : public ReactionRate
52{
53 public:
54 //! Default constructor.
55 ArrheniusBase();
56
57 //! Constructor.
58 /*!
59 * @param A Pre-exponential factor. The unit system is (kmol, m, s); actual units
60 * depend on the reaction order and the dimensionality (surface or bulk).
61 * @param b Temperature exponent (non-dimensional)
62 * @param Ea Activation energy in energy units [J/kmol]
63 */
64 ArrheniusBase(double A, double b, double Ea);
65
66 //! Constructor based on AnyValue content
67 ArrheniusBase(const AnyValue& rate,
68 const UnitSystem& units, const UnitStack& rate_units)
69 {
70 setRateParameters(rate, units, rate_units);
71 }
72
73 explicit ArrheniusBase(const AnyMap& node, const UnitStack& rate_units={})
74 : ArrheniusBase()
75 {
76 setParameters(node, rate_units);
77 }
78
79 //! Perform object setup based on AnyValue node information
80 /*!
81 * @param rate AnyValue containing rate information
82 * @param units Unit system
83 * @param rate_units Unit definitions specific to rate information
84 */
85 void setRateParameters(const AnyValue& rate,
86 const UnitSystem& units,
87 const UnitStack& rate_units);
88
89 //! Return parameters
90 void getRateParameters(AnyMap& node) const;
91
92 virtual void setParameters(
93 const AnyMap& node, const UnitStack& rate_units) override;
94
95 virtual void getParameters(AnyMap& node) const override;
96
97 //! Check rate expression
98 virtual void check(const std::string& equation, const AnyMap& node) override;
99
100 virtual void validate(const std::string& equation, const Kinetics& kin) override;
101
102 //! Return the pre-exponential factor *A* (in m, kmol, s to powers depending
103 //! on the reaction order)
104 /*!
105 * Class specializations may provide alternate definitions that describe
106 * an effective pre-exponential factor that depends on the thermodynamic state.
107 */
108 virtual double preExponentialFactor() const {
109 return m_A;
110 }
111
112 //! Return the temperature exponent *b*
113 /*!
114 * Class specializations may provide alternate definitions that describe
115 * an effective temperature exponent that depends on the thermodynamic state.
116 */
117 virtual double temperatureExponent() const {
118 return m_b;
119 }
120
121 //! Return the activation energy *Ea* [J/kmol]
122 //! The value corresponds to the constant specified by input parameters;
123 /*!
124 * Class specializations may provide alternate definitions that describe
125 * an effective activation energy that depends on the thermodynamic state.
126 */
127 virtual double activationEnergy() const {
128 return m_Ea_R * GasConstant;
129 }
130
131 // Return units of the reaction rate expression
132 const Units& rateUnits() const {
133 return m_rate_units;
134 }
135
136 //! Return reaction order associated with the reaction rate
137 double order() const {
138 return m_order;
139 }
140
141 //! Set units of the reaction rate expression
142 void setRateUnits(const UnitStack& rate_units) {
143 if (rate_units.size() > 1) {
144 m_rate_units = rate_units.product();
145 m_order = 1 - m_rate_units.dimension("quantity");
146 } else {
147 m_order = NAN;
148 m_rate_units = rate_units.standardUnits();
149 }
150 }
151
152 //! Get flag indicating whether negative A values are permitted
153 bool allowNegativePreExponentialFactor() const {
154 return m_negativeA_ok;
155 }
156
157 //! Set flag indicating whether negative A values are permitted
158 void setAllowNegativePreExponentialFactor(bool value) {
159 m_negativeA_ok = value;
160 }
161
162 protected:
163 bool m_negativeA_ok; //!< Flag indicating whether negative A values are permitted
164 double m_A; //!< Pre-exponential factor
165 double m_b; //!< Temperature exponent
166 double m_Ea_R; //!< Activation energy (in temperature units)
167 double m_E4_R; //!< Optional 4th energy parameter (in temperature units)
168 double m_logA; //!< Logarithm of pre-exponential factor
169 double m_order; //!< Reaction order
170 std::string m_A_str = "A"; //!< The string for temperature exponent
171 std::string m_b_str = "b"; //!< The string for temperature exponent
172 std::string m_Ea_str = "Ea"; //!< The string for activation energy
173 std::string m_E4_str = ""; //!< The string for an optional 4th parameter
174 Units m_rate_units; //!< Reaction rate units
175};
176
177//! Arrhenius reaction rate type depends only on temperature
178/*!
179 * A reaction rate coefficient of the following form.
180 *
181 * \f[
182 * k_f = A T^b \exp (-Ea/RT)
183 * \f]
184 *
185 * @ingroup arrheniusGroup
186 *
187 * @todo supersedes Arrhenius2 and will replace Arrhenius after Cantera 2.6. The new
188 * behavior can be forced in self-compiled Cantera installations by defining
189 * CT_NO_LEGACY_REACTIONS_26 via the 'no_legacy_reactions' option in SCons.
190 */
191 class ArrheniusRate : public ArrheniusBase
192{
193 public:
194 using ArrheniusBase::ArrheniusBase; // inherit constructors
195
196 unique_ptr<MultiRateBase> newMultiRate() const override {
197 return unique_ptr<MultiRateBase>(new MultiRate<ArrheniusRate, ArrheniusData>);
198 }
199
200 virtual const std::string type() const override {
201 return "Arrhenius";
202 }
203
204 //! Evaluate reaction rate
205 double evalRate(double logT, double recipT) const {
206 return m_A * std::exp(m_b * logT - m_Ea_R * recipT);
207 }
208
209 //! Evaluate natural logarithm of the rate constant.
210 double evalLog(double logT, double recipT) const {
211 return m_logA + m_b * logT - m_Ea_R * recipT;
212 }
213
214 //! Evaluate reaction rate
215 /*!
216 * @param shared_data data shared by all reactions of a given type
217 */
218 double evalFromStruct(const ArrheniusData& shared_data) const {
219 return m_A * std::exp(m_b * shared_data.logT - m_Ea_R * shared_data.recipT);
220 }
221
222 //! Evaluate derivative of reaction rate with respect to temperature
223 //! divided by reaction rate
224 /*!
225 * @param shared_data data shared by all reactions of a given type
226 */
227 double ddTScaledFromStruct(const ArrheniusData& shared_data) const {
228 return (m_Ea_R * shared_data.recipT + m_b) * shared_data.recipT;
229 }
230};
231
232}
233
234#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:399
Cantera::AnyValue
A wrapper for a variable whose type is determined at runtime.
Definition: AnyMap.h:84
Cantera::ArrheniusBase
Base class for Arrhenius-type Parameterizations.
Definition: Arrhenius.h:52
Cantera::ArrheniusBase::setAllowNegativePreExponentialFactor
void setAllowNegativePreExponentialFactor(bool value)
Set flag indicating whether negative A values are permitted.
Definition: Arrhenius.h:158
Cantera::ArrheniusBase::m_Ea_str
std::string m_Ea_str
The string for activation energy.
Definition: Arrhenius.h:172
Cantera::ArrheniusBase::setParameters
virtual void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
Definition: Arrhenius.cpp:113
Cantera::ArrheniusBase::check
virtual void check(const std::string &equation, const AnyMap &node) override
Check rate expression.
Definition: Arrhenius.cpp:139
Cantera::ArrheniusBase::m_E4_str
std::string m_E4_str
The string for an optional 4th parameter.
Definition: Arrhenius.h:173
Cantera::ArrheniusBase::temperatureExponent
virtual double temperatureExponent() const
Return the temperature exponent b
Definition: Arrhenius.h:117
Cantera::ArrheniusBase::m_rate_units
Units m_rate_units
Reaction rate units.
Definition: Arrhenius.h:174
Cantera::ArrheniusBase::m_A_str
std::string m_A_str
The string for temperature exponent.
Definition: Arrhenius.h:170
Cantera::ArrheniusBase::m_E4_R
double m_E4_R
Optional 4th energy parameter (in temperature units)
Definition: Arrhenius.h:167
Cantera::ArrheniusBase::getRateParameters
void getRateParameters(AnyMap &node) const
Return parameters.
Definition: Arrhenius.cpp:91
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:127
Cantera::ArrheniusBase::getParameters
virtual void getParameters(AnyMap &node) const override
Get parameters.
Definition: Arrhenius.cpp:124
Cantera::ArrheniusBase::m_A
double m_A
Pre-exponential factor.
Definition: Arrhenius.h:164
Cantera::ArrheniusBase::validate
virtual void validate(const std::string &equation, const Kinetics &kin) override
Validate the reaction rate expression.
Definition: Arrhenius.cpp:154
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:38
Cantera::ArrheniusBase::m_order
double m_order
Reaction order.
Definition: Arrhenius.h:169
Cantera::ArrheniusBase::allowNegativePreExponentialFactor
bool allowNegativePreExponentialFactor() const
Get flag indicating whether negative A values are permitted.
Definition: Arrhenius.h:153
Cantera::ArrheniusBase::m_negativeA_ok
bool m_negativeA_ok
Flag indicating whether negative A values are permitted.
Definition: Arrhenius.h:163
Cantera::ArrheniusBase::ArrheniusBase
ArrheniusBase(const AnyValue &rate, const UnitSystem &units, const UnitStack &rate_units)
Constructor based on AnyValue content.
Definition: Arrhenius.h:67
Cantera::ArrheniusBase::m_b
double m_b
Temperature exponent.
Definition: Arrhenius.h:165
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:108
Cantera::ArrheniusBase::ArrheniusBase
ArrheniusBase()
Default constructor.
Definition: Arrhenius.cpp:12
Cantera::ArrheniusBase::order
double order() const
Return reaction order associated with the reaction rate.
Definition: Arrhenius.h:137
Cantera::ArrheniusBase::setRateUnits
void setRateUnits(const UnitStack &rate_units)
Set units of the reaction rate expression.
Definition: Arrhenius.h:142
Cantera::ArrheniusBase::m_logA
double m_logA
Logarithm of pre-exponential factor.
Definition: Arrhenius.h:168
Cantera::ArrheniusBase::m_Ea_R
double m_Ea_R
Activation energy (in temperature units)
Definition: Arrhenius.h:166
Cantera::ArrheniusBase::m_b_str
std::string m_b_str
The string for temperature exponent.
Definition: Arrhenius.h:171
Cantera::ArrheniusRate
Arrhenius reaction rate type depends only on temperature.
Definition: Arrhenius.h:192
Cantera::ArrheniusRate::newMultiRate
unique_ptr< MultiRateBase > newMultiRate() const override
Create a rate evaluator for reactions of a particular derived type.
Definition: Arrhenius.h:196
Cantera::ArrheniusRate::evalRate
double evalRate(double logT, double recipT) const
Evaluate reaction rate.
Definition: Arrhenius.h:205
Cantera::ArrheniusRate::evalLog
double evalLog(double logT, double recipT) const
Evaluate natural logarithm of the rate constant.
Definition: Arrhenius.h:210
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:227
Cantera::ArrheniusRate::evalFromStruct
double evalFromStruct(const ArrheniusData &shared_data) const
Evaluate reaction rate.
Definition: Arrhenius.h:218
Cantera::ArrheniusRate::type
virtual const std::string type() const override
String identifying reaction rate specialization.
Definition: Arrhenius.h:200
Cantera::Kinetics
Public interface for kinetics managers.
Definition: Kinetics.h:114
Cantera::MultiRate
A class template handling ReactionRate specializations.
Definition: MultiRate.h:21
Cantera::ReactionRate
Abstract base class for reaction rate definitions; this base class is used by user-facing APIs to acc...
Definition: ReactionRate.h:45
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
Cantera::UnitSystem
Unit conversion utility.
Definition: Units.h:161
Cantera::Units
A representation of the units associated with a dimensional quantity.
Definition: Units.h:30
Cantera::Units::dimension
double dimension(const std::string &primary) const
Return dimension of primary unit component ("mass", "length", "time", "temperature",...
Definition: Units.cpp:314
ct_defs.h
This file contains definitions of constants, types and terms that are used in internal routines and a...
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::GasConstant
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:113
Cantera::ArrheniusData
Data container holding shared data specific to ArrheniusRate.
Definition: Arrhenius.h:30
Cantera::ArrheniusData::update
virtual bool update(const ThermoPhase &phase, const Kinetics &kin)
Update data container based on thermodynamic phase state.
Definition: Arrhenius.cpp:162
Cantera::ReactionData
Data container holding shared data used for ReactionRate calculation.
Definition: ReactionData.h:26
Cantera::ReactionData::recipT
double recipT
inverse of temperature
Definition: ReactionData.h:111
Cantera::ReactionData::update
virtual void update(double T)
Update data container based on temperature T
Definition: ReactionData.h:35
Cantera::ReactionData::logT
double logT
logarithm of temperature
Definition: ReactionData.h:110
Cantera::UnitStack
Unit aggregation utility.
Definition: Units.h:99
Cantera::UnitStack::size
size_t size() const
Size of UnitStack.
Definition: Units.h:110
Cantera::UnitStack::standardUnits
Units standardUnits() const
Get standard unit used by UnitStack.
Definition: Units.cpp:334
Cantera::UnitStack::product
Units product() const
Calculate product of units-exponent stack.
Definition: Units.cpp:388