Skip to content

Instantly share code, notes, and snippets.

@HojeChun
Last active July 2, 2023 13:44
Show Gist options
  • Save HojeChun/70ea137ccb12a4efa00a0aa147ddf646 to your computer and use it in GitHub Desktop.
Save HojeChun/70ea137ccb12a4efa00a0aa147ddf646 to your computer and use it in GitHub Desktop.
Make slab with pymatgen
from pymatgen.core.structure import Structure
from pymatgen.core.surface import SlabGenerator
from pymatgen.io.vasp.inputs import Poscar

struc = Structure.from_file("CONTCAR")
slab_gen = SlabGenerator(struc, [0,0,1], 12, 10, primitive=True) ### If you want the slab to be center set center_slab=True
slab = slab_gen.get_slab()
slab = slab.get_orthogonal_c_slab().get_sorted_structure()
Poscar(slab).write_file("Poscar.vasp")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment