diff --git a/include/cantera/kinetics/Falloff.h b/include/cantera/kinetics/Falloff.h index 4c282815ee..c982b4aba0 100644 --- a/include/cantera/kinetics/Falloff.h +++ b/include/cantera/kinetics/Falloff.h @@ -169,7 +169,7 @@ class FalloffRate : public ReactionRate return 0; } - virtual const std::string type() const { + virtual const std::string type() const override { if (m_chemicallyActivated) { return "chemically-activated"; } @@ -182,7 +182,8 @@ class FalloffRate : public ReactionRate return 0; } - virtual void setParameters(const AnyMap& node, const UnitStack& rate_units); + virtual void setParameters( + const AnyMap& node, const UnitStack& rate_units) override; //! Get the values of the parameters for this object. *params* must be an //! array of at least nParameters() elements. @@ -223,7 +224,7 @@ class FalloffRate : public ReactionRate } virtual void check(const std::string& equation) override; - virtual void validate(const std::string& equation, const Kinetics& kin); + virtual void validate(const std::string& equation, const Kinetics& kin) override; //! Get flag indicating whether negative A values are permitted bool allowNegativePreExponentialFactor() const { @@ -300,7 +301,7 @@ class LindemannRate final : public FalloffRate setFalloffCoeffs(c); } - unique_ptr newMultiRate() const { + unique_ptr newMultiRate() const override{ return unique_ptr( new MultiRate); } @@ -361,7 +362,7 @@ class TroeRate final : public FalloffRate setFalloffCoeffs(c); } - unique_ptr newMultiRate() const { + unique_ptr newMultiRate() const override { return unique_ptr(new MultiRate); } @@ -370,9 +371,9 @@ class TroeRate final : public FalloffRate * @param c Vector of three or four doubles: The doubles are the parameters, * a, T_3, T_1, and (optionally) T_2 of the Troe parameterization */ - virtual void setFalloffCoeffs(const vector_fp& c); + virtual void setFalloffCoeffs(const vector_fp& c) override; - virtual void getFalloffCoeffs(vector_fp& c) const; + virtual void getFalloffCoeffs(vector_fp& c) const override; //! Update the temperature parameters in the representation /*! @@ -380,11 +381,11 @@ class TroeRate final : public FalloffRate * @param work Vector of working space, length 1, representing the * temperature-dependent part of the parameterization. */ - virtual void updateTemp(double T, double* work) const; + virtual void updateTemp(double T, double* work) const override; - virtual double F(double pr, const double* work) const; + virtual double F(double pr, const double* work) const override; - virtual size_t workSize() const { + virtual size_t workSize() const override { return 1; } @@ -392,19 +393,20 @@ class TroeRate final : public FalloffRate return "Troe"; } - virtual size_t nParameters() const { + virtual size_t nParameters() const override { return 4; } - virtual void setParameters(const AnyMap& node, const UnitStack& rate_units); + virtual void setParameters( + const AnyMap& node, const UnitStack& rate_units) override; //! Sets params to contain, in order, \f[ (A, T_3, T_1, T_2) \f] /** * @deprecated To be removed after Cantera 3.0; superseded by getFalloffCoeffs() */ - virtual void getParameters(double* params) const; + virtual void getParameters(double* params) const override; - virtual void getParameters(AnyMap& node) const; + virtual void getParameters(AnyMap& node) const override; protected: //! parameter a in the 4-parameter Troe falloff function. Dimensionless @@ -463,7 +465,7 @@ class SriRate final : public FalloffRate setFalloffCoeffs(c); } - unique_ptr newMultiRate() const { + unique_ptr newMultiRate() const override { return unique_ptr(new MultiRate); } @@ -473,9 +475,9 @@ class SriRate final : public FalloffRate * a, b, c, d (optional; default 1.0), and e (optional; default * 0.0) of the SRI parameterization */ - virtual void setFalloffCoeffs(const vector_fp& c); + virtual void setFalloffCoeffs(const vector_fp& c) override; - virtual void getFalloffCoeffs(vector_fp& c) const; + virtual void getFalloffCoeffs(vector_fp& c) const override; //! Update the temperature parameters in the representation /*! @@ -483,11 +485,11 @@ class SriRate final : public FalloffRate * @param work Vector of working space, length 2, representing the * temperature-dependent part of the parameterization. */ - virtual void updateTemp(double T, double* work) const; + virtual void updateTemp(double T, double* work) const override; - virtual double F(double pr, const double* work) const; + virtual double F(double pr, const double* work) const override; - virtual size_t workSize() const { + virtual size_t workSize() const override { return 2; } @@ -495,19 +497,20 @@ class SriRate final : public FalloffRate return "SRI"; } - virtual size_t nParameters() const { + virtual size_t nParameters() const override { return 5; } - virtual void setParameters(const AnyMap& node, const UnitStack& rate_units); + virtual void setParameters( + const AnyMap& node, const UnitStack& rate_units) override; //! Sets params to contain, in order, \f[ (a, b, c, d, e) \f] /** * @deprecated To be removed after Cantera 3.0; superseded by getFalloffCoeffs() */ - virtual void getParameters(double* params) const; + virtual void getParameters(double* params) const override; - virtual void getParameters(AnyMap& node) const; + virtual void getParameters(AnyMap& node) const override; protected: //! parameter a in the 5-parameter SRI falloff function. Dimensionless. @@ -573,7 +576,7 @@ class TsangRate final : public FalloffRate setFalloffCoeffs(c); } - unique_ptr newMultiRate() const { + unique_ptr newMultiRate() const override { return unique_ptr(new MultiRate); } @@ -582,9 +585,9 @@ class TsangRate final : public FalloffRate * @param c Vector of one or two doubles: The doubles are the parameters, * a and (optionally) b of the Tsang F_cent parameterization */ - virtual void setFalloffCoeffs(const vector_fp& c); + virtual void setFalloffCoeffs(const vector_fp& c) override; - virtual void getFalloffCoeffs(vector_fp& c) const; + virtual void getFalloffCoeffs(vector_fp& c) const override; //! Update the temperature parameters in the representation /*! @@ -592,11 +595,11 @@ class TsangRate final : public FalloffRate * @param work Vector of working space, length 1, representing the * temperature-dependent part of the parameterization. */ - virtual void updateTemp(double T, double* work) const; + virtual void updateTemp(double T, double* work) const override; - virtual double F(double pr, const double* work) const; + virtual double F(double pr, const double* work) const override; - virtual size_t workSize() const { + virtual size_t workSize() const override { return 1; } @@ -604,19 +607,20 @@ class TsangRate final : public FalloffRate return "Tsang"; } - virtual size_t nParameters() const { + virtual size_t nParameters() const override { return 2; } - virtual void setParameters(const AnyMap& node, const UnitStack& rate_units); + virtual void setParameters( + const AnyMap& node, const UnitStack& rate_units) override; //! Sets params to contain, in order, \f[ (A, B) \f] /** * @deprecated To be removed after Cantera 3.0; superseded by getFalloffCoeffs() */ - virtual void getParameters(double* params) const; + virtual void getParameters(double* params) const override; - virtual void getParameters(AnyMap& node) const; + virtual void getParameters(AnyMap& node) const override; protected: //! parameter a in the Tsang F_cent formulation. Dimensionless diff --git a/interfaces/cython/cantera/reaction.pyx b/interfaces/cython/cantera/reaction.pyx index b4536a6472..63344c7982 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -1488,7 +1488,7 @@ cdef class Reaction: property third_body: """ - Returns an `ThirdBody` object if `Reaction` uses a third body collider, and + Returns a `ThirdBody` object if `Reaction` uses a third body collider, and ``None`` otherwise. .. versionadded:: 3.0 diff --git a/src/kinetics/Reaction.cpp b/src/kinetics/Reaction.cpp index 0312a22c34..87d5252ca3 100644 --- a/src/kinetics/Reaction.cpp +++ b/src/kinetics/Reaction.cpp @@ -252,7 +252,7 @@ void Reaction::setRate(shared_ptr rate) if (rate_type == "falloff" || rate_type == "chemically-activated") { if (!m_from_composition) { throw InputFileError("Reaction::setRate", input, - "Reaction eqution for falloff reaction '{}'\n does not " + "Reaction equation for falloff reaction '{}'\n does not " "contain valid pressure-dependent third body", equation()); } m_third_body.reset(new ThirdBody("(+M)")); @@ -317,9 +317,6 @@ void Reaction::setEquation(const std::string& equation, const Kinetics* kin) // user override m_explicit_rate = true; return; - } else if (rate_type == "two-temperature-plasma") { - // two-temperature-plasma reactions do not use third bodies - return; } else if (kin && kin->thermo(kin->reactionPhaseIndex()).nDim() != 3) { // interface reactions return; @@ -332,7 +329,8 @@ void Reaction::setEquation(const std::string& equation, const Kinetics* kin) // detect explicitly specified collision partner if (products.count(reac.first)) { third_body = reac.first; - size_t generic = third_body == "M" || ba::ends_with(third_body, "M)"); + size_t generic = third_body == "M" + || third_body == "(+M)" || third_body == "(+ M)"; count++; countM += generic; if (reac.second > 1 && products[third_body] > 1) { @@ -667,10 +665,6 @@ void ThirdBody::setName(const std::string& third_body) "Conflicting efficiency definition for explicit third body '{}'", name); } m_name = name; - if (name == "") { - // sentinel value for multiple third body colliders - return; - } default_efficiency = 0.; efficiencies[m_name] = 1.; } diff --git a/test/kinetics/kineticsFromYaml.cpp b/test/kinetics/kineticsFromYaml.cpp index 210f9c18f9..703297ea82 100644 --- a/test/kinetics/kineticsFromYaml.cpp +++ b/test/kinetics/kineticsFromYaml.cpp @@ -299,11 +299,11 @@ TEST(Reaction, TwoTempPlasmaFromYaml) " rate-constant: [1.523e+27 cm^6/mol^2/s, -1.0, -100 K, 700 K]}"); auto R = newReaction(rxn, *(sol->kinetics())); - EXPECT_FALSE(R->usesThirdBody()); - EXPECT_EQ(R->reactants.at("O2"), 2); + EXPECT_TRUE(R->usesThirdBody()); + EXPECT_EQ(R->thirdBody()->name(), "O2"); + EXPECT_EQ(R->reactants.at("O2"), 1); EXPECT_EQ(R->reactants.at("E"), 1); EXPECT_EQ(R->products.at("O2^-"), 1); - EXPECT_EQ(R->products.at("O2"), 1); const auto rate = std::dynamic_pointer_cast(R->rate()); EXPECT_DOUBLE_EQ(rate->preExponentialFactor(), 1.523e21);