Skip to content

Commit

Permalink
[test] add ETempRateTest and add TestETemp
Browse files Browse the repository at this point in the history
  • Loading branch information
BangShiuh committed Dec 23, 2021
1 parent 3020aec commit d1e2459
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
61 changes: 61 additions & 0 deletions interfaces/cython/cantera/test/test_reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions test/data/kineticsfromscratch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit d1e2459

Please sign in to comment.