-
Notifications
You must be signed in to change notification settings - Fork 5
/
kpoints.py
34 lines (28 loc) · 1.12 KB
/
kpoints.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
import pymatgen
from pymatgen.io.vasp import Kpoints
from ast import literal_eval
import os, yaml
if __name__ == '__main__':
if os.path.isfile('KPOINTS'):
print("KPOINTS already loaded")
exit
else:
with open('rendered_wano.yml') as file:
wano_file = yaml.full_load(file)
Rk = wano_file["TABS"]["KPOINTS"]["Kpoints_length"]
Monkhorst = wano_file["TABS"]["KPOINTS"]["Kpoints_Monkhorst"]
if Rk:
Rk_val = (wano_file["TABS"]["KPOINTS"]["Rk_length"])
kpoints = Kpoints.automatic(Rk_val)
kpoints.write_file('KPOINTS')
print("KPOINTS successfully created")
elif Monkhorst:
mat_n = literal_eval(wano_file["TABS"]["KPOINTS"]["Monkhorst"])
n = [mat_n[0][0], mat_n[0][1], mat_n[0][2]]
n_shift = [mat_n[1][0], mat_n[1][1], mat_n[1][2]]
kpoints = Kpoints.monkhorst_automatic(n, n_shift)
# kpoints = Kpoints.gamma_automatic(n, n_shift)
kpoints.write_file('KPOINTS')
print("KPOINTS successfully created")
else:
None