File: manipulating_atoms.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 (52 lines) | stat: -rw-r--r-- 1,404 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
# creates: a1.png a2.png a3.png
# creates: WL.png, Ni111slab2x2.png, WL_rot_c.png, WL_rot_a.png, WL_wrap.png
# creates: interface-h2o-wrap.png

import runpy
from math import sqrt

import numpy as np

from ase import Atoms
from ase.build import fcc111
from ase.io import read, write

a = 3.55
atoms = Atoms(
    'Ni4',
    cell=[sqrt(2) * a, sqrt(2) * a, 1.0, 90, 90, 120],
    pbc=(1, 1, 0),
    scaled_positions=[(0, 0, 0), (0.5, 0, 0), (0, 0.5, 0), (0.5, 0.5, 0)],
)
atoms.center(vacuum=5.0, axis=2)
write('a1.png', atoms, rotation='-73x')
a3 = atoms.repeat((3, 3, 2))
a3.cell = atoms.cell
write('a2.png', a3, rotation='-73x')
h = 1.9
relative = (1 / 6, 1 / 6, 0.5)
absolute = np.dot(relative, atoms.cell) + (0, 0, h)
atoms.append('Ag')
atoms.positions[-1] = absolute
a3 = atoms.repeat((3, 3, 2))
a3.cell = atoms.cell
write('a3.png', a3)

runpy.run_path('WL.py')
W = read('WL.traj')
write('WL.png', W)
slab = fcc111('Ni', size=[2, 4, 3], a=3.55, orthogonal=True)
write('Ni111slab2x2.png', slab)
W.cell = [W.cell[1, 1], W.cell[0, 0], 0.0]
write('WL_rot_c.png', W)
W.rotate(90, 'z', center=(0, 0, 0))
write('WL_rot_a.png', W)
W.wrap()
write('WL_wrap.png', W)
W.set_cell(slab.cell, scale_atoms=True)
zmin = W.positions[:, 2].min()
zmax = slab.positions[:, 2].max()
W.positions += (0, 0, zmax - zmin + 1.5)
interface = slab + W
interface.center(vacuum=6, axis=2)
write('interface-h2o-wrap.png', interface)