@@ -20,6 +20,7 @@ def write_rmg_input_file(rmg: dict,
2020 t3 : dict ,
2121 path : str ,
2222 iteration : int = 1 ,
23+ run_sa : bool = False ,
2324 walltime : str = '00:00:00:00' ,
2425 ):
2526 """
@@ -32,6 +33,7 @@ def write_rmg_input_file(rmg: dict,
3233 path (str): The path where the RMG input file should be saved.
3334 iteration (int, optional): The T3 iteration, used to determine ``core_tolerance`` and
3435 ``tolerance_interrupt_simulation``. Does not matter for simulating or computing SA.
36+ run_sa (bool, optional): Whether to add sensitivity analysis information into the RMG input file.
3537 walltime (str, optional): The time cap for an RMG run. Should pass here t3['options']['max_RMG_walltime']
3638 """
3739 rmg = rmg .copy ()
@@ -101,7 +103,7 @@ def write_rmg_input_file(rmg: dict,
101103 pressure=${pressure},
102104 initialMoleFractions={${concentrations()} },
103105 ${termination}
104- nSims=${conditions_per_iteration},${balance}${constant}
106+ nSims=${conditions_per_iteration},${balance}${constant}${sensitivity}
105107)
106108<%def name="concentrations()">
107109% for spc in species_list:
@@ -119,7 +121,7 @@ def write_rmg_input_file(rmg: dict,
119121 temperature=${temperature},
120122 initialConcentrations={${concentrations()} },
121123 ${termination}
122- nSims=${conditions_per_iteration},${constant}
124+ nSims=${conditions_per_iteration},${constant}${sensitivity}
123125)
124126<%def name="concentrations()">
125127% for spc in species_list:
@@ -167,6 +169,16 @@ def write_rmg_input_file(rmg: dict,
167169 constant = '\n constantSpecies=['
168170 constant += f"'{ spc ['label' ]} ', "
169171 constant += '],' if constant else ''
172+ sensitivity = ''
173+ observables = [spc ['label' ] for spc in species if spc ['observable' ]]
174+ if run_sa and len (observables ):
175+ sensitivity = '\n sensitivity=['
176+ for i , observable in enumerate (observables ):
177+ sensitivity += f"'{ observable } '"
178+ if i < len (observables ) - 1 :
179+ sensitivity += ', '
180+ sensitivity += f"],\n sensitivityThreshold={ t3 ['sensitivity' ]['SA_threshold' ]} "
181+
170182
171183 if reactor ['type' ] == 'gas batch constant T P' :
172184 if isinstance (reactor ['P' ], float ):
@@ -189,6 +201,7 @@ def write_rmg_input_file(rmg: dict,
189201 conditions_per_iteration = reactor ['conditions_per_iteration' ],
190202 balance = balance ,
191203 constant = constant ,
204+ sensitivity = sensitivity ,
192205 )
193206
194207 elif reactor ['type' ] == 'liquid batch constant T V' :
0 commit comments