diff --git a/rmgpy/molecule/molecule.py b/rmgpy/molecule/molecule.py index ba41a91b55..93ad7c6d3c 100644 --- a/rmgpy/molecule/molecule.py +++ b/rmgpy/molecule/molecule.py @@ -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 = [] @@ -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 @@ -1098,6 +1098,7 @@ def fromRDKitMol(self, rdkitmol): # Set atom types and connectivity values self.updateConnectivityValues() + self.updateLonePairs() self.updateAtomTypes() return self @@ -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 diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index 1d2d1ff6ce..00e6b15ef6 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -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 diff --git a/rmgpy/rmg/model.py b/rmgpy/rmg/model.py index c831f1f450..bd4e2753fb 100644 --- a/rmgpy/rmg/model.py +++ b/rmgpy/rmg/model.py @@ -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) @@ -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)