Exemplo n.º 1
0
 def setUp(self):
     """
     A function run before each unit test in this class.
     """
     self.inertia = 11.75
     self.symmetry = 2
     self.quantum = False
     self.mode = KRotor(
         inertia=(self.inertia, "amu*angstrom^2"),
         symmetry=self.symmetry,
         quantum=self.quantum,
     )
Exemplo n.º 2
0
 def setUp(self):
     """
     A function run before each unit test in this class.
     """
     self.inertia = 11.75
     self.symmetry = 2
     self.quantum = False
     self.mode = KRotor(inertia=(self.inertia, "amu*angstrom^2"), symmetry=self.symmetry, quantum=self.quantum)
Exemplo n.º 3
0
class TestKRotor(unittest.TestCase):
    """
    Contains unit tests of the KRotor class.
    """
    def setUp(self):
        """
        A function run before each unit test in this class.
        """
        self.inertia = 11.75
        self.symmetry = 2
        self.quantum = False
        self.mode = KRotor(
            inertia=(self.inertia, "amu*angstrom^2"),
            symmetry=self.symmetry,
            quantum=self.quantum,
        )

    def test_getRotationalConstant(self):
        """
        Test getting the KRotor.rotationalConstant property.
        """
        Bexp = 1.434692
        Bact = self.mode.rotationalConstant.value_si
        self.assertAlmostEqual(Bexp, Bact, 4)

    def test_setRotationalConstant(self):
        """
        Test setting the KRotor.rotationalConstant property.
        """
        B = self.mode.rotationalConstant
        B.value_si *= 2
        self.mode.rotationalConstant = B
        Iexp = 0.5 * self.inertia
        Iact = self.mode.inertia.value_si * constants.Na * 1e23
        self.assertAlmostEqual(Iexp, Iact, 4)

    def test_getLevelEnergy(self):
        """
        Test the KRotor.getLevelEnergy() method.
        """
        B = self.mode.rotationalConstant.value_si * constants.h * constants.c * 100.
        B *= constants.Na
        for J in range(0, 100):
            Eexp = float(B * J * J)
            Eact = float(self.mode.getLevelEnergy(J))
            if J == 0:
                self.assertEqual(Eact, 0)
            else:
                self.assertAlmostEqual(Eexp, Eact, delta=1e-4 * Eexp)

    def test_getLevelDegeneracy(self):
        """
        Test the KRotor.getLevelDegeneracy() method.
        """
        for J in range(0, 100):
            gexp = 1 if J == 0 else 2
            gact = self.mode.getLevelDegeneracy(J)
            self.assertEqual(gexp, gact, '{0} != {1}'.format(gact, gexp))

    def test_getPartitionFunction_classical(self):
        """
        Test the KRotor.getPartitionFunction() method for a classical
        rotor.
        """
        self.mode.quantum = False
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Qexplist = numpy.array([10.6839, 13.7929, 19.5060, 23.8899, 27.5857])
        for T, Qexp in zip(Tlist, Qexplist):
            Qact = self.mode.getPartitionFunction(T)
            self.assertAlmostEqual(Qexp, Qact, delta=1e-4 * Qexp)

    def test_getPartitionFunction_quantum(self):
        """
        Test the KRotor.getPartitionFunction() method for a quantum
        rotor.
        """
        self.mode.quantum = True
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Qexplist = numpy.array([10.6839, 13.7929, 19.5060, 23.8899, 27.5857])
        for T, Qexp in zip(Tlist, Qexplist):
            Qact = self.mode.getPartitionFunction(T)
            self.assertAlmostEqual(Qexp, Qact, delta=1e-4 * Qexp)

    def test_getHeatCapacity_classical(self):
        """
        Test the KRotor.getHeatCapacity() method using a classical rotor.
        """
        self.mode.quantum = False
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Cvexplist = numpy.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R
        for T, Cvexp in zip(Tlist, Cvexplist):
            Cvact = self.mode.getHeatCapacity(T)
            self.assertAlmostEqual(Cvexp, Cvact, delta=1e-4 * Cvexp)

    def test_getHeatCapacity_quantum(self):
        """
        Test the KRotor.getHeatCapacity() method using a quantum rotor.
        """
        self.mode.quantum = True
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Cvexplist = numpy.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R
        for T, Cvexp in zip(Tlist, Cvexplist):
            Cvact = self.mode.getHeatCapacity(T)
            self.assertAlmostEqual(Cvexp, Cvact, delta=1e-4 * Cvexp)

    def test_getEnthalpy_classical(self):
        """
        Test the KRotor.getEnthalpy() method using a classical rotor.
        """
        self.mode.quantum = False
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Hexplist = numpy.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R * Tlist
        for T, Hexp in zip(Tlist, Hexplist):
            Hact = self.mode.getEnthalpy(T)
            self.assertAlmostEqual(Hexp, Hact, delta=1e-4 * Hexp)

    def test_getEnthalpy_quantum(self):
        """
        Test the KRotor.getEnthalpy() method using a quantum rotor.
        """
        self.mode.quantum = True
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Hexplist = numpy.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R * Tlist
        for T, Hexp in zip(Tlist, Hexplist):
            Hact = self.mode.getEnthalpy(T)
            self.assertAlmostEqual(Hexp, Hact, delta=1e-4 * Hexp)

    def test_getEntropy_classical(self):
        """
        Test the KRotor.getEntropy() method using a classical rotor.
        """
        self.mode.quantum = False
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Sexplist = numpy.array([2.86874, 3.12415, 3.47072, 3.67346, 3.81730
                                ]) * constants.R
        for T, Sexp in zip(Tlist, Sexplist):
            Sact = self.mode.getEntropy(T)
            self.assertAlmostEqual(Sexp, Sact, delta=1e-4 * Sexp)

    def test_getEntropy_quantum(self):
        """
        Test the KRotor.getEntropy() method using a quantum rotor.
        """
        self.mode.quantum = True
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Sexplist = numpy.array([2.86874, 3.12415, 3.47072, 3.67346, 3.81730
                                ]) * constants.R
        for T, Sexp in zip(Tlist, Sexplist):
            Sact = self.mode.getEntropy(T)
            self.assertAlmostEqual(Sexp, Sact, delta=1e-4 * Sexp)

    def test_getSumOfStates_classical(self):
        """
        Test the KRotor.getSumOfStates() method using a classical rotor.
        """
        self.mode.quantum = False
        Elist = numpy.arange(0, 1000 * 11.96, 1 * 11.96)
        sumStates = self.mode.getSumOfStates(Elist)
        densStates = self.mode.getDensityOfStates(Elist)
        for n in range(10, len(Elist)):
            self.assertTrue(
                0.75 < numpy.sum(densStates[0:n + 1]) / sumStates[n] < 1.3333,
                '{0} != {1}'.format(numpy.sum(densStates[0:n + 1]),
                                    sumStates[n]))

    def test_getSumOfStates_quantum(self):
        """
        Test the KRotor.getSumOfStates() method using a quantum rotor.
        """
        self.mode.quantum = True
        Elist = numpy.arange(0, 1000 * 11.96, 1 * 11.96)
        sumStates = self.mode.getSumOfStates(Elist)
        densStates = self.mode.getDensityOfStates(Elist)
        for n in range(10, len(Elist)):
            self.assertTrue(
                0.8 < numpy.sum(densStates[0:n + 1]) / sumStates[n] < 1.25,
                '{0} != {1}'.format(numpy.sum(densStates[0:n + 1]),
                                    sumStates[n]))

    def test_getDensityOfStates_classical(self):
        """
        Test the KRotor.getDensityOfStates() method using a classical
        rotor.
        """
        self.mode.quantum = False
        Elist = numpy.arange(0, 3000 * 11.96, 0.05 * 11.96)
        densStates = self.mode.getDensityOfStates(Elist)
        T = 500
        Qact = numpy.sum(densStates * numpy.exp(-Elist / constants.R / T))
        Qexp = self.mode.getPartitionFunction(T)
        self.assertAlmostEqual(Qexp, Qact, delta=1e-2 * Qexp)

    def test_getDensityOfStates_quantum(self):
        """
        Test the KRotor.getDensityOfStates() method using a quantum rotor.
        """
        self.mode.quantum = True
        Elist = numpy.arange(0, 4000 * 11.96, 2 * 11.96)
        densStates = self.mode.getDensityOfStates(Elist)
        T = 500
        Qact = numpy.sum(densStates * numpy.exp(-Elist / constants.R / T))
        Qexp = self.mode.getPartitionFunction(T)
        self.assertAlmostEqual(Qexp, Qact, delta=1e-2 * Qexp)

    def test_repr(self):
        """
        Test that a KRotor object can be reconstructed from its repr() output
        with no loss of information.
        """
        mode = None
        exec('mode = {0!r}'.format(self.mode))
        self.assertAlmostEqual(self.mode.inertia.value, mode.inertia.value, 6)
        self.assertEqual(self.mode.inertia.units, mode.inertia.units)
        self.assertEqual(self.mode.symmetry, mode.symmetry)
        self.assertEqual(self.mode.quantum, mode.quantum)

    def test_pickle(self):
        """
        Test that a KRotor object can be pickled and unpickled with no loss
        of information.
        """
        import cPickle
        mode = cPickle.loads(cPickle.dumps(self.mode, -1))
        self.assertAlmostEqual(self.mode.inertia.value, mode.inertia.value, 6)
        self.assertEqual(self.mode.inertia.units, mode.inertia.units)
        self.assertEqual(self.mode.symmetry, mode.symmetry)
        self.assertEqual(self.mode.quantum, mode.quantum)
Exemplo n.º 4
0
class TestKRotor(unittest.TestCase):
    """
    Contains unit tests of the KRotor class.
    """

    def setUp(self):
        """
        A function run before each unit test in this class.
        """
        self.inertia = 11.75
        self.symmetry = 2
        self.quantum = False
        self.mode = KRotor(inertia=(self.inertia, "amu*angstrom^2"), symmetry=self.symmetry, quantum=self.quantum)

    def test_getRotationalConstant(self):
        """
        Test getting the KRotor.rotationalConstant property.
        """
        Bexp = 1.434692
        Bact = self.mode.rotationalConstant.value_si
        self.assertAlmostEqual(Bexp, Bact, 4)

    def test_setRotationalConstant(self):
        """
        Test setting the KRotor.rotationalConstant property.
        """
        B = self.mode.rotationalConstant
        B.value_si *= 2
        self.mode.rotationalConstant = B
        Iexp = 0.5 * self.inertia
        Iact = self.mode.inertia.value_si * constants.Na * 1e23
        self.assertAlmostEqual(Iexp, Iact, 4)

    def test_getLevelEnergy(self):
        """
        Test the KRotor.getLevelEnergy() method.
        """
        B = self.mode.rotationalConstant.value_si * constants.h * constants.c * 100.0
        B *= constants.Na
        for J in range(0, 100):
            Eexp = float(B * J * J)
            Eact = float(self.mode.getLevelEnergy(J))
            if J == 0:
                self.assertEqual(Eact, 0)
            else:
                self.assertAlmostEqual(Eexp, Eact, delta=1e-4 * Eexp)

    def test_getLevelDegeneracy(self):
        """
        Test the KRotor.getLevelDegeneracy() method.
        """
        for J in range(0, 100):
            gexp = 1 if J == 0 else 2
            gact = self.mode.getLevelDegeneracy(J)
            self.assertEqual(gexp, gact, "{0} != {1}".format(gact, gexp))

    def test_getPartitionFunction_classical(self):
        """
        Test the KRotor.getPartitionFunction() method for a classical
        rotor.
        """
        self.mode.quantum = False
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Qexplist = numpy.array([10.6839, 13.7929, 19.5060, 23.8899, 27.5857])
        for T, Qexp in zip(Tlist, Qexplist):
            Qact = self.mode.getPartitionFunction(T)
            self.assertAlmostEqual(Qexp, Qact, delta=1e-4 * Qexp)

    def test_getPartitionFunction_quantum(self):
        """
        Test the KRotor.getPartitionFunction() method for a quantum
        rotor.
        """
        self.mode.quantum = True
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Qexplist = numpy.array([10.6839, 13.7929, 19.5060, 23.8899, 27.5857])
        for T, Qexp in zip(Tlist, Qexplist):
            Qact = self.mode.getPartitionFunction(T)
            self.assertAlmostEqual(Qexp, Qact, delta=1e-4 * Qexp)

    def test_getHeatCapacity_classical(self):
        """
        Test the KRotor.getHeatCapacity() method using a classical rotor.
        """
        self.mode.quantum = False
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Cvexplist = numpy.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R
        for T, Cvexp in zip(Tlist, Cvexplist):
            Cvact = self.mode.getHeatCapacity(T)
            self.assertAlmostEqual(Cvexp, Cvact, delta=1e-4 * Cvexp)

    def test_getHeatCapacity_quantum(self):
        """
        Test the KRotor.getHeatCapacity() method using a quantum rotor.
        """
        self.mode.quantum = True
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Cvexplist = numpy.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R
        for T, Cvexp in zip(Tlist, Cvexplist):
            Cvact = self.mode.getHeatCapacity(T)
            self.assertAlmostEqual(Cvexp, Cvact, delta=1e-4 * Cvexp)

    def test_getEnthalpy_classical(self):
        """
        Test the KRotor.getEnthalpy() method using a classical rotor.
        """
        self.mode.quantum = False
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Hexplist = numpy.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R * Tlist
        for T, Hexp in zip(Tlist, Hexplist):
            Hact = self.mode.getEnthalpy(T)
            self.assertAlmostEqual(Hexp, Hact, delta=1e-4 * Hexp)

    def test_getEnthalpy_quantum(self):
        """
        Test the KRotor.getEnthalpy() method using a quantum rotor.
        """
        self.mode.quantum = True
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Hexplist = numpy.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R * Tlist
        for T, Hexp in zip(Tlist, Hexplist):
            Hact = self.mode.getEnthalpy(T)
            self.assertAlmostEqual(Hexp, Hact, delta=1e-4 * Hexp)

    def test_getEntropy_classical(self):
        """
        Test the KRotor.getEntropy() method using a classical rotor.
        """
        self.mode.quantum = False
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Sexplist = numpy.array([2.86874, 3.12415, 3.47072, 3.67346, 3.81730]) * constants.R
        for T, Sexp in zip(Tlist, Sexplist):
            Sact = self.mode.getEntropy(T)
            self.assertAlmostEqual(Sexp, Sact, delta=1e-4 * Sexp)

    def test_getEntropy_quantum(self):
        """
        Test the KRotor.getEntropy() method using a quantum rotor.
        """
        self.mode.quantum = True
        Tlist = numpy.array([300, 500, 1000, 1500, 2000])
        Sexplist = numpy.array([2.86874, 3.12415, 3.47072, 3.67346, 3.81730]) * constants.R
        for T, Sexp in zip(Tlist, Sexplist):
            Sact = self.mode.getEntropy(T)
            self.assertAlmostEqual(Sexp, Sact, delta=1e-4 * Sexp)

    def test_getSumOfStates_classical(self):
        """
        Test the KRotor.getSumOfStates() method using a classical rotor.
        """
        self.mode.quantum = False
        Elist = numpy.arange(0, 1000 * 11.96, 1 * 11.96)
        sumStates = self.mode.getSumOfStates(Elist)
        densStates = self.mode.getDensityOfStates(Elist)
        for n in range(10, len(Elist)):
            self.assertTrue(
                0.75 < numpy.sum(densStates[0 : n + 1]) / sumStates[n] < 1.3333,
                "{0} != {1}".format(numpy.sum(densStates[0 : n + 1]), sumStates[n]),
            )

    def test_getSumOfStates_quantum(self):
        """
        Test the KRotor.getSumOfStates() method using a quantum rotor.
        """
        self.mode.quantum = True
        Elist = numpy.arange(0, 1000 * 11.96, 1 * 11.96)
        sumStates = self.mode.getSumOfStates(Elist)
        densStates = self.mode.getDensityOfStates(Elist)
        for n in range(10, len(Elist)):
            self.assertTrue(
                0.8 < numpy.sum(densStates[0 : n + 1]) / sumStates[n] < 1.25,
                "{0} != {1}".format(numpy.sum(densStates[0 : n + 1]), sumStates[n]),
            )

    def test_getDensityOfStates_classical(self):
        """
        Test the KRotor.getDensityOfStates() method using a classical
        rotor.
        """
        self.mode.quantum = False
        Elist = numpy.arange(0, 3000 * 11.96, 0.05 * 11.96)
        densStates = self.mode.getDensityOfStates(Elist)
        T = 500
        Qact = numpy.sum(densStates * numpy.exp(-Elist / constants.R / T))
        Qexp = self.mode.getPartitionFunction(T)
        self.assertAlmostEqual(Qexp, Qact, delta=1e-2 * Qexp)

    def test_getDensityOfStates_quantum(self):
        """
        Test the KRotor.getDensityOfStates() method using a quantum rotor.
        """
        self.mode.quantum = True
        Elist = numpy.arange(0, 4000 * 11.96, 2 * 11.96)
        densStates = self.mode.getDensityOfStates(Elist)
        T = 500
        Qact = numpy.sum(densStates * numpy.exp(-Elist / constants.R / T))
        Qexp = self.mode.getPartitionFunction(T)
        self.assertAlmostEqual(Qexp, Qact, delta=1e-2 * Qexp)

    def test_repr(self):
        """
        Test that a KRotor object can be reconstructed from its repr() output
        with no loss of information.
        """
        mode = None
        exec("mode = {0!r}".format(self.mode))
        self.assertAlmostEqual(self.mode.inertia.value, mode.inertia.value, 6)
        self.assertEqual(self.mode.inertia.units, mode.inertia.units)
        self.assertEqual(self.mode.symmetry, mode.symmetry)
        self.assertEqual(self.mode.quantum, mode.quantum)

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

        mode = cPickle.loads(cPickle.dumps(self.mode, -1))
        self.assertAlmostEqual(self.mode.inertia.value, mode.inertia.value, 6)
        self.assertEqual(self.mode.inertia.units, mode.inertia.units)
        self.assertEqual(self.mode.symmetry, mode.symmetry)
        self.assertEqual(self.mode.quantum, mode.quantum)
