Skip to content

Commit

Permalink
rmgpy/rmg/*.py import numpy as np
Browse files Browse the repository at this point in the history
  • Loading branch information
amarkpayne committed Aug 20, 2019
1 parent 5035957 commit 682f446
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions rmgpy/rmg/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
20 changes: 10 additions & 10 deletions rmgpy/rmg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import logging
import os

import numpy
import numpy as np

import rmgpy.data.rmg
from rmgpy import settings
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions rmgpy/rmg/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 682f446

Please sign in to comment.