-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomize_3T_bulk_electrolyte_oxidation.py
More file actions
35 lines (32 loc) · 1.2 KB
/
randomize_3T_bulk_electrolyte_oxidation.py
File metadata and controls
35 lines (32 loc) · 1.2 KB
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
import random
import os, sys
from main_run_utils import multiple_runs
def config_modify_func(template):
# Prepare random config file
n_Li = str(random.randrange(1,5))
n_VC = str(random.randrange(1,4))
n_PF6 = str(1)
n_CO3 = str(random.randrange(1,3))
n_Ethylene = n_CO3
n_oEC = str(random.randrange(1,3))
n_EC = str( 10 )
config_str = template.replace('$$Li$$', n_Li)
config_str = config_str.replace('$$VC$$', n_VC)
config_str = config_str.replace('$$PF6$$', n_PF6)
config_str = config_str.replace('$$CO3$$', n_CO3)
config_str = config_str.replace('$$Ethylene$$', n_Ethylene)
config_str = config_str.replace('$$oEC$$', n_oEC)
config_str = config_str.replace('$$EC$$', n_EC)
config_dir = 'configs/'+tag
if not os.path.isdir(config_dir):
os.mkdir(config_dir)
duplicate = True
while duplicate:
config_json = config_dir + '/' + tag + '_' + hex(random.randrange(0, sys.maxsize)) + '.json'
if not os.path.isfile(config_json):
duplicate = False
with open(config_json,'w') as f:
f.write(config_str)
return config_json, config_str
tag = 'Electrolyte_Oxidation'
multiple_runs(10, tag, config_modify_func)