From 4efad93a6d69006b4cb1e7946ae4f6d739df7c0f Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 22 Jun 2015 11:56:56 -0400 Subject: [PATCH] [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. --- include/cantera/kinetics/StoichManager.h | 2 +- .../cython/cantera/test/test_kinetics.py | 7 +++++-- test/data/explicit-forward-order.inp | 6 ++++++ test/data/explicit-forward-order.xml | 18 +++++++++++++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/include/cantera/kinetics/StoichManager.h b/include/cantera/kinetics/StoichManager.h index bd9cb0850..34f20afd7 100644 --- a/include/cantera/kinetics/StoichManager.h +++ b/include/cantera/kinetics/StoichManager.h @@ -771,7 +771,7 @@ public: } bool frac = false; 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; break; } diff --git a/interfaces/cython/cantera/test/test_kinetics.py b/interfaces/cython/cantera/test/test_kinetics.py index 978f31bbb..75944337b 100644 --- a/interfaces/cython/cantera/test/test_kinetics.py +++ b/interfaces/cython/cantera/test/test_kinetics.py @@ -426,8 +426,8 @@ class ExplicitForwardOrderTest(utilities.CanteraTest): def test_irreversibility(self): # Reactions are irreversible Rr = self.gas.reverse_rate_constants - self.assertEqual(Rr[0], 0.0) - self.assertEqual(Rr[1], 0.0) + for i in range(3): + self.assertEqual(Rr[i], 0.0) def test_rateConstants(self): # species order: [H, AR, R1A, R1B, P1] @@ -436,6 +436,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest): kf = self.gas.forward_rate_constants 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[2], kf[2] * C[2]**3.0) def test_ratio1(self): rop1 = self.gas.forward_rates_of_progress @@ -445,6 +446,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest): ratio = rop2/rop1 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[2], 2**3) # order of R1A is 3 def test_ratio2(self): rop1 = self.gas.forward_rates_of_progress @@ -454,6 +456,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest): ratio = rop2/rop1 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[2], 2**0.0) # order of R1B is 0 class TestSofcKinetics(utilities.CanteraTest): diff --git a/test/data/explicit-forward-order.inp b/test/data/explicit-forward-order.inp index 0c0915fb1..345af1d9e 100644 --- a/test/data/explicit-forward-order.inp +++ b/test/data/explicit-forward-order.inp @@ -13,8 +13,14 @@ REACTIONS R1A+R1B=>H+P1 1e12 0.0 20000.0 FORD / R1A 1.5 / FORD / R1B 0.5 / + DUPLICATE H+P1=>R1A+R1B 5e13 -2.0 5000.0 FORD / P1 0.2 / +R1A+R1B=>H+P1 1e12 0.0 20000.0 + FORD / R1A 3.0 / + FORD / R1B 0.0 / + DUPLICATE + END diff --git a/test/data/explicit-forward-order.xml b/test/data/explicit-forward-order.xml index 549a43706..7632526a1 100644 --- a/test/data/explicit-forward-order.xml +++ b/test/data/explicit-forward-order.xml @@ -108,7 +108,7 @@ - + R1A + R1B =] H + P1 0.5 1.5 @@ -138,5 +138,21 @@ H:1.0 P1:1 R1B:1 R1A:1.0 + + + + R1A + R1B =] H + P1 + 0.0 + 3.0 + + + 1.000000E+06 + 0.0 + 20000.000000 + + + R1B:1 R1A:1.0 + H:1.0 P1:1 +