20template <
class RateType,
class DataType>
33 "Cannot determine type of empty rate handler.");
40 m_rxn_rates.emplace_back(rxn_index,
dynamic_cast<RateType&
>(rate));
47 "Invalid operation: cannot replace rate object "
48 "in empty rate handler.");
52 "Invalid operation: cannot replace rate object of type '{}' "
53 "with a new rate of type '{}'.",
type(), rate.
type());
56 if (m_indices.find(rxn_index) != m_indices.end()) {
57 size_t j = m_indices[rxn_index];
58 m_rxn_rates.at(j).second =
dynamic_cast<RateType&
>(rate);
71 kf[iRxn] = rate.evalFromStruct(
m_shared);
76 if constexpr (has_modifyRateConstants<RateType>::value) {
78 rate.modifyRateConstants(
m_shared, kf[iRxn], kr[iRxn]);
84 double deltaT)
override
86 if constexpr (has_ddT<RateType>::value) {
88 rop[iRxn] *= rate.ddTScaledFromStruct(
m_shared);
92 double dTinv = 1. / (
m_shared.temperature * deltaT);
99 double k1 = rate.evalFromStruct(
m_shared);
100 rop[iRxn] *= dTinv * (k1 / kf[iRxn] - 1.);
111 double deltaP)
override
113 if constexpr (has_ddP<DataType>::value) {
114 double dPinv = 1. / (
m_shared.pressure * deltaP);
119 if (kf[iRxn] != 0.) {
120 double k1 = rate.evalFromStruct(
m_shared);
121 rop[iRxn] *= dPinv * (k1 / kf[iRxn] - 1.);
136 double deltaM,
bool overwrite=
true)
override
138 if constexpr (has_ddM<DataType>::value) {
139 double dMinv = 1. / deltaM;
140 m_shared.perturbThirdBodies(deltaM);
144 if (kf[iRxn] != 0. &&
m_shared.conc_3b[iRxn] > 0.) {
145 double k1 = rate.evalFromStruct(
m_shared);
146 rop[iRxn] *= dMinv * (k1 / kf[iRxn] - 1.);
147 rop[iRxn] /=
m_shared.conc_3b[iRxn];
172 void update(
double T,
double extra)
override {
177 void update(
double T, span<const double> extra)
override {
183 bool changed =
m_shared.update(phase, kin);
193 RateType& R =
static_cast<RateType&
>(rate);
194 if constexpr (has_update<RateType>::value) {
209 if constexpr (has_update<RateType>::value) {
218 map<size_t, size_t> m_indices;
Base class for exceptions thrown by Cantera classes.
Public interface for kinetics managers.
An abstract base class for evaluating all reactions of a particular type.
A class template handling ReactionRate specializations.
void getRateConstants(span< double > kf) override
Evaluate all rate constants handled by the evaluator.
void processRateConstants_ddT(span< double > rop, span< const double > kf, double deltaT) override
Evaluate all rate constant temperature derivatives handled by the evaluator; which are multiplied wit...
bool update(const ThermoPhase &phase, const Kinetics &kin) override
Update data common to reaction rates of a specific type.
DataType & sharedData()
Access the underlying shared data object.
string type() override
Identifier of reaction rate type.
void update(double T) override
Update common reaction rate data based on temperature.
bool replace(size_t rxn_index, ReactionRate &rate) override
Replace reaction rate object handled by the evaluator.
void processRateConstants_ddP(span< double > rop, span< const double > kf, double deltaP) override
Evaluate all rate constant pressure derivatives handled by the evaluator; which are multiplied with t...
double evalSingle(ReactionRate &rate) override
Get the rate for a single reaction.
void _update()
Helper function to process updates.
DataType m_shared
Mapping of indices.
void resize(Kinetics &kin) override
Update array sizes that depend on number of species, reactions or phases.
void modifyRateConstants(span< double > kf, span< double > kr) override
For certain reaction types that do not follow mass action kinetics (for example, Butler-Volmer),...
void add(size_t rxn_index, ReactionRate &rate) override
Add reaction rate object to the evaluator.
void processRateConstants_ddM(span< double > rop, span< const double > kf, double deltaM, bool overwrite=true) override
Evaluate all rate constant third-body derivatives handled by the evaluator; which are multiplied with...
void update(double T, span< const double > extra) override
Update common reaction rate data based on temperature and extra parameter.
void update(double T, double extra) override
Update common reaction rate data based on temperature and extra parameter.
vector< pair< size_t, RateType > > m_rxn_rates
Vector of pairs of reaction rates indices and reaction rates.
Abstract base class for reaction rate definitions; this base class is used by user-facing APIs to acc...
virtual const string type() const =0
String identifying reaction rate specialization.
Base class for a phase with thermodynamic properties.
Namespace for the Cantera kernel.
Various templated functions that carry out common vector and polynomial operations (see Templated Arr...
#define CT_DEFINE_HAS_MEMBER(detector_name, func_name)
A macro for generating member function detectors, which can then be used in combination with if const...