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 committed Jul 6, 2022
1 parent b5de6dd commit f9208d1
Show file tree
Hide file tree
Showing 2 changed files with 18 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
31 changes: 17 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 @@ -284,6 +286,9 @@ void Reaction::setEquation(const std::string& equation, const Kinetics* kin)
if (rate_type == "two-temperature-plasma") {
// two-temperature-plasma reactions do not use third bodies
return;
} else if (rate_type == "elementary") {
// user override
return;
}

std::string third_body;
Expand Down Expand Up @@ -361,7 +366,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 @@ -691,7 +707,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 @@ -702,7 +717,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 @@ -717,7 +731,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 @@ -726,16 +739,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 f9208d1

Please sign in to comment.