Skip to content

Commit 5883156

Browse files
committed
Unit test for average_kinetics method
For now it just tests Arrhenius types, but should eventually work on others.
1 parent a1f8fee commit 5883156

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

rmgpy/data/kinetics/familyTest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@
3737
import numpy as np
3838

3939
from rmgpy import settings
40+
import rmgpy.data.kinetics.family
4041
from rmgpy.data.kinetics.database import KineticsDatabase
4142
from rmgpy.data.kinetics.family import TemplateReaction
4243
from rmgpy.data.rmg import RMGDatabase
4344
from rmgpy.data.thermo import ThermoDatabase
4445
from rmgpy.molecule import Molecule
4546
from rmgpy.species import Species
47+
from rmgpy.kinetics import Arrhenius
48+
4649

4750

4851
###################################################
@@ -1090,6 +1093,23 @@ def test_retaining_atom_labels_in_template_reaction(self):
10901093
self.assertEqual([(label, str(atom)) for label, atom in
10911094
reaction_list_2[0].labeled_atoms['products'].items()],
10921095
[('*1', 'C'), ('*2', 'C.'), ('*3', 'H')])
1096+
1097+
def test_average_kinetics(self):
1098+
"""
1099+
Test that the average kinetics are calculated correctly
1100+
"""
1101+
k1 = Arrhenius(A=(1e+13, 'cm^3/(mol*s)'), n=0, Ea=(0, 'kJ/mol'), T0=(1, 'K'))
1102+
k2 = Arrhenius(A=(4e+13, 'cm^3/(mol*s)'), n=1, Ea=(10, 'kJ/mol'), T0=(1, 'K'))
1103+
kav = rmgpy.data.kinetics.family.average_kinetics([k1, k2])
1104+
self.assertAlmostEqual(kav.A.value_si, 2.0e7, 2) # m3/mol/s
1105+
self.assertAlmostEqual(kav.n.value_si, 0.5, 6)
1106+
self.assertAlmostEqual(kav.Ea.value_si, 5.0e3, 2)
1107+
self.assertAlmostEqual(kav.T0.value_si, 1.0, 6)
1108+
self.assertEqual(kav.A.units, 'm^3/(mol*s)')
1109+
self.assertAlmostEqual(np.log(kav.get_rate_coefficient(300)),
1110+
np.average([np.log(k1.get_rate_coefficient(300)),
1111+
np.log(k2.get_rate_coefficient(300))]), 6)
1112+
10931113

10941114

10951115
################################################################################

0 commit comments

Comments
 (0)