Skip to content

Commit

Permalink
add allow_max_rate_violation attribute to exempt reactions from the m…
Browse files Browse the repository at this point in the history
…ax rate requirements
  • Loading branch information
mjohnson541 committed Jun 12, 2018
1 parent 3884814 commit 9568307
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions rmgpy/data/kinetics/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def sortEfficiencies(efficiencies0):
f.write(' allow_pdep_route = {0!r},\n'.format(entry.item.allow_pdep_route))
if entry.item.elementary_high_p:
f.write(' elementary_high_p = {0!r},\n'.format(entry.item.elementary_high_p))
if entry.item.allow_max_rate_violation:
f.write(' allow_max_rate_violation = {0!r},\n'.format(entry.item.allow_max_rate_violation))
#Entries for groups with have a group or logicNode for its item
elif isinstance(entry.item, Group):
f.write(' group = \n')
Expand Down
8 changes: 6 additions & 2 deletions rmgpy/data/kinetics/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def __init__(self,
library=None,
allow_pdep_route=False,
elementary_high_p=False,
entry=None
allow_max_rate_violation=False,
entry=None,
):
Reaction.__init__(self,
index=index,
Expand All @@ -93,6 +94,7 @@ def __init__(self,
pairs=pairs,
allow_pdep_route=allow_pdep_route,
elementary_high_p=elementary_high_p,
allow_max_rate_violation=allow_max_rate_violation,
)
self.library = library
self.family = library
Expand All @@ -116,6 +118,7 @@ def __reduce__(self):
self.library,
self.allow_pdep_route,
self.elementary_high_p,
self.allow_max_rate_violation,
self.entry
))

Expand Down Expand Up @@ -463,6 +466,7 @@ def loadEntry(self,
longDesc='',
allow_pdep_route=False,
elementary_high_p=False,
allow_max_rate_violation=False,
):

# reactants = [Species(label=reactant1.strip().splitlines()[0].strip(), molecule=[Molecule().fromAdjacencyList(reactant1)])]
Expand All @@ -475,7 +479,7 @@ def loadEntry(self,
#
# Make a blank reaction
rxn = Reaction(reactants=[], products=[], degeneracy=degeneracy, duplicate=duplicate, reversible=reversible,
allow_pdep_route=allow_pdep_route, elementary_high_p=elementary_high_p)
allow_pdep_route=allow_pdep_route, elementary_high_p=elementary_high_p, allow_max_rate_violation=allow_max_rate_violation)
# if not rxn.isBalanced():
# raise DatabaseError('Reaction {0} in kinetics library {1} was not balanced! Please reformulate.'.format(rxn, self.label))
# label = str(rxn)
Expand Down
1 change: 1 addition & 0 deletions rmgpy/reaction.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ cdef class Reaction:
cdef public bint elementary_high_p
cdef public str comment
cdef public dict k_effective_cache
cdef public bint allow_max_rate_violation

cpdef bint isIsomerization(self)

Expand Down
2 changes: 2 additions & 0 deletions rmgpy/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def __init__(self,
pairs=None,
allow_pdep_route=False,
elementary_high_p=False,
allow_max_rate_violation=False,
comment='',
):
self.index = index
Expand All @@ -122,6 +123,7 @@ def __init__(self,
self.elementary_high_p = elementary_high_p
self.comment = comment
self.k_effective_cache = {}
self.allow_max_rate_violation = allow_max_rate_violation

def __repr__(self):
"""
Expand Down
14 changes: 8 additions & 6 deletions testing/databaseTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,20 +437,22 @@ def kinetics_checkLibraryRatesAreReasonable(self, library):
kB = 1.38064852e-23 #m2 * kg *s^-2 * K^-1
h = 6.62607004e-34 #m2 kg / s
boo = False
TST_limit = (kB*T)/h
collision_limit = Na*np.pi*Hrad_diam**2*np.sqrt(8*kB*T/(np.pi*mHrad/2))
for entry in library.entries.values():
k = entry.data.getRateCoefficient(T,P)
rxn = entry.item
if k < 0:
boo = True
logging.error('library reaction {0} from library {1}, had a negative rate at 1000 K, 1 bar'.format(rxn,library.label))
if len(rxn.reactants) == 1:
if k > (kB*T)/h:
if len(rxn.reactants) == 1 and rxn.allow_max_rate_violation==False:
if k > TST_limit:
boo = True
logging.error('library reaction {0} from library {1}, exceeds the TST limit at 1000 K, 1 bar'.format(rxn,library.label))
elif len(rxn.reactants) == 2:
if k > Na*np.pi*Hrad_diam**2*np.sqrt(8*kB*T/(np.pi*mHrad/2)):
logging.error('library reaction {0} from library {1}, exceeds the TST limit at 1000 K, 1 bar of {2} mol/(m3*s) at {3} mol/(m3*s) and did not have allow_max_rate_violation=True'.format(rxn,library.label,TST_limit,k))
elif len(rxn.reactants) == 2 and rxn.allow_max_rate_violation==False:
if k > collision_limit:
boo = True
logging.error('library reaction {0} from library {1}, exceeds the collision limit at 1000 K, 1 bar'.format(rxn,library.label))
logging.error('library reaction {0} from library {1}, exceeds the collision limit at 1000 K, 1 bar of {2} mol/(m3*s) at {3} mol/(m3*s) and did not have allow_max_rate_violation=True'.format(rxn,library.label,collision_limit,k))
if boo:
raise ValueError('library {0} has unreasonable rates'.format(library.label))

Expand Down

0 comments on commit 9568307

Please sign in to comment.