Skip to content

Commit

Permalink
Use numpy_to_list() in rmg_constantTP to save human readable YAML files
Browse files Browse the repository at this point in the history
  • Loading branch information
alongd committed Dec 4, 2024
1 parent a8bc69b commit d55277c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions t3/simulate/rmg_constantTP.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from arc.common import save_yaml_file

from t3.common import get_chem_to_rmg_rxn_index_map, get_species_by_label, get_values_within_range, \
get_observable_label_from_header, get_parameter_from_header, time_lapse
get_observable_label_from_header, get_parameter_from_header, numpy_to_list, time_lapse
from t3.simulate.adapter import SimulateAdapter
from t3.simulate.factory import register_simulate_adapter
from t3.utils.writer import write_rmg_input_file
Expand Down Expand Up @@ -249,17 +249,14 @@ def get_sa_coefficients(self,
if not os.path.exists(solver_path):
self.logger.error("Could not find the path to RMG's SA solver output folder.")
return None
sa_files = list()
for file_ in os.listdir(solver_path):
if 'sensitivity' in file_ and file_.endswith(".csv"):
sa_files.append(file_)
sa_files = [file_ for file_ in os.listdir(solver_path) if 'sensitivity' in file_ and file_.endswith(".csv")]
sa_dict = {'kinetics': dict(), 'thermo': dict(), 'time': list()}
for sa_file in sa_files:
df = pd.read_csv(os.path.join(solver_path, sa_file))
for header in df.columns:
sa_type = None
if 'Time' in header:
sa_dict['time'] = df[header].values
sa_dict['time'] = numpy_to_list(df[header].values)
elif '/dln[k' in header:
sa_type = 'kinetics'
elif '/dG[' in header:
Expand All @@ -277,7 +274,7 @@ def get_sa_coefficients(self,
parameter = parameter[1:]
parameter = chem_to_rmg_rxn_index_map[int(parameter)] \
if all(c.isdigit() for c in parameter) else parameter
sa_dict[sa_type][observable_label][parameter] = df[header].values
sa_dict[sa_type][observable_label][parameter] = numpy_to_list(df[header].values)
if save_yaml:
save_yaml_file(path=self.paths['SA dict'], content=sa_dict)
return sa_dict
Expand Down

0 comments on commit d55277c

Please sign in to comment.