13#include "cantera/kinetics/Falloff.h"
20FalloffData::FalloffData()
29 "Missing state information: 'FalloffData' requires third-body concentration.");
52 conc_3b.assign(concm.begin(), concm.end());
62 "Cannot apply another perturbation as state is already perturbed.");
88FalloffRate::FalloffRate(
const AnyMap& node,
const UnitStack& rate_units)
91 setParameters(node, rate_units);
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 {}.",
138 if (node[
"type"] ==
"chemically-activated") {
144 if (rate_units.
size()) {
146 high_rate_units.
join(1);
148 low_rate_units.
join(-1);
151 if (node.
hasKey(
"low-P-rate-constant")) {
153 node[
"low-P-rate-constant"], node.
units(), low_rate_units);
156 if (node.
hasKey(
"high-P-rate-constant")) {
158 node[
"high-P-rate-constant"], node.
units(), high_rate_units);
166 node[
"negative-A"] =
true;
170 if (!rNode.
empty()) {
171 node[
"low-P-rate-constant"] = std::move(rNode);
175 if (!rNode.
empty()) {
176 node[
"high-P-rate-constant"] = std::move(rNode);
190 "Inconsistent rate definitions found in reaction '{}';\nhigh and low "
191 "rate pre-exponential factors must have the same sign.", equation);
205LindemannRate::LindemannRate(
const AnyMap& node,
const UnitStack& rate_units)
211LindemannRate::LindemannRate(
const ArrheniusRate& low,
const ArrheniusRate& high,
212 span<const double> c)
227 span<const double> c)
237 if (c.size() != 3 && c.size() != 4) {
239 "Incorrect number of coefficients. 3 or 4 required. Received {}.",
244 m_rt3 = std::numeric_limits<double>::infinity();
250 m_rt1 = std::numeric_limits<double>::infinity();
258 "Unexpected parameter value T2=0. Omitting exp(T2/T) term from "
259 "falloff expression. To suppress this warning, remove value "
260 "for T2 from the input file. In the unlikely case that the "
261 "exp(T2/T) term should be included with T2 effectively equal "
262 "to 0, set T2 to a sufficiently small value "
263 "(for example, T2 < 1e-16).");
285 Fcent += exp(-
m_t2 / T);
293 double cc = -0.4 - 0.67 * work[0];
294 double nn = 0.75 - 1.27 * work[0];
295 double f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
296 double lgf = work[0] / (1.0 + f1 * f1);
297 return pow(10.0, lgf);
307 auto& f = node[
"Troe"].as<
AnyMap>();
311 vector<double> params{
316 if (f.hasKey(
"T2")) {
317 params.push_back(f[
"T2"].asDouble());
329 params[
"T3"].setQuantity(1.0 /
m_rt3,
"K");
330 params[
"T1"].setQuantity(1.0 /
m_rt1,
"K");
332 params[
"T2"].setQuantity(
m_t2,
"K");
336 node[
"Troe"] = std::move(params);
347 if (c.size() != 3 && c.size() != 5) {
349 "Incorrect number of coefficients. 3 or 5 required. Received {}.",
355 "m_c parameter is less than zero: {}", c[2]);
364 "m_d parameter is less than zero: {}", c[3]);
387 work[0] =
m_a * exp(-
m_b / T);
389 work[0] += exp(- T/
m_c);
391 work[1] =
m_d * pow(T,
m_e);
397 double xx = 1.0/(1.0 + lpr*lpr);
398 return pow(work[0], xx) * work[1];
408 auto& f = node[
"SRI"].as<
AnyMap>();
412 vector<double> params{
418 params.push_back(f[
"D"].asDouble());
421 params.push_back(f[
"E"].asDouble());
433 params[
"B"].setQuantity(
m_b,
"K");
434 params[
"C"].setQuantity(
m_c,
"K");
435 if (
m_d != 1.0 ||
m_e != 0.0) {
441 node[
"SRI"] = std::move(params);
452 if (c.size() != 1 && c.size() != 2) {
454 "Incorrect number of coefficients. 1 or 2 required. Received {}.",
477 double Fcent =
m_a + (
m_b * T);
484 double cc = -0.4 - 0.67 * work[0];
485 double nn = 0.75 - 1.27 * work[0];
486 double f1 = (lpr + cc)/ (nn - 0.14 * (lpr + cc));
487 double lgf = work[0] / (1.0 + f1 * f1);
488 return pow(10.0, lgf);
498 auto& f = node[
"Tsang"].as<
AnyMap>();
502 vector<double> params{
522 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.
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.
void setLowRate(const ArrheniusRate &low)
Set reaction rate in the low-pressure limit.
virtual void setFalloffCoeffs(span< const double > c)
Set coefficients of the falloff parameterization.
Public interface for kinetics managers.
virtual span< const double > thirdBodyConcentrations() const
Provide direct access to current third-body concentration values.
size_t nReactions() const
Number of reactions in the reaction mechanism.
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.
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
double F(double pr, span< const double > work) const override
The falloff function.
double m_d
parameter d in the 5-parameter SRI falloff function. Dimensionless.
void getParameters(AnyMap &node) const override
Get parameters.
void getFalloffCoeffs(span< double > c) const override
Retrieve coefficients of the falloff parameterization.
double m_a
parameter a in the 5-parameter SRI falloff function. Dimensionless.
void setFalloffCoeffs(span< const double > c) override
Set coefficients used by parameterization.
void updateTemp(double T, span< double > work) const override
Update the temperature parameters in the representation.
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.
size_t nParameters() const override
Returns the number of parameters used by this parameterization.
Base class for a phase with thermodynamic properties.
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
double m_t2
parameter T_2 in the 4-parameter Troe falloff function. [K]
double F(double pr, span< const double > work) const override
The falloff function.
void getParameters(AnyMap &node) const override
Get parameters.
double m_rt1
parameter 1/T_1 in the 4-parameter Troe falloff function. [K^-1]
void getFalloffCoeffs(span< double > c) const override
Retrieve coefficients of the falloff parameterization.
double m_a
parameter a in the 4-parameter Troe falloff function. Dimensionless
void setFalloffCoeffs(span< const double > c) override
Set coefficients used by parameterization.
void updateTemp(double T, span< double > work) const override
Update the temperature parameters in the representation.
double m_rt3
parameter 1/T_3 in the 4-parameter Troe falloff function. [K^-1]
size_t nParameters() const override
Returns the number of parameters used by this parameterization.
The 1- or 2-parameter Tsang falloff parameterization.
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Set parameters.
double F(double pr, span< const double > work) const override
The falloff function.
void getParameters(AnyMap &node) const override
Get parameters.
void getFalloffCoeffs(span< double > c) const override
Retrieve coefficients of the falloff parameterization.
double m_a
parameter a in the Tsang F_cent formulation. Dimensionless
void setFalloffCoeffs(span< const double > c) override
Set coefficients used by parameterization.
void updateTemp(double T, span< double > work) const override
Update the temperature parameters in the representation.
double m_b
parameter b in the Tsang F_cent formulation. [K^-1]
size_t nParameters() const override
Returns the number of parameters used by this parameterization.
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 checkArraySize(const char *procedure, size_t available, size_t required)
Wrapper for throwing ArraySizeError.
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.
bool ready
boolean indicating whether vectors are accessible
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.
void resize(Kinetics &kin) override
Update array sizes that depend on number of species, reactions and phases.
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...