Hello. I am trying to create 3 layers of calcite on the 1 0 4 surface and add vacuum to make a slab. Then to convert it to a 2x2 supercell. However, when I use the ASE code, I see it gives me only 3 angstrom thickness for the 3 layers, which is wrong. I tried to add bond lengths but still it did not work. Can anyone help me to create the slab?
This is the code I have used:
from ase.io import read
from ase.visualize import view
from ase.build import surface
Load the primitive calcite structure
bulk = read(‘calcite_primitive.cif’)
Create the (1, 0, 4) surface with 3 layers
surf = surface(bulk, (1, 0, 4), 3)
Add a vacuum of 20 Å along the z-axis (axis=2)
surf.center(vacuum=20, axis=2)
Define the Ca-O and C-O bond lengths
ca_o_bond_length = 2.36 # Å
c_o_bond_length = 1.29 # Å
Find Ca-O and C-O bonds and set their bond lengths
for i, atom_i in enumerate(surf):
if atom_i.symbol == ‘Ca’:
# Set bond length for Ca-O (search for nearby O atoms)
for j, atom_j in enumerate(surf):
if atom_j.symbol == ‘O’ and surf.get_distance(i, j) < 3: # Rough initial guess for Ca-O bonds
surf.set_distance(i, j, ca_o_bond_length, fix=1)
elif atom_i.symbol == 'C':
# Set bond length for C-O (search for nearby O atoms)
for j, atom_j in enumerate(surf):
if atom_j.symbol == 'O' and surf.get_distance(i, j) < 2: # Rough initial guess for C-O bonds
surf.set_distance(i, j, c_o_bond_length, fix=1)
Visualize the surface after bond adjustment
view(surf)