File: test_surface_terminations.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (39 lines) | stat: -rw-r--r-- 1,306 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
def test_surface_terminations():
    from ase.build.surfaces_with_termination import surfaces_with_termination
    from ase.build import surface
    from ase.spacegroup import crystal

    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')