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.) {
74 if (!node.
hasKey(
"colliders")) {
76 "'colliders' key missing");
78 auto colliders = node[
"colliders"].asVector<
AnyMap>();
79 if (!colliders[0].hasKey(
"name")) {
80 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
81 "'name' key missing from collider entry");
82 }
else if (colliders[0][
"name"].asString() !=
"M") {
83 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
84 "The first collider must be 'M'. Found '{}'.", colliders[0][
"name"].asString());
85 }
else if (!colliders[0].hasKey(
"type")) {
86 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
87 "'type' key missing for 'M'. Must be either 'falloff'"
88 " (Troe format), 'pressure-dependent-Arrhenius', or 'Chebyshev'.");
89 }
else if (colliders[0].hasKey(
"efficiency")) {
90 if (colliders[0][
"efficiency"][
"A"] != 1 ||
91 colliders[0][
"efficiency"][
"b"] != 0 ||
92 colliders[0][
"efficiency"][
"Ea"] != 0) {
93 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
94 "It is not necessary to provide an 'efficiency' for 'M', "
95 "as it is always equal to 1, by definition. However, if it is "
96 "entered, then it must be: 'efficiency: {A: 1, b: 0, Ea: 0}'.");
99 if (colliders[0][
"type"] ==
"pressure-dependent-Arrhenius") {
102 }
else if (colliders[0][
"type"] ==
"falloff" && colliders[0].hasKey(
"Troe")) {
107 }
else if (colliders[0][
"type"] ==
"Chebyshev") {
111 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[0],
112 "Collider 'M' must be specified in a pressure-dependent-Arrhenius (PLOG), "
113 "falloff (Troe form), or Chebyshev format.");
120 string eig_eps_key, conflicting_key;
123 if (colliders[0].hasKey(
"eig0")) {
124 eig_eps_key =
"eig0";
125 conflicting_key =
"efficiency";
127 eig_eps_key =
"efficiency";
128 conflicting_key =
"eig0";
129 colliders[0][eig_eps_key] = params;
132 for (
size_t i = 1; i < colliders.size(); i++) {
133 if (!colliders[i].hasKey(
"name")) {
134 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
135 "'name' key missing from collider entry");
137 auto nm = colliders[i][
"name"].asString();
138 if (!colliders[i].hasKey(eig_eps_key)) {
139 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
140 "Collider '{}' lacks an '{}' key.", nm, eig_eps_key);
142 if (colliders[i].hasKey(conflicting_key)) {
143 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
144 "Collider '{}' cannot contain both 'efficiency' and 'eig0'. All "
145 "additional colliders must also make the same choice as that of 'M'.",
153 params[
"A"] = colliders[i][eig_eps_key][
"A"].asDouble() /
154 colliders[0][eig_eps_key][
"A"].asDouble();
155 params[
"b"] = colliders[i][eig_eps_key][
"b"].asDouble() -
156 colliders[0][eig_eps_key][
"b"].asDouble();
157 params[
"Ea"] = colliders[i][eig_eps_key][
"Ea"].asDouble() -
158 colliders[0][eig_eps_key][
"Ea"].asDouble();
160 if (params[
"A"].asDouble() < 0) {
161 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
162 "Invalid '{}' entry for collider '{}'.", eig_eps_key, nm);
166 if (colliders[i].hasKey(
"type")) {
167 if (colliders[i][
"type"] ==
"pressure-dependent-Arrhenius") {
172 }
else if (colliders[i][
"type"] ==
"falloff"
173 && colliders[i].hasKey(
"Troe"))
181 }
else if (colliders[i][
"type"] ==
"Chebyshev") {
187 throw InputFileError(
"LinearBurkeRate::setParameters", colliders[i],
188 "Collider '{}': '{}' rate parameterization is not supported. Must "
189 "be one of 'pressure-dependent-Arrhenius (PLOG), 'falloff' (Troe "
190 "form), or 'Chebyshev'.",
219 PlogData& data = std::get<PlogData>(dataObj);
220 PlogRate& rate = std::get<PlogRate>(rateObj);
233 TroeRate& rate = get<TroeRate>(rateObj);
246 data.
log10P = log10(exp(logPeff));
253double LinearBurkeRate::evalFromStruct(
const LinearBurkeData& shared_data)
255 double sigmaX_M = 0.0;
257 for (
size_t i = 0; i < shared_data.moleFractions.size(); i++) {
260 sigmaX_M += shared_data.moleFractions[i];
262 double eps_mix = 0.0;
265 eps_mix += shared_data.moleFractions[i]
267 sigmaX_M -= shared_data.moleFractions[i];
272 throw InputFileError(
"LinearBurkeRate::evalFromStruct",
m_input,
273 "eps_mix == 0 for some reason");
283 logPeff = shared_data.
logP + log(eps_mix) - log(eps2);
286 * eps1 * shared_data.moleFractions[i] / eps_mix;
289 * eps1 * shared_data.moleFractions[i] / eps_mix;
292 * eps1 * shared_data.moleFractions[i] / eps_mix;
294 throw InputFileError(
"LinearBurkeRate::evalFromStruct",
m_input,
295 "Something went wrong...");
301 logPeff = shared_data.
logP + log(eps_mix);
322 vector<AnyMap> topLevelList;
324 M_node[
"name"] =
"M";
327 M_params = rate.parameters();
330 M_params = rate.parameters();
333 M_params = rate.parameters();
336 topLevelList.push_back(std::move(M_node));
339 AnyMap collider, efficiency, params;
342 collider[
"efficiency"] = std::move(efficiency);
345 if (var_rate.index() == 0) {
346 auto& rate = get<PlogRate>(var_rate);
347 params = rate.parameters();
348 }
else if (var_rate.index() == 1) {
349 auto& rate = get<TroeRate>(var_rate);
350 params = rate.parameters();
351 }
else if (var_rate.index() == 2) {
352 auto& rate = get<ChebyshevRate>(var_rate);
353 params = rate.parameters();
357 topLevelList.push_back(std::move(collider));
359 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,...
void getMoleFractions(span< double > x) const
Get the species mole fraction vector.
double temperature() const
Temperature (K).
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.
bool ready
Boolean indicating whether vectors are accessible.
void restore() override
Restore data container after a perturbation.
virtual void resize(Kinetics &kin) override
Update array sizes that depend on number of species, reactions and phases.
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.