Attachment 'Build.py'
Download 1 """Module for building atomic structures"""
2
3 from ASE import ListOfAtoms, Atom
4
5
6 def BCC100(symbol, a, layers, h):
7 """Build a bcc(100) surface
8
9 symbol: chmical symbol ('H', 'Li', ...)
10 a : lattice constant
11 layers: number of layers
12 h : height of unit cell"""
13
14 # Distance between layers:
15 z = a / 2
16
17 assert h > layers * z, 'unit cell too small for ' + str(layers) + ' layers'
18
19 # Start with an empty ListOfAtoms object:
20 atoms = ListOfAtoms([], periodic=True)
21
22 # Fill in the atoms using scaled coordinates:
23 for n in range(layers):
24 position = [0.5 * (n % 2),
25 0.5 * (n % 2),
26 -n * z / h]
27 atoms.append(Atom(symbol, position))
28
29 # The unit cell is orthorhombic:
30 atoms.SetUnitCell((a, a, h))
31 # The unit cell could also have been set like this:
32 # atoms.SetUnitCell([(a, 0, 0),
33 # (0, a, 0),
34 # (0, 0, h)])
35 return atoms
36
37
38 if __name__ == '__main__':
39 bcc = BCC100('Al', 3.25, 4, 20.0)
40 from ASE.Visualization.RasMol import RasMol
41 p = RasMol(bcc, (4, 4, 2))
42 raw_input('Press [enter] to finish. ')
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.