예제 #1
0
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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #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