-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_settings.py
237 lines (178 loc) · 8.21 KB
/
update_settings.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
"""
update settings.json
"""
import os
from shutil import copy2
import read_write_configuration as rwc
import global_settings
def update_basic_setting(data_dir, g_s):
"""
update settings.json, the basic information that's will not change for this system
"""
# there will always be a current setting
fn0 = os.path.join(data_dir, "input", "setting_backup.json")
fn1 = os.path.join(data_dir, "input", "setting.json")
if os.path.isfile(fn1):
copy2(fn1, fn0)
setting = rwc.read_configuration(
os.path.join(data_dir, 'input', 'setting.json'))
setting['system']['condition'] = g_s['system']['condition']
setting['system']['initializer'] = g_s['system']['initializer']
setting['network']['merge_chatterings'] = g_s['network']['merge_chatterings']
setting['propagator']['primary_type'] = g_s['propagator']['primary_type']
setting['propagator']['type'] = g_s['propagator']['type']
setting['propagator']['sub_type'] = g_s['propagator']['sub_type']
setting['propagator']['convert_molar_concentration_to_mole_fraction'] = g_s['propagator']['convert_molar_concentration_to_mole_fraction']
setting['propagator']['normalize_initial_concentration'] = g_s['propagator']['normalize_initial_concentration']
rwc.write_configuration(setting, os.path.join(
data_dir, 'input', 'setting.json'))
def update_dlsode_setting(data_dir, max_time=1.0, critical_time=0.9):
"""
update settings.json, primarily for dlsode run and pathway generating
"""
# there will always be a current setting
fn0 = os.path.join(data_dir, "input", "setting_backup.json")
fn1 = os.path.join(data_dir, "input", "setting.json")
if os.path.isfile(fn1):
copy2(fn1, fn0)
setting = rwc.read_configuration(
os.path.join(data_dir, 'input', 'setting.json'))
setting['time']['critical_time'] = critical_time
setting['time']['max_time'] = max_time
setting['job']['job_type'] = "solve_ODEs_for_concentration_using_LSODE"
rwc.write_configuration(setting, os.path.join(
data_dir, 'input', 'setting.json'))
def update_terminal_species_setting(data_dir, terminal_spe=None):
"""
update settings.json, primarily for terminal species
"""
# there will always be a current setting
fn0 = os.path.join(data_dir, "input", "setting_backup.json")
fn1 = os.path.join(data_dir, "input", "setting.json")
if os.path.isfile(fn1):
copy2(fn1, fn0)
setting = rwc.read_configuration(
os.path.join(data_dir, 'input', 'setting.json'))
t_s = []
if terminal_spe is not None and terminal_spe is not []:
for _, val in enumerate(terminal_spe):
t_s.append(val)
setting['pathway']['terminal_species'] = t_s
rwc.write_configuration(setting, os.path.join(
data_dir, 'input', 'setting.json'))
return
def update_chattering_species_setting(data_dir, atom_followed="C"):
"""
update settings.json, primarily for chattering species and fast reactions
"""
# there will always be a current setting
fn0 = os.path.join(data_dir, "input", "setting_backup.json")
fn1 = os.path.join(data_dir, "input", "setting.json")
if os.path.isfile(fn1):
copy2(fn1, fn0)
setting = rwc.read_configuration(
os.path.join(data_dir, 'input', 'setting.json'))
chattering_spe = global_settings.get_chattering_species(
data_dir, atom_followed)
setting['pathway']['chattering_species'] = chattering_spe
rwc.write_configuration(setting, os.path.join(
data_dir, 'input', 'setting.json'))
return
def update_spe_concentration_at_time_w2f(data_dir, tau=10.0, end_t=1.0):
"""
update settings.json, primarily for update_spe_concentration_at_time_w2f
"""
# there will always be a current setting
fn0 = os.path.join(data_dir, "input", "setting_backup.json")
fn1 = os.path.join(data_dir, "input", "setting.json")
if os.path.isfile(fn1):
copy2(fn1, fn0)
setting = rwc.read_configuration(
os.path.join(data_dir, 'input', 'setting.json'))
setting['job']['job_type'] = "write_concentration_at_time_to_file"
setting['time']['tau'] = tau
setting['pathway']['end_t'] = end_t
rwc.write_configuration(setting, os.path.join(
data_dir, 'input', 'setting.json'))
def update_mc_trajectory_setting(data_dir, n_traj=1000000, atom_followed="C", init_spe=114,
tau=10.0, begin_t=0.0, end_t=1.0, species_path=False):
"""
update settings.json, primarily for generate_pathway_running_Monte_carlo_trajectory
"""
# there will always be a current setting
fn0 = os.path.join(data_dir, "input", "setting_backup.json")
fn1 = os.path.join(data_dir, "input", "setting.json")
if os.path.isfile(fn1):
copy2(fn1, fn0)
setting = rwc.read_configuration(
os.path.join(data_dir, 'input', 'setting.json'))
chattering_spe = global_settings.get_chattering_species(
data_dir, atom_followed)
setting['pathway']['chattering_species'] = chattering_spe
setting['time']['tau'] = tau
setting['pathway']['trajectoryNumber'] = n_traj
setting['pathway']['atom_followed'] = atom_followed
setting['pathway']['init_spe'] = init_spe
setting['pathway']['begin_t'] = begin_t
setting['pathway']['end_t'] = end_t
if species_path is True:
setting['job']['job_type'] = "generate_species_pathway_running_Monte_carlo_trajectory"
else:
setting['job']['job_type'] = "generate_pathway_running_Monte_carlo_trajectory"
rwc.write_configuration(setting, os.path.join(
data_dir, 'input', 'setting.json'))
return
def update_eval_path_integral(data_dir, top_n=5, n_traj=10000, atom_followed="C", init_spe=114,
tau=10.0, begin_t=0.0, end_t=1.0, species_path=False):
"""
update settings.json, primarily for evaluate path integral
"""
# there will always be a current setting
fn0 = os.path.join(data_dir, "input", "setting_backup.json")
fn1 = os.path.join(data_dir, "input", "setting.json")
if os.path.isfile(fn1):
copy2(fn1, fn0)
setting = rwc.read_configuration(
os.path.join(data_dir, 'input', 'setting.json'))
chattering_spe = global_settings.get_chattering_species(
data_dir, atom_followed)
setting['pathway']['chattering_species'] = chattering_spe
if species_path is True:
setting['job']['job_type'] = "evaluate_species_path_integral_over_time"
else:
setting['job']['job_type'] = "evaluate_path_integral_over_time"
setting['pathway']['topN'] = [top_n]
setting['pathway']['trajectoryNumber'] = n_traj
setting['pathway']['atom_followed'] = atom_followed
setting['pathway']['init_spe'] = init_spe
setting['time']['tau'] = tau
setting['pathway']['begin_t'] = begin_t
setting['pathway']['end_t'] = end_t
rwc.write_configuration(setting, os.path.join(
data_dir, 'input', 'setting.json'))
def update_s_a_setting(data_dir, init_temp=1000, critical_temp=1100,
target_temp=1800, end_temp=1900, spe_idx_conc=None):
"""
update settings.json, primarily for sensitivity analysis
the last parameter represents "species index concentration", is a dict
"""
# there will always be a current setting
fn0 = os.path.join(data_dir, "input", "setting_backup.json")
fn1 = os.path.join(data_dir, "input", "setting.json")
if os.path.isfile(fn1):
copy2(fn1, fn0)
setting = rwc.read_configuration(
os.path.join(data_dir, 'input', 'setting.json'))
setting['propagator']['primary_type'] = "not_from_file"
setting['propagator']['type'] = "dlsode"
setting['propagator']['sub_type'] = "temperature_propagator_cv_s2m_pgt"
setting['propagator']['normalize_initial_concentration'] = "no"
setting['job']['job_type'] = "evaluate_ignition_delay_time_once"
setting['chem_init']['init_temperature'] = init_temp
setting['T']['critical_temperature'] = critical_temp
setting['T']['target_temperature'] = target_temp
setting['T']['end_temperature'] = end_temp
if spe_idx_conc is not None:
setting['chem_init']['species_index_concentration'] = spe_idx_conc
rwc.write_configuration(setting, os.path.join(
data_dir, 'input', 'setting.json'))