27 m_logStandConc = log(
thermo().standardConcentration());
28 doublereal logT = log(T);
32 m_rates.update(T, logT,
m_rfn.data());
35 if (!m_rfn_low.empty()) {
39 if (!falloff_work.empty()) {
46 if (T != m_temp || P !=
m_pres) {
47 if (m_plog_rates.nReactions()) {
48 m_plog_rates.update(T, logT,
m_rfn.data());
52 if (m_cheb_rates.nReactions()) {
53 m_cheb_rates.update(T, logT,
m_rfn.data());
67 if (!concm_3b_values.empty()) {
68 m_3b_concm.update(m_conc, ctot, concm_3b_values.data());
72 if (!concm_falloff_values.empty()) {
73 m_falloff_concm.update(m_conc, ctot, concm_falloff_values.data());
77 if (m_plog_rates.nReactions()) {
78 double logP = log(
thermo().pressure());
79 m_plog_rates.update_C(&logP);
83 if (m_cheb_rates.nReactions()) {
84 double log10P = log10(
thermo().pressure());
85 m_cheb_rates.update_C(&log10P);
99 doublereal rrt = 1.0 /
thermo().
RT();
100 for (
size_t i = 0; i <
m_revindex.size(); i++) {
106 for (
size_t i = 0; i !=
m_irrev.size(); ++i) {
120 doublereal rrt = 1.0 /
thermo().
RT();
122 kc[i] = exp(-
m_rkcn[i]*rrt +
m_dn[i]*m_logStandConc);
130 void GasKinetics::processFalloffReactions()
136 pr[i] = concm_falloff_values[i] * m_rfn_low[i] / (m_rfn_high[i] +
SmallNumber);
137 AssertFinite(pr[i],
"GasKinetics::processFalloffReactions",
138 "pr[{}] is not finite.", i);
145 pr[i] *= m_rfn_high[i];
147 pr[i] *= m_rfn_low[i];
153 void GasKinetics::updateROP()
165 if (!concm_3b_values.empty()) {
166 m_3b_concm.multiply(
m_ropf.data(), concm_3b_values.data());
170 processFalloffReactions();
191 for (
size_t i = 0; i <
m_rfn.size(); i++) {
193 "m_rfn[{}] is not finite.", i);
195 "m_ropf[{}] is not finite.", i);
197 "m_ropr[{}] is not finite.", i);
211 if (!concm_3b_values.empty()) {
212 m_3b_concm.multiply(
m_ropf.data(), concm_3b_values.data());
216 processFalloffReactions();
233 switch (r->reaction_type) {
252 "Unknown reaction type specified: {}", r->reaction_type);
263 m_rfn_high.push_back(0.0);
265 m_rfn_low.push_back(0.0);
272 map<size_t, double> efficiencies;
276 efficiencies[k] = eff.second;
278 throw CanteraError(
"GasKinetics::addFalloffReaction",
"Found "
279 "third-body efficiency for undefined species '" + eff.first +
280 "' while adding reaction '" + r.
equation() +
"'");
283 m_falloff_concm.install(nfall, efficiencies,
285 concm_falloff_values.resize(m_falloff_concm.workSize());
289 falloff_work.resize(m_falloffn.
workSize());
292 void GasKinetics::addThreeBodyReaction(ThreeBodyReaction& r)
295 map<size_t, double> efficiencies;
296 for (
const auto& eff : r.third_body.efficiencies) {
299 efficiencies[k] = eff.second;
301 throw CanteraError(
"GasKinetics::addThreeBodyReaction",
"Found "
302 "third-body efficiency for undefined species '" + eff.first +
303 "' while adding reaction '" + r.equation() +
"'");
306 m_3b_concm.install(
nReactions()-1, efficiencies,
307 r.third_body.default_efficiency);
308 concm_3b_values.resize(m_3b_concm.workSize());
311 void GasKinetics::addPlogReaction(PlogReaction& r)
316 void GasKinetics::addChebyshevReaction(ChebyshevReaction& r)
326 switch (rNew->reaction_type) {
338 modifyPlogReaction(i,
dynamic_cast<PlogReaction&
>(*rNew));
345 "Unknown reaction type specified: {}", rNew->reaction_type);
356 m_rates.replace(i, r.rate);
359 void GasKinetics::modifyFalloffReaction(
size_t i, FalloffReaction& r)
364 m_falloffn.
replace(iFall, r.falloff);
367 void GasKinetics::modifyPlogReaction(
size_t i, PlogReaction& r)
369 m_plog_rates.replace(i, r.rate);
372 void GasKinetics::modifyChebyshevReaction(
size_t i, ChebyshevReaction& r)
374 m_cheb_rates.replace(i, r.rate);
383 void GasKinetics::invalidateCache()
385 BulkKinetics::invalidateCache();
Partial specialization of Kinetics for chemistry in a single bulk phase.
std::vector< size_t > m_revindex
Indices of reversible reactions.
vector_fp m_dn
Difference between the global reactants order and the global products order.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
std::vector< size_t > m_irrev
Indices of irreversible reactions.
Base class for exceptions thrown by Cantera classes.
A pressure-dependent reaction parameterized by a bi-variate Chebyshev polynomial in temperature and p...
A reaction which follows mass-action kinetics with a modified Arrhenius reaction rate.
size_t workSize()
Size of the work array required to store intermediate results.
void pr_to_falloff(doublereal *values, const doublereal *work)
Given a vector of reduced pressures for each falloff reaction, replace each entry by the value of the...
void install(size_t rxn, int reactionType, shared_ptr< Falloff > f)
Install a new falloff function calculator.
void replace(size_t rxn, shared_ptr< Falloff > f)
void updateTemp(doublereal t, doublereal *work)
Update the cached temperature-dependent intermediate results for all installed falloff functions.
A reaction that is first-order in [M] at low pressure, like a third-body reaction,...
ThirdBody third_body
Relative efficiencies of third-body species in enhancing the reaction rate.
Arrhenius low_rate
The rate constant in the low-pressure limit.
Arrhenius high_rate
The rate constant in the high-pressure limit.
shared_ptr< Falloff > falloff
Falloff function which determines how low_rate and high_rate are combined to determine the rate const...
virtual void init()
Prepare the class for the addition of reactions, after all phases have been added.
std::map< size_t, size_t > m_rfallindx
Map of reaction index to falloff reaction index (i.e indices in m_falloff_low_rates and m_falloff_hig...
doublereal m_pres
Last pressure at which rates were evaluated.
Rate1< Arrhenius > m_falloff_high_rates
Rate expressions for falloff reactions at the high-pressure limit.
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
void updateKc()
Update the equilibrium constants in molar units.
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
virtual void update_rates_C()
Update properties that depend on concentrations.
virtual void update_rates_T()
Update temperature-dependent portions of reaction rates and falloff functions.
std::vector< size_t > m_fallindx
Reaction index of each falloff reaction.
Rate1< Arrhenius > m_falloff_low_rates
Rate expressions for falloff reactions at the low-pressure limit.
virtual void getEquilibriumConstants(doublereal *kc)
Return a vector of Equilibrium constants.
vector_fp m_ropnet
Net rate-of-progress for each reaction.
thermo_t & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
virtual int reactionType(size_t i) const
Flag specifying the type of reaction.
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
virtual void getReactionDelta(const doublereal *property, doublereal *deltaProperty)
Change in species properties.
vector_fp m_rkcn
Reciprocal of the equilibrium constant in concentration units.
vector_fp m_ropf
Forward rate-of-progress for each reaction.
virtual void getRevReactionDelta(const doublereal *g, doublereal *dg)
Given an array of species properties 'g', return in array 'dg' the change in this quantity in the rev...
vector_fp m_ropr
Reverse rate-of-progress for each reaction.
virtual void init()
Prepare the class for the addition of reactions, after all phases have been added.
bool m_skipUndeclaredThirdBodies
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
StoichManagerN m_revProductStoich
Stoichiometry manager for the products of reversible reactions.
size_t nReactions() const
Number of reactions in the reaction mechanism.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
vector_fp m_rfn
Forward rate constant for each reaction.
StoichManagerN m_reactantStoich
Stoichiometry manager for the reactants for each reaction.
double molarDensity() const
Molar density (kmol/m^3).
doublereal temperature() const
Temperature (K).
virtual double pressure() const
Return the thermodynamic pressure (Pa).
A pressure-dependent reaction parameterized by logarithmically interpolating between Arrhenius rate e...
int reaction_type
Type of the reaction.
std::string equation() const
The chemical equation for this reaction.
Base class for a phase with thermodynamic properties.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
double default_efficiency
The default third body efficiency for species not listed in efficiencies.
Composition efficiencies
Map of species to third body efficiency.
A reaction with a non-reacting third body "M" that acts to add or remove energy from the reacting spe...
#define AssertFinite(expr, procedure,...)
Throw an exception if the specified exception is not a finite number.
const size_t npos
index returned by functions to indicate "no position"
const double SmallNumber
smallest number to compare to zero.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
const double GasConstant
Universal Gas Constant [J/kmol/K].
const double BigNumber
largest number to compare to inf.
Namespace for the Cantera kernel.
const int CHEBYSHEV_RXN
A general gas-phase pressure-dependent reaction where k(T,P) is defined in terms of a bivariate Cheby...
const int PLOG_RXN
A pressure-dependent rate expression consisting of several Arrhenius rate expressions evaluated at di...
const int THREE_BODY_RXN
A gas-phase reaction that requires a third-body collision partner.
const int ELEMENTARY_RXN
A reaction with a rate coefficient that depends only on temperature and voltage that also obeys mass-...
const int CHEMACT_RXN
A chemical activation reaction.
const int FALLOFF_RXN
The general form for a gas-phase association or dissociation reaction, with a pressure-dependent rate...