15 "Missing state information: 'ChebyshevData' requires pressure.");
33 "Cannot apply another perturbation as state is already perturbed.");
69 const auto& T_range = node[
"temperature-range"].asVector<
AnyValue>(2);
70 const auto& P_range = node[
"pressure-range"].asVector<
AnyValue>(2);
71 auto& vcoeffs = node[
"data"].asVector<vector<double>>();
72 coeffs =
Array2D(vcoeffs.size(), vcoeffs[0].size());
73 for (
size_t i = 0; i < coeffs.nRows(); i++) {
74 if (vcoeffs[i].size() != vcoeffs[0].size()) {
76 "Inconsistent number of coefficients in row {} of matrix", i + 1);
78 for (
size_t j = 0; j < coeffs.nColumns(); j++) {
79 coeffs(i, j) = vcoeffs[i][j];
83 coeffs(0, 0) += std::log10(
offset);
85 unit_system.
convert(T_range[0],
"K"),
86 unit_system.
convert(T_range[1],
"K"),
87 unit_system.
convert(P_range[0],
"Pa"),
88 unit_system.
convert(P_range[1],
"Pa")
98 double logPmin = std::log10(
Pmin);
99 double logPmax = std::log10(
Pmax);
100 double TminInv = 1.0 /
Tmin;
101 double TmaxInv = 1.0 /
Tmax;
103 TrNum_ = - TminInv - TmaxInv;
104 TrDen_ = 1.0 / (TmaxInv - TminInv);
105 PrNum_ = - logPmin - logPmax;
106 PrDen_ = 1.0 / (logPmax - logPmin);
132 rateNode[
"temperature-range"].setQuantity({
Tmin(),
Tmax()},
"K");
133 rateNode[
"pressure-range"].setQuantity({
Pmin(),
Pmax()},
"Pa");
136 vector<vector<double>> coeffs2d(nT, vector<double>(nP));
137 for (
size_t i = 0; i < nT; i++) {
138 for (
size_t j = 0; j < nP; j++) {
146 if (rate_units2.
factor() != 0.0) {
147 coeffs.
asVector<vector<double>>()[0][0] += \
148 std::log10(units.convertFrom(1.0, rate_units2));
149 }
else if (units.getDelta(
UnitSystem()).size()) {
150 throw CanteraError(
"ChebyshevRate::getParameters lambda",
151 "Cannot convert rate constant with unknown dimensions to a "
152 "non-default unit system");
156 coeffs = std::move(coeffs2d);
157 rateNode[
"data"].setQuantity(coeffs, converter);
164 "Rate object for reaction '{}' is not configured.", equation);
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.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
A wrapper for a variable whose type is determined at runtime.
const vector< T > & asVector(size_t nMin=npos, size_t nMax=npos) const
Return the held value, if it is a vector of type T.
A class for 2D arrays stored in column-major (Fortran-compatible) form.
size_t nRows() const
Number of rows.
size_t nColumns() const
Number of columns.
vector< double > & data()
Return a reference to the data vector.
Base class for exceptions thrown by Cantera classes.
Pressure-dependent rate expression where the rate coefficient is expressed as a bivariate Chebyshev p...
void getParameters(AnyMap &rateNode) const override
Get parameters.
double Tmax_
valid temperature range
void setParameters(const AnyMap &node, const UnitStack &rate_units) override
Perform object setup based on AnyMap node information.
double TrDen_
terms appearing in the reduced temperature
double Pmin() const
Minimum valid pressure [Pa].
double Tmin() const
Minimum valid temperature [K].
void validate(const string &equation, const Kinetics &kin) override
Validate the reaction rate expression.
vector< double > dotProd_
dot product of coeffs with the reduced pressure polynomial
void setData(const Array2D &coeffs)
Set the Chebyshev coefficients as 2-dimensional array.
double Tmax() const
Maximum valid temperature [K].
ChebyshevRate()=default
Default constructor.
Array2D m_coeffs
< coefficient array
double Pmax_
valid pressure range
double Pmax() const
Maximum valid pressure [Pa].
double PrDen_
terms appearing in the reduced pressure
void setLimits(double Tmin, double Tmax, double Pmin, double Pmax)
Set limits for ChebyshevRate object.
Public interface for kinetics managers.
double temperature() const
Temperature (K).
virtual double pressure() const
Return the thermodynamic pressure (Pa).
virtual void setParameters(const AnyMap &node, const UnitStack &units)
Set parameters.
const Units & conversionUnits() const
Get the units for converting the leading term in the reaction rate expression.
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.
Base class for a phase with thermodynamic properties.
double convertRateCoeff(const AnyValue &val, const Units &dest) const
Convert a generic AnyValue node representing a reaction rate coefficient to the units specified in de...
double convert(double value, const string &src, const string &dest) const
Convert value from the units of src to the units of dest.
A representation of the units associated with a dimensional quantity.
double factor() const
Return the factor for converting from this unit to Cantera's base units.
Namespace for the Cantera kernel.
const double Tiny
Small number to compare differences of mole fractions against.
offset
Offsets of solution components in the 1D solution array.
void perturbPressure(double deltaP)
Perturb pressure of data container.
double m_pressure_buf
buffered pressure
void update(double T) override
Update data container based on temperature T
void restore() override
Restore data container after a perturbation.
double temperature
temperature
virtual void restore()
Restore data container after a perturbation.
Unit aggregation utility.