Ejemplo n.º 1
0
 def setUp(self):
     """
     A function run before each unit test in this class.
     """
     self.Tmin = 350.0
     self.Tmax = 1500.0
     self.comment = "Comment"
     self.arrhenius = [
         Arrhenius(
             A=(9.3e-14, "cm^3/(molecule*s)"),
             n=0.0,
             Ea=(4740 * constants.R * 0.001, "kJ/mol"),
             T0=(1, "K"),
             Tmin=(self.Tmin, "K"),
             Tmax=(self.Tmax, "K"),
             comment=self.comment,
         ),
         Arrhenius(
             A=(1.4e-9, "cm^3/(molecule*s)"),
             n=0.0,
             Ea=(11200 * constants.R * 0.001, "kJ/mol"),
             T0=(1, "K"),
             Tmin=(self.Tmin, "K"),
             Tmax=(self.Tmax, "K"),
             comment=self.comment,
         ),
     ]
     self.kinetics = MultiArrhenius(
         arrhenius=self.arrhenius, Tmin=(self.Tmin, "K"), Tmax=(self.Tmax, "K"), comment=self.comment
     )
     self.single_kinetics = MultiArrhenius(
         arrhenius=self.arrhenius[:1], Tmin=(self.Tmin, "K"), Tmax=(self.Tmax, "K"), comment=self.comment
     )
Ejemplo n.º 2
0
 def setUp(self):
     """
     A function run before each unit test in this class.
     """
     self.Tmin = 350.
     self.Tmax = 1500.
     self.comment = 'Comment'
     self.arrhenius = [
         Arrhenius(
             A=(9.3e-14, "cm^3/(molecule*s)"),
             n=0.0,
             Ea=(4740 * constants.R * 0.001, "kJ/mol"),
             T0=(1, "K"),
             Tmin=(self.Tmin, "K"),
             Tmax=(self.Tmax, "K"),
             comment=self.comment,
         ),
         Arrhenius(
             A=(1.4e-9, "cm^3/(molecule*s)"),
             n=0.0,
             Ea=(11200 * constants.R * 0.001, "kJ/mol"),
             T0=(1, "K"),
             Tmin=(self.Tmin, "K"),
             Tmax=(self.Tmax, "K"),
             comment=self.comment,
         ),
     ]
     self.kinetics = MultiArrhenius(
         arrhenius=self.arrhenius,
         Tmin=(self.Tmin, "K"),
         Tmax=(self.Tmax, "K"),
         comment=self.comment,
     )
     self.single_kinetics = MultiArrhenius(
         arrhenius=self.arrhenius[:1],
         Tmin=(self.Tmin, "K"),
         Tmax=(self.Tmax, "K"),
         comment=self.comment,
     )
Ejemplo n.º 3
0
def get_arrhenius_from_param(params, settings, arrh_type='Arrhenius'):
    """
    Get Arrhenius object given params and settings
    
    Args:
        params (dict) : A dictionary contains the information about
                        A factor, n, Ea, T0 and multiplier
        settings (dict): A dictionary contains the information about
                         variable units, T and P range, description
        arrh_type (str): The type of Arrhenius object to be added,
                         supporting Arrhenius, MultiArrhenius, and
                         PdepArrehnius
    
    Returns:
        (Arrhenius object): The Arrhenius object generated
    """
    args = {}
    if 'Tmin' in settings and settings['Tmin']:
        args['Tmin'] = (settings['Tmin'], settings['T_unit'])
    if 'Tmax' in settings and settings['Tmax']:
        args['Tmax'] = (settings['Tmax'], settings['T_unit'])
    if 'Pmin' in settings and settings['Pmin']:
        args['Pmin'] = (settings['Pmin'], settings['P_unit'])
    if 'Pmax' in settings and settings['Pmax']:
        args['Pmax'] = (settings['Pmax'], settings['P_unit'])
    if 'comment' in settings and settings['comment']:
        args['comment'] = settings['comment']

    if arrh_type == 'Arrhenius':
        args['A'] = (params['A'], settings['A_unit'])
        args['n'] = params['n']
        args['Ea'] = (params['Ea'], settings['E_unit'])
        if 'T0' in params and params['T0']:
            args['T0'] = (params['T0'], settings['T_unit'])
        if 'uncertainty' in params and params['uncertainty']:
            args['uncertainty'] = params['uncertainty']
        return Arrhenius(**args)
    elif arrh_type == 'MultiArrhenius':
        args['arrhenius'] = params['arrhenius']
        return MultiArrhenius(**args)
    elif arrh_type == 'PdepArrhenius':
        args['arrhenius'] = params['arrhenius']
        args['pressures'] = (params['pressures'], settings['P_unit'])
        if 'highPlimit' and params['highPlimit']:
            args['highPlimit'] = params['highPlimit']
        return PDepArrhenius(**args)
