Skip to content

Commit f59d6db

Browse files
committed
Merge branch 'master' of git://github.com/jwallen/RMG-Py
Conflicts: rmgpy/kinetics/arrhenius.pyx
2 parents e616f13 + 6f60cd2 commit f59d6db

9 files changed

Lines changed: 582 additions & 423 deletions

File tree

rmgpy/data/kinetics/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
from rmgpy.kinetics import Arrhenius, ArrheniusEP, ThirdBody, Lindemann, Troe, \
3838
PDepArrhenius, MultiArrhenius, MultiPDepArrhenius, \
3939
Chebyshev, KineticsData, PDepKineticsModel
40+
from rmgpy.species import Species
4041

41-
from .common import KineticsError
42+
from .common import KineticsError, saveEntry
4243
from .depository import DepositoryReaction, KineticsDepository
4344
from .family import TemplateReaction, KineticsFamily, KineticsGroups, \
4445
ReactionRecipe, InvalidActionError, ReactionPairsError, \

rmgpy/data/kinetics/family.py

Lines changed: 82 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,55 +1621,104 @@ def __generateReactions(self, reactants, products=None, forward=True, **options)
16211621
# other than the ones specified (if given); these should be removed
16221622
rxnList0 = rxnList[:]
16231623
rxnList = []
1624-
for index0, reaction0 in enumerate(rxnList0):
1624+
index0 = 0
1625+
while index0 < len(rxnList0):
1626+
reaction0 = rxnList0[index0]
16251627

16261628
# Generate resonance isomers for products of the current reaction
1627-
products0 = [product.generateResonanceIsomers() for product in reaction0.products]
1628-
1629-
# If products is given, skip reactions that don't match the given products
1630-
if products is not None:
1631-
match = False
1632-
if len(products) == len(products0) == 1:
1633-
for product in products0[0]:
1634-
if products[0].isIsomorphic(product):
1635-
match = True
1636-
break
1637-
elif len(products) == len(products0) == 2:
1638-
for productA in products0[0]:
1639-
for productB in products0[1]:
1640-
if products[0].isIsomorphic(productA) and products[1].isIsomorphic(productB):
1629+
if forward:
1630+
reactants0 = None
1631+
products0 = [product.generateResonanceIsomers() for product in reaction0.products]
1632+
1633+
# If products is given, skip reactions that don't match the given products
1634+
if products is not None:
1635+
match = False
1636+
if len(products) == len(products0) == 1:
1637+
for product in products0[0]:
1638+
if products[0].isIsomorphic(product):
16411639
match = True
16421640
break
1643-
elif products[0].isIsomorphic(productB) and products[1].isIsomorphic(productA):
1641+
elif len(products) == len(products0) == 2:
1642+
for productA in products0[0]:
1643+
for productB in products0[1]:
1644+
if products[0].isIsomorphic(productA) and products[1].isIsomorphic(productB):
1645+
match = True
1646+
break
1647+
elif products[0].isIsomorphic(productB) and products[1].isIsomorphic(productA):
1648+
match = True
1649+
break
1650+
else:
1651+
match = True
1652+
1653+
else:
1654+
reactants0 = [reactant.generateResonanceIsomers() for reactant in reaction0.reactants]
1655+
products0 = None
1656+
1657+
# If products is given, skip reactions that don't match the given products
1658+
if products is not None:
1659+
match = False
1660+
if len(products) == len(reactants0) == 1:
1661+
for reactant in reactants0[0]:
1662+
if products[0].isIsomorphic(reactant):
16441663
match = True
16451664
break
1646-
else:
1647-
match = True
1648-
if not match: continue
1665+
elif len(products) == len(reactants0) == 2:
1666+
for reactantA in reactants0[0]:
1667+
for reactantB in reactants0[1]:
1668+
if products[0].isIsomorphic(reactantA) and reactants[1].isIsomorphic(reactantB):
1669+
match = True
1670+
break
1671+
elif products[0].isIsomorphic(reactantB) and reactants[1].isIsomorphic(reactantA):
1672+
match = True
1673+
break
1674+
else:
1675+
match = True
1676+
1677+
if not match:
1678+
index0 += 1
1679+
continue
16491680

16501681
rxnList.append(reaction0)
16511682

