Cantera 2.6.0

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Reaction Class Reference
Reactions and reaction rates

Abstract base class which stores data about a reaction and its rate parameterization so that it can be added to a Kinetics object. More...

`#include <Reaction.h>`

Inheritance diagram for Reaction:
[legend]
Collaboration diagram for Reaction:
[legend]

## Public Member Functions
| Reaction (const Composition &reactants, const Composition &products, shared_ptr< ReactionRate > rate={})
| Reaction (const AnyMap &node, const Kinetics &kin)
| Construct a Reaction and it's corresponding ReactionRate based on AnyMap (YAML) input. More...
| Reaction (int type)
| Reaction (int type, const Composition &reactants, const Composition &products)
virtual std::string | reactantString () const
| The reactant side of the chemical equation for this reaction. More...
virtual std::string | productString () const
| The product side of the chemical equation for this reaction. More...
std::string | equation () const
| The chemical equation for this reaction. More...
virtual void | setEquation (const std::string &equation, const Kinetics *kin=0)
| Set the reactants and products based on the reaction equation. More...
virtual std::string | type () const
| The type of reaction. More...
virtual void | calculateRateCoeffUnits (const Kinetics &kin)
| Calculate the units of the rate constant. More...
UnitStack | calculateRateCoeffUnits3 (const Kinetics &kin)
| Calculate the units of the rate constant. More...
virtual void | validate ()
| Ensure that the rate constant and other parameters for this reaction are valid. More...
virtual void | validate (Kinetics &kin)
| Perform validation checks that need access to a complete Kinetics objects, for. More...
AnyMap | parameters (bool withInput=true) const
| Return the parameters such that an identical Reaction could be reconstructed using the newReaction() function. More...
virtual void | setParameters (const AnyMap &node, const Kinetics &kin)
| Set up reaction based on AnyMap node More...
bool | valid () const
| Get validity flag of reaction. More...
void | setValid (bool valid)
| Set validity flag of reaction. More...
void | checkBalance (const Kinetics &kin) const
| Check that the specified reaction is balanced (same number of atoms for each element in the reactants and products). More...
bool | checkSpecies (const Kinetics &kin) const
| Verify that all species involved in the reaction are defined in the Kinetics object. More...
bool | usesElectrochemistry (const Kinetics &kin) const
| Check whether reaction uses electrochemistry. More...
shared_ptr< ReactionRate > | rate ()
| Get reaction rate pointer. More...
void | setRate (shared_ptr< ReactionRate > rate)
| Set reaction rate pointer. More...
shared_ptr< ThirdBody > | thirdBody ()
| Get pointer to third-body. More...
bool | usesLegacy () const
| Indicate whether object uses legacy framework. More...

## Public Attributes
int | reaction_type
| Type of the reaction. More...
Composition | reactants
| Reactant species and stoichiometric coefficients. More...
Composition | products
| Product species and stoichiometric coefficients. More...
Composition | orders
| Forward reaction order with respect to specific species. More...
std::string | id
| An identification string for the reaction, used in some filtering operations. More...
bool | reversible
| True if the current reaction is reversible. False otherwise. More...
bool | duplicate
| True if the current reaction is marked as duplicate. More...
bool | allow_nonreactant_orders
| True if reaction orders can be specified for non-reactant species. More...
bool | allow_negative_orders
| True if negative reaction orders are allowed. Default is `false`. More...
AnyMap | input
| Input data used for specific models. More...
Units | rate_units
| The units of the rate constant. More...

## Protected Member Functions
virtual void | getParameters (AnyMap &reactionNode) const
| Store the parameters of a Reaction needed to reconstruct an identical object using the newReaction(AnyMap&, Kinetics&) function. More...
virtual std::pair< std::vector< std::string >, bool > | undeclaredThirdBodies (const Kinetics &kin) const

## Protected Attributes
bool | m_valid
| Flag indicating whether reaction is set up correctly. More...
shared_ptr< ReactionRate > | m_rate
| Reaction rate used by generic reactions. More...
shared_ptr< ThirdBody > | m_third_body
| Relative efficiencies of third-body species in enhancing the reaction rate (if applicable) More...

## Detailed Description

Abstract base class which stores data about a reaction and its rate parameterization so that it can be added to a Kinetics object.

Definition at line 32 of file Reaction.h.

## Constructor & Destructor Documentation

## ◆ Reaction() [1/5]

Reaction | ( |  | ) |

Definition at line 31 of file Reaction.cpp.

## ◆ Reaction() [2/5]

Reaction | ( | const Composition & | reactants,
|  | const Composition & | products,
|  | shared_ptr< ReactionRate > | rate = `{}`
| ) |  |

Definition at line 42 of file Reaction.cpp.

## ◆ Reaction() [3/5]

Reaction | ( | const AnyMap & | node,
|  | const Kinetics & | kin
| ) |  |

Construct a Reaction and it's corresponding ReactionRate based on AnyMap (YAML) input.

Definition at line 58 of file Reaction.cpp.

References Reaction::calculateRateCoeffUnits3(), AnyMap::hasKey(), Phase::nDim(), Cantera::newReactionRate(), Kinetics::nPhases(), Kinetics::reactionPhaseIndex(), Reaction::setParameters(), Reaction::setRate(), Kinetics::thermo(), and Reaction::type().

## ◆ Reaction() [4/5]

Reaction | ( | int | type | ) |
| explicit

Deprecated:
  To be removed after Cantera 2.6.

Definition at line 93 of file Reaction.cpp.

## ◆ Reaction() [5/5]

Reaction | ( | int | type,
|  | const Composition & | reactants,
|  | const Composition & | products
| ) |  |

Deprecated:
  To be removed after Cantera 2.6.

Definition at line 107 of file Reaction.cpp.

## ◆ ~Reaction()

virtual ~Reaction | ( |  | ) |
| inline virtual

Definition at line 48 of file Reaction.h.

## Member Function Documentation

## ◆ reactantString()

std::string reactantString | ( |  | ) | const
| virtual

The reactant side of the chemical equation for this reaction.

Reimplemented in ThreeBodyReaction2, FalloffReaction2, ThreeBodyReaction3, and FalloffReaction3.

Definition at line 266 of file Reaction.cpp.

References Reaction::reactants.

Referenced by Reaction::equation(), ThreeBodyReaction2::reactantString(), FalloffReaction2::reactantString(), ThreeBodyReaction3::reactantString(), and FalloffReaction3::reactantString().

## ◆ productString()

std::string productString | ( |  | ) | const
| virtual

The product side of the chemical equation for this reaction.

Reimplemented in ThreeBodyReaction2, FalloffReaction2, ThreeBodyReaction3, and FalloffReaction3.

Definition at line 281 of file Reaction.cpp.

References Reaction::products.

Referenced by Reaction::equation(), ThreeBodyReaction2::productString(), FalloffReaction2::productString(), ThreeBodyReaction3::productString(), and FalloffReaction3::productString().

## ◆ equation()

std::string equation | ( |  | ) | const

The chemical equation for this reaction.

Definition at line 296 of file Reaction.cpp.

References Reaction::productString(), Reaction::reactantString(), and Reaction::reversible.

Referenced by InterfaceKinetics::buildSurfaceArrhenius(), Reaction::checkBalance(), Reaction::checkSpecies(), Reaction::getParameters(), StickingCoverage::setContext(), FalloffReaction3::setEquation(), Reaction::setEquation(), ThreeBodyReaction3::setEquation(), ElementaryReaction2::validate(), FalloffReaction2::validate(), PlogReaction2::validate(), and Reaction::validate().

## ◆ setEquation()

void setEquation | ( | const std::string & | equation,
|  | const Kinetics * | kin = `0`
| ) |  |
| virtual

Set the reactants and products based on the reaction equation.

If a Kinetics object is provided, it is used to check that all reactants and products exist.

Reimplemented in FalloffReaction3, and ThreeBodyReaction3.

Definition at line 305 of file Reaction.cpp.

References Reaction::equation(), Reaction::input, and Cantera::parseReactionEquation().

