# Atomic Simulation Environment (ASE) Modelling. Adding additional layer

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]]
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.center(vacuum=10, axis=2)

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


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]]