Exemplo n.º 5
0
class TestKRotor(unittest.TestCase):
    """
    Contains unit tests of the KRotor class.
    """
    def setUp(self):
        """
        A function run before each unit test in this class.
        """
        self.inertia = 11.75
        self.symmetry = 2
        self.quantum = False
        self.mode = KRotor(
            inertia=(self.inertia, "amu*angstrom^2"),
            symmetry=self.symmetry,
            quantum=self.quantum,
        )

    def test_get_rotational_constant(self):
        """
        Test getting the KRotor.rotationalConstant property.
        """
        b_exp = 1.434692
        b_act = self.mode.rotationalConstant.value_si
        self.assertAlmostEqual(b_exp, b_act, 4)

    def test_set_rotational_constant(self):
        """
        Test setting the KRotor.rotationalConstant property.
        """
        rotational_constant = self.mode.rotationalConstant
        rotational_constant.value_si *= 2
        self.mode.rotationalConstant = rotational_constant
        i_exp = 0.5 * self.inertia
        i_act = self.mode.inertia.value_si * constants.Na * 1e23
        self.assertAlmostEqual(i_exp, i_act, 4)

    def test_get_level_energy(self):
        """
        Test the KRotor.get_level_energy() method.
        """
        rotational_constant = self.mode.rotationalConstant.value_si * constants.h * constants.c * 100.
        rotational_constant *= constants.Na
        for j in range(0, 100):
            e_exp = float(rotational_constant * j * j)
            e_act = float(self.mode.get_level_energy(j))
            if j == 0:
                self.assertEqual(e_act, 0)
            else:
                self.assertAlmostEqual(e_exp, e_act, delta=1e-4 * e_exp)

    def test_get_level_degeneracy(self):
        """
        Test the KRotor.get_level_degeneracy() method.
        """
        for j in range(0, 100):
            g_exp = 1 if j == 0 else 2
            g_act = self.mode.get_level_degeneracy(j)
            self.assertEqual(g_exp, g_act, '{0} != {1}'.format(g_act, g_exp))

    def test_get_partition_function_classical(self):
        """
        Test the KRotor.get_partition_function() method for a classical
        rotor.
        """
        self.mode.quantum = False
        t_list = np.array([300, 500, 1000, 1500, 2000])
        q_exp_list = np.array([10.6839, 13.7929, 19.5060, 23.8899, 27.5857])
        for temperature, q_exp in zip(t_list, q_exp_list):
            q_act = self.mode.get_partition_function(temperature)
            self.assertAlmostEqual(q_exp, q_act, delta=1e-4 * q_exp)

    def test_get_partition_function_quantum(self):
        """
        Test the KRotor.get_partition_function() method for a quantum
        rotor.
        """
        self.mode.quantum = True
        t_list = np.array([300, 500, 1000, 1500, 2000])
        q_exp_list = np.array([10.6839, 13.7929, 19.5060, 23.8899, 27.5857])
        for temperature, q_exp in zip(t_list, q_exp_list):
            q_act = self.mode.get_partition_function(temperature)
            self.assertAlmostEqual(q_exp, q_act, delta=1e-4 * q_exp)

    def test_get_heat_capacity_classical(self):
        """
        Test the KRotor.get_heat_capacity() method using a classical rotor.
        """
        self.mode.quantum = False
        t_list = np.array([300, 500, 1000, 1500, 2000])
        cv_exp_list = np.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R
        for temperature, cv_exp in zip(t_list, cv_exp_list):
            cv_act = self.mode.get_heat_capacity(temperature)
            self.assertAlmostEqual(cv_exp, cv_act, delta=1e-4 * cv_exp)

    def test_get_heat_capacity_quantum(self):
        """
        Test the KRotor.get_heat_capacity() method using a quantum rotor.
        """
        self.mode.quantum = True
        t_list = np.array([300, 500, 1000, 1500, 2000])
        cv_exp_list = np.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R
        for temperature, cv_exp in zip(t_list, cv_exp_list):
            cv_act = self.mode.get_heat_capacity(temperature)
            self.assertAlmostEqual(cv_exp, cv_act, delta=1e-4 * cv_exp)

    def test_get_enthalpy_classical(self):
        """
        Test the KRotor.get_enthalpy() method using a classical rotor.
        """
        self.mode.quantum = False
        t_list = np.array([300, 500, 1000, 1500, 2000])
        h_exp_list = np.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R * t_list
        for temperature, h_exp in zip(t_list, h_exp_list):
            h_act = self.mode.get_enthalpy(temperature)
            self.assertAlmostEqual(h_exp, h_act, delta=1e-4 * h_exp)

    def test_get_enthalpy_quantum(self):
        """
        Test the KRotor.get_enthalpy() method using a quantum rotor.
        """
        self.mode.quantum = True
        t_list = np.array([300, 500, 1000, 1500, 2000])
        h_exp_list = np.array([0.5, 0.5, 0.5, 0.5, 0.5]) * constants.R * t_list
        for temperature, h_exp in zip(t_list, h_exp_list):
            h_act = self.mode.get_enthalpy(temperature)
            self.assertAlmostEqual(h_exp, h_act, delta=1e-4 * h_exp)

    def test_get_entropy_classical(self):
        """
        Test the KRotor.get_entropy() method using a classical rotor.
        """
        self.mode.quantum = False
        t_list = np.array([300, 500, 1000, 1500, 2000])
        s_exp_list = np.array([2.86874, 3.12415, 3.47072, 3.67346, 3.81730
                               ]) * constants.R
        for temperature, s_exp in zip(t_list, s_exp_list):
            s_act = self.mode.get_entropy(temperature)
            self.assertAlmostEqual(s_exp, s_act, delta=1e-4 * s_exp)

    def test_get_entropy_quantum(self):
        """
        Test the KRotor.get_entropy() method using a quantum rotor.
        """
        self.mode.quantum = True
        t_list = np.array([300, 500, 1000, 1500, 2000])
        s_exp_list = np.array([2.86874, 3.12415, 3.47072, 3.67346, 3.81730
                               ]) * constants.R
        for temperature, s_exp in zip(t_list, s_exp_list):
            s_act = self.mode.get_entropy(temperature)
            self.assertAlmostEqual(s_exp, s_act, delta=1e-4 * s_exp)

    def test_get_sum_of_states_classical(self):
        """
        Test the KRotor.get_sum_of_states() method using a classical rotor.
        """
        self.mode.quantum = False
        e_list = np.arange(0, 1000 * 11.96, 1 * 11.96)
        sum_states = self.mode.get_sum_of_states(e_list)
        dens_states = self.mode.get_density_of_states(e_list)
        for n in range(10, len(e_list)):
            self.assertTrue(
                0.75 < np.sum(dens_states[0:n + 1]) / sum_states[n] < 1.3333,
                '{0} != {1}'.format(np.sum(dens_states[0:n + 1]),
                                    sum_states[n]))

    def test_get_sum_of_states_quantum(self):
        """
        Test the KRotor.get_sum_of_states() method using a quantum rotor.
        """
        self.mode.quantum = True
        e_list = np.arange(0, 1000 * 11.96, 1 * 11.96)
        sum_states = self.mode.get_sum_of_states(e_list)
        dens_states = self.mode.get_density_of_states(e_list)
        for n in range(10, len(e_list)):
            self.assertTrue(
                0.8 < np.sum(dens_states[0:n + 1]) / sum_states[n] < 1.25,
                '{0} != {1}'.format(np.sum(dens_states[0:n + 1]),
                                    sum_states[n]))

    def test_get_density_of_states_classical(self):
        """
        Test the KRotor.get_density_of_states() method using a classical
        rotor.
        """
        self.mode.quantum = False
        e_list = np.arange(0, 3000 * 11.96, 0.05 * 11.96)
        dens_states = self.mode.get_density_of_states(e_list)
        temperature = 500
        q_act = np.sum(dens_states *
                       np.exp(-e_list / constants.R / temperature))
        q_exp = self.mode.get_partition_function(temperature)
        self.assertAlmostEqual(q_exp, q_act, delta=1e-2 * q_exp)

    def test_get_density_of_states_quantum(self):
        """
        Test the KRotor.get_density_of_states() method using a quantum rotor.
        """
        self.mode.quantum = True
        e_list = np.arange(0, 4000 * 11.96, 2 * 11.96)
        dens_states = self.mode.get_density_of_states(e_list)
        temperature = 500
        q_act = np.sum(dens_states *
                       np.exp(-e_list / constants.R / temperature))
        q_exp = self.mode.get_partition_function(temperature)
        self.assertAlmostEqual(q_exp, q_act, delta=1e-2 * q_exp)

    def test_repr(self):
        """
        Test that a KRotor object can be reconstructed from its repr() output
        with no loss of information.
        """
        namespace = {}
        exec('mode = {0!r}'.format(self.mode), globals(), namespace)
        self.assertIn('mode', namespace)
        mode = namespace['mode']
        self.assertAlmostEqual(self.mode.inertia.value, mode.inertia.value, 6)
        self.assertEqual(self.mode.inertia.units, mode.inertia.units)
        self.assertEqual(self.mode.symmetry, mode.symmetry)
        self.assertEqual(self.mode.quantum, mode.quantum)

    def test_pickle(self):
        """
        Test that a KRotor object can be pickled and unpickled with no loss
        of information.
        """
        import pickle
        mode = pickle.loads(pickle.dumps(self.mode, -1))
        self.assertAlmostEqual(self.mode.inertia.value, mode.inertia.value, 6)
        self.assertEqual(self.mode.inertia.units, mode.inertia.units)
        self.assertEqual(self.mode.symmetry, mode.symmetry)
        self.assertEqual(self.mode.quantum, mode.quantum)