[Kinetics] Check Reaction objects for orders on reversible reactions
This commit is contained in:
parent
82fbff7a05
commit
e3022a8057
2 changed files with 22 additions and 0 deletions
|
|
@ -653,6 +653,15 @@ void Kinetics::addReaction(shared_ptr<Reaction> r)
|
|||
{
|
||||
r->validateRateConstant();
|
||||
|
||||
// If reaction orders are specified, then this reaction does not follow
|
||||
// mass-action kinetics, and is not an elementary reaction. So check that it
|
||||
// is not reversible, since computing the reverse rate from thermochemistry
|
||||
// only works for elementary reactions.
|
||||
if (r->reversible && !r->orders.empty()) {
|
||||
throw CanteraError("Kinetics::addReaction", "Reaction orders may only "
|
||||
"be given for irreversible reactions");
|
||||
}
|
||||
|
||||
// Check for undeclared species
|
||||
for (Composition::const_iterator iter = r->reactants.begin();
|
||||
iter != r->reactants.end();
|
||||
|
|
|
|||
|
|
@ -249,6 +249,19 @@ TEST_F(KineticsFromScratch, allow_negative_A)
|
|||
ASSERT_EQ((size_t) 1, kin.nReactions());
|
||||
}
|
||||
|
||||
TEST_F(KineticsFromScratch, invalid_reversible_with_orders)
|
||||
{
|
||||
Composition reac = parseCompString("O:1 H2:1");
|
||||
Composition prod = parseCompString("H:1 OH:1");
|
||||
Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K);
|
||||
shared_ptr<ElementaryReaction> R(new ElementaryReaction(reac, prod, rate));
|
||||
R->orders["H2"] = 0.5;
|
||||
|
||||
ASSERT_THROW(kin.addReaction(R), CanteraError);
|
||||
ASSERT_EQ(0, kin.nReactions());
|
||||
}
|
||||
|
||||
|
||||
class InterfaceKineticsFromScratch : public testing::Test
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue