Skip to content

Commit

Permalink
[Kinetics] Enable creation of Reaction from reaction equation
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jul 17, 2022
1 parent c3ac046 commit 793ad34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/cantera/kinetics/Reaction.h
Expand Up @@ -35,6 +35,8 @@ class Reaction
Reaction() {}
Reaction(const Composition& reactants, const Composition& products,
shared_ptr<ReactionRate> rate={}, shared_ptr<ThirdBody> tbody=0);
Reaction(const std::string& equation,
shared_ptr<ReactionRate> rate={}, shared_ptr<ThirdBody> tbody=0);

//! Construct a Reaction and it's corresponding ReactionRate based on AnyMap (YAML)
//! input.
Expand Down
14 changes: 13 additions & 1 deletion src/kinetics/Reaction.cpp
Expand Up @@ -37,8 +37,16 @@ Reaction::Reaction(const Composition& reactants_,
{
}

Reaction::Reaction(const std::string& equation,
shared_ptr<ReactionRate> rate_,
shared_ptr<ThirdBody> tbody_)
: m_third_body(tbody_)
{
setEquation(equation);
setRate(rate_);
}

Reaction::Reaction(const AnyMap& node, const Kinetics& kin)
: Reaction()
{
std::string rate_type = node.getString("type", "Arrhenius");
if (rate_type == "falloff" || rate_type == "chemically-activated") {
Expand Down Expand Up @@ -200,6 +208,10 @@ void Reaction::setParameters(const AnyMap& node, const Kinetics& kin)

if (m_third_body) {
m_third_body->setParameters(node);
} else if (node.hasKey("default-efficiency") || node.hasKey("efficiencies")) {
throw InputFileError("Reaction::setParameters", input,
"Reaction '{}' specifies efficiency parameters\n"
"but does not involve third body colliders.", equation());
}
}

Expand Down

0 comments on commit 793ad34

Please sign in to comment.