7
$\begingroup$

Beginners here, to ASE. I've create a 2x2x2 supercell of TiO2 from unit cell (.cif file obtained from LegacyMaterialsProject ) using ASE. The script code is attached as follows. The outcome is shown as part (A) of the picture. However, I want to include another additional one atomic layer into the 20Å vacuum slab. What can I do to improve the script code so that I can get the structure indicated as the image part (B)?

from ase import io
from ase.io import read, write
from ase.build.supercells import make_supercell
from ase.visualize import view

#Make supercell of 2x2x2
M = [[2, 0, 0], [0, 2, 0], [0, 0, 2]]
cif = io.read('TiO2_mp-2657_computed.cif')
sc=make_supercell(cif, M)

#Export supercell into vasp
write('supercell.vasp', sc, vasp5=True, sort=True, direct=False)

#Add vacuum of 20Å (10Å top-bottom)
vac = io.read('supercell.vasp')
vac.center(vacuum=10, axis=2)

#Export vac into vasp
write('supercell_20vac_test.vasp', vac, vasp5=True, sort=True, direct=False)

enter image description here

$\endgroup$

1 Answer 1

8
$\begingroup$

To build a 5 layer TiO2 surface slab, you need to first build a 2x2x3 supercell and then remove the top layer. To do this, you need to first identify the atom indices in layer 0, 1, 2, 3, 4, 5 (counting from bottom) using ase.geometry.get_layers, and then select only the atom indices that have the layer number smaller than 5.

You can use the code below

from ase import io
from ase.io import read, write
from ase.build.supercells import make_supercell
from ase.visualize import view
from ase.geometry import get_layers
import numpy as np

#Make supercell of 2x2x3
M = [[2, 0, 0], [0, 2, 0], [0, 0, 3]]
cif = io.read('TiO2_mp-2657_computed.cif')
sc=make_supercell(cif, M)
sc.center(vacuum=10, axis=2)
view(sc)

layers = get_layers(sc, (0, 0, 1), tolerance=0.3)[0]
indices = np.argwhere(layers<np.max(layers)).ravel()
new_sc = sc[indices]
new_sc.center(vacuum=10, axis=2)
view(new_sc)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .