File: build_bcc.py

package info (click to toggle)
gpaw 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,328 kB
  • sloc: python: 111,596; ansic: 16,082; sh: 1,230; csh: 139; makefile: 56
file content (35 lines) | stat: -rw-r--r-- 855 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Module for building atomic structures"""

from ase import Atom, Atoms


def bcc100(symbol, a, layers, L):
    """Build a bcc(100) surface

    symbol: chemical symbol ('H', 'Li', ...)
    a     : lattice constant
    layers: number of layers
    L     : height of unit cell"""

    a = float(a)

    # Distance between layers:
    z = a / 2

    assert L > layers * z, 'Unit cell too small!'

    # Start with an empty Atoms object with an orthorhombic unit cell:
    atoms = Atoms(pbc=(True, True, False), cell=(a, a, L))

    # Fill in the atoms:
    for n in range(layers):
        position = [a / 2 * (n % 2), a / 2 * (n % 2), n * z]
        atoms.append(Atom(symbol, position))

    atoms.center(axis=2)
    return atoms

if __name__ == '__main__':
    bcc = bcc100('Al', 4.0, 4, 15.0)
    from ase.visualize import view
    view(bcc * (4, 4, 2))