-
Notifications
You must be signed in to change notification settings - Fork 1
/
rmginput.py
executable file
·86 lines (65 loc) · 2.26 KB
/
rmginput.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python3
import numpy as np
import os
import sys
from rmg_parser import *
from add_items_text import *
rmg_branch_list = ["rmg base code", "rmg localized orbital module", "NEGF"]
rmg_branch = rmg_branch_list[0]
# p="rmg base code use delocalized real space grids as basis set, localized orbitals module optimized atom-centered localized orbitals as a basis set")
filetype_supported = ["cif", "xyz", "vasp", "QE"]
filetype =""
kdelt = 1000.0
cutoff = 100.0
pp_type_list = ["SG15(NC)", "GBRV-1.5(US)","Pseudo Dojo(NC)"]
if len(sys.argv) < 2:
print("need to give a file including the initial files location and output directroy")
exit()
with open(sys.argv[1], "r") as f:
all_files = f.readlines()
default_options = """
start_mode ="LCAO Start"
calculation_mode ="Quench Electrons "
kohn_sham_solver ="davidson"
subdiag_driver ="auto"
#******* Pseudopotentials *******
internal_pseudo_type = "sg15"
"""
if len(sys.argv) == 3:
with open(sys.argv[2], "r") as f:
default_options = f.read()
for init_file in all_files:
if(init_file.lstrip()[0] == "#"):
continue
line = init_file.split()
filename = line[0]
filetype = line[1]
if not os.path.isdir(line[2]):
os.mkdir(line[2])
rmgfilename = line[2] +"/input"
cutoff = float(line[3])
kdelt = float(line[4])
name_split = filename.split(".")
# print("initial file name:", filename, " filetype: ", filetype)
crmg = rmg_interface(filename, filetype)
description = filename
rmginput_str = 'description="'+description+'" \n'
pp_type = pp_type_list[0]
grid_lines = add_grid_text(crmg.cell, cutoff)
pseudo_lines = add_pseudo_text(crmg.species, pp_type)
kpoint_lines = add_kpoints_text(crmg.cell, kdelt)
ctrl_lines = add_control_text()
xc_lines = "\n"
spin_lines, mag = add_spin_text(crmg.species_AFM, crmg.atoms, 0)
rmginput_str += grid_lines
rmginput_str += default_options;
# rmginput_str += ctrl_lines
rmginput_str += kpoint_lines
# rmginput_str += pseudo_lines
rmginput_str += xc_lines
if rmg_branch == "rmg base code":
rmginput_str += crmg.cell2rmg(mag)
else:
print("only works for rmg base code now")
with open(rmgfilename, "w") as f:
f.write(rmginput_str)