Example #1
0
    def test_energies(self):
        q1 = 1
        q2 = 1
        epsilon = 1

        positions = [0, 0.2, 0.5, 1, 2, 360]
        expected_result = np.array([
            np.inf, 0.397887358, 0.159154943, 0.0795774715, 0.0397887358,
            0.000221048532
        ])

        potential = pot.coulombPotential(q1=q1, q2=q2, epsilon=epsilon)
        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=list(expected_result),
                                       actual=list(energies),
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #2
0
    def test_dHdpos(self):
        q1 = 1
        q2 = 1
        epsilon = 1

        positions = [0, 0.2, 0.5, 1, 2, 360]
        expected_result = np.array([
            -np.inf, -1.98943679, -0.31830988, -0.0795774715, -0.0198943679,
            -0.000000614023700
        ])

        potential = pot.coulombPotential(q1=q1, q2=q2, epsilon=epsilon)
        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_almost_equal(desired=list(expected_result),
                                       actual=list(energies),
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #3
0
 def test_constructor(self):
     potential = pot.coulombPotential()