diff --git a/interfaces/cython/cantera/test/test_kinetics.py b/interfaces/cython/cantera/test/test_kinetics.py index 841d26dcd..f41983e86 100644 --- a/interfaces/cython/cantera/test/test_kinetics.py +++ b/interfaces/cython/cantera/test/test_kinetics.py @@ -314,3 +314,41 @@ class TestChemicallyActivated(utilities.CanteraTest): for i in range(len(P)): gas.TPX = 900.0, P[i], [0.01, 0.01, 0.04, 0.10, 0.84] self.assertNear(gas.forward_rates_of_progress[0], Rf[i], 2e-5) + + +class ExplicitForwardOrderTest(utilities.CanteraTest): + def setUp(self): + self.gas = ct.Solution('explicit-forward-order.xml') + self.gas.TPX = 800, 101325, [0.01, 0.90, 0.02, 0.03, 0.04] + + 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) + + def test_rateConstants(self): + # species order: [H, AR, R1A, R1B, P1] + C = self.gas.concentrations + Rf = self.gas.forward_rates_of_progress + 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) + + def test_ratio1(self): + rop1 = self.gas.forward_rates_of_progress + # Double concentration of H and R1A + self.gas.TPX = None, None, [0.02, 0.87, 0.04, 0.03, 0.04] + rop2 = self.gas.forward_rates_of_progress + 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 + + def test_ratio2(self): + rop1 = self.gas.forward_rates_of_progress + # Double concentration of P1 and R1B + self.gas.TPX = None, None, [0.01, 0.83, 0.02, 0.06, 0.08] + rop2 = self.gas.forward_rates_of_progress + 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 diff --git a/test/python/runTests.py b/test/python/runTests.py index 700135071..a1d352b5f 100644 --- a/test/python/runTests.py +++ b/test/python/runTests.py @@ -21,8 +21,7 @@ if __name__ == '__main__': loader = unittest.TestLoader() runner = unittest.TextTestRunner(verbosity=2) - suite = loader.loadTestsFromName('testKinetics') - suite.addTests(loader.loadTestsFromName('testPureFluid')) + suite = loader.loadTestsFromName('testPureFluid') suite.addTests(loader.loadTestsFromName('testEquilibrium')) suite.addTests(loader.loadTestsFromName('testReactors')) suite.addTests(loader.loadTestsFromName('testConvert')) diff --git a/test/python/testKinetics.py b/test/python/testKinetics.py deleted file mode 100644 index 317a66b8e..000000000 --- a/test/python/testKinetics.py +++ /dev/null @@ -1,40 +0,0 @@ -import utilities -import Cantera as ct - -class ExplicitForwardOrderTest(utilities.CanteraTest): - def setUp(self): - self.gas = ct.IdealGasMix('../data/explicit-forward-order.xml') - self.gas.set(T=800, P=101325, X=[0.01, 0.90, 0.02, 0.03, 0.04]) - - def test_irreversibility(self): - # Reactions are irreversible - Rr = self.gas.revRateConstants() - self.assertEqual(Rr[0], 0.0) - self.assertEqual(Rr[1], 0.0) - - def test_rateConstants(self): - # species order: [H, AR, R1A, R1B, P1] - - C = self.gas.moleFractions() * self.gas.molarDensity() - Rf = self.gas.fwdRatesOfProgress() - kf = self.gas.fwdRateConstants() - 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) - - def test_ratio1(self): - rop1 = self.gas.fwdRatesOfProgress() - # Double concentration of H and R1A - self.gas.set(T=800, P=101325, X=[0.02, 0.87, 0.04, 0.03, 0.04]) - rop2 = self.gas.fwdRatesOfProgress() - 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 - - def test_ratio2(self): - rop1 = self.gas.fwdRatesOfProgress() - # Double concentration of P1 and R1B - self.gas.set(T=800, P=101325, X=[0.01, 0.83, 0.02, 0.06, 0.08]) - rop2 = self.gas.fwdRatesOfProgress() - 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