Skip to content

Resonance structure generation crashing on H-bonded structures #1859

Closed as not planned
@rwest

Description

@rwest

Bug Description

I'm trying to represent HAN in RMG. There are two ways to represent it.

  1. an ionic form, where the two halves of the salt are charged and held together by an ionic bond (as well as two Hydrogen-bonds)
  2. a covalent form, where an H atom is moved across so the two halves are neutral, but still held together by two Hydrogen bonds.

According to quantum chemistry calculations (Bannerjee 2016) the ionic form is a bit more stable.
image

I think they can be represented like this in RMG, with the H bonds included.

# This is the covalent form of HAN
no3h_h2noh =  Molecule().from_adjacency_list("""
no3h_h2noh
1  O u0 p3 c-1 {2,S} {10,H}
2  N u0 p0 c+1 {1,S} {3,D} {4,S}
3  O u0 p2 c0 {2,D}
4  O u0 p2 c0 {2,S} {7,S}
5  N u0 p1 c0 {6,S} {8,S} {9,S} {7,H}
6  O u0 p2 c0 {5,S} {10,S}
7  H u0 p0 c0 {4,S} {5,H}
8  H u0 p0 c0 {5,S}
9  H u0 p0 c0 {5,S}
10 H u0 p0 c0 {6,S} {1,H}
""")
no3h_h2noh.to_smiles()
# Out: '[O-][N+](=O)O.NO'


# This is the ionic form of HAN
no3_h3noh =  Molecule().from_adjacency_list("""
no3-_h3noh+
1  O u0 p3 c-1 {2,S} {10,H}
2  N u0 p0 c+1 {1,S} {3,D} {4,S}
3  O u0 p2 c0 {2,D}
4  O u0 p3 c-1 {2,S} {7,H}
5  N u0 p0 c+1 {6,S} {8,S} {9,S} {7,S}
6  O u0 p2 c0 {5,S} {10,S}
7  H u0 p0 c0 {4,H} {5,S}
8  H u0 p0 c0 {5,S}
9  H u0 p0 c0 {5,S}
10 H u0 p0 c0 {6,S} {1,H}
""")
no3_h3noh.to_smiles()
# Out: '[O-][N+](=O)[O-].O[NH3+]'

The images are not well drawn, because the H bonds are ignored and the two halves end up on top of each other (but that's a separate issue).

Unfortunately, generating resonance structures fails

# covalent form
for m in no3h_h2noh.generate_resonance_structures():
    print(m.to_adjacency_list())
---------------------------------------------------------------------------
ResonanceError                            Traceback (most recent call last)
<ipython-input-9-ef4f7149c43a> in <module>
      1 # Unfortunately, generating resonance structures fails
----> 2 for m in no3h_h2noh.generate_resonance_structures():
      3     print(m.to_adjacency_list())

~/Code/RMG-Py/rmgpy/molecule/molecule.cpython-37m-darwin.so in rmgpy.molecule.molecule.Molecule.generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/molecule.cpython-37m-darwin.so in rmgpy.molecule.molecule.Molecule.generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/resonance.cpython-37m-darwin.so in rmgpy.molecule.resonance.generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/resonance.cpython-37m-darwin.so in rmgpy.molecule.resonance.generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/resonance.cpython-37m-darwin.so in rmgpy.molecule.resonance._generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/resonance.cpython-37m-darwin.so in rmgpy.molecule.resonance._generate_resonance_structures()

ResonanceError: Resonance generation gave a net charged molecule:
1  O u0 p2 c0 {5,S} {8,S}
2  O u0 p2 c0 {6,S} {7,S}
3  O u0 p2 c0 {6,S} {8,H}
4  O u0 p3 c-1 {6,S}
5  N u0 p1 c0 {1,S} {7,H} {9,S} {10,S}
6  N u0 p1 c0 {2,S} {3,S} {4,S}
7  H u0 p0 c0 {2,S} {5,H}
8  H u0 p0 c0 {1,S} {3,H}
9  H u0 p0 c0 {5,S}
10 H u0 p0 c0 {5,S}
Ions are not yet supported in RMG.

and

# ionic form
for m in no3_h3noh.generate_resonance_structures():
    print(m.to_adjacency_list())
---------------------------------------------------------------------------
ResonanceError                            Traceback (most recent call last)
<ipython-input-14-04b5476ebc81> in <module>
      1 # Unfortunately, generating resonance structures fails here too
----> 2 for m in no3_h3noh.generate_resonance_structures():
      3     print(m.to_adjacency_list())

~/Code/RMG-Py/rmgpy/molecule/molecule.cpython-37m-darwin.so in rmgpy.molecule.molecule.Molecule.generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/molecule.cpython-37m-darwin.so in rmgpy.molecule.molecule.Molecule.generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/resonance.cpython-37m-darwin.so in rmgpy.molecule.resonance.generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/resonance.cpython-37m-darwin.so in rmgpy.molecule.resonance.generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/resonance.cpython-37m-darwin.so in rmgpy.molecule.resonance._generate_resonance_structures()

~/Code/RMG-Py/rmgpy/molecule/resonance.cpython-37m-darwin.so in rmgpy.molecule.resonance._generate_resonance_structures()

ResonanceError: Resonance generation gave a net charged molecule:
1  O u0 p2 c0 {5,S} {8,S}
2  O u0 p2 c0 {6,S} {7,H}
3  O u0 p3 c-1 {6,S} {8,H}
4  O u0 p3 c-1 {6,S}
5  N u0 p0 c+1 {1,S} {7,S} {9,S} {10,S}
6  N u0 p1 c0 {2,S} {3,S} {4,S}
7  H u0 p0 c0 {2,H} {5,S}
8  H u0 p0 c0 {1,S} {3,H}
9  H u0 p0 c0 {5,S}
10 H u0 p0 c0 {5,S}
Ions are not yet supported in RMG.

I'm not very surprised that something went wrong, but I'm a bit surprised that the algorithm can make a charge appear/disappear. Anyway, it'd be nice if this worked. Perhaps this is closer to a feature request than a bug.

I'm aware that generating reactions and making sensible estimates for molecules like this in general may be a big project, but it'd be nice to be able to represent the molecule, even if not reactive, in seed mechanisms, reaction libraries, etc, so we can add the necessary reactions by hand.

How To Reproduce

Code snippets above and attached notebook.
HAN-representation.ipynb.txt

Installation Information

Describe your installation method and system information.

  • OS (include version if known): macOS 10.15 Catalina
  • Installation method: from source, in anaconda environment
  • RMG version information:
    • RMG-Py: current master as of 2020-01-05, 957ee80

Metadata

Metadata

Assignees

No one assigned

    Labels

    abandonedabandoned issue/PR as determined by actions botstalestale issue/PR as determined by actions bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions