Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reaction specializations #1333

Merged
merged 29 commits into from Jul 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d765e26
[Kinetics] Remove reactant/productString specializations
ischoegl Jul 5, 2022
fec5601
[Kinetics] Remove get/setParameter specializations for Reaction
ischoegl Jul 6, 2022
2647d4f
[Kinetics] Introduce ThirdBody::checkSpecies
ischoegl Jul 6, 2022
b232ad2
[Kinetics] Introduce ThirdBody::name
ischoegl Jul 6, 2022
be4733e
[Kinetics] Consolidate third-body detection logic
ischoegl Jul 6, 2022
6dadbd5
[Kinetics] Remove Reaction::type specialization
ischoegl Jul 6, 2022
76a2ac2
[Kinetics] Introduce ThirdBody::setName
ischoegl Jul 7, 2022
9d152f0
[Kinetics] Delegate specialized constructors
ischoegl Jul 7, 2022
9126759
[UnitTests] Call tests from base Reaction in C++
ischoegl Jul 7, 2022
1c64ca0
[Kinetics] Remove pre-screening for implicit three-body reactions
ischoegl Jul 7, 2022
167edae
[Kinetics] Add Reaction::setThirdBody
ischoegl Jul 7, 2022
2f8a7d0
[Python] Enable addition of ThirdBody from API
ischoegl Jul 7, 2022
87268f7
[Kinetics] Enable creation of Reaction from reaction equation
ischoegl Jul 7, 2022
e226389
[Kinetics] Remove ReactionFactory
ischoegl Jul 7, 2022
b9cd9a1
[Kinetics] Block instantiation with empty rate or node information
ischoegl Jul 8, 2022
347e674
[Kinetics] Update Reaction::type to include rate information
ischoegl Jul 8, 2022
41e0532
[Python] Remove obsolete code from Python API
ischoegl Jul 7, 2022
4738aee
[Samples] Remove kinetics argument from custom Reaction
ischoegl Jul 7, 2022
f581225
[Kinetics] Refine Reaction/ThirdBody logic
ischoegl Jul 9, 2022
c9e8834
[Kinetics] Ensure explicit types are serialized
ischoegl Jul 10, 2022
b477f85
[Python] Add ThirdBody to Python API
ischoegl Jul 8, 2022
c34658b
[UnitTests] Update C++ tests to reflect changes in Reaction
ischoegl Jul 7, 2022
617bea8
[yaml2ck] Update reaction detection
ischoegl Jul 11, 2022
e94f433
[UnitTest] Update Python UnitTests
ischoegl Jul 7, 2022
946eaf0
Address review comments
ischoegl Jul 15, 2022
fa4ed55
[Kinetics] Implicit ThirdBody for FalloffRate's created from composition
ischoegl Jul 15, 2022
922ef8d
[Kinetics] Add ReactionRate::subType to differentiate FalloffRate spe…
ischoegl Jul 15, 2022
8e139e2
Address review comments
ischoegl Jul 15, 2022
b3d0d9a
[Sphinx] Add ThirdBody to documentation
ischoegl Jul 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/sphinx/cython/kinetics.rst
Expand Up @@ -149,6 +149,11 @@ StickingBlowersMaselRate
Auxiliary Reaction Data
-----------------------

ThirdBody
^^^^^^^^^
.. autoclass:: ThirdBody
:no-undoc-members:

Arrhenius
^^^^^^^^^
.. autoclass:: Arrhenius(A, b, E)
Expand Down
85 changes: 46 additions & 39 deletions include/cantera/kinetics/Falloff.h
Expand Up @@ -169,8 +169,11 @@ class FalloffRate : public ReactionRate
return 0;
}

virtual const std::string type() const {
return "Falloff";
virtual const std::string type() const override {
if (m_chemicallyActivated) {
return "chemically-activated";
}
return "falloff";
}

//! Returns the number of parameters used by this parameterization. The
Expand All @@ -179,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 @@ -220,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 @@ -297,12 +301,12 @@ 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>);
}

virtual const std::string type() const {
virtual const std::string subType() const override {
ischoegl marked this conversation as resolved.
Show resolved Hide resolved
return "Lindemann";
}
};
Expand Down Expand Up @@ -358,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 @@ -367,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 type() const {
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 @@ -460,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 @@ -470,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 type() const {
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 @@ -570,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 @@ -579,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 type() const {
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