Referenced by FalloffReaction3::setEquation(), ThreeBodyReaction3::setEquation(), and Reaction::setParameters().

## ◆ type()

std::string type | ( |  | ) | const
| virtual

The type of reaction.

Reimplemented in ElementaryReaction2, ThreeBodyReaction2, FalloffReaction2, ChemicallyActivatedReaction2, PlogReaction2, ChebyshevReaction2, InterfaceReaction2, ThreeBodyReaction3, FalloffReaction3, and CustomFunc1Reaction.

Definition at line 310 of file Reaction.cpp.

Referenced by Reaction::getParameters(), Reaction::Reaction(), and ElementaryReaction2::validate().

## ◆ calculateRateCoeffUnits()

void calculateRateCoeffUnits | ( | const Kinetics & | kin | ) |
| virtual

Calculate the units of the rate constant.

These are determined by the units of the standard concentration of the reactant species' phases and the phase where the reaction occurs. Sets the value of rate_units.

Reimplemented in ThreeBodyReaction2, FalloffReaction2, ChemicallyActivatedReaction2, and InterfaceReaction2.

Definition at line 315 of file Reaction.cpp.

References Reaction::orders, Units::pow(), Reaction::rate_units, Reaction::reactants, Kinetics::reactionPhaseIndex(), Kinetics::speciesPhase(), ThermoPhase::standardConcentrationUnits(), Kinetics::thermo(), and Reaction::valid().

Referenced by ThreeBodyReaction2::calculateRateCoeffUnits(), FalloffReaction2::calculateRateCoeffUnits(), ChemicallyActivatedReaction2::calculateRateCoeffUnits(), and InterfaceReaction2::calculateRateCoeffUnits().

## ◆ calculateRateCoeffUnits3()

UnitStack calculateRateCoeffUnits3 | ( | const Kinetics & | kin | ) |

Calculate the units of the rate constant.

These are determined by the units of the standard concentration of the reactant species' phases and the phase where the reaction occurs. Sets the value of rate_units.

Definition at line 345 of file Reaction.cpp.

References Reaction::m_third_body, Reaction::orders, Reaction::rate_units, Reaction::reactants, Kinetics::reactionPhaseIndex(), Kinetics::speciesPhase(), Kinetics::thermo(), and Reaction::valid().

Referenced by Reaction::Reaction().

## ◆ validate() [1/2]

void validate | ( |  | ) |
| virtual

Ensure that the rate constant and other parameters for this reaction are valid.

Reimplemented in ElementaryReaction2, ElementaryReaction2, FalloffReaction2, FalloffReaction2, PlogReaction2, PlogReaction2, and InterfaceReaction2.

Definition at line 124 of file Reaction.cpp.

References Reaction::allow_negative_orders, Reaction::allow_nonreactant_orders, Reaction::equation(), Reaction::input, Reaction::m_rate, Reaction::orders, Reaction::reactants, Reaction::reversible, and Reaction::usesLegacy().

Referenced by ElementaryReaction2::validate(), FalloffReaction2::validate(), and PlogReaction2::validate().

## ◆ validate() [2/2]

virtual void validate | ( | Kinetics & | kin | ) |
| inline virtual

Perform validation checks that need access to a complete Kinetics objects, for.

Reimplemented in ElementaryReaction2, FalloffReaction2, PlogReaction2, InterfaceReaction2, and InterfaceReaction2.

Definition at line 82 of file Reaction.h.

References Reaction::equation(), and Reaction::m_rate.

## ◆ parameters()

AnyMap parameters | ( | bool | withInput = `true` | ) | const

Return the parameters such that an identical Reaction could be reconstructed using the newReaction() function.

Behavior specific to derived classes is handled by the getParameters() method.

Parameters

  withInput | If true, include additional input data fields associated with the object, such as user-defined fields from a YAML input file, as contained in the input attribute.

Definition at line 162 of file Reaction.cpp.

References AnyMap::addOrderingRules(), Reaction::getParameters(), Reaction::input, and AnyMap::update().

## ◆ setParameters()

