16 "Missing state information: 'PlogData' requires pressure.");
34 "Cannot apply another perturbation as state is already perturbed.");
73 std::multimap<double, ArrheniusRate> multi_rates;
74 if (!node.
hasKey(
"rate-constants")) {
79 auto&
rates = node[
"rate-constants"].asVector<
AnyMap>();
80 for (
const auto& rate :
rates) {
81 multi_rates.insert({rate.convert(
"P",
"Pa"),
88void PlogRate::getParameters(
AnyMap& rateNode,
const Units& rate_units)
const
90 std::vector<AnyMap> rateList;
91 rateNode[
"type"] =
type();
93 || (rates_.size() > 1 && std::isnan(rates_[1].preExponentialFactor())))
100 rateNode_[
"P"].setQuantity(r.first,
"Pa");
101 if (rate_units.
factor() == 0) {
102 r.second.getRateParameters(rateNode_);
105 Arrhenius2(r.second).getParameters(rateNode_, rate_units);
107 rateList.push_back(std::move(rateNode_));
109 rateNode[
"rate-constants"] = std::move(rateList);
114 std::multimap<double, ArrheniusRate> rates2;
115 for (
const auto& item :
rates) {
116 rates2.emplace(item.first, item.second);
126 rates_.reserve(
rates.size());
128 for (
const auto& rate :
rates) {
129 double logp = std::log(rate.first);
139 rates_.push_back(rate.second);
149 fmt::memory_buffer err_reactions;
150 double T[] = {200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0};
152 for (
auto iter = ++
pressures_.begin(); iter->first < 1000; iter++) {
154 for (
size_t i=0; i < 6; i++) {
156 for (
size_t p =
ilow1_; p < ilow2_; p++) {
157 k += rates_.at(p).evalRate(log(T[i]), 1.0 / T[i]);
160 fmt_append(err_reactions,
161 "\nInvalid rate coefficient for reaction '{}'\n"
162 "at P = {:.5g}, T = {:.1f}\n",
163 equation, std::exp(iter->first), T[i]);
167 if (err_reactions.size()) {
168 throw CanteraError(
"PlogRate::validate", to_string(err_reactions));
175 std::vector<std::pair<double, Arrhenius2>> out;
176 for (
const auto& item : rateMap) {
177 out.emplace_back(item.first,
Arrhenius2(item.second));
184 std::multimap<double, ArrheniusRate> rateMap;
189 for (
size_t i = iter->second.first; i < iter->second.second; i++) {
190 rateMap.insert({std::exp(iter->first), rates_[i]});
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.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
A wrapper for a variable whose type is determined at runtime.
Arrhenius reaction rate type depends only on temperature.
Arrhenius reaction rate type depends only on temperature.
Base class for exceptions thrown by Cantera classes.
Public interface for kinetics managers.
doublereal temperature() const
Temperature (K).
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Pressure-dependent reaction rate expressed by logarithmically interpolating between Arrhenius rate ex...
void setParameters(const AnyMap &node, const UnitStack &units)
Perform object setup based on AnyMap node information.
std::multimap< double, ArrheniusRate > getRates() const
Return the pressures and Arrhenius expressions which comprise this reaction.
std::vector< std::pair< double, Arrhenius2 > > rates() const
Return the pressures and Arrhenius expressions which comprise this reaction.
void setRates(const std::multimap< double, ArrheniusRate > &rates)
Set up Plog object.
PlogRate()
Default constructor.
std::map< double, std::pair< size_t, size_t > > pressures_
log(p) to (index range) in the rates_ vector
const std::string type() const
Identifier of reaction rate type.
void update_C(const double *c)
Update concentration-dependent parts of the rate coefficient.
void setup(const std::multimap< double, Arrhenius2 > &rates)
Set up Plog object.
void validate(const std::string &equation, const Kinetics &kin)
Check to make sure that the rate expression is finite over a range of temperatures at each interpolat...
size_t ilow1_
Indices to the ranges within rates_ for the lower / upper pressure, such that rates_[ilow1_] through ...
Base class for a phase with thermodynamic properties.
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.
void perturbPressure(double deltaP)
Perturb pressure of data container.
double m_pressure_buf
buffered pressure
virtual void update(double T) override
Update data container based on temperature T
virtual void restore() override
Restore data container after a perturbation.
double temperature
temperature
virtual void restore()
Restore data container after a perturbation.
Unit aggregation utility.