Ejemplo n.º 4
0
class TestMultiArrhenius(unittest.TestCase):
    """
    Contains unit tests of the :class:`MultiArrhenius` class.
    """
    def setUp(self):
        """
        A function run before each unit test in this class.
        """
        self.Tmin = 350.
        self.Tmax = 1500.
        self.comment = 'Comment'
        self.arrhenius = [
            Arrhenius(
                A=(9.3e-14, "cm^3/(molecule*s)"),
                n=0.0,
                Ea=(4740 * constants.R * 0.001, "kJ/mol"),
                T0=(1, "K"),
                Tmin=(self.Tmin, "K"),
                Tmax=(self.Tmax, "K"),
                comment=self.comment,
            ),
            Arrhenius(
                A=(1.4e-9, "cm^3/(molecule*s)"),
                n=0.0,
                Ea=(11200 * constants.R * 0.001, "kJ/mol"),
                T0=(1, "K"),
                Tmin=(self.Tmin, "K"),
                Tmax=(self.Tmax, "K"),
                comment=self.comment,
            ),
        ]
        self.kinetics = MultiArrhenius(
            arrhenius=self.arrhenius,
            Tmin=(self.Tmin, "K"),
            Tmax=(self.Tmax, "K"),
            comment=self.comment,
        )
        self.single_kinetics = MultiArrhenius(
            arrhenius=self.arrhenius[:1],
            Tmin=(self.Tmin, "K"),
            Tmax=(self.Tmax, "K"),
            comment=self.comment,
        )

    def test_arrhenius(self):
        """
        Test that the MultiArrhenius A property was properly set.
        """
        self.assertEqual(self.kinetics.arrhenius, self.arrhenius)

    def test_Tmin(self):
        """
        Test that the MultiArrhenius Tmin property was properly set.
        """
        self.assertAlmostEqual(self.kinetics.Tmin.value_si, self.Tmin, 6)

    def test_Tmax(self):
        """
        Test that the MultiArrhenius Tmax property was properly set.
        """
        self.assertAlmostEqual(self.kinetics.Tmax.value_si, self.Tmax, 6)

    def test_comment(self):
        """
        Test that the MultiArrhenius comment property was properly set.
        """
        self.assertEqual(self.kinetics.comment, self.comment)

    def test_isTemperatureValid(self):
        """
        Test the MultiArrhenius.isTemperatureValid() method.
        """
        Tdata = numpy.array(
            [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000])
        validdata = numpy.array(
            [False, True, True, True, True, True, True, False, False, False],
            numpy.bool)
        for T, valid in zip(Tdata, validdata):
            valid0 = self.kinetics.isTemperatureValid(T)
            self.assertEqual(valid0, valid)

    def test_getRateCoefficient(self):
        """
        Test the MultiArrhenius.getRateCoefficient() method.
        """
        Tlist = numpy.array(
            [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000])
        kexplist = numpy.array([
            2.85400e-06, 4.00384e-01, 2.73563e+01, 8.50699e+02, 1.20181e+04,
            7.56312e+04, 2.84724e+05, 7.71702e+05, 1.67743e+06, 3.12290e+06
        ])
        for T, kexp in zip(Tlist, kexplist):
            kact = self.kinetics.getRateCoefficient(T)
            self.assertAlmostEqual(kexp, kact, delta=1e-4 * kexp)

    def test_pickle(self):
        """
        Test that a MultiArrhenius object can be pickled and unpickled with no loss
        of information.
        """
        import cPickle
        kinetics = cPickle.loads(cPickle.dumps(self.kinetics, -1))
        self.assertEqual(len(self.kinetics.arrhenius), len(kinetics.arrhenius))
        for arrh0, arrh in zip(self.kinetics.arrhenius, kinetics.arrhenius):
            self.assertAlmostEqual(arrh0.A.value, arrh.A.value, delta=1e-18)
            self.assertEqual(arrh0.A.units, arrh.A.units)
            self.assertAlmostEqual(arrh0.n.value, arrh.n.value, 4)
            self.assertAlmostEqual(arrh0.Ea.value, arrh.Ea.value, 4)
            self.assertEqual(arrh0.Ea.units, arrh.Ea.units)
            self.assertAlmostEqual(arrh0.T0.value, arrh.T0.value, 4)
            self.assertEqual(arrh0.T0.units, arrh.T0.units)
        self.assertAlmostEqual(self.kinetics.Tmin.value, kinetics.Tmin.value,
                               4)
        self.assertEqual(self.kinetics.Tmin.units, kinetics.Tmin.units)
        self.assertAlmostEqual(self.kinetics.Tmax.value, kinetics.Tmax.value,
                               4)
        self.assertEqual(self.kinetics.Tmax.units, kinetics.Tmax.units)
        self.assertEqual(self.kinetics.comment, kinetics.comment)

    def test_repr(self):
        """
        Test that a MultiArrhenius object can be reconstructed from its repr()
        output with no loss of information.
        """
        kinetics = None
        exec('kinetics = {0!r}'.format(self.kinetics))
        self.assertEqual(len(self.kinetics.arrhenius), len(kinetics.arrhenius))
        for arrh0, arrh in zip(self.kinetics.arrhenius, kinetics.arrhenius):
            self.assertAlmostEqual(arrh0.A.value, arrh.A.value, delta=1e-18)
            self.assertEqual(arrh0.A.units, arrh.A.units)
            self.assertAlmostEqual(arrh0.n.value, arrh.n.value, 4)
            self.assertAlmostEqual(arrh0.Ea.value, arrh.Ea.value, 4)
            self.assertEqual(arrh0.Ea.units, arrh.Ea.units)
            self.assertAlmostEqual(arrh0.T0.value, arrh.T0.value, 4)
            self.assertEqual(arrh0.T0.units, arrh.T0.units)
        self.assertAlmostEqual(self.kinetics.Tmin.value, kinetics.Tmin.value,
                               4)
        self.assertEqual(self.kinetics.Tmin.units, kinetics.Tmin.units)
        self.assertAlmostEqual(self.kinetics.Tmax.value, kinetics.Tmax.value,
                               4)
        self.assertEqual(self.kinetics.Tmax.units, kinetics.Tmax.units)
        self.assertEqual(self.kinetics.comment, kinetics.comment)

    def test_toArrhenius(self):
        """
        Test that we can convert to an Arrhenius
        """
        answer = self.single_kinetics.arrhenius[0]
        fitted = self.single_kinetics.toArrhenius()

        self.assertAlmostEqual(fitted.A.value_si, answer.A.value_si, delta=1e0)
        self.assertAlmostEqual(fitted.n.value_si, answer.n.value_si, 1, 4)
        self.assertAlmostEqual(fitted.Ea.value_si, answer.Ea.value_si, 2)
        self.assertAlmostEqual(fitted.T0.value_si, answer.T0.value_si, 4)

    def test_toArrheniusTrange(self):
        """
        Test the toArrhenius temperature range is set correctly.
        """
        answer = self.single_kinetics.arrhenius[0]
        fitted = self.single_kinetics.toArrhenius(Tmin=800, Tmax=1200)
        self.assertAlmostEqual(fitted.Tmin.value_si, 800.0)
        self.assertAlmostEqual(fitted.Tmax.value_si, 1200.0)
        for T in [800, 1000, 1200]:
            self.assertAlmostEqual(
                fitted.getRateCoefficient(T) / answer.getRateCoefficient(T),
                1.0)

    def test_toArrheniusMultiple(self):
        """
        Test the toArrhenius fitting multiple kinetics over a small range, see if we're within 5% at a few points
        """
        answer = self.kinetics
        fitted = self.kinetics.toArrhenius(Tmin=800, Tmax=1200)
        self.assertAlmostEqual(fitted.Tmin.value_si, 800.0)
        self.assertAlmostEqual(fitted.Tmax.value_si, 1200.0)
        for T in [800, 1000, 1200]:
            self.assertAlmostEqual(fitted.getRateCoefficient(T) /
                                   answer.getRateCoefficient(T),
                                   1.0,
                                   delta=0.05)

    def test_changeRate(self):
        """
        Test the MultiArrhenius.changeRate() method.
        """
        Tlist = numpy.array([
            300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400,
            1500
        ])
        k0list = numpy.array(
            [self.kinetics.getRateCoefficient(T) for T in Tlist])
        self.kinetics.changeRate(2)
        for T, kexp in zip(Tlist, k0list):
            kact = self.kinetics.getRateCoefficient(T)
            self.assertAlmostEqual(2 * kexp, kact, delta=1e-6 * kexp)
