File: general_surface.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 (55 lines) | stat: -rw-r--r-- 1,433 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# creates: s1.png s2.png s3.png s4.png general_surface.pdf
import os
import shutil
from pathlib import Path

from ase import Atoms
from ase.build import bulk, surface
from ase.io import write

# Au example:
s1 = surface('Au', (2, 1, 1), 9)
s1.center(vacuum=10, axis=2)
# Mo example:
Mobulk = bulk('Mo', 'bcc', a=3.16, cubic=True)
s2 = surface(Mobulk, (3, 2, 1), 9)
s2.center(vacuum=10, axis=2)
# Pt3Rh example:
a = 4.0
Pt3Rh = Atoms(
    'Pt3Rh',
    scaled_positions=[(0, 0, 0), (0.5, 0.5, 0), (0.5, 0, 0.5), (0, 0.5, 0.5)],
    cell=[a, a, a],
    pbc=True,
)
s3 = surface(Pt3Rh, (2, 1, 1), 9)
s3.center(vacuum=10, axis=2)

Pt3Rh.set_chemical_symbols('PtRhPt2')
s4 = surface(Pt3Rh, (2, 1, 1), 9)
s4.center(vacuum=10, axis=2)
# Done

for atoms, name in [(s1, 's1'), (s2, 's2'), (s3, 's3'), (s4, 's4')]:
    write(
        name + '.pov',
        atoms,
        rotation='-90x',
        povray_settings=dict(transparent=False),
    ).render()


dir = os.environ.get('PDF_FILE_DIR')
if dir:
    shutil.copyfile(Path(dir) / 'general_surface.pdf', 'general_surface.pdf')
else:
    for i in range(2):
        error = os.system(
            'pdflatex -interaction=nonstopmode general_surface > /dev/null'
        )
        if error:
            with open('general_surface.pdf', 'w') as fd:
                fd.write('pdflatex not found\n')
            break
        os.remove('general_surface.aux')
        os.remove('general_surface.log')