Skip to content

Commit

Permalink
[Kinetics] Remove Reaction::type specialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jul 17, 2022
1 parent f8475e9 commit f66795e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
8 changes: 1 addition & 7 deletions include/cantera/kinetics/Reaction.h
Expand Up @@ -56,7 +56,7 @@ class Reaction
void setEquation(const std::string& equation, const Kinetics* kin=0);

//! The type of reaction
virtual std::string type() const;
std::string type() const;

//! Calculate the units of the rate constant. These are determined by the units
//! of the standard concentration of the reactant species' phases and the phase
Expand Down Expand Up @@ -261,10 +261,6 @@ class ThreeBodyReaction : public Reaction
const ArrheniusRate& rate, const ThirdBody& tbody);

ThreeBodyReaction(const AnyMap& node, const Kinetics& kin);

virtual std::string type() const {
return "three-body";
}
};


Expand All @@ -282,8 +278,6 @@ class FalloffReaction : public Reaction
const ReactionRate& rate, const ThirdBody& tbody);

FalloffReaction(const AnyMap& node, const Kinetics& kin);

virtual std::string type() const;
};


Expand Down
28 changes: 14 additions & 14 deletions src/kinetics/Reaction.cpp
Expand Up @@ -221,6 +221,8 @@ void Reaction::setRate(shared_ptr<ReactionRate> rate)
throw InputFileError("Reaction::setRate", input,
"Found superfluous '{}' in pressure-dependent-Arrhenius reaction.",
m_third_body->name);
} else if (std::dynamic_pointer_cast<FalloffRate>(m_rate)) {
m_third_body->mass_action = false;
}
} else {
if (std::dynamic_pointer_cast<FalloffRate>(m_rate)) {
Expand Down Expand Up @@ -367,7 +369,18 @@ void Reaction::setEquation(const std::string& equation, const Kinetics* kin)

std::string Reaction::type() const
{
return "reaction";
if (!m_third_body) {
return "reaction";
}

auto falloff = std::dynamic_pointer_cast<FalloffRate>(m_rate);
if (falloff) {
if (falloff->chemicallyActivated()) {
return "chemically-activated";
}
return "falloff";
}
return "three-body";
}

UnitStack Reaction::calculateRateCoeffUnits(const Kinetics& kin)
Expand Down Expand Up @@ -697,7 +710,6 @@ ThreeBodyReaction::ThreeBodyReaction(const AnyMap& node, const Kinetics& kin)
FalloffReaction::FalloffReaction()
{
m_third_body.reset(new ThirdBody);
m_third_body->mass_action = false;
setRate(newReactionRate(type()));
}

Expand All @@ -708,7 +720,6 @@ FalloffReaction::FalloffReaction(const Composition& reactants,
: Reaction(reactants, products)
{
m_third_body = std::make_shared<ThirdBody>(tbody);
m_third_body->mass_action = false;
AnyMap node = rate.parameters();
node.applyUnits();
std::string rate_type = node["type"].asString();
Expand All @@ -723,7 +734,6 @@ FalloffReaction::FalloffReaction(const Composition& reactants,
FalloffReaction::FalloffReaction(const AnyMap& node, const Kinetics& kin)
{
m_third_body.reset(new ThirdBody);
m_third_body->mass_action = false;
if (!node.empty()) {
setParameters(node, kin);
setRate(newReactionRate(node, calculateRateCoeffUnits(kin)));
Expand All @@ -732,16 +742,6 @@ FalloffReaction::FalloffReaction(const AnyMap& node, const Kinetics& kin)
}
}

std::string FalloffReaction::type() const
{
if (m_rate &&
std::dynamic_pointer_cast<FalloffRate>(m_rate)->chemicallyActivated())
{
return "chemically-activated";
}
return "falloff";
}

bool isThreeBody(const Reaction& R)
{
// detect explicitly specified collision partner
Expand Down

0 comments on commit f66795e

Please sign in to comment.