def setUp(self): """ A function run before each unit test in this class. """ self.arrheniusHigh = Arrhenius( A=(1.39e+16, "cm^3/(mol*s)"), n=-0.534, Ea=(2.243, "kJ/mol"), T0=(1, "K"), ) self.arrheniusLow = Arrhenius( A=(2.62e+33, "cm^6/(mol^2*s)"), n=-4.76, Ea=(10.21, "kJ/mol"), T0=(1, "K"), ) self.alpha = 0.783 self.T3 = 74 self.T1 = 2941 self.T2 = 6964 self.efficiencies = { "C": 3, "C(=O)=O": 2, "CC": 3, "O": 6, "[Ar]": 0.7, "[C]=O": 1.5, "[H][H]": 2 } self.Tmin = 300. self.Tmax = 2000. self.Pmin = 0.01 self.Pmax = 100. self.comment = """H + CH3 -> CH4""" self.troe = Troe( arrheniusHigh=self.arrheniusHigh, arrheniusLow=self.arrheniusLow, alpha=self.alpha, T3=(self.T3, "K"), T1=(self.T1, "K"), T2=(self.T2, "K"), Tmin=(self.Tmin, "K"), Tmax=(self.Tmax, "K"), Pmin=(self.Pmin, "bar"), Pmax=(self.Pmax, "bar"), efficiencies=self.efficiencies, comment=self.comment, )
def setUp(self): """ A function run before each unit test in this class. """ self.arrheniusHigh = Arrhenius( A = (1.39e+16,"cm^3/(mol*s)"), n = -0.534, Ea = (2.243,"kJ/mol"), T0 = (1,"K"), ) self.arrheniusLow = Arrhenius( A = (2.62e+33,"cm^6/(mol^2*s)"), n = -4.76, Ea = (10.21,"kJ/mol"), T0 = (1,"K"), ) self.alpha = 0.783 self.T3 = 74 self.T1 = 2941 self.T2 = 6964 self.efficiencies = {"C": 3, "C(=O)=O": 2, "CC": 3, "O": 6, "[Ar]": 0.7, "[C]=O": 1.5, "[H][H]": 2} self.Tmin = 300. self.Tmax = 2000. self.Pmin = 0.01 self.Pmax = 100. self.comment = """H + CH3 -> CH4""" self.troe = Troe( arrheniusHigh = self.arrheniusHigh, arrheniusLow = self.arrheniusLow, alpha = self.alpha, T3 = (self.T3,"K"), T1 = (self.T1,"K"), T2 = (self.T2,"K"), Tmin = (self.Tmin,"K"), Tmax = (self.Tmax,"K"), Pmin = (self.Pmin,"bar"), Pmax = (self.Pmax,"bar"), efficiencies = self.efficiencies, comment = self.comment, )
class TestTroe(unittest.TestCase): """ Contains unit tests of the Troe class. """ def setUp(self): """ A function run before each unit test in this class. """ self.arrheniusHigh = Arrhenius( A=(1.39e+16, "cm^3/(mol*s)"), n=-0.534, Ea=(2.243, "kJ/mol"), T0=(1, "K"), ) self.arrheniusLow = Arrhenius( A=(2.62e+33, "cm^6/(mol^2*s)"), n=-4.76, Ea=(10.21, "kJ/mol"), T0=(1, "K"), ) self.alpha = 0.783 self.T3 = 74 self.T1 = 2941 self.T2 = 6964 self.efficiencies = { "C": 3, "C(=O)=O": 2, "CC": 3, "O": 6, "[Ar]": 0.7, "[C]=O": 1.5, "[H][H]": 2 } self.Tmin = 300. self.Tmax = 2000. self.Pmin = 0.01 self.Pmax = 100. self.comment = """H + CH3 -> CH4""" self.troe = Troe( arrheniusHigh=self.arrheniusHigh, arrheniusLow=self.arrheniusLow, alpha=self.alpha, T3=(self.T3, "K"), T1=(self.T1, "K"), T2=(self.T2, "K"), Tmin=(self.Tmin, "K"), Tmax=(self.Tmax, "K"), Pmin=(self.Pmin, "bar"), Pmax=(self.Pmax, "bar"), efficiencies=self.efficiencies, comment=self.comment, ) def test_arrheniusHigh(self): """ Test that the Troe arrheniusHigh property was properly set. """ self.assertTrue(self.troe.arrheniusHigh is self.arrheniusHigh) def test_arrheniusLow(self): """ Test that the Troe arrheniusLow property was properly set. """ self.assertTrue(self.troe.arrheniusLow is self.arrheniusLow) def test_alpha(self): """ Test that the Troe alpha property was properly set. """ self.assertEqual(self.troe.alpha, self.alpha) def test_T3(self): """ Test that the Troe T3 property was properly set. """ self.assertAlmostEqual(self.troe.T3.value_si, self.T3, 6) def test_T1(self): """ Test that the Troe T1 property was properly set. """ self.assertAlmostEqual(self.troe.T1.value_si, self.T1, 6) def test_T2(self): """ Test that the Troe T2 property was properly set. """ self.assertAlmostEqual(self.troe.T2.value_si, self.T2, 6) def test_Tmin(self): """ Test that the Troe Tmin property was properly set. """ self.assertAlmostEqual(self.troe.Tmin.value_si, self.Tmin, 6) def test_Tmax(self): """ Test that the Troe Tmax property was properly set. """ self.assertAlmostEqual(self.troe.Tmax.value_si, self.Tmax, 6) def test_Pmin(self): """ Test that the Troe Pmin property was properly set. """ self.assertAlmostEqual(self.troe.Pmin.value_si * 1e-5, self.Pmin, 6) def test_Pmax(self): """ Test that the Troe Pmax property was properly set. """ self.assertAlmostEqual(self.troe.Pmax.value_si * 1e-5, self.Pmax, 6) def test_comment(self): """ Test that the Troe comment property was properly set. """ self.assertEqual(self.troe.comment, self.comment) def test_isPressureDependent(self): """ Test the Troe.isPressureDependent() method. """ self.assertTrue(self.troe.isPressureDependent()) def test_getRateCoefficient(self): """ Test the Troe.getRateCoefficient() method. """ Tlist = numpy.array([300, 500, 1000, 1500]) Plist = numpy.array([1e4, 1e5, 1e6]) Kexp = numpy.array([ [1.00866e+08, 2.03759e+08, 2.55190e+08], [4.74623e+07, 1.41629e+08, 2.47597e+08], [3.97397e+06, 2.89521e+07, 9.57569e+07], [5.91277e+05, 5.14013e+06, 3.12239e+07], ]) for t in range(Tlist.shape[0]): for p in range(Plist.shape[0]): Kact = self.troe.getRateCoefficient(Tlist[t], Plist[p]) self.assertAlmostEqual(Kact, Kexp[t, p], delta=1e-4 * Kexp[t, p]) def test_pickle(self): """ Test that a Troe object can be pickled and unpickled with no loss of information. """ import cPickle troe = cPickle.loads(cPickle.dumps(self.troe, -1)) self.assertAlmostEqual(self.troe.arrheniusHigh.A.value, troe.arrheniusHigh.A.value, delta=1e0) self.assertEqual(self.troe.arrheniusHigh.A.units, troe.arrheniusHigh.A.units) self.assertAlmostEqual(self.troe.arrheniusHigh.n.value, troe.arrheniusHigh.n.value, 4) self.assertEqual(self.troe.arrheniusHigh.n.units, troe.arrheniusHigh.n.units, 4) self.assertAlmostEqual(self.troe.arrheniusHigh.Ea.value, troe.arrheniusHigh.Ea.value, 4) self.assertEqual(self.troe.arrheniusHigh.Ea.units, troe.arrheniusHigh.Ea.units) self.assertAlmostEqual(self.troe.arrheniusHigh.T0.value, troe.arrheniusHigh.T0.value, 4) self.assertEqual(self.troe.arrheniusHigh.T0.units, troe.arrheniusHigh.T0.units) self.assertAlmostEqual(self.troe.arrheniusLow.A.value, troe.arrheniusLow.A.value, delta=1e0) self.assertEqual(self.troe.arrheniusLow.A.units, troe.arrheniusLow.A.units) self.assertAlmostEqual(self.troe.arrheniusLow.n.value, troe.arrheniusLow.n.value, 4) self.assertEqual(self.troe.arrheniusLow.n.units, troe.arrheniusLow.n.units, 4) self.assertAlmostEqual(self.troe.arrheniusLow.Ea.value, troe.arrheniusLow.Ea.value, 4) self.assertEqual(self.troe.arrheniusLow.Ea.units, troe.arrheniusLow.Ea.units) self.assertAlmostEqual(self.troe.arrheniusLow.T0.value, troe.arrheniusLow.T0.value, 4) self.assertEqual(self.troe.arrheniusLow.T0.units, troe.arrheniusLow.T0.units) self.assertAlmostEqual(self.troe.alpha, troe.alpha, 6) self.assertAlmostEqual(self.troe.T3.value, troe.T3.value, 6) self.assertEqual(self.troe.T3.units, troe.T3.units) self.assertAlmostEqual(self.troe.T1.value, troe.T1.value, 6) self.assertEqual(self.troe.T1.units, troe.T1.units) self.assertAlmostEqual(self.troe.T2.value, troe.T2.value, 6) self.assertEqual(self.troe.T2.units, troe.T2.units) self.assertAlmostEqual(self.troe.Tmin.value, troe.Tmin.value, 4) self.assertEqual(self.troe.Tmin.units, troe.Tmin.units) self.assertAlmostEqual(self.troe.Tmax.value, troe.Tmax.value, 4) self.assertEqual(self.troe.Tmax.units, troe.Tmax.units) self.assertAlmostEqual(self.troe.Pmin.value, troe.Pmin.value, 4) self.assertEqual(self.troe.Pmin.units, troe.Pmin.units) self.assertAlmostEqual(self.troe.Pmax.value, troe.Pmax.value, 4) self.assertEqual(self.troe.Pmax.units, troe.Pmax.units) efficiencies = {} for mol, eff in self.troe.efficiencies.iteritems(): efficiencies[mol.toSMILES()] = eff pickled_efficiencies = {} for mol, eff in troe.efficiencies.iteritems(): pickled_efficiencies[mol.toSMILES()] = eff self.assertEqual(efficiencies, pickled_efficiencies) self.assertEqual(self.troe.comment, troe.comment) def test_repr(self): """ Test that a Troe object can be reconstructed from its repr() output with no loss of information. """ troe = None exec('troe = {0!r}'.format(self.troe)) self.assertAlmostEqual(self.troe.arrheniusHigh.A.value, troe.arrheniusHigh.A.value, delta=1e0) self.assertEqual(self.troe.arrheniusHigh.A.units, troe.arrheniusHigh.A.units) self.assertAlmostEqual(self.troe.arrheniusHigh.n.value, troe.arrheniusHigh.n.value, 4) self.assertEqual(self.troe.arrheniusHigh.n.units, troe.arrheniusHigh.n.units, 4) self.assertAlmostEqual(self.troe.arrheniusHigh.Ea.value, troe.arrheniusHigh.Ea.value, 4) self.assertEqual(self.troe.arrheniusHigh.Ea.units, troe.arrheniusHigh.Ea.units) self.assertAlmostEqual(self.troe.arrheniusHigh.T0.value, troe.arrheniusHigh.T0.value, 4) self.assertEqual(self.troe.arrheniusHigh.T0.units, troe.arrheniusHigh.T0.units) self.assertAlmostEqual(self.troe.arrheniusLow.A.value, troe.arrheniusLow.A.value, delta=1e0) self.assertEqual(self.troe.arrheniusLow.A.units, troe.arrheniusLow.A.units) self.assertAlmostEqual(self.troe.arrheniusLow.n.value, troe.arrheniusLow.n.value, 4) self.assertEqual(self.troe.arrheniusLow.n.units, troe.arrheniusLow.n.units, 4) self.assertAlmostEqual(self.troe.arrheniusLow.Ea.value, troe.arrheniusLow.Ea.value, 4) self.assertEqual(self.troe.arrheniusLow.Ea.units, troe.arrheniusLow.Ea.units) self.assertAlmostEqual(self.troe.arrheniusLow.T0.value, troe.arrheniusLow.T0.value, 4) self.assertEqual(self.troe.arrheniusLow.T0.units, troe.arrheniusLow.T0.units) self.assertAlmostEqual(self.troe.alpha, troe.alpha, 6) self.assertAlmostEqual(self.troe.T3.value, troe.T3.value, 6) self.assertEqual(self.troe.T3.units, troe.T3.units) self.assertAlmostEqual(self.troe.T1.value, troe.T1.value, 6) self.assertEqual(self.troe.T1.units, troe.T1.units) self.assertAlmostEqual(self.troe.T2.value, troe.T2.value, 6) self.assertEqual(self.troe.T2.units, troe.T2.units) self.assertAlmostEqual(self.troe.Tmin.value, troe.Tmin.value, 4) self.assertEqual(self.troe.Tmin.units, troe.Tmin.units) self.assertAlmostEqual(self.troe.Tmax.value, troe.Tmax.value, 4) self.assertEqual(self.troe.Tmax.units, troe.Tmax.units) self.assertAlmostEqual(self.troe.Pmin.value, troe.Pmin.value, 4) self.assertEqual(self.troe.Pmin.units, troe.Pmin.units) self.assertAlmostEqual(self.troe.Pmax.value, troe.Pmax.value, 4) self.assertEqual(self.troe.Pmax.units, troe.Pmax.units) efficiencies = {} for mol, eff in self.troe.efficiencies.iteritems(): efficiencies[mol.toSMILES()] = eff pickled_efficiencies = {} for mol, eff in troe.efficiencies.iteritems(): pickled_efficiencies[mol.toSMILES()] = eff self.assertEqual(efficiencies, pickled_efficiencies) self.assertEqual(self.troe.comment, troe.comment) def test_changeRate(self): """ Test the Troe.changeRate() method. """ Tlist = numpy.array([ 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500 ]) k0list = numpy.array( [self.troe.getRateCoefficient(T, 1e5) for T in Tlist]) self.troe.changeRate(2) for T, kexp in zip(Tlist, k0list): kact = self.troe.getRateCoefficient(T, 1e5) self.assertAlmostEqual(2 * kexp, kact, delta=1e-6 * kexp)
class TestTroe(unittest.TestCase): """ Contains unit tests of the Troe class. """ def setUp(self): """ A function run before each unit test in this class. """ self.arrheniusHigh = Arrhenius( A = (1.39e+16,"cm^3/(mol*s)"), n = -0.534, Ea = (2.243,"kJ/mol"), T0 = (1,"K"), ) self.arrheniusLow = Arrhenius( A = (2.62e+33,"cm^6/(mol^2*s)"), n = -4.76, Ea = (10.21,"kJ/mol"), T0 = (1,"K"), ) self.alpha = 0.783 self.T3 = 74 self.T1 = 2941 self.T2 = 6964 self.efficiencies = {"C": 3, "C(=O)=O": 2, "CC": 3, "O": 6, "[Ar]": 0.7, "[C]=O": 1.5, "[H][H]": 2} self.Tmin = 300. self.Tmax = 2000. self.Pmin = 0.01 self.Pmax = 100. self.comment = """H + CH3 -> CH4""" self.troe = Troe( arrheniusHigh = self.arrheniusHigh, arrheniusLow = self.arrheniusLow, alpha = self.alpha, T3 = (self.T3,"K"), T1 = (self.T1,"K"), T2 = (self.T2,"K"), Tmin = (self.Tmin,"K"), Tmax = (self.Tmax,"K"), Pmin = (self.Pmin,"bar"), Pmax = (self.Pmax,"bar"), efficiencies = self.efficiencies, comment = self.comment, ) def test_arrheniusHigh(self): """ Test that the Troe arrheniusHigh property was properly set. """ self.assertTrue(self.troe.arrheniusHigh is self.arrheniusHigh) def test_arrheniusLow(self): """ Test that the Troe arrheniusLow property was properly set. """ self.assertTrue(self.troe.arrheniusLow is self.arrheniusLow) def test_alpha(self): """ Test that the Troe alpha property was properly set. """ self.assertEqual(self.troe.alpha, self.alpha) def test_T3(self): """ Test that the Troe T3 property was properly set. """ self.assertAlmostEqual(self.troe.T3.value_si, self.T3, 6) def test_T1(self): """ Test that the Troe T1 property was properly set. """ self.assertAlmostEqual(self.troe.T1.value_si, self.T1, 6) def test_T2(self): """ Test that the Troe T2 property was properly set. """ self.assertAlmostEqual(self.troe.T2.value_si, self.T2, 6) def test_Tmin(self): """ Test that the Troe Tmin property was properly set. """ self.assertAlmostEqual(self.troe.Tmin.value_si, self.Tmin, 6) def test_Tmax(self): """ Test that the Troe Tmax property was properly set. """ self.assertAlmostEqual(self.troe.Tmax.value_si, self.Tmax, 6) def test_Pmin(self): """ Test that the Troe Pmin property was properly set. """ self.assertAlmostEqual(self.troe.Pmin.value_si*1e-5, self.Pmin, 6) def test_Pmax(self): """ Test that the Troe Pmax property was properly set. """ self.assertAlmostEqual(self.troe.Pmax.value_si*1e-5, self.Pmax, 6) def test_comment(self): """ Test that the Troe comment property was properly set. """ self.assertEqual(self.troe.comment, self.comment) def test_isPressureDependent(self): """ Test the Troe.isPressureDependent() method. """ self.assertTrue(self.troe.isPressureDependent()) def test_getRateCoefficient(self): """ Test the Troe.getRateCoefficient() method. """ Tlist = numpy.array([300,500,1000,1500]) Plist = numpy.array([1e4,1e5,1e6]) Kexp = numpy.array([ [1.00866e+08, 2.03759e+08, 2.55190e+08], [4.74623e+07, 1.41629e+08, 2.47597e+08], [3.97397e+06, 2.89521e+07, 9.57569e+07], [5.91277e+05, 5.14013e+06, 3.12239e+07], ]) for t in range(Tlist.shape[0]): for p in range(Plist.shape[0]): Kact = self.troe.getRateCoefficient(Tlist[t], Plist[p]) self.assertAlmostEqual(Kact, Kexp[t,p], delta=1e-4*Kexp[t,p]) def test_pickle(self): """ Test that a Troe object can be pickled and unpickled with no loss of information. """ import cPickle troe = cPickle.loads(cPickle.dumps(self.troe,-1)) self.assertAlmostEqual(self.troe.arrheniusHigh.A.value, troe.arrheniusHigh.A.value, delta=1e0) self.assertEqual(self.troe.arrheniusHigh.A.units, troe.arrheniusHigh.A.units) self.assertAlmostEqual(self.troe.arrheniusHigh.n.value, troe.arrheniusHigh.n.value, 4) self.assertEqual(self.troe.arrheniusHigh.n.units, troe.arrheniusHigh.n.units, 4) self.assertAlmostEqual(self.troe.arrheniusHigh.Ea.value, troe.arrheniusHigh.Ea.value, 4) self.assertEqual(self.troe.arrheniusHigh.Ea.units, troe.arrheniusHigh.Ea.units) self.assertAlmostEqual(self.troe.arrheniusHigh.T0.value, troe.arrheniusHigh.T0.value, 4) self.assertEqual(self.troe.arrheniusHigh.T0.units, troe.arrheniusHigh.T0.units) self.assertAlmostEqual(self.troe.arrheniusLow.A.value, troe.arrheniusLow.A.value, delta=1e0) self.assertEqual(self.troe.arrheniusLow.A.units, troe.arrheniusLow.A.units) self.assertAlmostEqual(self.troe.arrheniusLow.n.value, troe.arrheniusLow.n.value, 4) self.assertEqual(self.troe.arrheniusLow.n.units, troe.arrheniusLow.n.units, 4) self.assertAlmostEqual(self.troe.arrheniusLow.Ea.value, troe.arrheniusLow.Ea.value, 4) self.assertEqual(self.troe.arrheniusLow.Ea.units, troe.arrheniusLow.Ea.units) self.assertAlmostEqual(self.troe.arrheniusLow.T0.value, troe.arrheniusLow.T0.value, 4) self.assertEqual(self.troe.arrheniusLow.T0.units, troe.arrheniusLow.T0.units) self.assertAlmostEqual(self.troe.alpha, troe.alpha, 6) self.assertAlmostEqual(self.troe.T3.value, troe.T3.value, 6) self.assertEqual(self.troe.T3.units, troe.T3.units) self.assertAlmostEqual(self.troe.T1.value, troe.T1.value, 6) self.assertEqual(self.troe.T1.units, troe.T1.units) self.assertAlmostEqual(self.troe.T2.value, troe.T2.value, 6) self.assertEqual(self.troe.T2.units, troe.T2.units) self.assertAlmostEqual(self.troe.Tmin.value, troe.Tmin.value, 4) self.assertEqual(self.troe.Tmin.units, troe.Tmin.units) self.assertAlmostEqual(self.troe.Tmax.value, troe.Tmax.value, 4) self.assertEqual(self.troe.Tmax.units, troe.Tmax.units) self.assertAlmostEqual(self.troe.Pmin.value, troe.Pmin.value, 4) self.assertEqual(self.troe.Pmin.units, troe.Pmin.units) self.assertAlmostEqual(self.troe.Pmax.value, troe.Pmax.value, 4) self.assertEqual(self.troe.Pmax.units, troe.Pmax.units) efficiencies = {} for mol, eff in self.troe.efficiencies.iteritems(): efficiencies[mol.toSMILES()] = eff pickled_efficiencies = {} for mol, eff in troe.efficiencies.iteritems(): pickled_efficiencies[mol.toSMILES()] = eff self.assertEqual(efficiencies, pickled_efficiencies) self.assertEqual(self.troe.comment, troe.comment) def test_repr(self): """ Test that a Troe object can be reconstructed from its repr() output with no loss of information. """ troe = None exec('troe = {0!r}'.format(self.troe)) self.assertAlmostEqual(self.troe.arrheniusHigh.A.value, troe.arrheniusHigh.A.value, delta=1e0) self.assertEqual(self.troe.arrheniusHigh.A.units, troe.arrheniusHigh.A.units) self.assertAlmostEqual(self.troe.arrheniusHigh.n.value, troe.arrheniusHigh.n.value, 4) self.assertEqual(self.troe.arrheniusHigh.n.units, troe.arrheniusHigh.n.units, 4) self.assertAlmostEqual(self.troe.arrheniusHigh.Ea.value, troe.arrheniusHigh.Ea.value, 4) self.assertEqual(self.troe.arrheniusHigh.Ea.units, troe.arrheniusHigh.Ea.units) self.assertAlmostEqual(self.troe.arrheniusHigh.T0.value, troe.arrheniusHigh.T0.value, 4) self.assertEqual(self.troe.arrheniusHigh.T0.units, troe.arrheniusHigh.T0.units) self.assertAlmostEqual(self.troe.arrheniusLow.A.value, troe.arrheniusLow.A.value, delta=1e0) self.assertEqual(self.troe.arrheniusLow.A.units, troe.arrheniusLow.A.units) self.assertAlmostEqual(self.troe.arrheniusLow.n.value, troe.arrheniusLow.n.value, 4) self.assertEqual(self.troe.arrheniusLow.n.units, troe.arrheniusLow.n.units, 4) self.assertAlmostEqual(self.troe.arrheniusLow.Ea.value, troe.arrheniusLow.Ea.value, 4) self.assertEqual(self.troe.arrheniusLow.Ea.units, troe.arrheniusLow.Ea.units) self.assertAlmostEqual(self.troe.arrheniusLow.T0.value, troe.arrheniusLow.T0.value, 4) self.assertEqual(self.troe.arrheniusLow.T0.units, troe.arrheniusLow.T0.units) self.assertAlmostEqual(self.troe.alpha, troe.alpha, 6) self.assertAlmostEqual(self.troe.T3.value, troe.T3.value, 6) self.assertEqual(self.troe.T3.units, troe.T3.units) self.assertAlmostEqual(self.troe.T1.value, troe.T1.value, 6) self.assertEqual(self.troe.T1.units, troe.T1.units) self.assertAlmostEqual(self.troe.T2.value, troe.T2.value, 6) self.assertEqual(self.troe.T2.units, troe.T2.units) self.assertAlmostEqual(self.troe.Tmin.value, troe.Tmin.value, 4) self.assertEqual(self.troe.Tmin.units, troe.Tmin.units) self.assertAlmostEqual(self.troe.Tmax.value, troe.Tmax.value, 4) self.assertEqual(self.troe.Tmax.units, troe.Tmax.units) self.assertAlmostEqual(self.troe.Pmin.value, troe.Pmin.value, 4) self.assertEqual(self.troe.Pmin.units, troe.Pmin.units) self.assertAlmostEqual(self.troe.Pmax.value, troe.Pmax.value, 4) self.assertEqual(self.troe.Pmax.units, troe.Pmax.units) efficiencies = {} for mol, eff in self.troe.efficiencies.iteritems(): efficiencies[mol.toSMILES()] = eff pickled_efficiencies = {} for mol, eff in troe.efficiencies.iteritems(): pickled_efficiencies[mol.toSMILES()] = eff self.assertEqual(efficiencies, pickled_efficiencies) self.assertEqual(self.troe.comment, troe.comment) def test_changeRate(self): """ Test the Troe.changeRate() method. """ Tlist = numpy.array([300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500]) k0list = numpy.array([self.troe.getRateCoefficient(T,1e5) for T in Tlist]) self.troe.changeRate(2) for T, kexp in zip(Tlist, k0list): kact = self.troe.getRateCoefficient(T,1e5) self.assertAlmostEqual(2*kexp, kact, delta=1e-6*kexp)