Coverage for /builds/ase/ase/ase/lattice/compounds.py: 100.00%

31 statements  

« prev     ^ index     » next       coverage.py v7.5.3, created at 2025-08-02 00:12 +0000

1# fmt: off 

2 

3"""Function-like objects creating lattices with more than one element. 

4 

5These lattice creators are mainly intended as examples for how to build you 

6own. The following crystal structures are defined: 

7 

8 B1 = NaCl = Rocksalt 

9 B2 = CsCl 

10 B3 = ZnS = Zincblende 

11 L1_2 = AuCu3 

12 L1_0 = AuCu 

13 TRI_Fe2O3 

14 HEX_Fe2O3 

15 

16""" 

17from ase.lattice.cubic import DiamondFactory, SimpleCubicFactory 

18from ase.lattice.hexagonal import HexagonalFactory 

19from ase.lattice.tetragonal import SimpleTetragonalFactory 

20from ase.lattice.triclinic import TriclinicFactory 

21 

22 

23# To prevent a layer of element one on one side, and a layer of 

24# element two on the other side, NaCl is based on SimpleCubic instead 

25# of on FaceCenteredCubic 

26class NaClFactory(SimpleCubicFactory): 

27 "A factory for creating NaCl (B1, Rocksalt) lattices." 

28 

29 bravais_basis = [[0, 0, 0], [0, 0, 0.5], [0, 0.5, 0], [0, 0.5, 0.5], 

30 [0.5, 0, 0], [0.5, 0, 0.5], [0.5, 0.5, 0], 

31 [0.5, 0.5, 0.5]] 

32 element_basis = (0, 1, 1, 0, 1, 0, 0, 1) 

33 

34 

35B1 = NaCl = Rocksalt = NaClFactory() 

36 

37 

38class CsClFactory(SimpleCubicFactory): 

39 "A factory for creating CsCl (B2) lattices." 

40 bravais_basis = [[0, 0, 0], [0.5, 0.5, 0.5]] 

41 element_basis = (0, 1) 

42 

43 

44B2 = CsCl = CsClFactory() 

45 

46 

47# The zincblende structure is easily derived from Diamond, which 

48# already has the right basis. 

49class ZnSFactory(DiamondFactory): 

50 "A factory for creating ZnS (B3, Zincblende) lattices." 

51 element_basis = (0, 1) 

52 

53 

54B3 = ZnS = Zincblende = ZnSFactory() 

55 

56 

57# The L1_0 structure is "based on FCC", but is a tetragonal distortion 

58# of fcc. It must therefore be derived from the base-centered 

59# tetragonal structure. That structure, however, does not exist, 

60# since it is equivalent to a simple tetragonal structure rotated 45 

61# degrees along the z-axis. Basing L1_2 on that would however give 

62# unexpected miller indices. L1_2 will therefore be based on a simple 

63# tetragonal structure, but with a basis corresponding to a 

64# base-centered tetragonal. 

65class AuCuFactory(SimpleTetragonalFactory): 

66 "A factory for creating AuCu (L1_0) lattices (tetragonal symmetry)." 

67 bravais_basis = [[0, 0, 0], [0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]] 

68 element_basis = (0, 1, 1, 0) 

69 

70 

71AuCu = L1_0 = AuCuFactory() 

72 

73 

74# The L1_2 structure is "based on FCC", but is really simple cubic 

75# with a basis. 

76class AuCu3Factory(SimpleCubicFactory): 

77 "A factory for creating AuCu3 (L1_2) lattices." 

78 bravais_basis = [[0, 0, 0], [0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]] 

79 element_basis = (0, 1, 1, 1) 

80 

81 

82AuCu3 = L1_2 = AuCu3Factory() 

83 

84 

85class TriclinicFe2O3Factory(TriclinicFactory): 

86 """A factory for creating hematite (Fe2O3) lattices. 

87 

88 Rhombohedral unit cell. 

89 Pauling L, Hendricks S B 

90 Journal of the American Chemical Society 47 (1925) 781-790 

91 

92 Example:: 

93 

94 #!/usr/bin/env python3 

95 

96 from ase.lattice.hexagonal import * 

97 from ase.lattice.compounds import * 

98 import ase.io as io 

99 from ase import Atoms, Atom 

100 

101 index1=3 

102 index2=3 

103 index3=3 

104 mya = 5.42 

105 myb = 5.42 

106 myc = 5.42 

107 myalpha = 55.28 

108 mybeta = 55.28 

109 mygamma = 55.28 

110 gra = TRI_Fe2O3(symbol = ('Fe', 'O'), 

111 latticeconstant={'a':mya,'b':myb, 'c':myc, 

112 'alpha':myalpha, 

113 'beta':mybeta, 

114 'gamma':mygamma}, 

115 size=(index1,index2,index3)) 

116 io.write('rhombohedralUC_Fe2O3.xyz', gra, format='xyz') 

117 

118 """ 

119 

120 bravais_basis = [[0.10534, 0.10534, 0.10534], [0.39466, 0.39466, 0.39466], 

121 [0.60534, 0.60534, 0.60534], [0.89466, 0.89466, 0.89466], 

122 [0.30569, 0.69431, 0.00000], [0.69431, 0.00000, 0.30569], 

123 [0.00000, 0.30569, 0.69431], [0.19431, 0.80569, 0.50000], 

124 [0.80569, 0.50000, 0.19431], [0.50000, 0.19431, 0.80569]] 

125 element_basis = (0, 0, 0, 0, 1, 1, 1, 1, 1, 1) 

126 

127 

128TRI_Fe2O3 = TriclinicFe2O3Factory() 

129 

130 

131class HexagonalFe2O3Factory(HexagonalFactory): 

132 """A factory for creating hematite (Fe2O3) lattices. 

133 With hexagonal unit cell. 

134 Blake R L, Hessevick R E, Zoltai T, Finger L W 

135 American Mineralogist 51 (1966) 123-129 

136 5.038 5.038 13.772 90 90 120 R-3c 

137 Fe 0 0 .3553 .0080 .0080 .00029 .0040 0 0 

138 O .3059 0 1/4 .0068 .0083 .00046 .0042 .00058 .0012 

139 

140 Example: 

141 #!/usr/bin/env python3 

142 from ase.lattice.hexagonal import * 

143 from ase.lattice.compounds import * 

144 import ase.io as io 

145 from ase import Atoms, Atom 

146 

147 index1=1 

148 index2=1 

149 index3=1 

150 mya = 5.038 

151 myb = 5.038 

152 myc = 13.772 

153 myalpha = 90 

154 mybeta = 90 

155 mygamma = 120 

156 gra = HEX_Fe2O3(symbol = ('Fe', 'O'), 

157 latticeconstant={'a':mya,'b':myb, 'c':myc, 

158 'alpha':myalpha, 

159 'beta':mybeta, 

160 'gamma':mygamma}, 

161 size=(index1,index2,index3)) 

162 io.write('hexaFe2O3.xyz', gra, format='xyz') 

163 

164 """ 

165 

166 bravais_basis = [[0.000000, 0.000000, 0.355300], 

167 [0.000000, 0.000000, 0.144700], 

168 [0.000000, 0.000000, 0.644700], 

169 [0.000000, 0.000000, 0.855300], 

170 [0.666667, 0.333333, 0.688633], 

171 [0.666667, 0.333333, 0.478033], 

172 [0.666667, 0.333333, 0.978033], 

173 [0.666667, 0.333333, 0.188633], 

174 [0.333333, 0.666667, 0.021967], 

175 [0.333333, 0.666667, 0.811367], 

176 [0.333333, 0.666667, 0.311367], 

177 [0.333333, 0.666667, 0.521967], 

178 # Fe to O here 

179 [0.305900, 0.000000, 0.250000], 

180 [0.000000, 0.305900, 0.250000], 

181 [0.694100, 0.694100, 0.250000], 

182 [0.694100, 0.000000, 0.750000], 

183 [0.000000, 0.694100, 0.750000], 

184 [0.305900, 0.305900, 0.750000], 

185 [0.972567, 0.333333, 0.583333], 

186 [0.666667, 0.639233, 0.583333], 

187 [0.360767, 0.027433, 0.583333], 

188 [0.360767, 0.333333, 0.083333], 

189 [0.666667, 0.027433, 0.083333], 

190 [0.972567, 0.639233, 0.083333], 

191 [0.639233, 0.666667, 0.916667], 

192 [0.333333, 0.972567, 0.916667], 

193 [0.027433, 0.360767, 0.916667], 

194 [0.027433, 0.666667, 0.416667], 

195 [0.333333, 0.360767, 0.416667], 

196 [0.639233, 0.972567, 0.416667]] 

197 element_basis = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 

198 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 

199 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) 

200 

201 

202HEX_Fe2O3 = HexagonalFe2O3Factory()