File: test_spacegroup_crystal.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (52 lines) | stat: -rw-r--r-- 2,283 bytes parent folder | download
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
import numpy as np

from ase.spacegroup import crystal
from ase.io import write


def test_diamond():
    diamond = crystal('C', [(0, 0, 0)], spacegroup=227,
                      cellpar=[3.57, 3.57, 3.57, 90, 90, 90])

    # Check that we can write to trajectory:
    write('c.traj', diamond)

    assert len(diamond) == 8
    correct_pos = np.array([[0., 0., 0.],
                            [0., 0.5, 0.5],
                            [0.5, 0.5, 0.],
                            [0.5, 0., 0.5],
                            [0.75, 0.25, 0.75],
                            [0.25, 0.25, 0.25],
                            [0.25, 0.75, 0.75],
                            [0.75, 0.75, 0.25]])
    assert np.allclose(diamond.get_scaled_positions(), correct_pos)


def test_skutterudite():
    # A CoSb3 skutterudite unit cell containing 32 atoms
    skutterudite = crystal(('Co', 'Sb'),
                           basis=[(0.25, 0.25, 0.25), (0.0, 0.335, 0.158)],
                           spacegroup=204,
                           cellpar=[9.04, 9.04, 9.04, 90, 90, 90])

    assert len(skutterudite) == 32

    correct_pos = np.array([[0.25, 0.25, 0.25], [0.75, 0.75, 0.25],
                            [0.75, 0.25, 0.75], [0.25, 0.75, 0.75],
                            [0.75, 0.75, 0.75], [0.25, 0.25, 0.75],
                            [0.25, 0.75, 0.25], [0.75, 0.25, 0.25],
                            [0., 0.335, 0.158], [0., 0.665, 0.158],
                            [0., 0.335, 0.842], [0., 0.665, 0.842],
                            [0.158, 0., 0.335], [0.158, 0., 0.665],
                            [0.842, 0., 0.335], [0.842, 0., 0.665],
                            [0.335, 0.158, 0.], [0.665, 0.158, 0.],
                            [0.335, 0.842, 0.], [0.665, 0.842, 0.],
                            [0.5, 0.835, 0.658], [0.5, 0.165, 0.658],
                            [0.5, 0.835, 0.342], [0.5, 0.165, 0.342],
                            [0.658, 0.5, 0.835], [0.658, 0.5, 0.165],
                            [0.342, 0.5, 0.835], [0.342, 0.5, 0.165],
                            [0.835, 0.658, 0.5], [0.165, 0.658, 0.5],
                            [0.835, 0.342, 0.5], [0.165, 0.342, 0.5]])

    assert np.allclose(skutterudite.get_scaled_positions(), correct_pos)