Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and modify calls for generateTransportData() #167

Merged
merged 2 commits into from
Dec 12, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions rmgpy/molecule/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ def fromRDKitMol(self, rdkitmol):
"""
# Below are the declared variables for cythonizing the module
cython.declare(i=cython.int)
cython.declare(radicalElectrons=cython.int, spinMultiplicity=cython.int, charge=cython.int)
cython.declare(radicalElectrons=cython.int, spinMultiplicity=cython.int, charge=cython.int, lonePairs=cython.int)
cython.declare(atom=Atom, atom1=Atom, atom2=Atom, bond=Bond)

self.vertices = []
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def fromRDKitMol(self, rdkitmol):
# Process charge
charge = rdkitatom.GetFormalCharge()

atom = Atom(element, radicalElectrons, spinMultiplicity, charge)
atom = Atom(element, radicalElectrons, spinMultiplicity, charge, '', 0)
self.vertices.append(atom)

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

# Set atom types and connectivity values
self.updateConnectivityValues()
self.updateLonePairs()
self.updateAtomTypes()

return self
Expand Down Expand Up @@ -1790,4 +1791,25 @@ def getRadicalAtoms(self):
if atom.radicalElectrons > 0:
radicalAtomsList.append(atom)
return radicalAtomsList

def updateLonePairs(self):
"""
Iterate through the atoms in the structure and calcualte the
number of lone electron pairs, assumin a neutral molecule.
"""
for atom1 in self.vertices:
order = 0
if not atom1.isHydrogen():
for atom2, bond12 in atom1.edges.items():
if bond12.isSingle():
order = order + 1
if bond12.isDouble():
order = order + 2
if bond12.isTriple():
order = order + 3

atom1.lonePairs = 4 - atom1.radicalElectrons - order

else:
atom1.lonePairs = 0

3 changes: 0 additions & 3 deletions rmgpy/rmg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@ def initialize(self, args):
# DON'T generate any more reactions for the seed species at this time
for seedMechanism in self.seedMechanisms:
self.reactionModel.addSeedMechanismToCore(seedMechanism, react=False)

for spec in self.reactionModel.core.species:
spec.generateTransportData(self.database)

# Reaction libraries: add species and reactions from reaction library to the edge so
# that RMG can find them if their rates are large enough
Expand Down
2 changes: 2 additions & 0 deletions rmgpy/rmg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,7 @@ def addSeedMechanismToCore(self, seedMechanism, react=False):
r, isNew = self.makeNewReaction(rxn) # updates self.newSpeciesList and self.newReactionlist
for spec in self.newSpeciesList:
if spec.reactive: spec.generateThermoData(database, quantumMechanics=self.quantumMechanics)
spec.generateTransportData(database)
for spec in self.newSpeciesList:
self.addSpeciesToCore(spec)

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

Expand Down