Coverage for ase/lattice/compounds.py: 100.00%
31 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-27 15:21 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-27 15:21 +0000
1"""Function-like objects creating lattices with more than one element.
3These lattice creators are mainly intended as examples for how to build you
4own. The following crystal structures are defined:
6 B1 = NaCl = Rocksalt
7 B2 = CsCl
8 B3 = ZnS = Zincblende
9 L1_2 = AuCu3
10 L1_0 = AuCu
11 TRI_Fe2O3
12 HEX_Fe2O3
14"""
16from ase.lattice.cubic import DiamondFactory, SimpleCubicFactory
17from ase.lattice.hexagonal import HexagonalFactory
18from ase.lattice.tetragonal import SimpleTetragonalFactory
19from ase.lattice.triclinic import TriclinicFactory
22# To prevent a layer of element one on one side, and a layer of
23# element two on the other side, NaCl is based on SimpleCubic instead
24# of on FaceCenteredCubic
25class NaClFactory(SimpleCubicFactory):
26 "A factory for creating NaCl (B1, Rocksalt) lattices."
28 bravais_basis = [
29 [0, 0, 0],
30 [0, 0, 0.5],
31 [0, 0.5, 0],
32 [0, 0.5, 0.5],
33 [0.5, 0, 0],
34 [0.5, 0, 0.5],
35 [0.5, 0.5, 0],
36 [0.5, 0.5, 0.5],
37 ]
38 element_basis = (0, 1, 1, 0, 1, 0, 0, 1)
41B1 = NaCl = Rocksalt = NaClFactory()
44class CsClFactory(SimpleCubicFactory):
45 "A factory for creating CsCl (B2) lattices."
47 bravais_basis = [[0, 0, 0], [0.5, 0.5, 0.5]]
48 element_basis = (0, 1)
51B2 = CsCl = CsClFactory()
54# The zincblende structure is easily derived from Diamond, which
55# already has the right basis.
56class ZnSFactory(DiamondFactory):
57 "A factory for creating ZnS (B3, Zincblende) lattices."
59 element_basis = (0, 1)
62B3 = ZnS = Zincblende = ZnSFactory()
65# The L1_0 structure is "based on FCC", but is a tetragonal distortion
66# of fcc. It must therefore be derived from the base-centered
67# tetragonal structure. That structure, however, does not exist,
68# since it is equivalent to a simple tetragonal structure rotated 45
69# degrees along the z-axis. Basing L1_2 on that would however give
70# unexpected miller indices. L1_2 will therefore be based on a simple
71# tetragonal structure, but with a basis corresponding to a
72# base-centered tetragonal.
73class AuCuFactory(SimpleTetragonalFactory):
74 "A factory for creating AuCu (L1_0) lattices (tetragonal symmetry)."
76 bravais_basis = [[0, 0, 0], [0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]]
77 element_basis = (0, 1, 1, 0)
80AuCu = L1_0 = AuCuFactory()
83# The L1_2 structure is "based on FCC", but is really simple cubic
84# with a basis.
85class AuCu3Factory(SimpleCubicFactory):
86 "A factory for creating AuCu3 (L1_2) lattices."
88 bravais_basis = [[0, 0, 0], [0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]]
89 element_basis = (0, 1, 1, 1)
92AuCu3 = L1_2 = AuCu3Factory()
95class TriclinicFe2O3Factory(TriclinicFactory):
96 """A factory for creating hematite (Fe2O3) lattices.
98 Rhombohedral unit cell.
99 Pauling L, Hendricks S B
100 Journal of the American Chemical Society 47 (1925) 781-790
102 Example::
104 #!/usr/bin/env python3
106 from ase.lattice.hexagonal import *
107 from ase.lattice.compounds import *
108 import ase.io as io
109 from ase import Atoms, Atom
111 index1=3
112 index2=3
113 index3=3
114 mya = 5.42
115 myb = 5.42
116 myc = 5.42
117 myalpha = 55.28
118 mybeta = 55.28
119 mygamma = 55.28
120 gra = TRI_Fe2O3(symbol = ('Fe', 'O'),
121 latticeconstant={'a':mya,'b':myb, 'c':myc,
122 'alpha':myalpha,
123 'beta':mybeta,
124 'gamma':mygamma},
125 size=(index1,index2,index3))
126 io.write('rhombohedralUC_Fe2O3.xyz', gra, format='xyz')
128 """
130 bravais_basis = [
131 [0.10534, 0.10534, 0.10534],
132 [0.39466, 0.39466, 0.39466],
133 [0.60534, 0.60534, 0.60534],
134 [0.89466, 0.89466, 0.89466],
135 [0.30569, 0.69431, 0.00000],
136 [0.69431, 0.00000, 0.30569],
137 [0.00000, 0.30569, 0.69431],
138 [0.19431, 0.80569, 0.50000],
139 [0.80569, 0.50000, 0.19431],
140 [0.50000, 0.19431, 0.80569],
141 ]
142 element_basis = (0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
145TRI_Fe2O3 = TriclinicFe2O3Factory()
148class HexagonalFe2O3Factory(HexagonalFactory):
149 """A factory for creating hematite (Fe2O3) lattices.
150 With hexagonal unit cell.
151 Blake R L, Hessevick R E, Zoltai T, Finger L W
152 American Mineralogist 51 (1966) 123-129
153 5.038 5.038 13.772 90 90 120 R-3c
154 Fe 0 0 .3553 .0080 .0080 .00029 .0040 0 0
155 O .3059 0 1/4 .0068 .0083 .00046 .0042 .00058 .0012
157 Example:
158 #!/usr/bin/env python3
159 from ase.lattice.hexagonal import *
160 from ase.lattice.compounds import *
161 import ase.io as io
162 from ase import Atoms, Atom
164 index1=1
165 index2=1
166 index3=1
167 mya = 5.038
168 myb = 5.038
169 myc = 13.772
170 myalpha = 90
171 mybeta = 90
172 mygamma = 120
173 gra = HEX_Fe2O3(symbol = ('Fe', 'O'),
174 latticeconstant={'a':mya,'b':myb, 'c':myc,
175 'alpha':myalpha,
176 'beta':mybeta,
177 'gamma':mygamma},
178 size=(index1,index2,index3))
179 io.write('hexaFe2O3.xyz', gra, format='xyz')
181 """
183 bravais_basis = [
184 [0.000000, 0.000000, 0.355300],
185 [0.000000, 0.000000, 0.144700],
186 [0.000000, 0.000000, 0.644700],
187 [0.000000, 0.000000, 0.855300],
188 [0.666667, 0.333333, 0.688633],
189 [0.666667, 0.333333, 0.478033],
190 [0.666667, 0.333333, 0.978033],
191 [0.666667, 0.333333, 0.188633],
192 [0.333333, 0.666667, 0.021967],
193 [0.333333, 0.666667, 0.811367],
194 [0.333333, 0.666667, 0.311367],
195 [0.333333, 0.666667, 0.521967],
196 # Fe to O here
197 [0.305900, 0.000000, 0.250000],
198 [0.000000, 0.305900, 0.250000],
199 [0.694100, 0.694100, 0.250000],
200 [0.694100, 0.000000, 0.750000],
201 [0.000000, 0.694100, 0.750000],
202 [0.305900, 0.305900, 0.750000],
203 [0.972567, 0.333333, 0.583333],
204 [0.666667, 0.639233, 0.583333],
205 [0.360767, 0.027433, 0.583333],
206 [0.360767, 0.333333, 0.083333],
207 [0.666667, 0.027433, 0.083333],
208 [0.972567, 0.639233, 0.083333],
209 [0.639233, 0.666667, 0.916667],
210 [0.333333, 0.972567, 0.916667],
211 [0.027433, 0.360767, 0.916667],
212 [0.027433, 0.666667, 0.416667],
213 [0.333333, 0.360767, 0.416667],
214 [0.639233, 0.972567, 0.416667],
215 ]
216 element_basis = (
217 0,
218 0,
219 0,
220 0,
221 0,
222 0,
223 0,
224 0,
225 0,
226 0,
227 0,
228 0,
229 1,
230 1,
231 1,
232 1,
233 1,
234 1,
235 1,
236 1,
237 1,
238 1,
239 1,
240 1,
241 1,
242 1,
243 1,
244 1,
245 1,
246 1,
247 )
250HEX_Fe2O3 = HexagonalFe2O3Factory()