1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
import pytest
from ase.lattice.cubic import FaceCenteredCubic
from ase.lattice.hexagonal import HexagonalClosedPacked
def test_miller_lindep():
with pytest.raises(ValueError):
# The Miller indices of the surfaces are linearly dependent
FaceCenteredCubic(symbol='Cu',
miller=[[1, 1, 0], [1, 1, 0], [0, 0, 1]])
def test_fcc_ok():
atoms = FaceCenteredCubic(symbol='Cu',
miller=[[1, 1, 0], [0, 1, 0], [0, 0, 1]])
print(atoms.get_cell())
@pytest.mark.parametrize('directions', [
[[1, 1, 0], [1, 1, 0], [0, 0, 1]],
[[1, 1, 0], [1, 0, 0], [0, 1, 0]]
])
def test_fcc_directions_linearly_dependent(directions):
# The directions spanning the unit cell are linearly dependent
with pytest.raises(ValueError):
FaceCenteredCubic(symbol='Cu', directions=directions)
def test_fcc_directions_ok():
atoms = FaceCenteredCubic(symbol='Cu',
directions=[[1, 1, 0], [0, 1, 0], [0, 0, 1]])
print(atoms.get_cell())
def test_hcp_miller_lienarly_dependent():
with pytest.raises((ValueError, NotImplementedError)):
# The Miller indices of the surfaces are linearly dependent
HexagonalClosedPacked(symbol='Mg',
miller=[[1, -1, 0, 0],
[1, 0, -1, 0],
[0, 1, -1, 0]])
# This one should be OK
#
# It is not! The miller argument is broken in hexagonal crystals!
#
# atoms = HexagonalClosedPacked(symbol='Mg',
# miller=[[1, -1, 0, 0],
# [1, 0, -1, 0],
# [0, 0, 0, 1]])
# print(atoms.get_cell())
def test_hcp_cell_linearly_dependent():
with pytest.raises(ValueError):
# The directions spanning the unit cell are linearly dependent
HexagonalClosedPacked(symbol='Mg',
directions=[[1, -1, 0, 0],
[1, 0, -1, 0],
[0, 1, -1, 0]])
def test_hcp():
atoms = HexagonalClosedPacked(symbol='Mg',
directions=[[1, -1, 0, 0],
[1, 0, -1, 0],
[0, 0, 0, 1]])
print(atoms.get_cell())
|