Skip to content

Commit

Permalink
Don't replace PDep kinetics of a library reaction
Browse files Browse the repository at this point in the history
Library reactions marked with an ``elementary_high_p`` flag set to ``True`` can either have PDep kinetics or Arrhenius kinetics. The high-pressure-limit kinetics is used in PDep networks to improve them instead of using RMG's estimations. However, if the original library reaction already has PDep kinetics, then this library rate should end up in the model rather than a PDep estimation. Of course, if the library reaction only has Arrhenius (non-PDep) kinetics, and the reaction is pressure-dependent, the kinetics must be replaced with the PDep estimation.
  • Loading branch information
alongd authored and mjohnson541 committed Jul 26, 2023
1 parent eb178e1 commit 65dfeca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions rmgpy/rmg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,9 @@ def process_new_reactions(self, new_reactions, new_species, pdep_network=None, g
# Since PDepReactions are created as irreversible, not doing so
# would cause you to miss the reverse reactions!
self.add_reaction_to_unimolecular_networks(rxn, new_species=new_species, network=pdep_network)
if isinstance(rxn, LibraryReaction):
# If reaction came from a reaction library, omit it from the core and edge so that it does
# not get double-counted with the pdep network
if isinstance(rxn, LibraryReaction) and not rxn.kinetics.is_pressure_dependent():
# If the reaction came from a library, and it does not have PDep kinetics,
# omit it from the core and edge so that it does not get double-counted with the pdep network
if rxn in self.core.reactions:
self.core.reactions.remove(rxn)
if rxn in self.edge.reactions:
Expand Down
18 changes: 9 additions & 9 deletions rmgpy/rmg/pdep.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def update(self, reaction_model, pdep_settings):
reactants=configurations[j],
products=configurations[i],
network=self,
kinetics=None
kinetics=None,
)
net_reaction = reaction_model.make_new_pdep_reaction(net_reaction)
self.net_reactions.append(net_reaction)
Expand All @@ -911,10 +911,10 @@ def update(self, reaction_model, pdep_settings):
for rxn in reaction_model.core.reactions:
if isinstance(rxn, LibraryReaction) \
and rxn.is_isomorphic(net_reaction, either_direction=True) \
and not rxn.allow_pdep_route and not rxn.elementary_high_p:
logging.info('Network reaction {0} matched an existing core reaction {1}'
' from the {2} library, and was not added to the model'.format(
str(net_reaction), str(rxn), rxn.library))
and not rxn.allow_pdep_route \
and (rxn.kinetics.is_pressure_dependent() or not rxn.elementary_high_p):
logging.info(f'Network reaction {net_reaction} matched an existing core reaction {rxn} '
f'from the {rxn.library} library, and was not added to the model')
break
else:
reaction_model.add_reaction_to_core(net_reaction)
Expand All @@ -923,10 +923,10 @@ def update(self, reaction_model, pdep_settings):
for rxn in reaction_model.edge.reactions:
if isinstance(rxn, LibraryReaction) \
and rxn.is_isomorphic(net_reaction, either_direction=True) \
and not rxn.allow_pdep_route and not rxn.elementary_high_p:
logging.info('Network reaction {0} matched an existing edge reaction {1}'
' from the {2} library, and was not added to the model'.format(
str(net_reaction), str(rxn), rxn.library))
and not rxn.allow_pdep_route \
and (rxn.kinetics.is_pressure_dependent() or not rxn.elementary_high_p):
logging.info(f'Network reaction {net_reaction} matched an existing edge reaction {rxn} '
f'from the {rxn.library} library, and was not added to the model')
break
else:
reaction_model.add_reaction_to_edge(net_reaction)
Expand Down

0 comments on commit 65dfeca

Please sign in to comment.