void setParameters | ( | const AnyMap & | node,
|  | const Kinetics & | kin
| ) |  |
| virtual

Set up reaction based on AnyMap node

Reimplemented in ThreeBodyReaction3, and FalloffReaction3.

Definition at line 216 of file Reaction.cpp.

References Reaction::allow_negative_orders, Reaction::allow_nonreactant_orders, AnyMap::copyMetadata(), Reaction::duplicate, AnyMap::empty(), AnyMap::getBool(), AnyMap::getString(), AnyMap::hasKey(), Reaction::input, Kinetics::kineticsSpeciesIndex(), Cantera::npos, Reaction::orders, Reaction::setEquation(), and Reaction::setValid().

Referenced by Reaction::Reaction(), ThreeBodyReaction3::setParameters(), and FalloffReaction3::setParameters().

## ◆ valid()

bool valid | ( |  | ) | const
| inline

Get validity flag of reaction.

Definition at line 100 of file Reaction.h.

References Reaction::m_valid.

Referenced by Reaction::calculateRateCoeffUnits(), Reaction::calculateRateCoeffUnits3(), and Reaction::setValid().

## ◆ setValid()

void setValid | ( | bool | valid | ) |
| inline

Set validity flag of reaction.

Definition at line 105 of file Reaction.h.

References Reaction::m_valid, and Reaction::valid().

Referenced by Reaction::setParameters().

## ◆ checkBalance()

void checkBalance | ( | const Kinetics & | kin | ) | const

Check that the specified reaction is balanced (same number of atoms for each element in the reactants and products).

Raises an exception if the reaction is not balanced. Used by checkSpecies.

Parameters

  kin | Kinetics object

Definition at line 409 of file Reaction.cpp.

References Phase::elementName(), Reaction::equation(), Reaction::input, Phase::nAtoms(), Phase::nDim(), Phase::nElements(), Cantera::npos, Reaction::products, Reaction::reactants, Kinetics::reactionPhaseIndex(), Phase::speciesIndex(), Kinetics::speciesPhase(), Kinetics::surfacePhaseIndex(), and Kinetics::thermo().

Referenced by Reaction::checkSpecies().

## ◆ checkSpecies()

bool checkSpecies | ( | const Kinetics & | kin | ) | const

Verify that all species involved in the reaction are defined in the Kinetics object.

The function returns true if all species are found, and raises an exception unless the kinetics object is configured to skip undeclared species, in which case false is returned.

Parameters

  kin | Kinetics object

Definition at line 479 of file Reaction.cpp.

References Reaction::checkBalance(), Reaction::equation(), AnyMap::hasKey(), Reaction::input, Reaction::orders, Reaction::products, Reaction::reactants, Kinetics::skipUndeclaredSpecies(), Kinetics::skipUndeclaredThirdBodies(), and Reaction::undeclaredThirdBodies().

## ◆ usesElectrochemistry()

bool usesElectrochemistry | ( | const Kinetics & | kin | ) | const

Check whether reaction uses electrochemistry.

Parameters

  kin | Kinetics object

Definition at line 540 of file Reaction.cpp.

References Phase::charge(), Kinetics::kineticsSpeciesIndex(), Kinetics::nPhases(), Reaction::products, Reaction::reactants, Phase::speciesIndex(), Kinetics::speciesPhaseIndex(), and Kinetics::thermo().

Referenced by InterfaceRateBase::setContext().

## ◆ rate()

shared_ptr< ReactionRate > rate | ( |  | ) |
| inline

Get reaction rate pointer.

Definition at line 171 of file Reaction.h.

References Reaction::m_rate.

Referenced by Reaction::setRate().

## ◆ setRate()

void setRate | ( | shared_ptr< ReactionRate > | rate | ) |

Set reaction rate pointer.

Definition at line 243 of file Reaction.cpp.

References Reaction::input, Reaction::m_rate, Reaction::products, Reaction::rate(), Reaction::reactants, and Cantera::warn_deprecated().

Referenced by Reaction::Reaction().

## ◆ thirdBody()

shared_ptr< ThirdBody > thirdBody | ( |  | ) |
| inline

