Skip to content

Commit 1668d08

Browse files
committed
Reorganize initial react step to react for each reaction system
This fixes a bug where no reactions are generated because the react flags are reset after each reaction system. This also makes the initial react stage more similar to how reactions are generated in the main loop, where reacting is done for each reactor.
1 parent 3f3703a commit 1668d08

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

rmgpy/rmg/main.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,15 @@ def execute(self, **kwargs):
616616
self.rmg_memories = []
617617

618618
# Initiate first reaction discovery step after adding all core species
619-
if self.filterReactions:
620-
# Run the reaction system to update threshold and react flags
621-
for index, reactionSystem in enumerate(self.reactionSystems):
622-
self.rmg_memories.append(RMG_Memory(reactionSystem,self.balanceSpecies))
623-
self.rmg_memories[index].generate_cond()
624-
log_conditions(self.rmg_memories,index)
619+
for index, reactionSystem in enumerate(self.reactionSystems):
620+
# Initialize memory object to track conditions for ranged reactors
621+
self.rmg_memories.append(RMG_Memory(reactionSystem, self.balanceSpecies))
622+
self.rmg_memories[index].generate_cond()
623+
log_conditions(self.rmg_memories, index)
624+
625+
# Update react flags
626+
if self.filterReactions:
627+
# Run the reaction system to update threshold and react flags
625628
reactionSystem.initializeModel(
626629
coreSpecies=self.reactionModel.core.species,
627630
coreReactions=self.reactionModel.core.reactions,
@@ -639,23 +642,27 @@ def execute(self, **kwargs):
639642
rxnSysBimolecularThreshold=reactionSystem.bimolecularThreshold,
640643
rxnSysTrimolecularThreshold=reactionSystem.trimolecularThreshold,
641644
)
642-
else:
643-
for index, reactionSystem in enumerate(self.reactionSystems):
644-
self.rmg_memories.append(RMG_Memory(reactionSystem,self.balanceSpecies))
645-
self.rmg_memories[index].generate_cond()
646-
log_conditions(self.rmg_memories,index)
645+
else:
646+
# If we're not filtering reactions, then we only need to react
647+
# the first reaction system since they share the same core
648+
if index > 0:
649+
continue
650+
651+
# React core species to enlarge edge
652+
self.reactionModel.enlarge(reactEdge=True,
653+
unimolecularReact=self.unimolecularReact,
654+
bimolecularReact=self.bimolecularReact,
655+
trimolecularReact=self.trimolecularReact)
647656

648657
if not np.isinf(self.modelSettingsList[0].toleranceThermoKeepSpeciesInEdge):
649-
self.reactionModel.setThermodynamicFilteringParameters(self.Tmax,toleranceThermoKeepSpeciesInEdge=self.modelSettingsList[0].toleranceThermoKeepSpeciesInEdge,
650-
minCoreSizeForPrune=self.modelSettingsList[0].minCoreSizeForPrune,
651-
maximumEdgeSpecies =self.modelSettingsList[0].maximumEdgeSpecies,
652-
reactionSystems=self.reactionSystems)
653-
654-
self.reactionModel.enlarge(reactEdge=True,
655-
unimolecularReact=self.unimolecularReact,
656-
bimolecularReact=self.bimolecularReact,
657-
trimolecularReact=self.trimolecularReact)
658-
658+
self.reactionModel.setThermodynamicFilteringParameters(
659+
self.Tmax,
660+
toleranceThermoKeepSpeciesInEdge=self.modelSettingsList[0].toleranceThermoKeepSpeciesInEdge,
661+
minCoreSizeForPrune=self.modelSettingsList[0].minCoreSizeForPrune,
662+
maximumEdgeSpecies=self.modelSettingsList[0].maximumEdgeSpecies,
663+
reactionSystems=self.reactionSystems
664+
)
665+
659666
if not np.isinf(self.modelSettingsList[0].toleranceThermoKeepSpeciesInEdge):
660667
self.reactionModel.thermoFilterDown(maximumEdgeSpecies=self.modelSettingsList[0].maximumEdgeSpecies)
661668

0 commit comments

Comments
 (0)