Cantera  2.5.1
Reaction.h
Go to the documentation of this file.
1 /**
2  * @file Reaction.h
3  */
4 
5 // This file is part of Cantera. See License.txt in the top-level directory or
6 // at https://cantera.org/license.txt for license and copyright information.
7 
8 #ifndef CT_REACTION_H
9 #define CT_REACTION_H
10 
11 #include "cantera/base/utilities.h"
12 #include "cantera/base/AnyMap.h"
14 #include "cantera/kinetics/Falloff.h"
15 
16 namespace Cantera
17 {
18 
19 class Kinetics;
20 
21 //! Intermediate class which stores data about a reaction and its rate
22 //! parameterization so that it can be added to a Kinetics object.
23 class Reaction
24 {
25 public:
26  explicit Reaction(int type);
27  Reaction(int type, const Composition& reactants,
28  const Composition& products);
29  virtual ~Reaction() {}
30 
31  //! The reactant side of the chemical equation for this reaction
32  virtual std::string reactantString() const;
33 
34  //! The product side of the chemical equation for this reaction
35  virtual std::string productString() const;
36 
37  //! The chemical equation for this reaction
38  std::string equation() const;
39 
40  //! Ensure that the rate constant and other parameters for this reaction are
41  //! valid.
42  virtual void validate();
43 
44  //! Type of the reaction. The valid types are listed in the file,
45  //! reaction_defs.h, with constants ending in `RXN`.
47 
48  //! Reactant species and stoichiometric coefficients
50 
51  //! Product species and stoichiometric coefficients
53 
54  //! Forward reaction order with respect to specific species. By default,
55  //! mass-action kinetics is assumed, with the reaction order equal to each
56  //! reactant's stoichiometric coefficient.
58 
59  //! An identification string for the reaction, used in some filtering
60  //! operations
61  std::string id;
62 
63  //! True if the current reaction is reversible. False otherwise
64  bool reversible;
65 
66  //! True if the current reaction is marked as duplicate
67  bool duplicate;
68 
69  //! True if reaction orders can be specified for non-reactant species.
70  //! Default is `false`.
72 
73  //! True if negative reaction orders are allowed. Default is `false`.
75 
76  //! Input data used for specific models
78 };
79 
80 
81 //! A reaction which follows mass-action kinetics with a modified Arrhenius
82 //! reaction rate.
84 {
85 public:
88  const Arrhenius& rate);
89  virtual void validate();
90 
91  Arrhenius rate;
92  bool allow_negative_pre_exponential_factor;
93 };
94 
95 //! A class for managing third-body efficiencies, including default values
96 class ThirdBody
97 {
98 public:
99  explicit ThirdBody(double default_efficiency=1.0);
100 
101  //! Get the third-body efficiency for species *k*
102  double efficiency(const std::string& k) const {
104  }
105 
106  //! Map of species to third body efficiency
108 
109  //! The default third body efficiency for species not listed in
110  //! #efficiencies.
112 };
113 
114 //! A reaction with a non-reacting third body "M" that acts to add or remove
115 //! energy from the reacting species
117 {
118 public:
121  const Arrhenius& rate, const ThirdBody& tbody);
122  virtual std::string reactantString() const;
123  virtual std::string productString() const;
124 
125  //! Relative efficiencies of third-body species in enhancing the reaction
126  //! rate.
128 };
129 
130 //! A reaction that is first-order in [M] at low pressure, like a third-body
131 //! reaction, but zeroth-order in [M] as pressure increases.
132 class FalloffReaction : public Reaction
133 {
134 public:
135  FalloffReaction();
137  const Arrhenius& low_rate, const Arrhenius& high_rate,
138  const ThirdBody& tbody);
139  virtual std::string reactantString() const;
140  virtual std::string productString() const;
141  virtual void validate();
142 
143  //! The rate constant in the low-pressure limit
145 
146  //! The rate constant in the high-pressure limit
148 
149  //! Relative efficiencies of third-body species in enhancing the reaction rate
151 
152  //! Falloff function which determines how low_rate and high_rate are
153  //! combined to determine the rate constant for the reaction.
154  shared_ptr<Falloff> falloff;
155 
156  bool allow_negative_pre_exponential_factor;
157 };
158 
159 //! A reaction where the rate decreases as pressure increases due to collisional
160 //! stabilization of a reaction intermediate. Like a FalloffReaction, except
161 //! that the forward rate constant is written as being proportional to the low-
162 //! pressure rate constant.
164 {
165 public:
168  const Composition& products, const Arrhenius& low_rate,
169  const Arrhenius& high_rate, const ThirdBody& tbody);
170 };
171 
172 //! A pressure-dependent reaction parameterized by logarithmically interpolating
173 //! between Arrhenius rate expressions at various pressures.
174 class PlogReaction : public Reaction
175 {
176 public:
177  PlogReaction();
179  const Plog& rate);
180  virtual void validate();
181  Plog rate;
182 };
183 
184 //! A pressure-dependent reaction parameterized by a bi-variate Chebyshev
185 //! polynomial in temperature and pressure
187 {
188 public:
191  const ChebyshevRate& rate);
192 
193  ChebyshevRate rate;
194 };
195 
196 //! Modifications to an InterfaceReaction rate based on a surface species
197 //! coverage.
199 {
200  //! Constructor
201  //! @param a_ coefficient for exponential dependence on coverage [dimensionless]
202  //! @param E_ modification to the activation energy [K]
203  //! @param m_ exponent for power law dependence on coverage [dimensionless]
204  CoverageDependency(double a_, double E_, double m_) : a(a_), E(E_), m(m_) {}
205  CoverageDependency() {}
206  double a; //!< coefficient for exponential dependence on coverage [dimensionless]
207  double E; //!< modification to the activation energy [K]
208  double m; //!< exponent for power law dependence on coverage [dimensionless]
209 };
210 
211 //! A reaction occurring on an interface (i.e. a SurfPhase or an EdgePhase)
213 {
214 public:
217  const Arrhenius& rate, bool isStick=false);
218 
219  //! Adjustments to the Arrhenius rate expression dependent on surface
220  //! species coverages. Three coverage parameters (a, E, m) are used for each
221  //! species on which the rate depends. See SurfaceArrhenius for details on
222  //! the parameterization.
223  std::map<std::string, CoverageDependency> coverage_deps;
224 
225  //! Set to true if `rate` is a parameterization of the sticking coefficient
226  //! rather than the forward rate constant
228 
229  //! Set to true if `rate` is a sticking coefficient which should be
230  //! translated into a rate coefficient using the correction factor developed
231  //! by Motz & Wise for reactions with high (near-unity) sticking
232  //! coefficients. Defaults to 'false'.
234 
235  //! For reactions with multiple non-surface species, the sticking species
236  //! needs to be explicitly identified.
237  std::string sticking_species;
238 };
239 
240 //! An interface reaction which involves charged species
242 {
243 public:
246  const Composition& products, const Arrhenius& rate);
247 
248  //! Film Resistivity value
249  /*!
250  * For Butler Volmer reactions, a common addition to the formulation is to
251  * add an electrical resistance to the formulation. The resistance modifies
252  * the electrical current flow in both directions. Only valid for Butler-
253  * Volmer formulations. Units are in ohms m2. Default = 0.0 ohms m2.
254  * @deprecated Unused. To be removed after Cantera 2.5.
255  */
256  doublereal film_resistivity;
257 
258  //! Forward value of the apparent Electrochemical transfer coefficient
259  doublereal beta;
260 
261  bool exchange_current_density_formulation;
262 };
263 
264 //! Create a new Reaction object for the reaction defined in `rxn_node`
265 //!
266 //! @deprecated The XML input format is deprecated and will be removed in
267 //! Cantera 3.0.
268 shared_ptr<Reaction> newReaction(const XML_Node& rxn_node);
269 
270 //! Create a new Reaction object using the specified parameters
271 unique_ptr<Reaction> newReaction(const AnyMap& rxn_node, const Kinetics& kin);
272 
273 //! Create Reaction objects for all `<reaction>` nodes in an XML document.
274 //!
275 //! The `<reaction>` nodes are assumed to be children of the `<reactionData>`
276 //! node in an XML document with a `<ctml>` root node, as in the case of XML
277 //! files produced by conversion from CTI files.
278 //!
279 //! This function can be used in combination with get_XML_File() and
280 //! get_XML_from_string() to get Reaction objects from either a file or a
281 //! string, respectively, where the string or file is formatted as either CTI
282 //! or XML.
283 //!
284 //! If Reaction objects are being created from a CTI definition that does not
285 //! contain corresponding phase definitions, then one of the following must be
286 //! true, or the resulting rate constants will be incorrect:
287 //!
288 //! - The rate constants are expressed in (kmol, meter, second) units
289 //! - A `units` directive is included **and** all reactions take place in
290 //! bulk (e.g. gas) phases
291 //!
292 //! @deprecated The XML input format is deprecated and will be removed in
293 //! Cantera 3.0.
294 std::vector<shared_ptr<Reaction> > getReactions(const XML_Node& node);
295 
296 //! Create Reaction objects for each item (an AnyMap) in `items`. The species
297 //! involved in these reactions must exist in the phases associated with the
298 //! Kinetics object `kinetics`.
299 std::vector<shared_ptr<Reaction>> getReactions(const AnyValue& items,
300  Kinetics& kinetics);
301 }
302 
303 #endif
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:360
A wrapper for a variable whose type is determined at runtime.
Definition: AnyMap.h:77
Arrhenius reaction rate type depends only on temperature.
Definition: RxnRates.h:32
Pressure-dependent rate expression where the rate coefficient is expressed as a bivariate Chebyshev p...
Definition: RxnRates.h:356
A pressure-dependent reaction parameterized by a bi-variate Chebyshev polynomial in temperature and p...
Definition: Reaction.h:187
A reaction where the rate decreases as pressure increases due to collisional stabilization of a react...
Definition: Reaction.h:164
An interface reaction which involves charged species.
Definition: Reaction.h:242
doublereal beta
Forward value of the apparent Electrochemical transfer coefficient.
Definition: Reaction.h:259
doublereal film_resistivity
Film Resistivity value.
Definition: Reaction.h:256
A reaction which follows mass-action kinetics with a modified Arrhenius reaction rate.
Definition: Reaction.h:84
virtual void validate()
Ensure that the rate constant and other parameters for this reaction are valid.
Definition: Reaction.cpp:120
A reaction that is first-order in [M] at low pressure, like a third-body reaction,...
Definition: Reaction.h:133
virtual std::string reactantString() const
The reactant side of the chemical equation for this reaction.
Definition: Reaction.cpp:178
virtual void validate()
Ensure that the rate constant and other parameters for this reaction are valid.
Definition: Reaction.cpp:198
virtual std::string productString() const
The product side of the chemical equation for this reaction.
Definition: Reaction.cpp:188
ThirdBody third_body
Relative efficiencies of third-body species in enhancing the reaction rate.
Definition: Reaction.h:150
Arrhenius low_rate
The rate constant in the low-pressure limit.
Definition: Reaction.h:144
Arrhenius high_rate
The rate constant in the high-pressure limit.
Definition: Reaction.h:147
shared_ptr< Falloff > falloff
Falloff function which determines how low_rate and high_rate are combined to determine the rate const...
Definition: Reaction.h:154
A reaction occurring on an interface (i.e. a SurfPhase or an EdgePhase)
Definition: Reaction.h:213
bool is_sticking_coefficient
Set to true if rate is a parameterization of the sticking coefficient rather than the forward rate co...
Definition: Reaction.h:227
std::map< std::string, CoverageDependency > coverage_deps
Adjustments to the Arrhenius rate expression dependent on surface species coverages.
Definition: Reaction.h:223
std::string sticking_species
For reactions with multiple non-surface species, the sticking species needs to be explicitly identifi...
Definition: Reaction.h:237
bool use_motz_wise_correction
Set to true if rate is a sticking coefficient which should be translated into a rate coefficient usin...
Definition: Reaction.h:233
Public interface for kinetics managers.
Definition: Kinetics.h:111
A pressure-dependent reaction parameterized by logarithmically interpolating between Arrhenius rate e...
Definition: Reaction.h:175
virtual void validate()
Ensure that the rate constant and other parameters for this reaction are valid.
Definition: Reaction.cpp:737
Pressure-dependent reaction rate expressed by logarithmically interpolating between Arrhenius rate ex...
Definition: RxnRates.h:222
Intermediate class which stores data about a reaction and its rate parameterization so that it can be...
Definition: Reaction.h:24
virtual std::string reactantString() const
The reactant side of the chemical equation for this reaction.
Definition: Reaction.cpp:66
Composition orders
Forward reaction order with respect to specific species.
Definition: Reaction.h:57
virtual void validate()
Ensure that the rate constant and other parameters for this reaction are valid.
Definition: Reaction.cpp:45
virtual std::string productString() const
The product side of the chemical equation for this reaction.
Definition: Reaction.cpp:81
bool reversible
True if the current reaction is reversible. False otherwise.
Definition: Reaction.h:64
bool allow_nonreactant_orders
True if reaction orders can be specified for non-reactant species.
Definition: Reaction.h:71
bool allow_negative_orders
True if negative reaction orders are allowed. Default is false.
Definition: Reaction.h:74
Composition products
Product species and stoichiometric coefficients.
Definition: Reaction.h:52
Composition reactants
Reactant species and stoichiometric coefficients.
Definition: Reaction.h:49
AnyMap input
Input data used for specific models.
Definition: Reaction.h:77
bool duplicate
True if the current reaction is marked as duplicate.
Definition: Reaction.h:67
int reaction_type
Type of the reaction.
Definition: Reaction.h:46
std::string equation() const
The chemical equation for this reaction.
Definition: Reaction.cpp:96
std::string id
An identification string for the reaction, used in some filtering operations.
Definition: Reaction.h:61
A class for managing third-body efficiencies, including default values.
Definition: Reaction.h:97
double default_efficiency
The default third body efficiency for species not listed in efficiencies.
Definition: Reaction.h:111
double efficiency(const std::string &k) const
Get the third-body efficiency for species k
Definition: Reaction.h:102
Composition efficiencies
Map of species to third body efficiency.
Definition: Reaction.h:107
A reaction with a non-reacting third body "M" that acts to add or remove energy from the reacting spe...
Definition: Reaction.h:117
virtual std::string reactantString() const
The reactant side of the chemical equation for this reaction.
Definition: Reaction.cpp:151
virtual std::string productString() const
The product side of the chemical equation for this reaction.
Definition: Reaction.cpp:155
ThirdBody third_body
Relative efficiencies of third-body species in enhancing the reaction rate.
Definition: Reaction.h:127
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:104
std::map< std::string, double > Composition
Map from string names to doubles.
Definition: ct_defs.h:176
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
const U & getValue(const std::map< T, U > &m, const T &key, const U &default_val)
Const accessor for a value in a std::map.
Definition: utilities.h:528
std::vector< shared_ptr< Reaction > > getReactions(const XML_Node &node)
Create Reaction objects for all <reaction> nodes in an XML document.
Definition: Reaction.cpp:1116
shared_ptr< Reaction > newReaction(const XML_Node &rxn_node)
Create a new Reaction object for the reaction defined in rxn_node
Definition: Reaction.cpp:1010
Modifications to an InterfaceReaction rate based on a surface species coverage.
Definition: Reaction.h:199
double a
coefficient for exponential dependence on coverage [dimensionless]
Definition: Reaction.h:206
double E
modification to the activation energy [K]
Definition: Reaction.h:207
double m
exponent for power law dependence on coverage [dimensionless]
Definition: Reaction.h:208
CoverageDependency(double a_, double E_, double m_)
Constructor.
Definition: Reaction.h:204
Various templated functions that carry out common vector operations (see Templated Utility Functions)...