Skip to content

Commit

Permalink
[Kinetics] Apply suggestions from review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and bryanwweber committed May 28, 2022
1 parent e41449e commit c040b12
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 12 deletions.
1 change: 0 additions & 1 deletion include/cantera/kinetics/Arrhenius.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ class ArrheniusRate : public ArrheniusBase
}
};

typedef ArrheniusRate Arrhenius;
}

#endif
1 change: 1 addition & 0 deletions include/cantera/kinetics/GasKinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class GasKinetics : public BulkKinetics

//! Helper function ensuring that all rate derivatives can be calculated
//! @param name method name used for error output
//! @throw CanteraError if ideal gas assumption does not hold
void assertDerivativesValid(const std::string& name);

//! @}
Expand Down
8 changes: 4 additions & 4 deletions include/cantera/kinetics/Kinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ class Kinetics
//! - `_ddX`: derivative with respect to species mole fractions (a matrix)
//!
//! Settings for derivative evaluation are set by keyword/value pairs using
//! the methods @see getDerivativeSettings and @see setDerivativeSettings.
//! the methods getDerivativeSettings() and setDerivativeSettings().
//!
//! For GasKinetics, the following keyword/value pairs are supported:
//! - `skip-third-bodies` (boolean) ... if `false` (default), third body
Expand Down Expand Up @@ -1003,7 +1003,7 @@ class Kinetics
* String specifying the type of reaction.
*
* @param i reaction index
* @version Method returned magic number prior to Cantera 3.0.
* @since Method returned magic number prior to Cantera 3.0.
*/
virtual std::string reactionType(size_t i) const;

Expand Down Expand Up @@ -1045,7 +1045,7 @@ class Kinetics
* The computed values include all temperature-dependent and pressure-dependent
* contributions. By default, third-body concentrations are only considered if
* they are part of the reaction rate definition; for a legacy implementation that
* includes third-body concentrations @see Cantera::use_legacy_rate_constants().
* includes third-body concentrations see Cantera::use_legacy_rate_constants().
* Length is the number of reactions. Units are a combination of kmol, m^3 and s,
* that depend on the rate expression for the reaction.
*
Expand All @@ -1062,7 +1062,7 @@ class Kinetics
* The computed values include all temperature-dependent and pressure-dependent
* contributions. By default, third-body concentrations are only considered if
* they are part of the reaction rate definition; for a legacy implementation that
* includes third-body concentrations @see Cantera::use_legacy_rate_constants().
* includes third-body concentrations see Cantera::use_legacy_rate_constants().
* Length is the number of reactions. Units are a combination of kmol, m^3 and s,
* that depend on the rate expression for the reaction. Note, this routine will
* return rate constants for irreversible reactions if the default for
Expand Down
5 changes: 2 additions & 3 deletions include/cantera/kinetics/PlogRate.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ class PlogRate final : public ReactionRate

auto iter = pressures_.upper_bound(logP_);
AssertThrowMsg(iter != pressures_.end(), "PlogRate::updateFromStruct",
"Pressure out of range: {}", logP_);
"Pressure out of range: {}", logP_);
AssertThrowMsg(iter != pressures_.begin(), "PlogRate::updateFromStruct",
"Pressure out of range: {}", logP_);
"Pressure out of range: {}", logP_);

// upper interpolation pressure
logP2_ = iter->first;
Expand Down Expand Up @@ -200,6 +200,5 @@ class PlogRate final : public ReactionRate
double rDeltaP_; //!< reciprocal of (logP2 - logP1)
};

typedef PlogRate Plog;
}
#endif
13 changes: 13 additions & 0 deletions include/cantera/kinetics/Reaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ class Reaction
//! where the reaction occurs. Sets the value of #rate_units.
UnitStack calculateRateCoeffUnits(const Kinetics& kin);

//! Calculate the units of the rate constant.
//! @deprecated To be removed after Cantera 3.0. Replaceable by
//! calculateRateCoeffUnits.
UnitStack calculateRateCoeffUnits3(const Kinetics& kin) {
warn_deprecated("Reaction::calculateRateCoeffUnits3",
"Deprecated in Cantera 3.0 and to be removed thereafter; replaceable "
"by calculateRateCoeffUnits.");
return calculateRateCoeffUnits(kin);
}

//! Ensure that the rate constant and other parameters for this reaction are
//! valid.
virtual void validate();
Expand Down Expand Up @@ -313,5 +323,8 @@ std::vector<shared_ptr<Reaction>> getReactions(const AnyValue& items,
void parseReactionEquation(Reaction& R, const std::string& equation,
const AnyBase& reactionNode, const Kinetics* kin);

using ThreeBodyReaction3 = ThreeBodyReaction; // @todo: remove after Cantera 3.0
using FalloffReaction3 = FalloffReaction; // @todo: remove after Cantera 3.0

}
#endif
1 change: 1 addition & 0 deletions include/cantera/kinetics/ThirdBodyCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class ThirdBodyCalc
Eigen::SparseMatrix<double> m_multipliers;
};

using ThirdBodyCalc3 = ThirdBodyCalc; // @todo: remove after Cantera 3.0

}

Expand Down
2 changes: 1 addition & 1 deletion src/base/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class Application
* consistent with conventional definitions (for example Eq. 9.75 in Kee, Coltrin
* and Glarborg, 'Chemically Reacting Flow', Wiley Interscience, 2003). If set to
* 'true', output for rate constants of three-body reactions is multiplied by
* third-body concentrations (legacy behavior prior to Cantera 3.0).
* third-body concentrations, consistent with Cantera's behavior prior to version 3.0.
*/
void use_legacy_rate_constants(bool legacy=true) {
m_use_legacy_rate_constants = legacy;
Expand Down
9 changes: 7 additions & 2 deletions src/kinetics/Kinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ std::string Kinetics::reactionType(size_t i) const {
}

std::string Kinetics::reactionTypeStr(size_t i) const {
warn_deprecated("Kinetics::reactionTypeStr",
"To be removed after Cantera 3.0.");
warn_deprecated("Kinetics::reactionTypeStr", "To be removed after Cantera 3.0.");
return reactionType(i);
}

Expand Down Expand Up @@ -713,6 +712,12 @@ void Kinetics::modifyReaction(size_t i, shared_ptr<Reaction> rNew)
rOld->type(), rNew->type());
}

if (rNew->rate()->type() != rOld->rate()->type()) {
throw CanteraError("Kinetics::modifyReaction",
"ReactionRate types are different: {} != {}.",
rOld->rate()->type(), rNew->rate()->type());
}

if (rNew->reactants != rOld->reactants) {
throw CanteraError("Kinetics::modifyReaction",
"Reactants are different: '{}' != '{}'.",
Expand Down
2 changes: 1 addition & 1 deletion test/kinetics/kineticsFromYaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ TEST(Reaction, PlogFromYaml)

auto R = newReaction(rxn, *(sol->kinetics()));
const auto& rateMap = std::dynamic_pointer_cast<PlogRate>(R->rate())->getRates();
std::vector<std::pair<double, Arrhenius>> rates(rateMap.begin(), rateMap.end());
std::vector<std::pair<double, ArrheniusRate>> rates(rateMap.begin(), rateMap.end());
EXPECT_EQ(rates.size(), (size_t) 4);
EXPECT_NEAR(rates[0].first, 0.039474 * OneAtm, 1e-6);
EXPECT_NEAR(rates[2].first, OneAtm, 1e-6);
Expand Down

0 comments on commit c040b12

Please sign in to comment.