20template <
class RateType,
class DataType>
32 "Cannot determine type of empty rate handler.");
39 m_rxn_rates.emplace_back(rxn_index,
dynamic_cast<RateType&
>(rate));
46 "Invalid operation: cannot replace rate object "
47 "in empty rate handler.");
51 "Invalid operation: cannot replace rate object of type '{}' "
52 "with a new rate of type '{}'.",
type(), rate.
type());
55 if (m_indices.find(rxn_index) != m_indices.end()) {
56 size_t j = m_indices[rxn_index];
57 m_rxn_rates.at(j).second =
dynamic_cast<RateType&
>(rate);
63 void resize(
size_t nSpecies,
size_t nReactions,
size_t nPhases)
override {
64 m_shared.resize(nSpecies, nReactions, nPhases);
70 kf[iRxn] = rate.evalFromStruct(
m_shared);
76 if constexpr (has_ddT<RateType>::value) {
78 rop[iRxn] *= rate.ddTScaledFromStruct(
m_shared);
82 double dTinv = 1. / (
m_shared.temperature * deltaT);
89 double k1 = rate.evalFromStruct(
m_shared);
90 rop[iRxn] *= dTinv * (k1 / kf[iRxn] - 1.);
102 if constexpr (has_ddP<DataType>::value) {
103 double dPinv = 1. / (
m_shared.pressure * deltaP);
108 if (kf[iRxn] != 0.) {
109 double k1 = rate.evalFromStruct(
m_shared);
110 rop[iRxn] *= dPinv * (k1 / kf[iRxn] - 1.);
125 bool overwrite=
true)
override
127 if constexpr (has_ddM<DataType>::value) {
128 double dMinv = 1. / deltaM;
129 m_shared.perturbThirdBodies(deltaM);
133 if (kf[iRxn] != 0. &&
m_shared.conc_3b[iRxn] > 0.) {
134 double k1 = rate.evalFromStruct(
m_shared);
135 rop[iRxn] *= dMinv * (k1 / kf[iRxn] - 1.);
136 rop[iRxn] /=
m_shared.conc_3b[iRxn];
161 void update(
double T,
double extra)
override {
166 void update(
double T,
const vector<double>& extra)
override {
172 bool changed =
m_shared.update(phase, kin);
182 RateType& R =
static_cast<RateType&
>(rate);
183 if constexpr (has_update<RateType>::value) {
198 if constexpr (has_update<RateType>::value) {
207 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 processRateConstants_ddM(double *rop, 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 getRateConstants(double *kf) override
Evaluate all rate constants handled by the evaluator.
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, const vector< double > &extra) override
Update common reaction rate data based on temperature and extra parameter.
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 resize(size_t nSpecies, size_t nReactions, size_t nPhases) override
Update number of species and reactions.
void processRateConstants_ddT(double *rop, const double *kf, double deltaT) override
Evaluate all rate constant temperature derivatives handled by the evaluator; which are multiplied wit...
double evalSingle(ReactionRate &rate) override
Get the rate for a single reaction.
void _update()
Helper function to process updates.
void processRateConstants_ddP(double *rop, const double *kf, double deltaP) override
Evaluate all rate constant pressure derivatives handled by the evaluator; which are multiplied with t...
DataType m_shared
Mapping of indices.
void add(size_t rxn_index, ReactionRate &rate) override
Add reaction rate object to the evaluator.
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...