-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_ini.py
58 lines (51 loc) · 1.96 KB
/
make_ini.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
import sys, os
import configparser
# check number of arguments as input
if len(sys.argv) != 3:
print("Insert path to folder, in which molecule folders are stored.")
sys.exit(1)
# Define sections and parameters for functionals and basis sets
sections = {
'functionals': [],
'basis': [],
# Add more sections and parameters if wanted
}
# create an instance of the configparser
config = configparser.ConfigParser()
# Add sections and parameters
for section, params in sections.items():
config.add_section(section)
if section == 'functionals':
i = 1
while True:
param = 'functional' + str(i)
value = input(f"Please put in a value for {param} (or '*' to stop): ")
if value == '*':
break # Exit the loop if '*' is entered
params.append(param)
config.set(section, param, value)
i += 1
elif section == 'basis':
i = 1
while True:
param = 'basis' + str(i)
value = input(f"Please put in a value for {param} (or '*' to stop): ")
if value == '*':
break # Exit the loop if '*' is entered
params.append(param)
config.set(section, param, value)
i += 1
config['system'] = {'molecule': sys.argv[1],
'unpaired_elecs': input("How many unpaired electrons does the system have?: "),
'charge': input("What charge does the system have?: "),
'single_atm': input("Type 'True' if the system is a single Atom and 'False' if it is not: ")}
# Define output folder
system = config['system']['molecule']
output_folder = sys.argv[2] + '/' + system
if not os.path.exists(output_folder):
os.makedirs(output_folder)
# Save INI-file
configfile_path = os.path.join(output_folder, system + '.ini')
with open(configfile_path, 'w') as configfile:
config.write(configfile)
print(f"The INI-file for '{system}' was created successfully.")