Ejemplo n.º 5
0
    def test_process_duplicate_reactions(self):
        """
        Test that duplicate reactions are handled correctly when
        loading a Chemkin file.
        """
        s1 = Species().from_smiles('CC')
        s2 = Species().from_smiles('[CH3]')
        s3 = Species().from_smiles('[OH]')
        s4 = Species().from_smiles('C[CH2]')
        s5 = Species().from_smiles('O')
        r1 = Reaction(reactants=[s1],
                      products=[s2, s2],
                      duplicate=False,
                      kinetics=Arrhenius())
        r2 = Reaction(reactants=[s1, s3],
                      products=[s4, s5],
                      duplicate=True,
                      kinetics=Arrhenius())
        r3 = Reaction(reactants=[s1, s3],
                      products=[s4, s5],
                      duplicate=True,
                      kinetics=Arrhenius())
        r4 = Reaction(reactants=[s1, s3],
                      products=[s4, s5],
                      duplicate=False,
                      kinetics=Arrhenius())
        r5 = LibraryReaction(reactants=[s1, s3],
                             products=[s4, s5],
                             duplicate=True,
                             kinetics=Arrhenius(),
                             library='lib1')
        r6 = LibraryReaction(reactants=[s1, s3],
                             products=[s4, s5],
                             duplicate=True,
                             kinetics=Arrhenius(),
                             library='lib2')
        r7 = LibraryReaction(reactants=[s1, s3],
                             products=[s4, s5],
                             duplicate=True,
                             kinetics=Chebyshev(),
                             library='lib1')
        r8 = LibraryReaction(reactants=[s1, s3],
                             products=[s4, s5],
                             duplicate=True,
                             kinetics=Arrhenius(),
                             library='lib1')
        r9 = LibraryReaction(
            reactants=[s1, s3],
            products=[s4, s5],
            duplicate=False,
            kinetics=MultiArrhenius(
                arrhenius=[Arrhenius(), Arrhenius()]),
            library='lib1')
        reaction_list_with_duplicate = [r1, r2, r3]
        reaction_list_with_duplicate2 = [r1, r2, r3]
        reaction_list_unmarked_duplicate = [r1, r2, r4]
        reaction_list_unequal_libraries = [r1, r5, r6]
        reaction_list_mixed_kinetics = [r1, r5, r7]
        reaction_list_mergeable = [r1, r5, r8]
        reaction_list_merged = [r1, r9]

        # Test that duplicates are not removed for non-library reactions
        _process_duplicate_reactions(reaction_list_with_duplicate)
        self.assertEqual(reaction_list_with_duplicate,
                         reaction_list_with_duplicate2)

        # Test that unmarked duplicate reactions are detected if both
        # reactions are p-dep or p-indep
        self.assertRaisesRegexp(ChemkinError,
                                'Encountered unmarked duplicate reaction',
                                _process_duplicate_reactions,
                                reaction_list_unmarked_duplicate)

        # Test that unequal libraries are recognized
        self.assertRaisesRegexp(ChemkinError, 'from different libraries',
                                _process_duplicate_reactions,
                                reaction_list_unequal_libraries)

        # Test that an error is raised for reactions with kinetics
        # that cannot be merged
        self.assertRaisesRegexp(ChemkinError,
                                'Mixed kinetics for duplicate reaction',
                                _process_duplicate_reactions,
                                reaction_list_mixed_kinetics)

        # Test that duplicate library reactions are merged successfully
        _process_duplicate_reactions(reaction_list_mergeable)
        self.assertEqual(len(reaction_list_mergeable),
                         len(reaction_list_merged))
        self.assertEqual(reaction_list_mergeable[0], reaction_list_merged[0])
        rtest = reaction_list_mergeable[1]
        rtrue = reaction_list_merged[1]
        self.assertEqual(rtest.reactants, rtrue.reactants)
        self.assertEqual(rtest.products, rtrue.products)
        self.assertEqual(rtest.duplicate, rtrue.duplicate)
        self.assertEqual(rtest.library, rtrue.library)
        self.assertTrue(isinstance(rtest.kinetics, MultiArrhenius))
        self.assertTrue(
            all(isinstance(k, Arrhenius) for k in rtest.kinetics.arrhenius))
