Coverage for /builds/kinetik161/ase/ase/spacegroup/crystal_data.py: 100.00%

28 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-10 11:04 +0000

1from ase.lattice import bravais_classes 

2 

3_crystal_family = ('Øaammmmmmmmmmmmmoooooooooooooooooooooooooooooooooooooooooo' 

4 'ooooooooooooooooottttttttttttttttttttttttttttttttttttttttt' 

5 'ttttttttttttttttttttttttttthhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh' 

6 'hhhhhhhhhhhhhhhhhhhhhcccccccccccccccccccccccccccccccccccc') 

7 

8_lattice_centering = ('ØPPPPCPPCCPPCPPCPPPPCCFIIPPPPPPPPPPCCCCCCCFFIIIPPPPPPPP' 

9 'PPPPPPPPCCCCCCFFIIIIPPPPIIPIPPPPIIPPPPPPPPIIPPPPPPPPII' 

10 'IIPPPPPPPPIIIIPPPPPPPPPPPPPPPPIIIIPPPRPRPPPPPPRPPPPRRP' 

11 'PPPRRPPPPPPPPPPPPPPPPPPPPPPPPPPPPFIPIPPFFIPIPPFFIPPIPF' 

12 'IPFIPPPPFFFFII') 

13 

14_point_group_ranges = [(1, '1'), 

15 (2, '-1'), 

16 (3, '2'), 

17 (6, 'm'), 

18 (10, '2/m'), 

19 (16, '222'), 

20 (25, 'mm2'), 

21 (47, '2/m 2/m 2/m'), 

22 (75, '4'), 

23 (81, '-4'), 

24 (83, '4/m'), 

25 (89, '422'), 

26 (99, '4mm'), 

27 (111, '-42m'), 

28 (123, '4/m 2/m 2/m'), 

29 (143, '3'), 

30 (147, '-3'), 

31 (149, '32'), 

32 (156, '3m'), 

33 (162, '-3 2/m'), 

34 (168, '6'), 

35 (174, '-6'), 

36 (175, '6/m'), 

37 (177, '622'), 

38 (183, '6mm'), 

39 (187, '-6m2'), 

40 (191, '6/m 2/m 2/m'), 

41 (195, '23'), 

42 (200, '2/m -3'), 

43 (207, '432'), 

44 (215, '-43m'), 

45 (221, '4/m -3 2/m'), 

46 (231, 'Ø')] 

47 

48_point_groups = ['Ø'] 

49for i, (start, pg) in enumerate(_point_group_ranges[:-1]): 

50 next_start, _ = _point_group_ranges[i + 1] 

51 count = next_start - start 

52 for j in range(start, start + count): 

53 _point_groups.append(pg) 

54 

55 

56def validate_space_group(sg): 

57 sg = int(sg) 

58 if sg < 1: 

59 raise ValueError(f'Spacegroup must be positive, but is {sg}') 

60 if sg > 230: 

61 raise ValueError('Bad spacegroup', sg) 

62 return sg 

63 

64 

65def get_bravais_class(sg): 

66 sg = validate_space_group(sg) 

67 pearson_symbol = _crystal_family[sg] + _lattice_centering[sg] 

68 return bravais_classes[pearson_symbol] 

69 

70 

71def get_point_group(sg): 

72 sg = validate_space_group(sg) 

73 return _point_groups[sg] 

74 

75 

76def polar_space_group(sg): 

77 sg = validate_space_group(sg) 

78 pg = get_point_group(sg) 

79 return pg in ['1', '2', 'm', 'mm2', '4', '4mm', '3', '3m', '6', '6mm']