-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_surf.py
55 lines (40 loc) · 1.75 KB
/
gen_surf.py
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
53
54
55
from pymatgen.analysis.adsorption import *
from pymatgen.core.surface import Slab, SlabGenerator, generate_all_slabs, Structure, Lattice, ReconstructionGenerator
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
from pymatgen.core.structure import Structure
from pymatgen.ext.matproj import MPRester
from matplotlib import pyplot as plt
from pymatgen.io.vasp.inputs import Poscar
import os
mpr = MPRester('TifC7AaCt035HrCAFLx1i30ZjXt0NJMd')
print("Please enter the max miller index:")
a = int(input("max miller index a:"))
outputfile = f"symeteric_25_{a}"
os.makedirs(outputfile, exist_ok=True)
mp_id = "mp-20674"
struct = mpr.get_structure_by_material_id(mp_id)
struct = SpacegroupAnalyzer(struct).get_conventional_standard_structure()
all_slabs = generate_all_slabs(struct, a, 25, 16, symmetrize=True)
print(
"%s unique slab structures have been found for a max Miller index"
% (len(all_slabs))
)
max_step = 0
for n,slab in enumerate(all_slabs):
print(slab.miller_index)
slab.make_supercell([[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
ouc = slab.oriented_unit_cell
miller_index_str = ''.join(str(x) for x in slab.miller_index)
folder_path = os.path.join(outputfile, miller_index_str)
os.makedirs(folder_path, exist_ok=True)
filename = os.path.join(folder_path, f"POSCAR-{n}")
oucname = os.path.join(folder_path, f"POSCAR-0")
open(filename, 'w').write(str(Poscar(slab)))
open(oucname, 'w').write(str(Poscar(ouc)))
max_steps = max(max_step, n)
print(
"Notice some Miller indices are repeated. Again, this is due to there being more than one termination"
)
print("the total number of slab is:", max_steps + 1)