Exemplo n.º 1
0
 def test_distance_fractional(self):
     """ Test the fractional distance between atoms """
     atm1 = Atom("He", [0, 0, 0])
     atm2 = Atom("He", [1, 0, 0])
     self.assertEqual(distance_fractional(atm1, atm2), 1)
     self.assertEqual(distance_fractional(atm1, atm2),
                      distance_fractional(atm2, atm1))
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
def test_atomic_distance_fractional():
    """Test the fractional distance between atoms"""
    atm1 = Atom("He", [0, 0, 0])
    atm2 = Atom("He", [1, 0, 0])
    assert distance_fractional(atm1, atm2) == 1
    assert distance_fractional(atm1, atm2) == distance_fractional(atm2, atm1)