mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Kinetics] Fix implicit ThirdBody edge cases
This commit is contained in:
parent
900169b375
commit
09ee7dce7e
@ -35,21 +35,35 @@ Reaction::Reaction(const Composition& reactants_,
|
|||||||
, m_from_composition(true)
|
, m_from_composition(true)
|
||||||
, m_third_body(tbody_)
|
, m_third_body(tbody_)
|
||||||
{
|
{
|
||||||
|
if (reactants.count("M") || products.count("M")) {
|
||||||
|
throw CanteraError("Reaction::Reaction",
|
||||||
|
"Third body 'M' must not be included in either reactant or product maps.");
|
||||||
|
}
|
||||||
setRate(rate_);
|
setRate(rate_);
|
||||||
|
|
||||||
// set flags ensuring correct serialization output
|
// set flags ensuring correct serialization output
|
||||||
bool count = 0;
|
Composition third;
|
||||||
for (const auto& [name, stoich] : reactants) {
|
for (const auto& [name, stoich] : reactants) {
|
||||||
if (products.count(name)) {
|
if (products.count(name)) {
|
||||||
count = true;
|
third[name] = products.at(name) - stoich;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count) {
|
if (tbody_) {
|
||||||
if (tbody_ && tbody_->name() != "M") {
|
string name = tbody_->name();
|
||||||
|
if (reactants.count(name) && products.count(name)) {
|
||||||
|
throw CanteraError("Reaction::Reaction",
|
||||||
|
"'{}' not acting as third body collider must not be included in both "
|
||||||
|
"reactant and product maps.", name);
|
||||||
|
}
|
||||||
|
if (name != "M") {
|
||||||
|
m_third_body->explicit_3rd = true;
|
||||||
|
}
|
||||||
|
} else if (!tbody_ && third.size() == 1) {
|
||||||
|
// implicit third body
|
||||||
|
string name = third.begin()->first;
|
||||||
|
m_third_body = make_shared<ThirdBody>(name);
|
||||||
|
if (name != "M") {
|
||||||
m_third_body->explicit_3rd = true;
|
m_third_body->explicit_3rd = true;
|
||||||
} else if (!tbody_) {
|
|
||||||
m_explicit_type = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +75,7 @@ Reaction::Reaction(const string& equation,
|
|||||||
{
|
{
|
||||||
setEquation(equation);
|
setEquation(equation);
|
||||||
setRate(rate_);
|
setRate(rate_);
|
||||||
if (tbody_ && tbody_->name() != "M") {
|
if (m_third_body && m_third_body->name() != "M") {
|
||||||
m_third_body->explicit_3rd = true;
|
m_third_body->explicit_3rd = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user