Skip to content

Commit 8531027

Browse files
committed
Merge pull request #167 from bbuesser/master
Add and modify calls for generateTransportData() and add updateLonePairs to fix adjacency lists generated by fromSMILES
2 parents d8e7734 + eb1c544 commit 8531027

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

rmgpy/molecule/molecule.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ def fromRDKitMol(self, rdkitmol):
10481048
"""
10491049
# Below are the declared variables for cythonizing the module
10501050
cython.declare(i=cython.int)
1051-
cython.declare(radicalElectrons=cython.int, spinMultiplicity=cython.int, charge=cython.int)
1051+
cython.declare(radicalElectrons=cython.int, spinMultiplicity=cython.int, charge=cython.int, lonePairs=cython.int)
10521052
cython.declare(atom=Atom, atom1=Atom, atom2=Atom, bond=Bond)
10531053

10541054
self.vertices = []
@@ -1076,7 +1076,7 @@ def fromRDKitMol(self, rdkitmol):
10761076
# Process charge
10771077
charge = rdkitatom.GetFormalCharge()
10781078

1079-
atom = Atom(element, radicalElectrons, spinMultiplicity, charge)
1079+
atom = Atom(element, radicalElectrons, spinMultiplicity, charge, '', 0)
10801080
self.vertices.append(atom)
10811081

10821082
# Add bonds by iterating again through atoms
@@ -1098,6 +1098,7 @@ def fromRDKitMol(self, rdkitmol):
10981098

10991099
# Set atom types and connectivity values
11001100
self.updateConnectivityValues()
1101+
self.updateLonePairs()
11011102
self.updateAtomTypes()
11021103

11031104
return self
@@ -1790,4 +1791,25 @@ def getRadicalAtoms(self):
17901791
if atom.radicalElectrons > 0:
17911792
radicalAtomsList.append(atom)
17921793
return radicalAtomsList
1794+
1795+
def updateLonePairs(self):
1796+
"""
1797+
Iterate through the atoms in the structure and calcualte the
1798+
number of lone electron pairs, assumin a neutral molecule.
1799+
"""
1800+
for atom1 in self.vertices:
1801+
order = 0
1802+
if not atom1.isHydrogen():
1803+
for atom2, bond12 in atom1.edges.items():
1804+
if bond12.isSingle():
1805+
order = order + 1
1806+
if bond12.isDouble():
1807+
order = order + 2
1808+
if bond12.isTriple():
1809+
order = order + 3
1810+
1811+
atom1.lonePairs = 4 - atom1.radicalElectrons - order
1812+
1813+
else:
1814+
atom1.lonePairs = 0
17931815

rmgpy/rmg/main.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,6 @@ def initialize(self, args):
335335
# DON'T generate any more reactions for the seed species at this time
336336
for seedMechanism in self.seedMechanisms:
337337
self.reactionModel.addSeedMechanismToCore(seedMechanism, react=False)
338-
339-
for spec in self.reactionModel.core.species:
340-
spec.generateTransportData(self.database)
341338

342339
# Reaction libraries: add species and reactions from reaction library to the edge so
343340
# that RMG can find them if their rates are large enough

rmgpy/rmg/model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,7 @@ def addSeedMechanismToCore(self, seedMechanism, react=False):
12781278
r, isNew = self.makeNewReaction(rxn) # updates self.newSpeciesList and self.newReactionlist
12791279
for spec in self.newSpeciesList:
12801280
if spec.reactive: spec.generateThermoData(database, quantumMechanics=self.quantumMechanics)
1281+
spec.generateTransportData(database)
12811282
for spec in self.newSpeciesList:
12821283
self.addSpeciesToCore(spec)
12831284

@@ -1327,6 +1328,7 @@ def addReactionLibraryToEdge(self, reactionLibrary):
13271328
if not isNew: logging.info("This library reaction was not new: {0}".format(rxn))
13281329
for spec in self.newSpeciesList:
13291330
if spec.reactive: spec.generateThermoData(database, quantumMechanics=self.quantumMechanics)
1331+
spec.generateTransportData(database)
13301332
for spec in self.newSpeciesList:
13311333
self.addSpeciesToEdge(spec)
13321334

0 commit comments

Comments
 (0)