def test_coulomb_two_noshift(self): coul = interaction.Coulomb(5.4, 1.0, "None") f = coul.pair_force(np.array([2.0, 0.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = coul.pair_energ(np.array([2.0, 0.0, 0.0]), np.array([0.0, 0.0, 0.0])) np.testing.assert_array_almost_equal(f, np.array([0.25, 0, 0])) np.testing.assert_almost_equal(e, 0.5) f = coul.pair_force(np.array([0.0, 1.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = coul.pair_energ(np.array([0.0, 1.0, 0.0]), np.array([0.0, 0.0, 0.0])) np.testing.assert_array_almost_equal(f, np.array([0, 1.0, 0])) np.testing.assert_almost_equal(e, 1.0) f = coul.pair_force(np.array([0.0, 7.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = coul.pair_energ(np.array([0.0, 7.0, 0.0]), np.array([0.0, 0.0, 0.0])) np.testing.assert_array_almost_equal(f, np.zeros(3)) np.testing.assert_almost_equal(e, 0.0)
def test_coulomb_two_displace(self): coul = interaction.Coulomb(5.4, 1.0, "Displace") vcut = 0.185185185185185 f = coul.pair_force(np.array([2.0, 0.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = coul.pair_energ(np.array([2.0, 0.0, 0.0]), np.array([0.0, 0.0, 0.0])) np.testing.assert_array_almost_equal(f, np.array([0.25, 0, 0])) np.testing.assert_almost_equal(e, 0.5 - vcut) f = coul.pair_force(np.array([0.0, 1.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = coul.pair_energ(np.array([0.0, 1.0, 0.0]), np.array([0.0, 0.0, 0.0])) np.testing.assert_array_almost_equal(f, np.array([0, 1.0, 0])) np.testing.assert_almost_equal(e, 1.0 - vcut) f = coul.pair_force(np.array([0.0, 7.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = coul.pair_energ(np.array([0.0, 7.0, 0.0]), np.array([0.0, 0.0, 0.0])) np.testing.assert_array_almost_equal(f, np.zeros(3)) np.testing.assert_almost_equal(e, 0.0)
def test_coulomb_forces_diff(self): coul = interaction.Coulomb(5.4, 1.0, "None") f, e = coul.forces(self.four_by3, self.four_by3, pairs=np.array([[0, 2], [0, 3], [1, 2], [1, 3]], dtype=np.int64)) force_by_hand = np.array([[1.0, 0.0, 0.0], [0.25, 0.0, 0.0], [-1.25, 0.0, 0.0], [0.0, 0.0, 0.0]]) np.testing.assert_array_almost_equal(f, force_by_hand)
def test_coulomb_forces_equal(self): coul = interaction.Coulomb(5.4, 1.0, "None") f, e = coul.forces(self.four_by3, self.four_by3) force_by_hand = np.array([[0.0, 0.0, 0.0], [1.25, 0.0, 0.0], [-1.25, 0.0, 0.0], [0.0, 0.0, 0.0]]) np.testing.assert_array_almost_equal(f, force_by_hand)
def test_create_coulomb(self): interaction.Coulomb(5.4, 1.0, "None")