Skip to content

Commit

Permalink
[test] add ETempRateTest
Browse files Browse the repository at this point in the history
  • Loading branch information
BangShiuh committed Dec 21, 2021
1 parent f104f9e commit 7cc5706
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
38 changes: 38 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": -5.8201, "Ea_Te": 10.809}} # Te associated cal. is wrong
_yaml = """
type: electron-temperature
rate-constant: {A: 17283, b: -3.1, Ea_T: -700 K, Ea_Te: 1300 K}
"""

@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
4 changes: 4 additions & 0 deletions test/data/kineticsfromscratch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ 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
units: {length: cm, quantity: mol}
type: electron-temperature
rate-constant: {A: 17283, b: -3.1, Ea_T: -700 K, Ea_Te: 1300 K}

0 comments on commit 7cc5706

Please sign in to comment.