Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions rmgpy/data/kinetics/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def extract_source_from_comments(self, reaction):
A reaction can only be estimated using one of these methods.

source = {'RateRules': (Family_Label, OriginalTemplate, RateRules),
'Library': String_Name_of_Library_Used,
'Library': (String_Name_of_Library_Used, Library_Entry),
'PDep': Network_Index,
'Training': (Family_Label, Training_Reaction_Entry),
}
Expand All @@ -715,7 +715,25 @@ def extract_source_from_comments(self, reaction):
source['Rate Rules'] = data_source
elif isinstance(reaction, LibraryReaction):
# This reaction comes from a reaction library or seed mechanism
source['Library'] = reaction.library
if reaction.library not in self.libraries:
raise ValueError(f'Library {reaction.library} not found in kinetics database. Make sure libraries match input file used to generate kinetics.')
library_reactions = self.generate_reactions_from_library(
library=self.libraries[reaction.library],
reactants=reaction.reactants,
products=reaction.products
)
if not library_reactions:
raise ValueError(f'Could not find reaction {reaction} in library {reaction.library} when trying to extract source data from comments.')
entry = self.libraries[reaction.library].entries[library_reactions[0].entry.index]
if len(library_reactions) > 1:
# Library contains multiple reactions of the same type, so pick the one with matching kinetics
for rxn in library_reactions:
if rxn.entry.data.is_similar_to(reaction.kinetics): # units might have been changed, so use is_similar_to instead of direct comparison
entry = self.libraries[reaction.library].entries[rxn.entry.index]
Comment thread
sevyharris marked this conversation as resolved.
break
else:
raise ValueError(f'Found multiple instances of reaction {reaction} in library {reaction.library}, but none of them have kinetics identical to the reaction kinetics.')
source['Library'] = (reaction.library, entry)
Comment thread
sevyharris marked this conversation as resolved.

elif isinstance(reaction, PDepReaction):
# This reaction is a pressure-dependent reaction
Expand Down
Loading
Loading