Skip to content

Commit 65dfeca

Browse files
alongdmjohnson541
authored andcommitted
Don't replace PDep kinetics of a library reaction
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.
1 parent eb178e1 commit 65dfeca

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

rmgpy/rmg/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,9 @@ def process_new_reactions(self, new_reactions, new_species, pdep_network=None, g
864864
# Since PDepReactions are created as irreversible, not doing so
865865
# would cause you to miss the reverse reactions!
866866
self.add_reaction_to_unimolecular_networks(rxn, new_species=new_species, network=pdep_network)
867-
if isinstance(rxn, LibraryReaction):
868-
# If reaction came from a reaction library, omit it from the core and edge so that it does
869-
# not get double-counted with the pdep network
867+
if isinstance(rxn, LibraryReaction) and not rxn.kinetics.is_pressure_dependent():
868+
# If the reaction came from a library, and it does not have PDep kinetics,
869+
# omit it from the core and edge so that it does not get double-counted with the pdep network
870870
if rxn in self.core.reactions:
871871
self.core.reactions.remove(rxn)
872872
if rxn in self.edge.reactions:

rmgpy/rmg/pdep.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ def update(self, reaction_model, pdep_settings):
898898
reactants=configurations[j],
899899
products=configurations[i],
900900
network=self,
901-
kinetics=None
901+
kinetics=None,
902902
)
903903
net_reaction = reaction_model.make_new_pdep_reaction(net_reaction)
904904
self.net_reactions.append(net_reaction)
@@ -911,10 +911,10 @@ def update(self, reaction_model, pdep_settings):
911911
for rxn in reaction_model.core.reactions:
912912
if isinstance(rxn, LibraryReaction) \
913913
and rxn.is_isomorphic(net_reaction, either_direction=True) \
914-
and not rxn.allow_pdep_route and not rxn.elementary_high_p:
915-
logging.info('Network reaction {0} matched an existing core reaction {1}'
916-
' from the {2} library, and was not added to the model'.format(
917-
str(net_reaction), str(rxn), rxn.library))
914+
and not rxn.allow_pdep_route \
915+
and (rxn.kinetics.is_pressure_dependent() or not rxn.elementary_high_p):
916+
logging.info(f'Network reaction {net_reaction} matched an existing core reaction {rxn} '
917+
f'from the {rxn.library} library, and was not added to the model')
918918
break
919919
else:
920920
reaction_model.add_reaction_to_core(net_reaction)
@@ -923,10 +923,10 @@ def update(self, reaction_model, pdep_settings):
923923
for rxn in reaction_model.edge.reactions:
924924
if isinstance(rxn, LibraryReaction) \
925925
and rxn.is_isomorphic(net_reaction, either_direction=True) \
926-
and not rxn.allow_pdep_route and not rxn.elementary_high_p:
927-
logging.info('Network reaction {0} matched an existing edge reaction {1}'
928-
' from the {2} library, and was not added to the model'.format(
929-
str(net_reaction), str(rxn), rxn.library))
926+
and not rxn.allow_pdep_route \
927+
and (rxn.kinetics.is_pressure_dependent() or not rxn.elementary_high_p):
928+
logging.info(f'Network reaction {net_reaction} matched an existing edge reaction {rxn} '
929+
f'from the {rxn.library} library, and was not added to the model')
930930
break
931931
else:
932932
reaction_model.add_reaction_to_edge(net_reaction)

0 commit comments

Comments
 (0)