16521683
# Remove duplicates from the reaction list
16531684
index = index0 + 1
16541685
while index < len(rxnList0):
16551686
reaction = rxnList0[index]
1656-
# We know the reactants are the same, so we only need to compare the products
1687+
16571688
match = False
1658-
if len(reaction.products) == len(products0) == 1:
1659-
for product in products0[0]:
1660-
if rxnList0[index].products[0].isIsomorphic(product):
1661-
match = True
1662-
break
1663-
elif len(reaction.products) == len(products0) == 2:
1664-
for productA in products0[0]:
1665-
for productB in products0[1]:
1666-
if reaction.products[0].isIsomorphic(productA) and reaction.products[1].isIsomorphic(productB):
1689+
if forward:
1690+
# We know the reactants are the same, so we only need to compare the products
1691+
if len(reaction.products) == len(products0) == 1:
1692+
for product in products0[0]:
1693+
if reaction.products[0].isIsomorphic(product):
16671694
match = True
16681695
break
1669-
elif reaction.products[0].isIsomorphic(productB) and reaction.products[1].isIsomorphic(productA):
1696+
elif len(reaction.products) == len(products0) == 2:
1697+
for productA in products0[0]:
1698+
for productB in products0[1]:
1699+
if reaction.products[0].isIsomorphic(productA) and reaction.products[1].isIsomorphic(productB):
1700+
match = True
1701+
break
1702+
elif reaction.products[0].isIsomorphic(productB) and reaction.products[1].isIsomorphic(productA):
1703+
match = True
1704+
break
1705+
else:
1706+
# We know the products are the same, so we only need to compare the reactants
1707+
if len(reaction.reactants) == len(reactants0) == 1:
1708+
for reactant in reactants0[0]:
1709+
if reaction.reactants[0].isIsomorphic(reactant):
16701710
match = True
16711711
break
1672-
1712+
elif len(reaction.reactants) == len(reactants0) == 2:
1713+
for reactantA in reactants0[0]:
1714+
for reactantB in reactants0[1]:
1715+
if reaction.reactants[0].isIsomorphic(reactantA) and reaction.reactants[1].isIsomorphic(reactantB):
1716+
match = True
1717+
break
1718+
elif reaction.reactants[0].isIsomorphic(reactantB) and reaction.reactants[1].isIsomorphic(reactantA):
1719+
match = True
1720+
break
1721+
16731722
# If we found a match, remove it from the list
16741723
# Also increment the reaction path degeneracy of the remaining reaction
16751724
if match:
@@ -1678,6 +1727,8 @@ def __generateReactions(self, reactants, products=None, forward=True, **options)
16781727
else:
16791728
index += 1
16801729

1730+
index0 += 1
1731+
16811732
# For R_Recombination reactions, the degeneracy is twice what it should
16821733
# be, so divide those by two
16831734
# This is hardcoding of reaction families!

rmgpy/kinetics/arrhenius.pyx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,21 @@ cdef class MultiPDepArrhenius(PDepKineticsModel):
597597
cdef double k, klow, khigh, Plow, Phigh
598598
cdef PDepArrhenius arrh
599599
cdef Arrhenius arrh_low, arrh_high
600+
cdef numpy.ndarray Plist1, Plist2
601+
cdef int i
600602

601603
if P == 0:
602604
raise ValueError('No pressure specified to pressure-dependent MultiPDepArrhenius.getRateCoefficient().')
603605

606+
Plist1 = self.arrhenius[0].pressures.value_si
607+
for arrh in self.arrhenius[1:]:
608+
Plist2 = arrh.pressures.value_si
609+
assert Plist1.shape[0] == Plist2.shape[0]
610+
for i in range(Plist1.shape[0]):
611+
assert 0.99 < (Plist2[i] / Plist1[i]) < 1.01
612+
604613
klow = 0.0; khigh = 0.0
605614
for arrh in self.arrhenius:
606-
assert arrh.pressures == self.arrhenius[0].pressures
607615
Plow, Phigh, arrh_low, arrh_high = arrh.getAdjacentExpressions(P)
608616
klow += arrh_low.getRateCoefficient(T)
609617
khigh += arrh_high.getRateCoefficient(T)

rmgpy/molecule/graph.pxd

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ cdef class Graph:
8686

8787
cpdef Graph copy(self, bint deep=?)
8888

89-
cpdef Graph merge(self, other)
89+
cpdef Graph merge(self, Graph other)
9090

9191
cpdef list split(self)
9292

@@ -112,22 +112,14 @@ cdef class Graph:
112112

113113
cpdef bint __isChainInCycle(self, list chain) except -2
114114

115-
cpdef getAllCycles(self, Vertex startingVertex)
116-
117-
cpdef __exploreCyclesRecursively(self, list chain, list cycleList)
118-
119-
cpdef getSmallestSetOfSmallestRings(self)
115+
cpdef list getAllCyclicVertices(self)
120116

121-
cpdef bint isMappingValid(self, Graph other, dict mapping) except -2
122-
123-
################################################################################
117+
cpdef list getAllPolycyclicVertices(self)
124118

125-
cpdef VF2_isomorphism(Graph graph1, Graph graph2, bint subgraph=?, bint findAll=?, dict initialMapping=?)
119+
cpdef list getAllCycles(self, Vertex startingVertex)
126120

127-
cpdef bint VF2_feasible(Graph graph1, Graph graph2, Vertex vertex1, Vertex vertex2, bint subgraph) except -2
121+
cpdef list __exploreCyclesRecursively(self, list chain, list cycles)
128122

129-
cpdef bint VF2_match(Graph graph1, Graph graph2, bint subgraph, bint findAll, list mappingList, int callDepth) except -2
130-
131-
cpdef VF2_addToMapping(Vertex vertex1, Vertex vertex2)
132-
133-
cpdef VF2_removeFromMapping(Vertex vertex1, Vertex vertex2)
123+
cpdef list getSmallestSetOfSmallestRings(self)
124+
125+
cpdef bint isMappingValid(self, Graph other, dict mapping) except -2

0 commit comments

Comments
 (0)