コード例 #1
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_monoclinic_lattice_system():
    """Test that the Lattice.lattice_system attribute is working properly for monoclinic lattice
    including all possible permutations."""
    parameters = (1, 2, 3, 90, 115, 90)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.monoclinic

    parameters = (2, 3, 1, 115, 90, 90)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.monoclinic

    parameters = (3, 1, 2, 90, 90, 115)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.monoclinic
コード例 #2
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_lattice_parameters_reciprocal_and_back():
    """Create lattice from parameters, take reciprocal twice,
    and see if the parameters have changed."""
    triclinic = (3, 4, 20, 45, 90, 126)
    triclinic2 = Lattice.from_parameters(
        *triclinic).reciprocal.reciprocal.lattice_parameters
    assert np.allclose(triclinic, triclinic2)
コード例 #3
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_hexagonal_lattice_system():
    """Test that the Lattice.lattice_system attribute is working properly for hexagonal lattice,
    including all possible permutations of lattice parameters."""
    parameters = (2, 2, 3, 90, 90, 120)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.hexagonal

    parameters = (3, 2, 2, 120, 90, 90)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.hexagonal

    parameters = (2, 3, 2, 90, 120, 90)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.hexagonal

    parameters = (2, 2, 2, 90, 120, 90)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.hexagonal
コード例 #4
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_lattice_parameters_triclinic():
    """ alpha, beta, gama =/= 90 """
    a1, a2, a3 = Lattice.from_parameters(1, 2, 3, 75, 40, 81).lattice_vectors

    assert round(abs(norm(a1) - 1), 7) == 0
    assert round(abs(norm(a2) - 2), 7) == 0
    assert round(abs(norm(a3) - 3), 7) == 0

    assert round(abs(angle_between(a2, a3) - 75), 7) == 0
    assert round(abs(angle_between(a3, a1) - 40), 7) == 0
    assert round(abs(angle_between(a1, a2) - 81), 7) == 0
コード例 #5
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_lattice_parameters_monoclinic():
    """ beta =/= 90 """
    a1, a2, a3 = Lattice.from_parameters(1, 2, 3, 90, 120, 90).lattice_vectors

    assert round(abs(norm(a1) - 1), 7) == 0
    assert round(abs(norm(a2) - 2), 7) == 0
    assert round(abs(norm(a3) - 3), 7) == 0

    assert round(abs(angle_between(a2, a3) - 90), 7) == 0
    assert round(abs(angle_between(a3, a1) - 120), 7) == 0
    assert round(abs(angle_between(a1, a2) - 90), 7) == 0
コード例 #6
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_lattice_parameters_orthorombic():
    """ alpha = beta = gamma = 90"""
    a1, a2, a3 = Lattice.from_parameters(2, 1, 5, 90, 90, 90).lattice_vectors
    assert np.allclose(a1, [2, 0, 0])
    assert np.allclose(a2, [0, 1, 0])
    assert np.allclose(a3, [0, 0, 5])
コード例 #7
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_triclinic_lattice_system():
    """ Test that the Lattice.lattice_system attribute is working properly for triclinic lattice """
    l = Lattice.from_parameters(1, 2, 3, 75, 40, 81)
    assert l.lattice_system == LatticeSystem.triclinic
コード例 #8
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_rhombohedral_lattice_system():
    """ Test that the Lattice.lattice_system attribute is working properly for rhombohedral lattice """
    parameters = (1, 1, 1, 87, 87, 87)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.rhombohedral
コード例 #9
0
ファイル: test_lattice.py プロジェクト: anilkunwar/crystals
def test_tetragonal_lattice_system():
    """ Test that the Lattice.lattice_system attribute is working properly for tetragonal lattice """
    parameters = (2, 2, 3, 90, 90, 90)
    l = Lattice.from_parameters(*parameters)
    assert l.lattice_system == LatticeSystem.tetragonal