Ejemplo n.º 6
0
class TestMultiArrhenius(unittest.TestCase):
    """
    Contains unit tests of the :class:`MultiArrhenius` class.
    """

    def setUp(self):
        """
        A function run before each unit test in this class.
        """
        self.Tmin = 350.0
        self.Tmax = 1500.0
        self.comment = ""
        self.arrhenius = [
            Arrhenius(
                A=(9.3e-14, "cm^3/(molecule*s)"),
                n=0.0,
                Ea=(4740 * constants.R * 0.001, "kJ/mol"),
                T0=(1, "K"),
                Tmin=(self.Tmin, "K"),
                Tmax=(self.Tmax, "K"),
                comment=self.comment,
            ),
            Arrhenius(
                A=(1.4e-9, "cm^3/(molecule*s)"),
                n=0.0,
                Ea=(11200 * constants.R * 0.001, "kJ/mol"),
                T0=(1, "K"),
                Tmin=(self.Tmin, "K"),
                Tmax=(self.Tmax, "K"),
                comment=self.comment,
            ),
        ]
        self.kinetics = MultiArrhenius(
            arrhenius=self.arrhenius, Tmin=(self.Tmin, "K"), Tmax=(self.Tmax, "K"), comment=self.comment
        )

    def test_arrhenius(self):
        """
        Test that the MultiArrhenius A property was properly set.
        """
        self.assertEqual(self.kinetics.arrhenius, self.arrhenius)

    def test_Tmin(self):
        """
        Test that the MultiArrhenius Tmin property was properly set.
        """
        self.assertAlmostEqual(self.kinetics.Tmin.value_si, self.Tmin, 6)

    def test_Tmax(self):
        """
        Test that the MultiArrhenius Tmax property was properly set.
        """
        self.assertAlmostEqual(self.kinetics.Tmax.value_si, self.Tmax, 6)

    def test_comment(self):
        """
        Test that the MultiArrhenius comment property was properly set.
        """
        self.assertEqual(self.kinetics.comment, self.comment)

    def test_isTemperatureValid(self):
        """
        Test the MultiArrhenius.isTemperatureValid() method.
        """
        Tdata = numpy.array([200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000])
        validdata = numpy.array([False, True, True, True, True, True, True, False, False, False], numpy.bool)
        for T, valid in zip(Tdata, validdata):
            valid0 = self.kinetics.isTemperatureValid(T)
            self.assertEqual(valid0, valid)

    def test_getRateCoefficient(self):
        """
        Test the MultiArrhenius.getRateCoefficient() method.
        """
        Tlist = numpy.array([200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000])
        kexplist = numpy.array(
            [
                2.85400e-06,
                4.00384e-01,
                2.73563e01,
                8.50699e02,
                1.20181e04,
                7.56312e04,
                2.84724e05,
                7.71702e05,
                1.67743e06,
                3.12290e06,
            ]
        )
        for T, kexp in zip(Tlist, kexplist):
            kact = self.kinetics.getRateCoefficient(T)
            self.assertAlmostEqual(kexp, kact, delta=1e-4 * kexp)

    def test_pickle(self):
        """
        Test that a MultiArrhenius object can be pickled and unpickled with no loss
        of information.
        """
        import cPickle

        kinetics = cPickle.loads(cPickle.dumps(self.kinetics))
        self.assertEqual(len(self.kinetics.arrhenius), len(kinetics.arrhenius))
        for arrh0, arrh in zip(self.kinetics.arrhenius, kinetics.arrhenius):
            self.assertAlmostEqual(arrh0.A.value, arrh.A.value, delta=1e-18)
            self.assertEqual(arrh0.A.units, arrh.A.units)
            self.assertAlmostEqual(arrh0.n.value, arrh.n.value, 4)
            self.assertAlmostEqual(arrh0.Ea.value, arrh.Ea.value, 4)
            self.assertEqual(arrh0.Ea.units, arrh.Ea.units)
            self.assertAlmostEqual(arrh0.T0.value, arrh.T0.value, 4)
            self.assertEqual(arrh0.T0.units, arrh.T0.units)
        self.assertAlmostEqual(self.kinetics.Tmin.value, kinetics.Tmin.value, 4)
        self.assertEqual(self.kinetics.Tmin.units, kinetics.Tmin.units)
        self.assertAlmostEqual(self.kinetics.Tmax.value, kinetics.Tmax.value, 4)
        self.assertEqual(self.kinetics.Tmax.units, kinetics.Tmax.units)
        self.assertEqual(self.kinetics.comment, kinetics.comment)

    def test_repr(self):
        """
        Test that a MultiArrhenius object can be reconstructed from its repr()
        output with no loss of information.
        """
        kinetics = None
        exec("kinetics = {0!r}".format(self.kinetics))
        self.assertEqual(len(self.kinetics.arrhenius), len(kinetics.arrhenius))
        for arrh0, arrh in zip(self.kinetics.arrhenius, kinetics.arrhenius):
            self.assertAlmostEqual(arrh0.A.value, arrh.A.value, delta=1e-18)
            self.assertEqual(arrh0.A.units, arrh.A.units)
            self.assertAlmostEqual(arrh0.n.value, arrh.n.value, 4)
            self.assertAlmostEqual(arrh0.Ea.value, arrh.Ea.value, 4)
            self.assertEqual(arrh0.Ea.units, arrh.Ea.units)
            self.assertAlmostEqual(arrh0.T0.value, arrh.T0.value, 4)
            self.assertEqual(arrh0.T0.units, arrh.T0.units)
        self.assertAlmostEqual(self.kinetics.Tmin.value, kinetics.Tmin.value, 4)
        self.assertEqual(self.kinetics.Tmin.units, kinetics.Tmin.units)
        self.assertAlmostEqual(self.kinetics.Tmax.value, kinetics.Tmax.value, 4)
        self.assertEqual(self.kinetics.Tmax.units, kinetics.Tmax.units)
        self.assertEqual(self.kinetics.comment, kinetics.comment)
