Skip to content

Commit

Permalink
[Kinetics] Fix compilation errors with 'no_legacy_reactions'=y
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jan 28, 2022
1 parent eced332 commit 3fe51f0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
11 changes: 11 additions & 0 deletions include/cantera/kinetics/Arrhenius.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ class ArrheniusBase : public ReactionRate

void check(const std::string& equation, const AnyMap& node);

//! Evaluate reaction rate
double evalRate(double logT, double recipT) const {
return m_A * std::exp(m_b * logT - m_Ea_R * recipT);
}

//! Evaluate natural logarithm of the rate constant.
double evalLog(double logT, double recipT) const {
return m_logA + m_b * logT - m_Ea_R * recipT;
}

//! Return the pre-exponential factor *A* (in m, kmol, s to powers depending
//! on the reaction order)
double preExponentialFactor() const {
Expand Down Expand Up @@ -120,6 +130,7 @@ class ArrheniusBase : public ReactionRate
double m_A; //!< Pre-exponential factor
double m_b; //!< Temperature exponent
double m_Ea_R; //!< Activation energy (in temperature units)
double m_logA; //!< Logarithm of pre-exponential factor
double m_order; //!< Reaction order
std::string m_A_str = "A"; //!< The string for temperature exponent
std::string m_b_str = "b"; //!< The string for temperature exponent
Expand Down
11 changes: 4 additions & 7 deletions include/cantera/kinetics/RxnRates.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ class Arrhenius2 : public ArrheniusBase
unique_ptr<MultiRateBase> newMultiRate() const {
throw NotImplementedError("Arrhenius2::newMultiRate");
}

protected:
double m_logA;
};

//! Blowers Masel reaction rate type depends on the enthalpy of reaction
Expand Down Expand Up @@ -431,21 +428,21 @@ class PlogRate final : public ReactionRate
doublereal updateRC(doublereal logT, doublereal recipT) const {
double log_k1, log_k2;
if (ilow1_ == ilow2_) {
log_k1 = rates_[ilow1_].updateLog(logT, recipT);
log_k1 = rates_[ilow1_].evalLog(logT, recipT);
} else {
double k = 1e-300; // non-zero to make log(k) finite
for (size_t i = ilow1_; i < ilow2_; i++) {
k += rates_[i].updateRC(logT, recipT);
k += rates_[i].evalRate(logT, recipT);
}
log_k1 = std::log(k);
}

if (ihigh1_ == ihigh2_) {
log_k2 = rates_[ihigh1_].updateLog(logT, recipT);
log_k2 = rates_[ihigh1_].evalLog(logT, recipT);
} else {
double k = 1e-300; // non-zero to make log(k) finite
for (size_t i = ihigh1_; i < ihigh2_; i++) {
k += rates_[i].updateRC(logT, recipT);
k += rates_[i].evalRate(logT, recipT);
}
log_k2 = std::log(k);
}
Expand Down
7 changes: 7 additions & 0 deletions src/kinetics/Arrhenius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ArrheniusBase::ArrheniusBase()
, m_A(NAN)
, m_b(NAN)
, m_Ea_R(NAN)
, m_logA(NAN)
, m_order(NAN)
, m_rate_units(Units(0.))
{
Expand All @@ -28,6 +29,9 @@ ArrheniusBase::ArrheniusBase(double A, double b, double Ea)
, m_order(NAN)
, m_rate_units(Units(0.))
{
if (m_A > 0.0) {
m_logA = std::log(m_A);
}
}

void ArrheniusBase::setRateParameters(
Expand Down Expand Up @@ -74,6 +78,9 @@ void ArrheniusBase::setRateParameters(
m_Ea_R = NAN;
}
}
if (m_A > 0.0) {
m_logA = std::log(m_A);
}
}

void ArrheniusBase::getParameters(AnyMap& node) const
Expand Down
4 changes: 0 additions & 4 deletions src/kinetics/RxnRates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Arrhenius2::Arrhenius2(doublereal A, doublereal b, doublereal E)
{
if (m_A <= 0.0) {
m_logA = -1.0E300;
} else {
m_logA = std::log(m_A);
}
}

Expand All @@ -39,8 +37,6 @@ void Arrhenius2::setRateParameters(const AnyValue& rate,
ArrheniusBase::setRateParameters(rate, units, units_stack);
if (m_A <= 0.0) {
m_logA = -1.0E300;
} else {
m_logA = std::log(m_A);
}
}

Expand Down

0 comments on commit 3fe51f0

Please sign in to comment.