Skip to content

Commit 653a26b

Browse files
committed
Return YAML content when logging species & reactions based on SA
1 parent 965ec71 commit 653a26b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

t3/logger.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def log_footer(self):
166166

167167
def log_species_to_calculate(self,
168168
species_keys: List[int],
169-
species_dict: Dict[int, dict]):
169+
species_dict: Dict[int, dict]) -> Dict:
170170
"""
171171
Report the species to be calculated in the next iteration.
172172
The 'QM label' is used for reporting, it is principally the
@@ -178,9 +178,10 @@ def log_species_to_calculate(self,
178178
species_keys (List[int]): Entries are T3 species indices.
179179
species_dict (dict): The T3 species dictionary.
180180
181-
Todo:
182-
Log the reasons one by one with line breaks and enumerate
181+
Returns:
182+
Dict: SA content for the YAML file.
183183
"""
184+
yml_content = dict()
184185
if len(species_keys):
185186
self.info('\n\nSpecies to calculate thermodynamic data for:')
186187
max_label_length = max([len(spc_dict['QM label'])
@@ -201,18 +202,27 @@ def log_species_to_calculate(self,
201202
for j, reason in enumerate(spc_dict['reasons']):
202203
if j:
203204
self.info(f"{' ' * (max_label_length + max_smiles_length + 4)}{j + 1}. {spc_dict['reasons'][j]}")
205+
yml_content[key] = {'SMILES': smiles,
206+
'QM label': spc_dict['QM label'],
207+
'reasons': spc_dict['reasons'],
208+
}
209+
return yml_content
204210

205211
def log_reactions_to_calculate(self,
206212
reaction_keys: List[int],
207-
reaction_dict: Dict[int, dict]):
213+
reaction_dict: Dict[int, dict]) -> Dict:
208214
"""
209215
Report reaction rate coefficients to be calculated in the next iteration.
210216
The reaction 'QM label' is used for reporting.
211217
212218
Args:
213219
reaction_keys (List[int]): Entries are T3 reaction indices.
214220
reaction_dict (dict): The T3 reaction dictionary.
221+
222+
Returns:
223+
Dict: SA content for the YAML file.
215224
"""
225+
yml_content = dict()
216226
if len(reaction_keys):
217227
self.info('\n\nReactions to calculate high-pressure limit rate coefficients for:')
218228
max_label_length = max([len(rxn_dict['QM label'])
@@ -228,10 +238,16 @@ def log_reactions_to_calculate(self,
228238
space1 = ' ' * (max_label_length - len(rxn_dict['QM label']) + 1)
229239
self.info(f"\n{rxn_dict['QM label']}{space1} {rxn_dict['reasons']}")
230240
self.info(f"{rxn_dict['SMILES label']}\n")
241+
yml_content[key] = {'SMILES label': rxn_dict['SMILES label'],
242+
'QM label': rxn_dict['QM label'],
243+
'reasons': rxn_dict['reasons'],
244+
}
231245
if hasattr(rxn_dict['object'], 'family') and rxn_dict['object'].family is not None:
232246
label = rxn_dict['object'].family if isinstance(rxn_dict['object'].family, str) \
233247
else rxn_dict['object'].family.label
234248
self.info(f'RMG family: {label}\n')
249+
yml_content[key]['RMG family'] = label
250+
return yml_content
235251

236252
def log_species_summary(self, species_dict: Dict[int, dict]):
237253
"""

0 commit comments

Comments
 (0)