Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jul 17, 2022
1 parent c0fc8ac commit 0d4e8b0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 47 deletions.
72 changes: 38 additions & 34 deletions include/cantera/kinetics/Falloff.h
Expand Up @@ -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";
}
Expand All @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -300,7 +301,7 @@ class LindemannRate final : public FalloffRate
setFalloffCoeffs(c);
}

unique_ptr<MultiRateBase> newMultiRate() const {
unique_ptr<MultiRateBase> newMultiRate() const override{
return unique_ptr<MultiRateBase>(
new MultiRate<LindemannRate, FalloffData>);
}
Expand Down Expand Up @@ -361,7 +362,7 @@ class TroeRate final : public FalloffRate
setFalloffCoeffs(c);
}

unique_ptr<MultiRateBase> newMultiRate() const {
unique_ptr<MultiRateBase> newMultiRate() const override {
return unique_ptr<MultiRateBase>(new MultiRate<TroeRate, FalloffData>);
}

Expand All @@ -370,41 +371,42 @@ 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
/*!
* @param T Temperature (Kelvin)
* @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;
}

virtual const std::string subType() const override {
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
Expand Down Expand Up @@ -463,7 +465,7 @@ class SriRate final : public FalloffRate
setFalloffCoeffs(c);
}

unique_ptr<MultiRateBase> newMultiRate() const {
unique_ptr<MultiRateBase> newMultiRate() const override {
return unique_ptr<MultiRateBase>(new MultiRate<SriRate, FalloffData>);
}

Expand All @@ -473,41 +475,42 @@ 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
/*!
* @param T Temperature (Kelvin)
* @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;
}

virtual const std::string subType() const override {
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.
Expand Down Expand Up @@ -573,7 +576,7 @@ class TsangRate final : public FalloffRate
setFalloffCoeffs(c);
}

unique_ptr<MultiRateBase> newMultiRate() const {
unique_ptr<MultiRateBase> newMultiRate() const override {
return unique_ptr<MultiRateBase>(new MultiRate<TsangRate, FalloffData>);
}

Expand All @@ -582,41 +585,42 @@ 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
/*!
* @param T Temperature (Kelvin)
* @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;
}

virtual const std::string subType() const override {
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
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/reaction.pyx
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions src/kinetics/Reaction.cpp
Expand Up @@ -252,7 +252,7 @@ void Reaction::setRate(shared_ptr<ReactionRate> 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)"));
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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 == "<multiple>") {
// sentinel value for multiple third body colliders
return;
}
default_efficiency = 0.;
efficiencies[m_name] = 1.;
}
Expand Down
6 changes: 3 additions & 3 deletions test/kinetics/kineticsFromYaml.cpp
Expand Up @@ -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<TwoTempPlasmaRate>(R->rate());
EXPECT_DOUBLE_EQ(rate->preExponentialFactor(), 1.523e21);
Expand Down

0 comments on commit 0d4e8b0

Please sign in to comment.