Get pointer to third-body.

Definition at line 179 of file Reaction.h.

References Reaction::m_third_body.

## ◆ usesLegacy()

bool usesLegacy | ( |  | ) | const
| inline

Indicate whether object uses legacy framework.

Definition at line 184 of file Reaction.h.

References Reaction::m_rate.

Referenced by Reaction::validate().

## ◆ getParameters()

void getParameters | ( | AnyMap & | reactionNode | ) | const
| protected virtual

Store the parameters of a Reaction needed to reconstruct an identical object using the newReaction(AnyMap&, Kinetics&) function.

Does not include user-defined fields available in the input map.

Reimplemented in ElementaryReaction2, ThreeBodyReaction2, FalloffReaction2, ChemicallyActivatedReaction2, PlogReaction2, ChebyshevReaction2, InterfaceReaction2, ElectrochemicalReaction2, ThreeBodyReaction3, and FalloffReaction3.

Definition at line 184 of file Reaction.cpp.

References Reaction::allow_negative_orders, Reaction::allow_nonreactant_orders, Reaction::duplicate, Reaction::equation(), AnyMap::erase(), AnyMap::hasKey(), Reaction::m_rate, Reaction::orders, Reaction::type(), and AnyMap::update().

Referenced by ElementaryReaction2::getParameters(), FalloffReaction2::getParameters(), PlogReaction2::getParameters(), ChebyshevReaction2::getParameters(), ThreeBodyReaction3::getParameters(), FalloffReaction3::getParameters(), and Reaction::parameters().

## ◆ undeclaredThirdBodies()

std::pair< std::vector< std::string >, bool > undeclaredThirdBodies | ( | const Kinetics & | kin | ) | const
| protected virtual

Helper function returning vector of undeclared third body species and a boolean expression indicating whether the third body is specified. The function is used by the checkSpecies method and only needed as long as there is no unified approach to handle third body collision partners.

Parameters

  kin | Kinetics object

Reimplemented in ThreeBodyReaction2, and FalloffReaction2.

Definition at line 398 of file Reaction.cpp.

References Reaction::m_third_body.

Referenced by Reaction::checkSpecies().

## Member Data Documentation

## ◆ reaction_type

int reaction_type

Type of the reaction.

The valid types are listed in the file, reaction_defs.h, with constants ending in `RXN`.

Deprecated:
  To be removed in Cantera 2.6. Superseded by Reaction::type().

Definition at line 132 of file Reaction.h.

## ◆ reactants

Composition reactants

Reactant species and stoichiometric coefficients.

Definition at line 135 of file Reaction.h.

Referenced by InterfaceKinetics::buildSurfaceArrhenius(), Reaction::calculateRateCoeffUnits(), ThreeBodyReaction2::calculateRateCoeffUnits(), Reaction::calculateRateCoeffUnits3(), Reaction::checkBalance(), Reaction::checkSpecies(), Reaction::reactantString(), InterfaceRateBase::setContext(), StickingCoverage::setContext(), BlowersMaselRate::setContext(), FalloffReaction3::setEquation(), ThreeBodyReaction3::setEquation(), Reaction::setRate(), Reaction::usesElectrochemistry(), and Reaction::validate().

## ◆ products

Composition products

Product species and stoichiometric coefficients.

Definition at line 138 of file Reaction.h.

Referenced by ThreeBodyReaction2::calculateRateCoeffUnits(), Reaction::checkBalance(), Reaction::checkSpecies(), Reaction::productString(), InterfaceRateBase::setContext(), BlowersMaselRate::setContext(), FalloffReaction3::setEquation(), ThreeBodyReaction3::setEquation(), Reaction::setRate(), and Reaction::usesElectrochemistry().

## ◆ orders

Composition orders

Forward reaction order with respect to specific species.

By default, mass-action kinetics is assumed, with the reaction order equal to each reactant's stoichiometric coefficient.

Definition at line 143 of file Reaction.h.

