Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from ase.lattice import bravais_classes
4_crystal_family = ('Øaammmmmmmmmmmmmoooooooooooooooooooooooooooooooooooooooooo'
5 'ooooooooooooooooottttttttttttttttttttttttttttttttttttttttt'
6 'ttttttttttttttttttttttttttthhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh'
7 'hhhhhhhhhhhhhhhhhhhhhcccccccccccccccccccccccccccccccccccc')
9_lattice_centering = ('ØPPPPCPPCCPPCPPCPPPPCCFIIPPPPPPPPPPCCCCCCCFFIIIPPPPPPPP'
10 'PPPPPPPPCCCCCCFFIIIIPPPPIIPIPPPPIIPPPPPPPPIIPPPPPPPPII'
11 'IIPPPPPPPPIIIIPPPPPPPPPPPPPPPPIIIIPPPRPRPPPPPPRPPPPRRP'
12 'PPPRRPPPPPPPPPPPPPPPPPPPPPPPPPPPPFIPIPPFFIPIPPFFIPPIPF'
13 'IPFIPPPPFFFFII')
15_point_group_ranges = [(1, '1'),
16 (2, '-1'),
17 (3, '2'),
18 (6, 'm'),
19 (10, '2/m'),
20 (16, '222'),
21 (25, 'mm2'),
22 (47, '2/m 2/m 2/m'),
23 (75, '4'),
24 (81, '-4'),
25 (83, '4/m'),
26 (89, '422'),
27 (99, '4mm'),
28 (111, '-42m'),
29 (123, '4/m 2/m 2/m'),
30 (143, '3'),
31 (147, '-3'),
32 (149, '32'),
33 (156, '3m'),
34 (162, '-3 2/m'),
35 (168, '6'),
36 (174, '-6'),
37 (175, '6/m'),
38 (177, '622'),
39 (183, '6mm'),
40 (187, '-6m2'),
41 (191, '6/m 2/m 2/m'),
42 (195, '23'),
43 (200, '2/m -3'),
44 (207, '432'),
45 (215, '-43m'),
46 (221, '4/m -3 2/m'),
47 (231, 'Ø')]
49_point_groups = ['Ø']
50for i, (start, pg) in enumerate(_point_group_ranges[:-1]):
51 next_start, _ = _point_group_ranges[i + 1]
52 count = next_start - start
53 for j in range(start, start + count):
54 _point_groups.append(pg)
57def validate_space_group(sg):
58 sg = int(sg)
59 if sg < 1:
60 raise ValueError('Spacegroup must be positive, but is {}'.format(sg))
61 if sg > 230:
62 raise ValueError('Bad spacegroup', sg)
63 return sg
66def get_bravais_class(sg):
67 sg = validate_space_group(sg)
68 pearson_symbol = _crystal_family[sg] + _lattice_centering[sg]
69 return bravais_classes[pearson_symbol]
72def get_point_group(sg):
73 sg = validate_space_group(sg)
74 return _point_groups[sg]
77def polar_space_group(sg):
78 sg = validate_space_group(sg)
79 pg = get_point_group(sg)
80 return pg in ['1', '2', 'm', 'mm2', '4', '4mm', '3', '3m', '6', '6mm']