diff --git a/examples/rmg/heptane-filterReactions/input.py b/examples/rmg/heptane-filterReactions/input.py new file mode 100644 index 0000000000..8d3805791f --- /dev/null +++ b/examples/rmg/heptane-filterReactions/input.py @@ -0,0 +1,75 @@ +# Data sources +database( + thermoLibraries = ['primaryThermoLibrary'], + reactionLibraries = [], + seedMechanisms = [], + kineticsDepositories = ['training'], + kineticsFamilies = 'default', + kineticsEstimator = 'rate rules', +) + +# Constraints on generated species +generatedSpeciesConstraints( + maximumCarbonAtoms = 7, +) + +# List of species +species( + label='n-heptane', + structure=SMILES("CCCCCCC"), +) + +species( + label='Ar', + reactive=False, + structure=SMILES("[Ar]"), +) + + +simpleReactor( + temperature=(1600,'K'), + pressure=(400,'Pa'), + initialMoleFractions={ + "n-heptane": 0.02, + "Ar": 0.98, + }, + terminationConversion={ + 'n-heptane': 0.99, + }, + terminationTime=(1e6,'s'), +) + +simpleReactor( + temperature=(2000,'K'), + pressure=(400,'Pa'), + initialMoleFractions={ + "n-heptane": 0.02, + "Ar": 0.98, + }, + terminationConversion={ + 'n-heptane': 0.99, + }, + terminationTime=(1e6,'s'), +) + +simulator( + atol=1e-16, + rtol=1e-8, +) + +model( + toleranceMoveToCore=0.01, + toleranceInterruptSimulation=0.01, + filterReactions=True, +) + +pressureDependence( + method='modified strong collision', + maximumGrainSize=(0.5,'kcal/mol'), + minimumNumberOfGrains=250, + temperatures=(300,3000,'K',8), + pressures=(0.001,100,'bar',5), + interpolation=('Chebyshev', 6, 4), +) + + diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index 32463bf26a..3bda5a8d79 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -609,35 +609,37 @@ def execute(self, inputFile, output_directory, **kwargs): for objectToEnlarge in objectsToEnlarge: self.reactionModel.enlarge(objectToEnlarge) - if self.filterReactions: - # Run a raw simulation to get updated reaction system threshold values - for index, reactionSystem in enumerate(self.reactionSystems): - # Run with the same conditions as with pruning off - reactionSystem.simulate( - coreSpecies = self.reactionModel.core.species, - coreReactions = self.reactionModel.core.reactions, - edgeSpecies = [], - edgeReactions = [], - toleranceKeepInEdge = 0, - toleranceMoveToCore = self.fluxToleranceMoveToCore, - toleranceInterruptSimulation = self.fluxToleranceMoveToCore, - pdepNetworks = self.reactionModel.networkList, - absoluteTolerance = self.absoluteTolerance, - relativeTolerance = self.relativeTolerance, - filterReactions=True, - ) - reactEdge = self.updateReactionThresholdAndReactFlags( - rxnSysUnimolecularThreshold = reactionSystem.unimolecularThreshold, - rxnSysBimolecularThreshold = reactionSystem.bimolecularThreshold) - - logging.info('') - else: - reactEdge = self.updateReactionThresholdAndReactFlags() - - if reactEdge: + if len(self.reactionModel.core.species) > numCoreSpecies: + # If there were core species added, then react the edge + # If there were no new core species, it means the pdep network needs be updated through another enlarge core step + if self.filterReactions: + # Run a raw simulation to get updated reaction system threshold values + for index, reactionSystem in enumerate(self.reactionSystems): + # Run with the same conditions as with pruning off + reactionSystem.simulate( + coreSpecies = self.reactionModel.core.species, + coreReactions = self.reactionModel.core.reactions, + edgeSpecies = [], + edgeReactions = [], + toleranceKeepInEdge = 0, + toleranceMoveToCore = self.fluxToleranceMoveToCore, + toleranceInterruptSimulation = self.fluxToleranceMoveToCore, + pdepNetworks = self.reactionModel.networkList, + absoluteTolerance = self.absoluteTolerance, + relativeTolerance = self.relativeTolerance, + filterReactions=True, + ) + self.updateReactionThresholdAndReactFlags( + rxnSysUnimolecularThreshold = reactionSystem.unimolecularThreshold, + rxnSysBimolecularThreshold = reactionSystem.bimolecularThreshold) + + logging.info('') + else: + self.updateReactionThresholdAndReactFlags() + self.reactionModel.enlarge(reactEdge=True, - unimolecularReact=self.unimolecularReact, - bimolecularReact=self.bimolecularReact) + unimolecularReact=self.unimolecularReact, + bimolecularReact=self.bimolecularReact) self.saveEverything() @@ -715,7 +717,6 @@ def updateReactionThresholdAndReactFlags(self, rxnSysUnimolecularThreshold=None, prevNumCoreSpecies = len(self.unimolecularReact) stale = True if numCoreSpecies > prevNumCoreSpecies else False - reactEdge = True if self.filterReactions: if stale: @@ -759,11 +760,7 @@ def updateReactionThresholdAndReactFlags(self, rxnSysUnimolecularThreshold=None, for i in xrange(numCoreSpecies): for j in xrange(prevNumCoreSpecies,numCoreSpecies): self.bimolecularReact[i,j] = True - else: - # No reacting of edge because unimolecularReact and bimolecularReact will be False - reactEdge = False - - return reactEdge + def saveEverything(self): """