def test_lj_forces_diff(self): lj = interaction.LennardJones(5.4, 1.0, 1.0, "None") f, e = lj.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([[24.0, 0.0, 0.0], [-0.181641, 0.0, 0.0], [-23.818359, 0.0, 0.0], [0.0, 0.0, 0.0]]) np.testing.assert_array_almost_equal(f, force_by_hand)
def test_lj_two_noshift(self): lj = interaction.LennardJones(5.4, 1.0, 1.0, "None") f = lj.pair_force(np.array([2.0**(1.0 / 6), 0.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = lj.pair_energ(np.array([2.0**(1.0 / 6), 0.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, -1.0) f = lj.pair_force(np.array([0.0, 1.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = lj.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, 24, 0])) np.testing.assert_almost_equal(e, 0.0) f = lj.pair_force(np.array([0.0, 7.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = lj.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_lj_two_displace(self): lj = interaction.LennardJones(5.4, 1.0, 1.0, "Displace") vcut = -0.0001613169181702531 f = lj.pair_force(np.array([2.0**(1.0 / 6), 0.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = lj.pair_energ(np.array([2.0**(1.0 / 6), 0.0, 0.0]), np.array([0.0, 0.0, 0.0])) np.testing.assert_almost_equal(e, -1.0 - vcut) np.testing.assert_array_almost_equal(f, np.zeros(3)) f = lj.pair_force(np.array([0.0, 1.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = lj.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, 24, 0])) np.testing.assert_almost_equal(e, 0.0 - vcut) f = lj.pair_force(np.array([0.0, 7.0, 0.0]), np.array([0.0, 0.0, 0.0])) e = lj.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_lj_forces_equal(self): lj = interaction.LennardJones([1, 1], 5.4, 1.0, 1.0, "None") f, e = lj.forces(self.four_by3, self.four_by3, self.four_type) force_by_hand = np.array([[0.0, 0.0, 0.0], [23.818359, 0.0, 0.0], [-23.818359, 0.0, 0.0], [0.0, 0.0, 0.0]]) np.testing.assert_array_almost_equal(f, force_by_hand)
def test_create_lennardjones(self): interaction.LennardJones([1, 1], 5.4, 1.0, 1.0, "None")