def test_atomic_distance_different_lattice(): """Test that fractional and cartesian distances between atoms in different lattices raises an error.""" lattice1 = Lattice(np.eye(3)) lattice2 = Lattice(2 * np.eye(3)) atm1 = Atom("He", [0, 0, 0], lattice=lattice1) atm2 = Atom("He", [1, 0, 0], lattice=lattice2) with pytest.raises(RuntimeError): distance_fractional(atm1, atm2) with pytest.raises(RuntimeError): distance_cartesian(atm1, atm2)
def test_distance_different_lattice(self): """ Test that fractional and cartesian distances between atoms in different lattices raises an error. """ lattice1 = Lattice(np.eye(3)) lattice2 = Lattice(2 * np.eye(3)) atm1 = Atom("He", [0, 0, 0], lattice=lattice1) atm2 = Atom("He", [1, 0, 0], lattice=lattice2) with self.subTest("Fractional distance"): with self.assertRaises(RuntimeError): distance_fractional(atm1, atm2) with self.subTest("Cartesian distance"): with self.assertRaises(RuntimeError): distance_cartesian(atm1, atm2)
def test_distance_cartesian(self): """ Test the cartesian distance between atom """ lattice = Lattice(4 * np.eye(3)) # Cubic lattice side length 4 angs atm1 = Atom("He", [0, 0, 0], lattice=lattice) atm2 = Atom("He", [1, 0, 0], lattice=lattice) self.assertEqual(distance_cartesian(atm1, atm2), 4.0)
def test_atomic_distance_cartesian(): """Test the cartesian distance between atom""" lattice = Lattice(4 * np.eye(3)) # Cubic lattice side length 4 angs atm1 = Atom("He", [0, 0, 0], lattice=lattice) atm2 = Atom("He", [1, 0, 0], lattice=lattice) assert distance_cartesian(atm1, atm2) == 4.0