Referenced by InterfaceKinetics::buildSurfaceArrhenius(), Reaction::calculateRateCoeffUnits(), Reaction::calculateRateCoeffUnits3(), Reaction::checkSpecies(), Reaction::getParameters(), StickingCoverage::setContext(), Reaction::setParameters(), and Reaction::validate().

## ◆ id

std::string id

An identification string for the reaction, used in some filtering operations.

Definition at line 147 of file Reaction.h.

## ◆ reversible

bool reversible

True if the current reaction is reversible. False otherwise.

Definition at line 150 of file Reaction.h.

Referenced by Reaction::equation(), TwoTempPlasmaRate::setContext(), and Reaction::validate().

## ◆ duplicate

bool duplicate

True if the current reaction is marked as duplicate.

Definition at line 153 of file Reaction.h.

Referenced by Reaction::getParameters(), and Reaction::setParameters().

## ◆ allow_nonreactant_orders

bool allow_nonreactant_orders

True if reaction orders can be specified for non-reactant species.

Default is `false`.

Definition at line 157 of file Reaction.h.

Referenced by Reaction::getParameters(), Reaction::setParameters(), and Reaction::validate().

## ◆ allow_negative_orders

bool allow_negative_orders

True if negative reaction orders are allowed. Default is `false`.

Definition at line 160 of file Reaction.h.

Referenced by Reaction::getParameters(), Reaction::setParameters(), and Reaction::validate().

## ◆ input

AnyMap input

Input data used for specific models.

Definition at line 163 of file Reaction.h.

Referenced by InterfaceKinetics::buildSurfaceArrhenius(), InterfaceReaction2::calculateRateCoeffUnits(), Reaction::checkBalance(), Reaction::checkSpecies(), Reaction::parameters(), StickingCoverage::setContext(), TwoTempPlasmaRate::setContext(), FalloffReaction3::setEquation(), Reaction::setEquation(), ThreeBodyReaction3::setEquation(), Reaction::setParameters(), Reaction::setRate(), Reaction::validate(), ElementaryReaction2::validate(), and FalloffReaction2::validate().

## ◆ rate_units

Units rate_units

The units of the rate constant.

These are determined by the units of the standard concentration of the reactant species' phases of the phase where the reaction occurs.

Definition at line 168 of file Reaction.h.

Referenced by Reaction::calculateRateCoeffUnits(), ThreeBodyReaction2::calculateRateCoeffUnits(), FalloffReaction2::calculateRateCoeffUnits(), ChemicallyActivatedReaction2::calculateRateCoeffUnits(), InterfaceReaction2::calculateRateCoeffUnits(), Reaction::calculateRateCoeffUnits3(), ElementaryReaction2::getParameters(), FalloffReaction2::getParameters(), PlogReaction2::getParameters(), and ChebyshevReaction2::getParameters().

## ◆ m_valid

bool m_valid
| protected

Flag indicating whether reaction is set up correctly.

Definition at line 195 of file Reaction.h.

Referenced by Reaction::setValid(), and Reaction::valid().

## ◆ m_rate

shared_ptr<ReactionRate> m_rate
| protected

Reaction rate used by generic reactions.

Definition at line 206 of file Reaction.h.

Referenced by Reaction::getParameters(), Reaction::rate(), Reaction::setRate(), FalloffReaction3::type(), Reaction::usesLegacy(), and Reaction::validate().

## ◆ m_third_body

shared_ptr<ThirdBody> m_third_body
| protected

Relative efficiencies of third-body species in enhancing the reaction rate (if applicable)

Definition at line 210 of file Reaction.h.

Referenced by Reaction::calculateRateCoeffUnits3(), ThreeBodyReaction3::getParameters(), FalloffReaction3::getParameters(), ThreeBodyReaction3::productString(), FalloffReaction3::productString(), ThreeBodyReaction3::reactantString(), FalloffReaction3::reactantString(), FalloffReaction3::setEquation(), ThreeBodyReaction3::setParameters(), FalloffReaction3::setParameters(), Reaction::thirdBody(), and Reaction::undeclaredThirdBodies().

The documentation for this class was generated from the following files:

- Reaction.h
- Reaction.cpp