Skip to content

Commit

Permalink
[Kinetics] ensure correct setup routine is called for XML node
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Feb 21, 2021
1 parent fe57129 commit 9b5f0ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/cantera/kinetics/ReactionFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ unique_ptr<Reaction> newReaction(const XML_Node& rxn_node);

//! Create a new Reaction object using the specified parameters
/*!
* @param node AnyMap node describing reaction.
* @param rxn_node AnyMap node describing reaction.
* @param kin kinetics manager
*/
unique_ptr<Reaction> newReaction(const AnyMap& node,
unique_ptr<Reaction> newReaction(const AnyMap& rxn_node,
const Kinetics& kin);
}
#endif
17 changes: 10 additions & 7 deletions src/kinetics/ReactionFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,26 @@ unique_ptr<Reaction> newReaction(const XML_Node& rxn_node)
throw CanteraError("newReaction",
"Unknown reaction type '" + rxn_node["type"] + "'");
}
ReactionFactory::factory()->setup_XML(R->type(), R, rxn_node);
if (type != "electrochemical") {
type = R->type();
}
ReactionFactory::factory()->setup_XML(type, R, rxn_node);

return unique_ptr<Reaction>(R);
}

unique_ptr<Reaction> newReaction(const AnyMap& node,
unique_ptr<Reaction> newReaction(const AnyMap& rxn_node,
const Kinetics& kin)
{
std::string type = "elementary";
if (node.hasKey("type")) {
type = node["type"].asString();
if (rxn_node.hasKey("type")) {
type = rxn_node["type"].asString();
}

if (kin.thermo().nDim() < 3) {
// See if this is an electrochemical reaction
Reaction testReaction(0);
parseReactionEquation(testReaction, node["equation"], kin);
parseReactionEquation(testReaction, rxn_node["equation"], kin);
if (isElectrochemicalReaction(testReaction, kin)) {
type = "electrochemical";
} else {
Expand All @@ -204,10 +207,10 @@ unique_ptr<Reaction> newReaction(const AnyMap& node,
try {
R = ReactionFactory::factory()->create(type);
} catch (CanteraError& err) {
throw InputFileError("ReactionFactory::newReaction", node["type"],
throw InputFileError("ReactionFactory::newReaction", rxn_node["type"],
"Unknown reaction type '{}'", type);
}
ReactionFactory::factory()->setup_AnyMap(type, R, node, kin);
ReactionFactory::factory()->setup_AnyMap(type, R, rxn_node, kin);

return unique_ptr<Reaction>(R);
}
Expand Down

0 comments on commit 9b5f0ba

Please sign in to comment.