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);
94 "Detected inconsistent rate definitions;\nhigh and low "
95 "rate pre-exponential factors must have the same sign.");
107 "Detected inconsistent rate definitions;\nhigh and low "
108 "rate pre-exponential factors must have the same sign.");
117 "Incorrect number of parameters. 0 required. Received {}.",
136 if (node[
"type"] ==
"chemically-activated") {
142 if (rate_units.
size()) {
144 high_rate_units.
join(1);
146 low_rate_units.
join(-1);
149 if (node.
hasKey(
"low-P-rate-constant")) {
151 node[
"low-P-rate-constant"], node.
units(), low_rate_units);
154 if (node.
hasKey(
"high-P-rate-constant")) {
156 node[
"high-P-rate-constant"], node.
units(), high_rate_units);
164 node[
"negative-A"] =
true;
168 if (!rNode.
empty()) {
169 node[
"low-P-rate-constant"] = std::move(rNode);
173 if (!rNode.
empty()) {
174 node[
"high-P-rate-constant"] = std::move(rNode);
188 "Inconsistent rate definitions found in reaction '{}';\nhigh and low "
189 "rate pre-exponential factors must have the same sign.", equation);
203LindemannRate::LindemannRate(
const AnyMap& node,
const UnitStack& rate_units)
209LindemannRate::LindemannRate(
const ArrheniusRate& low,
const ArrheniusRate& high,
210 const vector<double>& c)
225 const vector<double>& c)
235 if (c.size() != 3 && c.size() != 4) {
237 "Incorrect number of coefficients. 3 or 4 required. Received {}.",
242 m_rt3 = std::numeric_limits<double>::infinity();
248 m_rt1 = std::numeric_limits<double>::infinity();
256 "Unexpected parameter value T2=0. Omitting exp(T2/T) term from "
257 "falloff expression. To suppress this warning, remove value "
258 "for T2 from the input file. In the unlikely case that the "
259 "exp(T2/T) term should be included with T2 effectively equal "
260 "to 0, set T2 to a sufficiently small value "
261 "(for example, T2 < 1e-16).");
287 Fcent += exp(-
m_t2 / T);
295 double cc = -0.4 - 0.67 * (*work);
296 double nn = 0.75 - 1.27 * (*work);
297 double f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
298 double lgf = (*work) / (1.0 + f1 * f1);
299 return pow(10.0, lgf);
309 auto& f = node[
"Troe"].as<
AnyMap>();
313 vector<double> params{
318 if (f.hasKey(
"T2")) {
319 params.push_back(f[
"T2"].asDouble());
331 params[
"T3"].setQuantity(1.0 /
m_rt3,
"K");
332 params[
"T1"].setQuantity(1.0 /
m_rt1,
"K");
334 params[
"T2"].setQuantity(
m_t2,
"K");
338 node[
"Troe"] = std::move(params);
349 if (c.size() != 3 && c.size() != 5) {
351 "Incorrect number of coefficients. 3 or 5 required. Received {}.",
357 "m_c parameter is less than zero: {}", c[2]);
366 "m_d parameter is less than zero: {}", c[3]);
393 *work =
m_a * exp(-
m_b / T);
395 *work += exp(- T/
m_c);
397 work[1] =
m_d * pow(T,
m_e);
403 double xx = 1.0/(1.0 + lpr*lpr);
404 return pow(*work, xx) * work[1];
414 auto& f = node[
"SRI"].as<
AnyMap>();
418 vector<double> params{
424 params.push_back(f[
"D"].asDouble());
427 params.push_back(f[
"E"].asDouble());
439 params[
"B"].setQuantity(
m_b,
"K");
440 params[
"C"].setQuantity(
m_c,
"K");
441 if (
m_d != 1.0 ||
m_e != 0.0) {
447 node[
"SRI"] = std::move(params);
458 if (c.size() != 1 && c.size() != 2) {
460 "Incorrect number of coefficients. 1 or 2 required. Received {}.",
487 double Fcent =
m_a + (
m_b * T);
494 double cc = -0.4 - 0.67 * (*work);
495 double nn = 0.75 - 1.27 * (*work);
496 double f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
497 double lgf = (*work) / (1.0 + f1 * f1);
498 return pow(10.0, lgf);
508 auto& f = node[
"Tsang"].as<
AnyMap>();
512 vector<double> params{
532 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.
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.
void getParameters(AnyMap &node) const override
Get parameters.
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.
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(AnyMap &node) const override
Get parameters.
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(AnyMap &node) const override
Get parameters.
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(AnyMap &node) const override
Get parameters.
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.
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...