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

Fix nitrogen symmetry #1064

Merged
merged 2 commits into from
Jun 27, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions rmgpy/molecule/symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def calculateAtomSymmetryNumber(molecule, atom):
elif double == 2:
# Two double bonds
if count == [2]: symmetryNumber *= 2
# for nitrogen resonance hybrids
elif single == 0:
if count == [2]: symmetryNumber *=2
elif atom.radicalElectrons == 1:
if single == 3:
# Three single bonds
Expand All @@ -111,11 +114,6 @@ def calculateAtomSymmetryNumber(molecule, atom):
if count == [2]:
symmetryNumber *= 2

if atom.isNitrogen():
for groupN in groups:
if groupN.toSMILES() == "[N+](=O)[O-]":
symmetryNumber *= 2

return symmetryNumber

################################################################################
Expand Down
9 changes: 8 additions & 1 deletion rmgpy/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,14 @@ def getSymmetryNumber(self):
if self.symmetryNumber < 1:
cython.declare(resonanceHybrid = Molecule, maxSymmetryNum = cython.short)
resonanceHybrid = self.getResonanceHybrid()
self.symmetryNumber = resonanceHybrid.getSymmetryNumber()
try:
self.symmetryNumber = resonanceHybrid.getSymmetryNumber()
except KeyError:
logging.error('Wrong bond order generated by resonance hybrid.')
logging.error('Resonance Hybrid: {}'.format(resonanceHybrid.toAdjacencyList()))
for index, mol in enumerate(self.molecule):
logging.error("Resonance Structure {}: {}".format(index,mol.toAdjacencyList()))
raise
return self.symmetryNumber

def getResonanceHybrid(self):
Expand Down