File: test_surface_terminations.py

package info (click to toggle)
python-ase 3.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (39 lines) | stat: -rw-r--r-- 1,313 bytes parent folder | download
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
36
37
38
39
# fmt: off
from ase.build import surface
from ase.build.surfaces_with_termination import surfaces_with_termination
from ase.spacegroup import crystal


def test_surface_terminations():

    a = 4.6
    c = 2.95

    # Rutile:
    rutile = crystal(['Ti', 'O'], basis=[(0, 0, 0), (0.3, 0.3, 0.0)],
                     spacegroup=136, cellpar=[a, a, c, 90, 90, 90])

    slb = surface(rutile, indices=(1, 1, 0), layers=4, vacuum=10)
    slb *= (1, 2, 1)

    def check_surf_composition(images, formula):
        for atoms in images:
            zmax = atoms.positions[:, 2].max()
            sym = atoms.symbols[abs(atoms.positions[:, 2] - zmax) < 1e-2]
            red_formula, _ = sym.formula.reduce()
            assert red_formula == formula

    images = surfaces_with_termination(rutile,
                                       indices=(1, 1, 0),
                                       layers=4,
                                       vacuum=10,
                                       termination='O')

    check_surf_composition(images, 'O')

    images = surfaces_with_termination(rutile,
                                       indices=(1, 1, 0),
                                       layers=4, vacuum=10,
                                       termination='TiO')

    check_surf_composition(images, 'TiO')