Beispiel #1
0
def test_back_and_forth():
    """Test that Lattice.miller_indices and Lattice.scattering_vector are
    reciprocal to each other"""
    lattice = Lattice(np.random.random((3, 3)))
    h, k, l = np.random.randint(-10, 10, size=(3, ))
    vector = lattice.scattering_vector((h, k, l))
    hp, kp, lp = lattice.miller_indices(vector)

    assert round(abs(h - float(hp)), 7) == 0
    assert round(abs(k - float(kp)), 7) == 0
    assert round(abs(l - float(lp)), 7) == 0
Beispiel #2
0
def test_scattering_vector_table():
    """ Test that Lattice.scattering_vector is working on tables of reflections """
    lattice = Lattice(2 * np.pi * np.eye(3))
    vectors = np.random.random(size=(10, 3))
    assert np.allclose(lattice.scattering_vector(vectors), vectors)
Beispiel #3
0
def test_scattering_vector_trivial():
    """ Test that Lattice.scattering_vectors is working """
    lattice = Lattice(np.random.random((3, 3)))
    assert np.allclose(lattice.scattering_vector((0, 0, 0)), ((0, 0, 0)))