[Kinetics] Allow skipping third-body efficiencies when using Reaction
This commit is contained in:
parent
ffe3eb5e5a
commit
6727902c3f
4 changed files with 49 additions and 2 deletions
|
|
@ -814,6 +814,15 @@ public:
|
|||
m_skipUndeclaredSpecies = skip;
|
||||
}
|
||||
|
||||
//! Determine behavior when adding a new reaction that contains third-body
|
||||
//! efficiencies for species not defined in any of the phases associated
|
||||
//! with this kinetics manager. If set to true, the given third-body
|
||||
//! efficiency will be ignored. If false, (the default) an exception will be
|
||||
//! raised.
|
||||
void skipUndeclaredThirdBodies(bool skip) {
|
||||
m_skipUndeclaredThirdBodies = skip;
|
||||
}
|
||||
|
||||
//! @deprecated To be removed after Cantera 2.2. No longer called as part
|
||||
//! of addReaction.
|
||||
virtual void installReagents(const ReactionData& r) {
|
||||
|
|
@ -1084,6 +1093,9 @@ protected:
|
|||
//! @see skipUndeclaredSpecies()
|
||||
bool m_skipUndeclaredSpecies;
|
||||
|
||||
//! @see skipUndeclaredThirdBodies()
|
||||
bool m_skipUndeclaredThirdBodies;
|
||||
|
||||
private:
|
||||
std::map<size_t, std::vector<grouplist_t> > m_rgroups;
|
||||
std::map<size_t, std::vector<grouplist_t> > m_pgroups;
|
||||
|
|
|
|||
|
|
@ -375,7 +375,14 @@ void GasKinetics::addThreeBodyReaction(ThirdBodyReaction& r)
|
|||
for (Composition::const_iterator iter = r.third_body.efficiencies.begin();
|
||||
iter != r.third_body.efficiencies.end();
|
||||
++iter) {
|
||||
efficiencies[kineticsSpeciesIndex(iter->first)] = iter->second;
|
||||
size_t k = kineticsSpeciesIndex(iter->first);
|
||||
if (k != npos) {
|
||||
efficiencies[k] = iter->second;
|
||||
} else if (!m_skipUndeclaredThirdBodies) {
|
||||
throw CanteraError("GasKinetics::addThreeBodyReaction", "Found "
|
||||
"third-body efficiency for undefined species '" + iter->first +
|
||||
"' while adding reaction '" + r.equation() + "'");
|
||||
}
|
||||
}
|
||||
m_3b_concm.install(nReactions(), efficiencies,
|
||||
r.third_body.default_efficiency);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ Kinetics::Kinetics() :
|
|||
m_surfphase(npos),
|
||||
m_rxnphase(npos),
|
||||
m_mindim(4),
|
||||
m_skipUndeclaredSpecies(false)
|
||||
m_skipUndeclaredSpecies(false),
|
||||
m_skipUndeclaredThirdBodies(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,33 @@ TEST_F(KineticsFromScratch, add_three_body_reaction)
|
|||
check_rates(1);
|
||||
}
|
||||
|
||||
TEST_F(KineticsFromScratch, undefined_third_body)
|
||||
{
|
||||
Composition reac = parseCompString("O:2");
|
||||
Composition prod = parseCompString("O2:1");
|
||||
Arrhenius rate(1.2e11, -1.0, 0.0);
|
||||
ThirdBody tbody;
|
||||
tbody.efficiencies = parseCompString("H2:0.1 CO2:0.83");
|
||||
shared_ptr<ThirdBodyReaction> R(new ThirdBodyReaction(reac, prod, rate, tbody));
|
||||
|
||||
ASSERT_THROW(kin.addReaction(R), CanteraError);
|
||||
}
|
||||
|
||||
TEST_F(KineticsFromScratch, skip_undefined_third_body)
|
||||
{
|
||||
Composition reac = parseCompString("O:2");
|
||||
Composition prod = parseCompString("O2:1");
|
||||
Arrhenius rate(1.2e11, -1.0, 0.0);
|
||||
ThirdBody tbody;
|
||||
tbody.efficiencies = parseCompString("H2:0.1 CO2:0.83");
|
||||
shared_ptr<ThirdBodyReaction> R(new ThirdBodyReaction(reac, prod, rate, tbody));
|
||||
|
||||
kin.skipUndeclaredThirdBodies(true);
|
||||
kin.addReaction(R);
|
||||
ASSERT_EQ((size_t) 1, kin.nReactions());
|
||||
}
|
||||
|
||||
|
||||
TEST_F(KineticsFromScratch, add_falloff_reaction)
|
||||
{
|
||||
// reaction 2:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue