Skip to content

Commit d85b1d4

Browse files
committed
Updated RMG libraries in plotter
1 parent 6baf562 commit d85b1d4

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

arc/plotter.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,15 @@ def draw_thermo_parity_plots(species_list: list,
437437
labels, comments, h298_arc, h298_rmg, s298_arc, s298_rmg = [], [], [], [], [], []
438438
for spc in species_list:
439439
labels.append(spc.label)
440-
h298_arc.append(spc.thermo.get_enthalpy(298) * 0.001) # converted to kJ/mol
441-
h298_rmg.append(spc.rmg_thermo['H298'])
442-
s298_arc.append(spc.thermo.get_entropy(298)) # in J/mol*K
443-
s298_rmg.append(spc.rmg_thermo['S298']) # in J/mol*K
444-
comments.append(spc.rmg_thermo['comment'] if 'comment' in spc.rmg_thermo else '')
445-
var_units_h = r"$\left(\frac{J}{mol}\right)$"
446-
var_units_s = r"$\left(\frac{J}{mol\cdot{K}}\right)$"
447-
label_h = r"$\Delta H ^{298_K} _f}$"
448-
label_s = r"$\Delta S ^{298_K} _f}$"
440+
h298_arc.append(spc.thermo.H298)
441+
h298_rmg.append(spc.rmg_thermo.H298)
442+
s298_arc.append(spc.thermo.S298)
443+
s298_rmg.append(spc.rmg_thermo.S298)
444+
comments.append(spc.rmg_thermo.comment)
445+
var_units_h = r"$\mathrm{J\,mol^{-1}}$"
446+
var_units_s = r"$\mathrm{J\,mol^{-1}\,K^{-1}}$"
447+
label_h = r"$\Delta H^\circ_{f}(298\,\mathrm{K})$"
448+
label_s = r"$\Delta S^\circ_{f}(298\,\mathrm{K})$"
449449
draw_parity_plot(var_arc=h298_arc, var_rmg=h298_rmg, var_label=label_h, var_units=var_units_h, labels=labels, pp=pp)
450450
draw_parity_plot(var_arc=s298_arc, var_rmg=s298_rmg, var_label=label_s, var_units=var_units_s, labels=labels, pp=pp)
451451
pp.close()
@@ -469,9 +469,11 @@ def draw_parity_plot(var_arc, var_rmg, labels, var_label, var_units, pp=None):
469469
labels (list): Species labels corresponding to the data in ``var_arc`` and ``var_rmg``.
470470
var_label (str): The variable name.
471471
var_units (str): The variable units.
472-
pp (PdfPages, optional): Used for storing the image as a multi-page PFD file.
472+
pp (PdfPages, optional): Used for storing the image as a multipage PFD file.
473473
"""
474474
combined= [x for n in (var_arc, var_rmg) for x in n]
475+
if any(x is None for x in combined):
476+
return
475477
min_var = min(combined)
476478
max_var = max(combined)
477479
fig, ax = plt.subplots(dpi=120)
@@ -786,11 +788,7 @@ def save_thermo_lib(species_list: list,
786788
return
787789

788790
for i, spc in enumerate(species_list):
789-
thermo_key = 'thermo_data' if hasattr(spc.thermo, 'thermo_data') else 'nasa' if hasattr(spc.thermo, 'nasa') else None
790-
if thermo_key is None:
791-
logger.warning(f'Species {spc.label} did not contain any thermo data and was omitted from the thermo library.')
792-
continue
793-
if spc.thermo is not None and 'thermo_data' and spc.include_in_thermo_lib:
791+
if spc.thermo.data and spc.include_in_thermo_lib:
794792
if spc.label not in species_dict:
795793
adjlist = spc.adjlist or spc.mol_list[0].copy(deep=True).to_adjacency_list()
796794
species_dict[spc.label] = adjlist
@@ -799,12 +797,12 @@ def save_thermo_lib(species_list: list,
799797
f'optical isomers: {spc.optical_isomers}\n'
800798
f'\nGeometry:\n{xyz_to_str(spc.final_xyz)}'
801799
)
802-
comment = spc.thermo.comment if hasattr(spc.thermo, 'comment') else ''
800+
comment = spc.thermo.comment or ''
803801
thermo_txt += f"""entry(
804802
index = {i + 1},
805803
label = "{spc.label}",
806804
molecule = \"\"\"\n{species_dict[spc.label]}\n\"\"\",
807-
thermo = {repr(spc.thermo[thermo_key])},
805+
thermo = {spc.thermo.data},
808806
shortDesc = u\"\"\"{comment}\"\"\",
809807
longDesc = u\"\"\"\n{spc.long_thermo_description}\n\"\"\",
810808
)
@@ -825,7 +823,7 @@ def save_thermo_lib(species_list: list,
825823
species_dict_path = os.path.join(lib_path, 'species_dictionary.txt')
826824
with open(species_dict_path, 'w') as f:
827825
for label, adjlist in species_dict.items():
828-
f.write(f'{label}\n{adjlist}\n\n')
826+
f.write(f'{label}\n{adjlist}\n')
829827

830828

831829
def save_transport_lib(species_list, path, name, lib_long_desc=''):
@@ -910,7 +908,7 @@ def save_kinetics_lib(rxn_list: list,
910908
species_dict_path = os.path.join(lib_path, 'species_dictionary.txt')
911909
with open(species_dict_path, 'w') as f:
912910
for label, adjlist in species_dict.items():
913-
f.write(f'{label}\n{adjlist}\n\n')
911+
f.write(f'{label}\n{adjlist}\n')
914912

915913

916914
def save_conformers_file(project_directory: str,

0 commit comments

Comments
 (0)