Example #1
0
    def test_energies(self):
        c6: float = 1**(-1)
        c12: float = 1**(-1)
        x_shift: float = 0
        y_shift = 0

        positions = [0, 0.1, 0.2, 0.5, 1, 2, 3, 6]
        expected_result = np.array([
            np.nan, 9.99999000 * 10**11, 2.44125000 * 10**8,
            4.03200000 * 10**3, 0, -1.53808594 * 10**-2, -1.36986044 * 10**-3,
            -2.14330111 * 10**-5
        ])

        potential = pot.lennardJonesPotential(c6=c6,
                                              c12=c12,
                                              x_shift=x_shift,
                                              y_shift=y_shift)
        energies = potential.ene(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=expected_result,
                                       actual=energies,
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=2)
Example #2
0
    def test_dHdpos(self):
        c6: float = 1**(-1)
        c12: float = 1**(-1)
        x_shift: float = 0
        y_shift = 0

        positions = [0, 0.1, 0.2, 0.5, 1, 2, 3, 6]
        expected_result = np.array([
            np.inf, 1.19999940 * 10**14, 1.46479687 * 10**10,
            9.75360000 * 10**4, 6.00000000, -4.54101562 * 10**-2,
            -2.73595752 * 10**-3, -2.14325517 * 10**-5
        ])

        potential = pot.lennardJonesPotential(c6=c6,
                                              c12=c12,
                                              x_shift=x_shift,
                                              y_shift=y_shift)
        energies = potential.dhdpos(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_allclose(desired=expected_result,
                                   actual=energies,
                                   err_msg="The results of " + potential.name +
                                   " are not correct!")
Example #3
0
 def test_constructor(self):
     potential = pot.lennardJonesPotential()