File: spacegroup_crystal.py

package info (click to toggle)
python-ase 3.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,340 kB
  • sloc: python: 117,348; makefile: 91
file content (65 lines) | stat: -rw-r--r-- 2,694 bytes parent folder | download | duplicates (2)
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
import numpy as np

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

# A diamond unit cell
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)


# 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)