13#include "cantera/kinetics/Falloff.h"
20FalloffData::FalloffData()
29 "Missing state information: 'FalloffData' requires third-body concentration.");
61 "Cannot apply another perturbation as state is already perturbed.");
81FalloffRate::FalloffRate(
const AnyMap& node,
const UnitStack& rate_units)
84 setParameters(node, rate_units);
90 "To be removed after Cantera 3.0; superseded by setFalloffCoeffs.");
101 "Detected inconsistent rate definitions;\nhigh and low "
102 "rate pre-exponential factors must have the same sign.");
114 "Detected inconsistent rate definitions;\nhigh and low "
115 "rate pre-exponential factors must have the same sign.");
124 "Incorrect number of parameters. 0 required. Received {}.",
143 if (node[
"type"] ==
"chemically-activated") {
149 if (rate_units.
size()) {
151 high_rate_units.
join(1);
153 low_rate_units.
join(-1);
156 if (node.
hasKey(
"low-P-rate-constant")) {
158 node[
"low-P-rate-constant"], node.
units(), low_rate_units);
161 if (node.
hasKey(
"high-P-rate-constant")) {
163 node[
"high-P-rate-constant"], node.
units(), high_rate_units);
171 node[
"negative-A"] =
true;
175 if (!rNode.
empty()) {
176 node[
"low-P-rate-constant"] = std::move(rNode);
180 if (!rNode.
empty()) {
181 node[
"high-P-rate-constant"] = std::move(rNode);
195 "Inconsistent rate definitions found in reaction '{}';\nhigh and low "
196 "rate pre-exponential factors must have the same sign.", equation);
210LindemannRate::LindemannRate(
const AnyMap& node,
const UnitStack& rate_units)
216LindemannRate::LindemannRate(
const ArrheniusRate& low,
const ArrheniusRate& high,
217 const vector<double>& c)
232 const vector<double>& c)
242 if (c.size() != 3 && c.size() != 4) {
244 "Incorrect number of coefficients. 3 or 4 required. Received {}.",
249 m_rt3 = std::numeric_limits<double>::infinity();
255 m_rt1 = std::numeric_limits<double>::infinity();
263 "Unexpected parameter value T2=0. Omitting exp(T2/T) term from "
264 "falloff expression. To suppress this warning, remove value "
265 "for T2 from the input file. In the unlikely case that the "
266 "exp(T2/T) term should be included with T2 effectively equal "
267 "to 0, set T2 to a sufficiently small value "
268 "(for example, T2 < 1e-16).");
294 Fcent += exp(-
m_t2 / T);
302 double cc = -0.4 - 0.67 * (*work);
303 double nn = 0.75 - 1.27 * (*work);
304 double f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
305 double lgf = (*work) / (1.0 + f1 * f1);
306 return pow(10.0, lgf);
316 auto& f = node[
"Troe"].as<
AnyMap>();
320 vector<double> params{
325 if (f.hasKey(
"T2")) {
326 params.push_back(f[
"T2"].asDouble());
333 "To be removed after Cantera 3.0; superseded by getFalloffCoeffs.");
335 params[1] = 1.0/
m_rt3;
336 params[2] = 1.0/
m_rt1;
347 params[
"T3"].setQuantity(1.0 /
m_rt3,
"K");
348 params[
"T1"].setQuantity(1.0 /
m_rt1,
"K");
350 params[
"T2"].setQuantity(
m_t2,
"K");
354 node[
"Troe"] = std::move(params);
365 if (c.size() != 3 && c.size() != 5) {
367 "Incorrect number of coefficients. 3 or 5 required. Received {}.",
373 "m_c parameter is less than zero: {}", c[2]);
382 "m_d parameter is less than zero: {}", c[3]);
409 *work =
m_a * exp(-
m_b / T);
411 *work += exp(- T/
m_c);
413 work[1] =
m_d * pow(T,
m_e);
419 double xx = 1.0/(1.0 + lpr*lpr);
420 return pow(*work, xx) * work[1];
430 auto& f = node[
"SRI"].as<
AnyMap>();
434 vector<double> params{
440 params.push_back(f[
"D"].asDouble());
443 params.push_back(f[
"E"].asDouble());
451 "To be removed after Cantera 3.0; superseded by getFalloffCoeffs.");
466 params[
"B"].setQuantity(
m_b,
"K");
467 params[
"C"].setQuantity(
m_c,
"K");
468 if (
m_d != 1.0 ||
m_e != 0.0) {
474 node[
"SRI"] = std::move(params);
485 if (c.size() != 1 && c.size() != 2) {
487 "Incorrect number of coefficients. 1 or 2 required. Received {}.",
514 double Fcent =
m_a + (
m_b * T);
521 double cc = -0.4 - 0.67 * (*work);
522 double nn = 0.75 - 1.27 * (*work);
523 double f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
524 double lgf = (*work) / (1.0 + f1 * f1);
525 return pow(10.0, lgf);
535 auto& f = node[
"Tsang"].as<
AnyMap>();
539 vector<double> params{
548 "To be removed after Cantera 3.0; superseded by getFalloffCoeffs.");
566 node[
"Tsang"] = std::move(params);
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.
size_t size() const
Returns the number of elements in this map.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
bool empty() const
Return boolean indicating whether AnyMap is empty.
void setFlowStyle(bool flow=true)
Use "flow" style when outputting this AnyMap to YAML.
bool getBool(const string &key, bool default_) const
If key exists, return it as a bool, otherwise return default_.
void clear()
Erase all items in the mapping.
const string & getString(const string &key, const string &default_) const
If key exists, return it as a string, otherwise return default_.
void setAllowNegativePreExponentialFactor(bool value)
Set flag indicating whether negative A values are permitted.
void getRateParameters(AnyMap &node) const
Get Arrhenius parameters used to populate the rate-coefficient or equivalent field.
void validate(const string &equation, const Kinetics &kin) override
Validate the reaction rate expression.
virtual double preExponentialFactor() const
Return the pre-exponential factor A (in m, kmol, s to powers depending on the reaction order)
void check(const string &equation) override
Check rate expression.
Arrhenius reaction rate type depends only on temperature.
Base class for exceptions thrown by Cantera classes.
virtual string getMessage() const
Method overridden by derived classes to format the error message.
Base class for falloff rate calculators.
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
void setHighRate(const ArrheniusRate &high)
Set reaction rate in the high-pressure limit.
virtual void setFalloffCoeffs(const vector< double > &c)
Set coefficients of the falloff parameterization.
virtual void getParameters(double *params) const
Get the values of the parameters for this object.
ArrheniusRate m_highRate
The reaction rate in the high-pressure limit.
void validate(const string &equation, const Kinetics &kin) override
Validate the reaction rate expression.
ArrheniusRate m_lowRate
The reaction rate in the low-pressure limit.
bool m_chemicallyActivated
Flag labeling reaction as chemically activated.
bool m_negativeA_ok
Flag indicating whether negative A values are permitted.
void check(const string &equation) override
Check basic syntax and settings of reaction rate expression.
void init(const vector< double > &c)
Initialize.
virtual void getFalloffCoeffs(vector< double > &c) const
Retrieve coefficients of the falloff parameterization.
void setLowRate(const ArrheniusRate &low)
Set reaction rate in the low-pressure limit.
Public interface for kinetics managers.
virtual const vector< double > & thirdBodyConcentrations() const
Provide direct access to current third-body concentration values.
The Lindemann falloff parameterization.
virtual double molarDensity() const
Molar density (kmol/m^3).
double temperature() const
Temperature (K).
int stateMFNumber() const
Return the State Mole Fraction Number.
virtual void setParameters(const AnyMap &node, const UnitStack &units)
Set parameters.
bool valid() const
Get flag indicating whether reaction rate is set up correctly.
bool m_valid
Flag indicating whether reaction rate is set up correctly.
AnyMap m_input
Input data used for specific models.
The SRI falloff function.
double F(double pr, const double *work) const override
The falloff function.
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
void setFalloffCoeffs(const vector< double > &c) override
Set coefficients used by parameterization.
void updateTemp(double T, double *work) const override
Update the temperature parameters in the representation.
double m_d
parameter d in the 5-parameter SRI falloff function. Dimensionless.
void getParameters(double *params) const override
Sets params to contain, in order,.
double m_a
parameter a in the 5-parameter SRI falloff function. Dimensionless.
void getFalloffCoeffs(vector< double > &c) const override
Retrieve coefficients of the falloff parameterization.
double m_c
parameter c in the 5-parameter SRI falloff function. [K]
double m_b
parameter b in the 5-parameter SRI falloff function. [K]
double m_e
parameter d in the 5-parameter SRI falloff function. Dimensionless.
Base class for a phase with thermodynamic properties.
double F(double pr, const double *work) const override
The falloff function.
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
void setFalloffCoeffs(const vector< double > &c) override
Set coefficients used by parameterization.
void updateTemp(double T, double *work) const override
Update the temperature parameters in the representation.
double m_t2
parameter T_2 in the 4-parameter Troe falloff function. [K]
void getParameters(double *params) const override
Sets params to contain, in order,.
double m_rt1
parameter 1/T_1 in the 4-parameter Troe falloff function. [K^-1]
double m_a
parameter a in the 4-parameter Troe falloff function. Dimensionless
void getFalloffCoeffs(vector< double > &c) const override
Retrieve coefficients of the falloff parameterization.
double m_rt3
parameter 1/T_3 in the 4-parameter Troe falloff function. [K^-1]
The 1- or 2-parameter Tsang falloff parameterization.
double F(double pr, const double *work) const override
The falloff function.
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
void setFalloffCoeffs(const vector< double > &c) override
Set coefficients used by parameterization.
void updateTemp(double T, double *work) const override
Update the temperature parameters in the representation.
void getParameters(double *params) const override
Sets params to contain, in order,.
double m_a
parameter a in the Tsang F_cent formulation. Dimensionless
void getFalloffCoeffs(vector< double > &c) const override
Retrieve coefficients of the falloff parameterization.
double m_b
parameter b in the Tsang F_cent formulation. [K^-1]
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Namespace for the Cantera kernel.
const double SmallNumber
smallest number to compare to zero.
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Contains declarations for string manipulation functions within Cantera.
int m_state_mf_number
integer that is incremented when composition changes
vector< double > m_conc_3b_buf
buffered third-body concentrations
void perturbThirdBodies(double deltaM)
Perturb third-body concentration vector of data container.
bool update(const ThermoPhase &phase, const Kinetics &kin) override
Update data container based on thermodynamic phase state.
vector< double > conc_3b
vector of effective third-body concentrations
double molar_density
used to determine if updates are needed
void restore() override
Restore data container after a perturbation.
bool m_perturbed
boolean indicating whether 3-rd body values are perturbed
virtual void update(double T)
Update data container based on temperature T
double temperature
temperature
virtual void restore()
Restore data container after a perturbation.
Unit aggregation utility.
size_t size() const
Size of UnitStack.
void join(double exponent)
Join (update) exponent of standard units, where the updated exponent is the sum of the pre-existing e...