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];
155 void GasKinetics::updateROP()
167 if (!concm_3b_values.empty()) {
168 m_3b_concm.multiply(
m_ropf.data(), concm_3b_values.data());
172 processFalloffReactions();
195 for (
size_t i = 0; i <
m_rfn.size(); i++) {
197 "m_rfn[{}] is not finite.", i);
199 "m_ropf[{}] is not finite.", i);
201 "m_ropr[{}] is not finite.", i);
215 if (!concm_3b_values.empty()) {
216 m_3b_concm.multiply(
m_ropf.data(), concm_3b_values.data());
220 processFalloffReactions();
239 switch (r->reaction_type) {
241 addElementaryReaction(dynamic_cast<ElementaryReaction&>(*r));
244 addThreeBodyReaction(dynamic_cast<ThreeBodyReaction&>(*r));
248 addFalloffReaction(dynamic_cast<FalloffReaction&>(*r));
251 addPlogReaction(dynamic_cast<PlogReaction&>(*r));
254 addChebyshevReaction(dynamic_cast<ChebyshevReaction&>(*r));
258 "Unknown reaction type specified: {}", r->reaction_type);
269 m_rfn_high.push_back(0.0);
271 m_rfn_low.push_back(0.0);
278 map<size_t, double> efficiencies;
282 efficiencies[k] = eff.second;
284 throw CanteraError(
"GasKinetics::addFalloffReaction",
"Found " 285 "third-body efficiency for undefined species '" + eff.first +
286 "' while adding reaction '" + r.
equation() +
"'");
289 m_falloff_concm.install(nfall, efficiencies,
291 concm_falloff_values.resize(m_falloff_concm.workSize());
295 falloff_work.resize(m_falloffn.
workSize());
298 void GasKinetics::addThreeBodyReaction(ThreeBodyReaction& r)
301 map<size_t, double> efficiencies;
302 for (
const auto& eff : r.third_body.efficiencies) {
305 efficiencies[k] = eff.second;
307 throw CanteraError(
"GasKinetics::addThreeBodyReaction",
"Found " 308 "third-body efficiency for undefined species '" + eff.first +
309 "' while adding reaction '" + r.equation() +
"'");
312 m_3b_concm.install(
nReactions()-1, efficiencies,
313 r.third_body.default_efficiency);
314 concm_3b_values.resize(m_3b_concm.workSize());
317 void GasKinetics::addPlogReaction(PlogReaction& r)
322 void GasKinetics::addChebyshevReaction(ChebyshevReaction& r)
332 switch (rNew->reaction_type) {
334 modifyElementaryReaction(i, dynamic_cast<ElementaryReaction&>(*rNew));
337 modifyThreeBodyReaction(i, dynamic_cast<ThreeBodyReaction&>(*rNew));
341 modifyFalloffReaction(i, dynamic_cast<FalloffReaction&>(*rNew));
344 modifyPlogReaction(i, dynamic_cast<PlogReaction&>(*rNew));
347 modifyChebyshevReaction(i, dynamic_cast<ChebyshevReaction&>(*rNew));
351 "Unknown reaction type specified: {}", rNew->reaction_type);
362 m_rates.replace(i, r.rate);
365 void GasKinetics::modifyFalloffReaction(
size_t i, FalloffReaction& r)
370 m_falloffn.
replace(iFall, r.falloff);
373 void GasKinetics::modifyPlogReaction(
size_t i, PlogReaction& r)
375 m_plog_rates.replace(i, r.rate);
378 void GasKinetics::modifyChebyshevReaction(
size_t i, ChebyshevReaction& r)
380 m_cheb_rates.replace(i, r.rate);
389 void GasKinetics::invalidateCache()
391 BulkKinetics::invalidateCache();
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
const int PLOG_RXN
A pressure-dependent rate expression consisting of several Arrhenius rate expressions evaluated at di...
StoichManagerN m_revProductStoich
Stoichiometry manager for the products of reversible reactions.
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...
vector_fp m_ropr
Reverse rate-of-progress for each reaction.
int reaction_type
Type of the reaction.
doublereal temperature() const
Temperature (K).
thermo_t & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism...
void replace(size_t rxn, shared_ptr< Falloff > f)
virtual void getFwdRateConstants(doublereal *kfwd)
Return the forward rate constants.
const size_t npos
index returned by functions to indicate "no position"
void install(size_t rxn, int reactionType, shared_ptr< Falloff > f)
Install a new falloff function calculator.
const int CHEBYSHEV_RXN
A general gas-phase pressure-dependent reaction where k(T,P) is defined in terms of a bivariate Cheby...
virtual void init()
Prepare the class for the addition of reactions, after all phases have been added.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
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_ropnet
Net rate-of-progress for each reaction.
const int CHEMACT_RXN
A chemical activation reaction.
virtual int reactionType(size_t i) const
Flag specifying the type of reaction.
void updateTemp(doublereal t, doublereal *work)
Update the cached temperature-dependent intermediate results for all installed falloff functions...
size_t workSize()
Size of the work array required to store intermediate results.
void multiply_each(OutputIter x_begin, OutputIter x_end, InputIter y_begin)
Multiply each entry in x by the corresponding entry in y.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void update_rates_T()
Update temperature-dependent portions of reaction rates and falloff functions.
vector_fp m_ropf
Forward rate-of-progress for each reaction.
Base class for a phase with thermodynamic properties.
Partial specialization of Kinetics for chemistry in a single bulk phase.
const int FALLOFF_RXN
The general form for a gas-phase association or dissociation reaction, with a pressure-dependent rate...
virtual void init()
Prepare the class for the addition of reactions, after all phases have been added.
virtual void getEquilibriumConstants(doublereal *kc)
Return a vector of Equilibrium constants.
shared_ptr< Falloff > falloff
Falloff function which determines how low_rate and high_rate are combined to determine the rate const...
Rate1< Arrhenius > m_falloff_high_rates
Rate expressions for falloff reactions at the high-pressure limit.
std::vector< size_t > m_irrev
Indices of irreversible reactions.
doublereal molarDensity() const
Molar density (kmol/m^3).
const doublereal BigNumber
largest number to compare to inf.
vector_fp m_rfn
Forward rate constant for each reaction.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
StoichManagerN m_reactantStoich
Stoichiometry manager for the reactants for each reaction.
bool m_skipUndeclaredThirdBodies
void updateKc()
Update the equilibrium constants in molar units.
vector_fp m_perturb
Vector of perturbation factors for each reaction's rate of progress vector.
A reaction that is first-order in [M] at low pressure, like a third-body reaction, but zeroth-order in [M] as pressure increases.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
Base class for exceptions thrown by Cantera classes.
std::vector< size_t > m_revindex
Indices of reversible reactions.
size_t nReactions() const
Number of reactions in the reaction mechanism.
#define AssertFinite(expr, procedure,...)
Throw an exception if the specified exception is not a finite number.
std::vector< size_t > m_fallindx
Reaction index of each falloff reaction.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
const int THREE_BODY_RXN
A gas-phase reaction that requires a third-body collision partner.
vector_fp m_rkcn
Reciprocal of the equilibrium constant in concentration units.
virtual void update_rates_C()
Update properties that depend on concentrations.
const doublereal 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.
Composition efficiencies
Map of species to third body efficiency.
doublereal m_pres
Last pressure at which rates were evaluated.
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...
A reaction with a non-reacting third body "M" that acts to add or remove energy from the reacting spe...
void scatter_copy(InputIter begin, InputIter end, OutputIter result, IndexIter index)
Copies a contiguous range in a sequence to indexed positions in another sequence. ...
vector_fp m_dn
Difference between the global reactants order and the global products order.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
const int ELEMENTARY_RXN
A reaction with a rate coefficient that depends only on temperature and voltage that also obeys mass-...
Arrhenius high_rate
The rate constant in the high-pressure limit.
Arrhenius low_rate
The rate constant in the low-pressure limit.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
virtual void modifyReaction(size_t i, shared_ptr< Reaction > rNew)
Modify the rate expression associated with a reaction.
Namespace for the Cantera kernel.
Rate1< Arrhenius > m_falloff_low_rates
Rate expressions for falloff reactions at the low-pressure limit.
double default_efficiency
The default third body efficiency for species not listed in efficiencies.
virtual void getReactionDelta(const doublereal *property, doublereal *deltaProperty)
Change in species properties.
ThirdBody third_body
Relative efficiencies of third-body species in enhancing the reaction rate.
std::string equation() const
The chemical equation for this reaction.