[Kinetics] Fix handling of integral, explicit reaction orders

If any of the reaction orders differ from the corresponding stoichiometric
coefficients, the reaction needs to be handled as the general case, instead of
just when the orders are non-integral.
This commit is contained in:
Ray Speth 2015-06-22 11:56:56 -04:00
parent 2aec189ddc
commit d0c62ada84
4 changed files with 29 additions and 4 deletions

View file

@ -771,7 +771,7 @@ public:
} }
bool frac = false; bool frac = false;
for (size_t n = 0; n < stoich.size(); n++) { for (size_t n = 0; n < stoich.size(); n++) {
if (fmod(stoich[n], 1.0) || fmod(order[n], 1.0)) { if (fmod(stoich[n], 1.0) || stoich[n] != order[n]) {
frac = true; frac = true;
break; break;
} }

View file

@ -426,8 +426,8 @@ class ExplicitForwardOrderTest(utilities.CanteraTest):
def test_irreversibility(self): def test_irreversibility(self):
# Reactions are irreversible # Reactions are irreversible
Rr = self.gas.reverse_rate_constants Rr = self.gas.reverse_rate_constants
self.assertEqual(Rr[0], 0.0) for i in range(3):
self.assertEqual(Rr[1], 0.0) self.assertEqual(Rr[i], 0.0)
def test_rateConstants(self): def test_rateConstants(self):
# species order: [H, AR, R1A, R1B, P1] # species order: [H, AR, R1A, R1B, P1]
@ -436,6 +436,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest):
kf = self.gas.forward_rate_constants kf = self.gas.forward_rate_constants
self.assertNear(Rf[0], kf[0] * C[2]**1.5 * C[3]**0.5) self.assertNear(Rf[0], kf[0] * C[2]**1.5 * C[3]**0.5)
self.assertNear(Rf[1], kf[1] * C[0]**1.0 * C[4]**0.2) self.assertNear(Rf[1], kf[1] * C[0]**1.0 * C[4]**0.2)
self.assertNear(Rf[2], kf[2] * C[2]**3.0)
def test_ratio1(self): def test_ratio1(self):
rop1 = self.gas.forward_rates_of_progress rop1 = self.gas.forward_rates_of_progress
@ -445,6 +446,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest):
ratio = rop2/rop1 ratio = rop2/rop1
self.assertNear(ratio[0], 2**1.5) # order of R1A is 1.5 self.assertNear(ratio[0], 2**1.5) # order of R1A is 1.5
self.assertNear(ratio[1], 2**1.0) # order of H is 1.0 self.assertNear(ratio[1], 2**1.0) # order of H is 1.0
self.assertNear(ratio[2], 2**3) # order of R1A is 3
def test_ratio2(self): def test_ratio2(self):
rop1 = self.gas.forward_rates_of_progress rop1 = self.gas.forward_rates_of_progress
@ -454,6 +456,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest):
ratio = rop2/rop1 ratio = rop2/rop1
self.assertNear(ratio[0], 2**0.5) # order of R1B is 0.5 self.assertNear(ratio[0], 2**0.5) # order of R1B is 0.5
self.assertNear(ratio[1], 2**0.2) # order of P1 is 1.0 self.assertNear(ratio[1], 2**0.2) # order of P1 is 1.0
self.assertNear(ratio[2], 2**0.0) # order of R1B is 0
class TestSofcKinetics(utilities.CanteraTest): class TestSofcKinetics(utilities.CanteraTest):

View file

@ -13,8 +13,14 @@ REACTIONS
R1A+R1B=>H+P1 1e12 0.0 20000.0 R1A+R1B=>H+P1 1e12 0.0 20000.0
FORD / R1A 1.5 / FORD / R1A 1.5 /
FORD / R1B 0.5 / FORD / R1B 0.5 /
DUPLICATE
H+P1=>R1A+R1B 5e13 -2.0 5000.0 H+P1=>R1A+R1B 5e13 -2.0 5000.0
FORD / P1 0.2 / FORD / P1 0.2 /
R1A+R1B=>H+P1 1e12 0.0 20000.0
FORD / R1A 3.0 /
FORD / R1B 0.0 /
DUPLICATE
END END

View file

@ -108,7 +108,7 @@
<reactionData id="reaction_data"> <reactionData id="reaction_data">
<!-- reaction 0001 --> <!-- reaction 0001 -->
<reaction reversible="no" id="0001"> <reaction duplicate="yes" reversible="no" id="0001">
<equation>R1A + R1B =] H + P1</equation> <equation>R1A + R1B =] H + P1</equation>
<order species="R1B">0.5</order> <order species="R1B">0.5</order>
<order species="R1A">1.5</order> <order species="R1A">1.5</order>
@ -138,5 +138,21 @@
<reactants>H:1.0 P1:1</reactants> <reactants>H:1.0 P1:1</reactants>
<products>R1B:1 R1A:1.0</products> <products>R1B:1 R1A:1.0</products>
</reaction> </reaction>
<!-- reaction 0003 -->
<reaction duplicate="yes" reversible="no" id="0003">
<equation>R1A + R1B =] H + P1</equation>
<order species="R1B">0.0</order>
<order species="R1A">3.0</order>
<rateCoeff>
<Arrhenius>
<A>1.000000E+06</A>
<b>0.0</b>
<E units="cal/mol">20000.000000</E>
</Arrhenius>
</rateCoeff>
<reactants>R1B:1 R1A:1.0</reactants>
<products>H:1.0 P1:1</products>
</reaction>
</reactionData> </reactionData>
</ctml> </ctml>