Coverage for gpaw/benchmark/systems.py: 17%

78 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-12 00:18 +0000

1import numpy as np 

2 

3 

4def system_magic_graphene(): 

5 from gpaw.benchmark.generate_twisted import make_heterostructure 

6 from ase.build import graphene 

7 atoms = graphene(vacuum=5) 

8 transa_cc = np.array([[29, -30, 0], [59, 29, 0], [0, 0, 1]]) 

9 transb_cc = np.array([[30, -29, 0], [59, 30, 0], [0, 0, 1]]) 

10 atoms = make_heterostructure(atoms, atoms, 

11 transa_cc=transa_cc, 

12 transb_cc=transb_cc, 

13 straina_vv=np.eye(3), 

14 interlayer_dist=3.35) 

15 return atoms 

16 

17 

18def system_2188_bl_graphene(): 

19 from gpaw.benchmark.generate_twisted import make_heterostructure 

20 from ase.build import graphene 

21 atoms = graphene(vacuum=5) 

22 transa_cc = np.array([[27, 13, 0], [14, 27, 0], [0, 0, 1]]) 

23 transb_cc = np.array([[27, 24, 0], [13, 27, 0], [0, 0, 1]]) 

24 atoms = make_heterostructure(atoms, atoms, 

25 transa_cc=transa_cc, 

26 transb_cc=transb_cc, 

27 straina_vv=np.eye(3), 

28 interlayer_dist=3.35) 

29 return atoms 

30 

31 

32def system_6000_bl_graphene(): 

33 from gpaw.benchmark.generate_twisted import make_heterostructure 

34 from ase.build import graphene 

35 atoms = graphene(vacuum=5) 

36 transa_cc = np.array([[23, 45, 0], [-22, 23, 0], [0, 0, 1]]) 

37 transb_cc = np.array([[22, 45, 0], [-23, 22, 0], [0, 0, 1]]) 

38 atoms = make_heterostructure(atoms, atoms, 

39 transa_cc=transa_cc, 

40 transb_cc=transb_cc, 

41 straina_vv=np.eye(3), 

42 interlayer_dist=3.35) 

43 return atoms 

44 

45 

46def system_676_bl_graphene(): 

47 from gpaw.benchmark.generate_twisted import make_heterostructure 

48 from ase.build import graphene 

49 atoms = graphene(vacuum=5) 

50 transa_cc = np.array([[7, -8, 0], [15, 7, 0], [0, 0, 1]]) 

51 transb_cc = np.array([[8, -7, 0], [15, 8, 0], [0, 0, 1]]) 

52 atoms = make_heterostructure(atoms, atoms, 

53 transa_cc=transa_cc, 

54 transb_cc=transb_cc, 

55 straina_vv=np.eye(3), 

56 interlayer_dist=3.35) 

57 return atoms 

58 

59 

60def system_H2(): 

61 from ase.build import molecule 

62 atoms = molecule('H2') 

63 atoms.center(vacuum=3) 

64 return atoms 

65 

66 

67def system_C60(): 

68 from ase.build import molecule 

69 atoms = molecule('C60') 

70 atoms.center(vacuum=5) 

71 return atoms 

72 

73 

74def system_diamond(): 

75 from ase.build import bulk 

76 atoms = bulk('C') 

77 return atoms 

78 

79 

80def system_MoS2_tube(): 

81 from math import pi 

82 import numpy as np 

83 from ase.build import mx2 

84 

85 # Create tube of MoS2: 

86 atoms = mx2('MoS2', size=(3, 2, 1)) 

87 atoms.cell[1, 0] = 0 

88 atoms = atoms.repeat((1, 10, 1)) 

89 p = atoms.positions 

90 p2 = p.copy() 

91 L = atoms.cell[1, 1] 

92 r0 = L / (2 * pi) 

93 angle = p[:, 1] / L * 2 * pi 

94 p2[:, 1] = (r0 + p[:, 2]) * np.cos(angle) 

95 p2[:, 2] = (r0 + p[:, 2]) * np.sin(angle) 

96 atoms.positions = p2 

97 atoms.cell = [atoms.cell[0, 0], 0, 0] 

98 atoms.center(vacuum=6, axis=[1, 2]) 

99 atoms.pbc = True 

100 

101 return atoms 

102 

103 

104def system_magbulk(): 

105 from ase.build import bulk 

106 atoms = bulk('Fe') * 2 

107 atoms.set_initial_magnetic_moments([3] * len(atoms)) 

108 return atoms 

109 

110 

111def system_metalslab(): 

112 from ase.build import fcc111 

113 slab = fcc111('Al', size=(3, 4, 8), vacuum=6.0) 

114 return slab 

115 

116 

117systems = {'C60': system_C60, 

118 'diamond': system_diamond, 

119 'H2': system_H2, 

120 'MoS2_tube': system_MoS2_tube, 

121 'C6000': system_6000_bl_graphene, 

122 'C2188': system_2188_bl_graphene, 

123 'C676': system_676_bl_graphene, 

124 'magbulk': system_magbulk, 

125 'metalslab': system_metalslab, 

126 'magic_graphene': system_magic_graphene} 

127 

128 

129def parse_system(name): 

130 return systems[name]()