Пример #1
0
def test_gvectors_fcc():
    from numpy import array, allclose, sqrt
    from numpy.linalg import norm
    from itertools import chain
    from pylada.crystal import _space_group

    cell = array([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]])
    result = _space_group.__gvectors(cell, 1e-12)
    assert len(result) == 3
    assert len(result[0]) > 0
    assert len(result[0]) == len(result[1])
    assert len(result[0]) == len(result[2])
    # check directions are equivalent and each vector is unique
    for vectors in result:
        for vector in vectors:
            assert sum([allclose(u, vector) for u in result[0]]) == 1

    for vector in result[0]:
        assert abs(norm(vector) - 0.5 * sqrt(2.)) < 1e-8
Пример #2
0
def test_gvectors_non_fcc():
    from numpy import array, allclose, sqrt
    from numpy.linalg import norm
    from itertools import chain
    from pylada.crystal import _space_group

    cell = array([[0.6, 0.5, 0.5], [0.6, -0.5, 0.5], [0.6, 0.5, -0.5]])
    result = _space_group.__gvectors(cell, 1e-12)
    assert len(result) == 3
    assert len(result[0]) > 0
    assert len(result[1]) == len(result[2])
    # check directions 1 and 2 are equivalent
    for vector in result[1]:
        assert sum([allclose(u, vector) for u in result[2]]) == 1
    # check unicity
    for vector in result[0]:
        assert sum([allclose(u, vector) for u in result[0]]) == 1
    for vector in result[1]:
        assert sum([allclose(u, vector) for u in result[1]]) == 1

    for vector in result[0]:
        assert abs(norm(vector) - 0.6 * sqrt(3.)) < 1e-8
    for vector in result[1]:
        assert abs(norm(vector) - 0.5 * sqrt(3.)) < 1e-8