From 682f446f0cd56fc6be00a722536fbfaf602533fa Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Tue, 20 Aug 2019 17:00:40 -0400 Subject: [PATCH] rmgpy/rmg/*.py import numpy as np --- rmgpy/rmg/input.py | 10 +++++----- rmgpy/rmg/model.py | 20 ++++++++++---------- rmgpy/rmg/settings.py | 14 +++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/rmgpy/rmg/input.py b/rmgpy/rmg/input.py index 0e9bbe770ff..34ab5ec4775 100644 --- a/rmgpy/rmg/input.py +++ b/rmgpy/rmg/input.py @@ -32,7 +32,7 @@ import os from copy import deepcopy -import numpy +import numpy as np from rmgpy import settings from rmgpy.exceptions import InputError @@ -545,16 +545,16 @@ def solvation(solvent): rmg.solvent = solvent -def model(toleranceMoveToCore=None, toleranceMoveEdgeReactionToCore=numpy.inf, toleranceKeepInEdge=0.0, +def model(toleranceMoveToCore=None, toleranceMoveEdgeReactionToCore=np.inf, toleranceKeepInEdge=0.0, toleranceInterruptSimulation=1.0, - toleranceMoveEdgeReactionToSurface=numpy.inf, toleranceMoveSurfaceSpeciesToCore=numpy.inf, - toleranceMoveSurfaceReactionToCore=numpy.inf, + toleranceMoveEdgeReactionToSurface=np.inf, toleranceMoveSurfaceSpeciesToCore=np.inf, + toleranceMoveSurfaceReactionToCore=np.inf, toleranceMoveEdgeReactionToSurfaceInterrupt=None, toleranceMoveEdgeReactionToCoreInterrupt=None, maximumEdgeSpecies=1000000, minCoreSizeForPrune=50, minSpeciesExistIterationsForPrune=2, filterReactions=False, filterThreshold=1e8, ignoreOverallFluxCriterion=False, maxNumSpecies=None, maxNumObjsPerIter=1, terminateAtMaxObjects=False, - toleranceThermoKeepSpeciesInEdge=numpy.inf, dynamicsTimeScale=(0.0, 'sec'), + toleranceThermoKeepSpeciesInEdge=np.inf, dynamicsTimeScale=(0.0, 'sec'), toleranceBranchReactionToCore=0.0, branchingIndex=0.5, branchingRatioMax=1.0): """ How to generate the model. `toleranceMoveToCore` must be specified. diff --git a/rmgpy/rmg/model.py b/rmgpy/rmg/model.py index 73be4151720..2b416f1f36a 100644 --- a/rmgpy/rmg/model.py +++ b/rmgpy/rmg/model.py @@ -38,7 +38,7 @@ import logging import os -import numpy +import numpy as np import rmgpy.data.rmg from rmgpy import settings @@ -211,10 +211,10 @@ def __init__(self, core=None, edge=None, surface=None): self.indexSpeciesDict = {} self.saveEdgeSpecies = False self.iterationNum = 0 - self.toleranceThermoKeepSpeciesInEdge = numpy.inf - self.Gfmax = numpy.inf - self.Gmax = numpy.inf - self.Gmin = -numpy.inf + self.toleranceThermoKeepSpeciesInEdge = np.inf + self.Gfmax = np.inf + self.Gmax = np.inf + self.Gmin = -np.inf self.minCoreSizeForPrune = 50 self.maximumEdgeSpecies = 100000 self.Tmax = 0 @@ -612,7 +612,7 @@ def enlarge(self, newObject=None, reactEdge=False, self.applyThermoToSpecies(procnum) # Do thermodynamic filtering - if not numpy.isinf(self.toleranceThermoKeepSpeciesInEdge) and self.newSpeciesList != []: + if not np.isinf(self.toleranceThermoKeepSpeciesInEdge) and self.newSpeciesList != []: self.thermoFilterSpecies(self.newSpeciesList) # Generate kinetics of new reactions @@ -1125,9 +1125,9 @@ def thermoFilterDown(self, maximumEdgeSpecies, minSpeciesExistIterationsForPrune logging.info('Reached maximum number of edge species') logging.info('Attempting to remove excess edge species with Thermodynamic filtering') spcs = self.edge.species - Gfs = numpy.array([spc.thermo.getFreeEnergy(Tmax) for spc in spcs]) + Gfs = np.array([spc.thermo.getFreeEnergy(Tmax) for spc in spcs]) Gns = (Gfs - self.Gmax) / (self.Gmax - self.Gmin) - inds = numpy.argsort(Gns) # could actually do this with the Gfs, but want to print the Gn value later + inds = np.argsort(Gns) # could actually do this with the Gfs, but want to print the Gn value later inds = inds[::-1] # get in order of increasing Gf ind = 0 @@ -1200,7 +1200,7 @@ def prune(self, reactionSystems, toleranceKeepInEdge, toleranceMoveToCore, maxim # Get the maximum species rates (and network leak rates) # across all reaction systems - max_edge_species_rate_ratios = numpy.zeros((num_prunable_species), numpy.float64) + max_edge_species_rate_ratios = np.zeros((num_prunable_species), np.float64) for reactionSystem in reactionSystems: for i in range(num_prunable_species): rate_ratio = reactionSystem.maxEdgeSpeciesRateRatios[i] @@ -1223,7 +1223,7 @@ def prune(self, reactionSystems, toleranceKeepInEdge, toleranceMoveToCore, maxim ineligible_species.append(spec) # Sort the edge species rates by index - indices = numpy.argsort(max_edge_species_rate_ratios) + indices = np.argsort(max_edge_species_rate_ratios) # Determine which species to prune species_to_prune = [] prune_due_to_rate_counter = 0 diff --git a/rmgpy/rmg/settings.py b/rmgpy/rmg/settings.py index 62cbd4ac5fe..36908bedc44 100644 --- a/rmgpy/rmg/settings.py +++ b/rmgpy/rmg/settings.py @@ -54,7 +54,7 @@ `maxNumObjPerIter` Maximum number of objects that can be sent for enlargement from a single simulation ================================================================================================================================================== """ -import numpy +import numpy as np from rmgpy.quantity import Quantity @@ -64,15 +64,15 @@ class ModelSettings(object): class for holding the parameters affecting an RMG run """ - def __init__(self, toleranceMoveToCore=None, toleranceMoveEdgeReactionToCore=numpy.inf, toleranceKeepInEdge=0.0, + def __init__(self, toleranceMoveToCore=None, toleranceMoveEdgeReactionToCore=np.inf, toleranceKeepInEdge=0.0, toleranceInterruptSimulation=1.0, - toleranceMoveEdgeReactionToSurface=numpy.inf, toleranceMoveSurfaceSpeciesToCore=numpy.inf, - toleranceMoveSurfaceReactionToCore=numpy.inf, + toleranceMoveEdgeReactionToSurface=np.inf, toleranceMoveSurfaceSpeciesToCore=np.inf, + toleranceMoveSurfaceReactionToCore=np.inf, toleranceMoveEdgeReactionToSurfaceInterrupt=None, toleranceMoveEdgeReactionToCoreInterrupt=None, maximumEdgeSpecies=1000000, minCoreSizeForPrune=50, minSpeciesExistIterationsForPrune=2, filterReactions=False, filterThreshold=1e8, ignoreOverallFluxCriterion=False, maxNumSpecies=None, maxNumObjsPerIter=1, - terminateAtMaxObjects=False, toleranceThermoKeepSpeciesInEdge=numpy.inf, + terminateAtMaxObjects=False, toleranceThermoKeepSpeciesInEdge=np.inf, dynamicsTimeScale=Quantity((0.0, 'sec')), toleranceBranchReactionToCore=0.0, branchingIndex=0.5, branchingRatioMax=1.0): @@ -114,10 +114,10 @@ def __init__(self, toleranceMoveToCore=None, toleranceMoveEdgeReactionToCore=num if maxNumSpecies: self.maxNumSpecies = maxNumSpecies else: - self.maxNumSpecies = numpy.inf + self.maxNumSpecies = np.inf if maxNumObjsPerIter <= 0: - self.maxNumObjsPerIter = numpy.inf + self.maxNumObjsPerIter = np.inf else: self.maxNumObjsPerIter = maxNumObjsPerIter