From d1e2459280f2b8de6288815f212d4ad8f53ace5d Mon Sep 17 00:00:00 2001 From: bangshiuh Date: Tue, 14 Dec 2021 18:39:53 -0500 Subject: [PATCH] [test] add ETempRateTest and add TestETemp --- .../cython/cantera/test/test_reaction.py | 61 +++++++++++++++++++ test/data/kineticsfromscratch.yaml | 3 + 2 files changed, 64 insertions(+) diff --git a/interfaces/cython/cantera/test/test_reaction.py b/interfaces/cython/cantera/test/test_reaction.py index a7c42f4f94e..a49580695d1 100644 --- a/interfaces/cython/cantera/test/test_reaction.py +++ b/interfaces/cython/cantera/test/test_reaction.py @@ -133,6 +133,7 @@ def setUpClass(cls): cls.gas = ct.Solution("kineticsfromscratch.yaml") cls.gas.X = "H2:0.1, H2O:0.2, O2:0.7, O:1e-4, OH:1e-5, H:2e-5" cls.gas.TP = 900, 2*ct.one_atm + cls.gas.Te = 2300 def from_parts(self): # create reaction rate object from parts @@ -285,6 +286,43 @@ def test_negative_A(self): self.assertTrue(rate.allow_negative_pre_exponential_factor) +class TestETempRate(ReactionRateTests, utilities.CanteraTest): + # test ETemp rate expressions + + _cls = ct.ETempRate + _type = "electron-temperature" + _index = 11 + _input = {"rate-constant": {"A": 17283, "b": -3.1, "Ea_T": -5820000, "Ea_Te": 1081000}} + _yaml = """ + type: electron-temperature + rate-constant: {A: 17283, b: -3.1, Ea_T: -5820 J/mol, Ea_Te: 1081 J/mol} + """ + + @classmethod + def setUpClass(cls): + ReactionRateTests.setUpClass() + cls._parts = cls._input["rate-constant"] + + def eval(self, rate): + # check evaluation as a function of temperature and electron temperature + return rate(self.gas.T, self.gas.Te) + + def test_from_parts(self): + rate = self.from_parts() + self.assertEqual(self._parts["A"], rate.pre_exponential_factor) + self.assertEqual(self._parts["b"], rate.temperature_exponent) + self.assertAlmostEqual(self._parts["Ea_T"], rate.activation_energy) + self.assertAlmostEqual(self._parts["Ea_Te"], rate.activation_electron_energy) + self.check_rate(rate) + + def test_negative_A(self): + # test reaction rate property + rate = self.from_parts() + self.assertFalse(rate.allow_negative_pre_exponential_factor) + rate.allow_negative_pre_exponential_factor = True + self.assertTrue(rate.allow_negative_pre_exponential_factor) + + class FalloffRateTests(ReactionRateTests): # test Falloff rate expressions _n_data = [0] # list of valid falloff coefficient array lengths @@ -886,6 +924,29 @@ def test_efficiencies(self): self.assertEqual(rxn.default_efficiency, 0.) +class TestETemp(ReactionTests, utilities.CanteraTest): + # test electron-temperature reaction + + _cls = ct.ETempReaction + _type = "electron-temperature" + _equation = "O + H <=> O + H" + _rate = {"A": 17283, "b": -3.1, "Ea_T": -5820000, "Ea_Te": 1081000} + _index = 11 + _yaml = """ + equation: O + H <=> O + H + type: electron-temperature + rate-constant: {A: 17283, b: -3.1, Ea_T: -5820 J/mol, Ea_Te: 1081 J/mol} + """ + + @classmethod + def setUpClass(cls): + ReactionTests.setUpClass() + cls._rate_obj = ct.ETempRate(**cls._rate) + + def eval_rate(self, rate): + return rate(self.gas.T, self.gas.Te) + + class TestBlowersMasel(ReactionTests, utilities.CanteraTest): # test updated version of Blowers-Masel reaction diff --git a/test/data/kineticsfromscratch.yaml b/test/data/kineticsfromscratch.yaml index 2b873616d82..59377689e63 100644 --- a/test/data/kineticsfromscratch.yaml +++ b/test/data/kineticsfromscratch.yaml @@ -80,3 +80,6 @@ reactions: type: chemically-activated high-P-rate-constant: [5.88E-14, 6.721, -3022.227] low-P-rate-constant: [282320.078, 1.46878, -3270.56495] +- equation: O + H <=> O + H # Reaction 12 + type: electron-temperature + rate-constant: {A: 17283, b: -3.1, Ea_T: -5820 J/mol, Ea_Te: 1081 J/mol} \ No newline at end of file