14LinearBurkeData::LinearBurkeData()
16 moleFractions.resize(1, NAN);
24 if (moleFractions.empty()) {
40 if (m_pressure_buf > 0.) {
42 "Cannot apply another perturbation as state is already perturbed.");
51 if (m_pressure_buf < 0.) {
67 if (!node.
hasKey(
"colliders")) {
69 "'colliders' key missing");
71 auto colliders = node[
"colliders"].asVector<
AnyMap>();
72 if (!colliders[0].hasKey(
"name")) {
73 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
74 "'name' key missing from collider entry");
75 }
else if (colliders[0][
"name"].asString() !=
"M") {
76 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
77 "The first collider must be 'M'. Found '{}'.", colliders[0][
"name"].asString());
78 }
else if (!colliders[0].hasKey(
"type")) {
79 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
80 "'type' key missing for 'M'. Must be either 'falloff'"
81 " (Troe format), 'pressure-dependent-Arrhenius', or 'Chebyshev'.");
82 }
else if (colliders[0].hasKey(
"efficiency")) {
83 if (colliders[0][
"efficiency"][
"A"] != 1 ||
84 colliders[0][
"efficiency"][
"b"] != 0 ||
85 colliders[0][
"efficiency"][
"Ea"] != 0) {
86 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
87 "It is not necessary to provide an 'efficiency' for 'M', "
88 "as it is always equal to 1, by definition. However, if it is "
89 "entered, then it must be: 'efficiency: {A: 1, b: 0, Ea: 0}'.");
92 if (colliders[0][
"type"] ==
"pressure-dependent-Arrhenius") {
95 }
else if (colliders[0][
"type"] ==
"falloff" && colliders[0].hasKey(
"Troe")) {
100 }
else if (colliders[0][
"type"] ==
"Chebyshev") {
104 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
105 "Collider 'M' must be specified in a pressure-dependent-Arrhenius (PLOG), "
106 "falloff (Troe form), or Chebyshev format.");
113 string eig_eps_key, conflicting_key;
116 if (colliders[0].hasKey(
"eig0")) {
117 eig_eps_key =
"eig0";
118 conflicting_key =
"efficiency";
120 eig_eps_key =
"efficiency";
121 conflicting_key =
"eig0";
122 colliders[0][eig_eps_key] = params;
125 for (
size_t i = 1; i < colliders.size(); i++) {
126 if (!colliders[i].hasKey(
"name")) {
127 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
128 "'name' key missing from collider entry");
130 auto nm = colliders[i][
"name"].asString();
131 if (!colliders[i].hasKey(eig_eps_key)) {
132 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
133 "Collider '{}' lacks an '{}' key.", nm, eig_eps_key);
135 if (colliders[i].hasKey(conflicting_key)) {
136 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
137 "Collider '{}' cannot contain both 'efficiency' and 'eig0'. All "
138 "additional colliders must also make the same choice as that of 'M'.",
146 params[
"A"] = colliders[i][eig_eps_key][
"A"].asDouble() /
147 colliders[0][eig_eps_key][
"A"].asDouble();
148 params[
"b"] = colliders[i][eig_eps_key][
"b"].asDouble() -
149 colliders[0][eig_eps_key][
"b"].asDouble();
150 params[
"Ea"] = colliders[i][eig_eps_key][
"Ea"].asDouble() -
151 colliders[0][eig_eps_key][
"Ea"].asDouble();
153 if (params[
"A"].asDouble() < 0) {
154 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
155 "Invalid '{}' entry for collider '{}'.", eig_eps_key, nm);
159 if (colliders[i].hasKey(
"type")) {
160 if (colliders[i][
"type"] ==
"pressure-dependent-Arrhenius") {
165 }
else if (colliders[i][
"type"] ==
"falloff"
166 && colliders[i].hasKey(
"Troe"))
174 }
else if (colliders[i][
"type"] ==
"Chebyshev") {
180 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
181 "Collider '{}': '{}' rate parameterization is not supported. Must "
182 "be one of 'pressure-dependent-Arrhenius (PLOG), 'falloff' (Troe "
183 "form), or 'Chebyshev'.",
212 PlogData& data = std::get<PlogData>(dataObj);
213 PlogRate& rate = std::get<PlogRate>(rateObj);
226 TroeRate& rate = get<TroeRate>(rateObj);
239 data.
log10P = log10(exp(logPeff));
246double LinearBurkeRate::evalFromStruct(
const LinearBurkeData& shared_data)
248 double sigmaX_M = 0.0;
250 for (
size_t i = 0; i < shared_data.moleFractions.size(); i++) {
253 sigmaX_M += shared_data.moleFractions[i];
255 double eps_mix = 0.0;
258 eps_mix += shared_data.moleFractions[i]
260 sigmaX_M -= shared_data.moleFractions[i];
265 throw InputFileError(
"LinearBurkeRate::evalFromStruct",
m_input,
266 "eps_mix == 0 for some reason");
276 logPeff = shared_data.
logP + log(eps_mix) - log(eps2);
279 * eps1 * shared_data.moleFractions[i] / eps_mix;
282 * eps1 * shared_data.moleFractions[i] / eps_mix;
285 * eps1 * shared_data.moleFractions[i] / eps_mix;
287 throw InputFileError(
"LinearBurkeRate::evalFromStruct",
m_input,
288 "Something went wrong...");
294 logPeff = shared_data.
logP + log(eps_mix);
315 vector<AnyMap> topLevelList;
317 M_node[
"name"] =
"M";
320 M_params = rate.parameters();
323 M_params = rate.parameters();
326 M_params = rate.parameters();
329 topLevelList.push_back(std::move(M_node));
332 AnyMap collider, efficiency, params;
335 collider[
"efficiency"] = std::move(efficiency);
338 if (var_rate.index() == 0) {
339 auto& rate = get<PlogRate>(var_rate);
340 params = rate.parameters();
341 }
else if (var_rate.index() == 1) {
342 auto& rate = get<TroeRate>(var_rate);
343 params = rate.parameters();
344 }
else if (var_rate.index() == 2) {
345 auto& rate = get<ChebyshevRate>(var_rate);
346 params = rate.parameters();
350 topLevelList.push_back(std::move(collider));
352 rateNode[
"colliders"] = std::move(topLevelList);
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
void update(const AnyMap &other, bool keepExisting=true)
Add items from other to this AnyMap.
A wrapper for a variable whose type is determined at runtime.
Arrhenius reaction rate type depends only on temperature.
Base class for exceptions thrown by Cantera classes.
Pressure-dependent rate expression where the rate coefficient is expressed as a bivariate Chebyshev p...
void updateFromStruct(const ChebyshevData &shared_data)
Update information specific to reaction.
double evalFromStruct(const ChebyshevData &shared_data)
Evaluate reaction rate.
double evalFromStruct(const FalloffData &shared_data)
Evaluate reaction rate.
Public interface for kinetics managers.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
void getParameters(AnyMap &rateNode) const override
Get parameters.
std::variant< PlogData, FalloffData, ChebyshevData > DataTypes
Type alias that refers to PlogData, FalloffData, and ChebyshevData.
double evalTroeRate(const LinearBurkeData &shared_data, DataTypes &dataObj, RateTypes &rateObj, double logPeff)
Evaluate overall reaction rate using Troe to evaluate pressure-dependent aspect of the reaction.
std::variant< PlogRate, TroeRate, ChebyshevRate > RateTypes
Type alias that refers to PlogRate, TroeRate, and ChebyshevRate.
void setContext(const Reaction &rxn, const Kinetics &kin) override
Set context of reaction rate evaluation.
vector< string > m_colliderNames
String name of each collider, appearing in the same order as that of the original reaction input.
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Perform object setup based on AnyMap node information.
vector< RateTypes > m_rateObjs
Stores rate objects corresponding to each non-M collider, which can be either PlogRate,...
LinearBurkeRate()=default
Default constructor.
DataTypes m_dataObj_M
Stores data objects corresponding to the reference collider M, which can be either PlogData,...
void validate(const string &equation, const Kinetics &kin) override
Validate the reaction rate expression.
double evalChebyshevRate(const LinearBurkeData &shared_data, DataTypes &dataObj, RateTypes &rateObj, double logPeff)
Evaluate overall reaction rate using Chebyshev to evaluate pressure-dependent aspect of the reaction.
ArrheniusRate m_epsObj_M
Third-body collision efficiency object for the reference collider M (eig0_M/eig0_M = 1 always)
vector< size_t > m_colliderIndices
Index of each collider in the kinetics object species list where the vector elements appear in the sa...
vector< ArrheniusRate > m_epsObjs1
Third-body collision efficiency object for k(T,P,X) and eig0_mix calculation.
double evalPlogRate(const LinearBurkeData &shared_data, DataTypes &dataObj, RateTypes &rateObj, double logPeff)
Evaluate overall reaction rate using PLOG to evaluate pressure-dependent aspect of the reaction.
vector< bool > m_hasRateConstant
Indicates which colliders have a distinct k(T,P) versus only an efficiency.
vector< ArrheniusRate > m_epsObjs2
Third-body collision efficiency object for logPeff calculation.
RateTypes m_rateObj_M
Stores rate objects corresponding the reference collider M, which can be either PlogRate,...
vector< DataTypes > m_dataObjs
Stores data objects corresponding to each non-M collider, which can be either PlogData,...
double temperature() const
Temperature (K).
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
int stateMFNumber() const
Return the State Mole Fraction Number.
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Pressure-dependent reaction rate expressed by logarithmically interpolating between Arrhenius rate ex...
void updateFromStruct(const PlogData &shared_data)
Update information specific to reaction.
double evalFromStruct(const PlogData &shared_data)
Evaluate reaction rate.
virtual void setParameters(const AnyMap &node, const UnitStack &units)
Set parameters.
void setRateIndex(size_t idx)
Set reaction rate index within kinetics evaluator.
AnyMap m_input
Input data used for specific models.
Abstract base class which stores data about a reaction and its rate parameterization so that it can b...
Base class for a phase with thermodynamic properties.
The 3- or 4-parameter Troe falloff parameterization.
A representation of the units associated with a dimensional quantity.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Namespace for the Cantera kernel.
Data container holding shared data specific to ChebyshevRate.
double log10P
base 10 logarithm of pressure
Data container holding shared data specific to Falloff rates.
vector< double > conc_3b
vector of effective third-body concentrations
Data container holding shared data specific to LinearBurkeRate.
void perturbPressure(double deltaP)
Perturb pressure of data container.
double logP
Logarithm of pressure.
void restore() override
Restore data container after a perturbation.
void update(double T, double P) override
Update data container based on temperature T and an extra parameter.
Data container holding shared data specific to PlogRate.
double logP
logarithm of pressure
double recipT
inverse of temperature
virtual void update(double T)
Update data container based on temperature T
double temperature
temperature
double logT
logarithm of temperature
virtual void restore()
Restore data container after a perturbation.
Unit aggregation utility.