Ejemplo n.º 7
0
class TestMultiArrhenius(unittest.TestCase):
    """
    Contains unit tests of the :class:`MultiArrhenius` class.
    """
    
    def setUp(self):
        """
        A function run before each unit test in this class.
        """
        self.Tmin = 350.
        self.Tmax = 1500.
        self.comment = 'Comment'
        self.arrhenius = [
            Arrhenius(
                A = (9.3e-14,"cm^3/(molecule*s)"),
                n = 0.0,
                Ea = (4740*constants.R*0.001,"kJ/mol"),
                T0 = (1,"K"),
                Tmin = (self.Tmin,"K"),
                Tmax = (self.Tmax,"K"),
                comment = self.comment,
            ),
            Arrhenius(
                A = (1.4e-9,"cm^3/(molecule*s)"),
                n = 0.0,
                Ea = (11200*constants.R*0.001,"kJ/mol"),
                T0 = (1,"K"),
                Tmin = (self.Tmin,"K"),
                Tmax = (self.Tmax,"K"),
                comment = self.comment,
            ),
        ]
        self.kinetics = MultiArrhenius(
            arrhenius = self.arrhenius,
            Tmin = (self.Tmin,"K"),
            Tmax = (self.Tmax,"K"),
            comment = self.comment,
        )
        self.single_kinetics = MultiArrhenius(
            arrhenius = self.arrhenius[:1],
            Tmin = (self.Tmin,"K"),
            Tmax = (self.Tmax,"K"),
            comment = self.comment,
        )
    
    def test_arrhenius(self):
        """
        Test that the MultiArrhenius A property was properly set.
        """
        self.assertEqual(self.kinetics.arrhenius, self.arrhenius)
        
    def test_Tmin(self):
        """
        Test that the MultiArrhenius Tmin property was properly set.
        """
        self.assertAlmostEqual(self.kinetics.Tmin.value_si, self.Tmin, 6)
        
    def test_Tmax(self):
        """
        Test that the MultiArrhenius Tmax property was properly set.
        """
        self.assertAlmostEqual(self.kinetics.Tmax.value_si, self.Tmax, 6)
        
    def test_comment(self):
        """
        Test that the MultiArrhenius comment property was properly set.
        """
        self.assertEqual(self.kinetics.comment, self.comment)
        
    def test_isTemperatureValid(self):
        """
        Test the MultiArrhenius.isTemperatureValid() method.
        """
        Tdata = numpy.array([200,400,600,800,1000,1200,1400,1600,1800,2000])
        validdata = numpy.array([False,True,True,True,True,True,True,False,False,False], numpy.bool)
        for T, valid in zip(Tdata, validdata):
            valid0 = self.kinetics.isTemperatureValid(T)
            self.assertEqual(valid0, valid)
                
    def test_getRateCoefficient(self):
        """
        Test the MultiArrhenius.getRateCoefficient() method.
        """
        Tlist = numpy.array([200,400,600,800,1000,1200,1400,1600,1800,2000])
        kexplist = numpy.array([2.85400e-06, 4.00384e-01, 2.73563e+01, 8.50699e+02, 1.20181e+04, 7.56312e+04, 2.84724e+05, 7.71702e+05, 1.67743e+06, 3.12290e+06])
        for T, kexp in zip(Tlist, kexplist):
            kact = self.kinetics.getRateCoefficient(T)
            self.assertAlmostEqual(kexp, kact, delta=1e-4*kexp)
        
    def test_pickle(self):
        """
        Test that a MultiArrhenius object can be pickled and unpickled with no loss
        of information.
        """
        import cPickle
        kinetics = cPickle.loads(cPickle.dumps(self.kinetics,-1))
        self.assertEqual(len(self.kinetics.arrhenius), len(kinetics.arrhenius))
        for arrh0, arrh in zip(self.kinetics.arrhenius, kinetics.arrhenius):
            self.assertAlmostEqual(arrh0.A.value, arrh.A.value, delta=1e-18)
            self.assertEqual(arrh0.A.units, arrh.A.units)
            self.assertAlmostEqual(arrh0.n.value, arrh.n.value, 4)
            self.assertAlmostEqual(arrh0.Ea.value, arrh.Ea.value, 4)
            self.assertEqual(arrh0.Ea.units, arrh.Ea.units)
            self.assertAlmostEqual(arrh0.T0.value, arrh.T0.value, 4)
            self.assertEqual(arrh0.T0.units, arrh.T0.units)
        self.assertAlmostEqual(self.kinetics.Tmin.value, kinetics.Tmin.value, 4)
        self.assertEqual(self.kinetics.Tmin.units, kinetics.Tmin.units)
        self.assertAlmostEqual(self.kinetics.Tmax.value, kinetics.Tmax.value, 4)
        self.assertEqual(self.kinetics.Tmax.units, kinetics.Tmax.units)
        self.assertEqual(self.kinetics.comment, kinetics.comment)
    
    def test_repr(self):
        """
        Test that a MultiArrhenius object can be reconstructed from its repr()
        output with no loss of information.
        """
        kinetics = None
        exec('kinetics = {0!r}'.format(self.kinetics))
        self.assertEqual(len(self.kinetics.arrhenius), len(kinetics.arrhenius))
        for arrh0, arrh in zip(self.kinetics.arrhenius, kinetics.arrhenius):
            self.assertAlmostEqual(arrh0.A.value, arrh.A.value, delta=1e-18)
            self.assertEqual(arrh0.A.units, arrh.A.units)
            self.assertAlmostEqual(arrh0.n.value, arrh.n.value, 4)
            self.assertAlmostEqual(arrh0.Ea.value, arrh.Ea.value, 4)
            self.assertEqual(arrh0.Ea.units, arrh.Ea.units)
            self.assertAlmostEqual(arrh0.T0.value, arrh.T0.value, 4)
            self.assertEqual(arrh0.T0.units, arrh.T0.units)
        self.assertAlmostEqual(self.kinetics.Tmin.value, kinetics.Tmin.value, 4)
        self.assertEqual(self.kinetics.Tmin.units, kinetics.Tmin.units)
        self.assertAlmostEqual(self.kinetics.Tmax.value, kinetics.Tmax.value, 4)
        self.assertEqual(self.kinetics.Tmax.units, kinetics.Tmax.units)
        self.assertEqual(self.kinetics.comment, kinetics.comment)
    
    def test_toArrhenius(self):
        """
        Test that we can convert to an Arrhenius
        """
        answer = self.single_kinetics.arrhenius[0]
        fitted = self.single_kinetics.toArrhenius()

        self.assertAlmostEqual(fitted.A.value_si, answer.A.value_si, delta=1e0)
        self.assertAlmostEqual(fitted.n.value_si, answer.n.value_si, 1, 4)
        self.assertAlmostEqual(fitted.Ea.value_si, answer.Ea.value_si, 2)
        self.assertAlmostEqual(fitted.T0.value_si, answer.T0.value_si, 4)

    def test_toArrheniusTrange(self):
        """
        Test the toArrhenius temperature range is set correctly.
        """
        answer = self.single_kinetics.arrhenius[0]
        fitted = self.single_kinetics.toArrhenius(Tmin=800, Tmax=1200)
        self.assertAlmostEqual(fitted.Tmin.value_si, 800.0)
        self.assertAlmostEqual(fitted.Tmax.value_si, 1200.0)
        for T in [800,1000,1200]:
            self.assertAlmostEqual(fitted.getRateCoefficient(T) / answer.getRateCoefficient(T), 1.0)

    def test_toArrheniusMultiple(self):
        """
        Test the toArrhenius fitting multiple kinetics over a small range, see if we're within 5% at a few points
        """
        answer = self.kinetics
        fitted = self.kinetics.toArrhenius(Tmin=800, Tmax=1200)
        self.assertAlmostEqual(fitted.Tmin.value_si, 800.0)
        self.assertAlmostEqual(fitted.Tmax.value_si, 1200.0)
        for T in [800,1000,1200]:
            self.assertAlmostEqual(fitted.getRateCoefficient(T) / answer.getRateCoefficient(T), 1.0, delta=0.05)
  
    def test_changeRate(self):
        """
        Test the MultiArrhenius.changeRate() method.
        """
        Tlist = numpy.array([300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500])
        k0list = numpy.array([self.kinetics.getRateCoefficient(T) for T in Tlist])
        self.kinetics.changeRate(2)
        for T, kexp in zip(Tlist, k0list):
            kact = self.kinetics.getRateCoefficient(T)
            self.assertAlmostEqual(2*kexp, kact, delta=1e-6*kexp)