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

Resonance structure generation crashing on H-bonded structures #1859

Closed
rwest opened this issue Jan 5, 2020 · 3 comments
Closed

Resonance structure generation crashing on H-bonded structures #1859

rwest opened this issue Jan 5, 2020 · 3 comments
Labels
abandoned abandoned issue/PR as determined by actions bot stale stale issue/PR as determined by actions bot

Comments

@rwest
Copy link
Member

rwest commented Jan 5, 2020

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
@rwest
Copy link
Member Author

rwest commented Jan 6, 2020

May be related to ReactionMechanismGenerator/AutoTST#53 which is about resonance structure generation creating charged species

@alongd
Copy link
Member

alongd commented Jan 7, 2020

I recommend trying to run the relevant resonance functions separately (e.g., https://github.com/ReactionMechanismGenerator/RMG-Py/blob/master/rmgpy/molecule/resonance.py#L347) on this molecule (in either form), and see which ones add charges. Then let's modify them according to what we would expect them to do.

@github-actions
Copy link

This issue is being automatically marked as stale because it has not received any interaction in the last 90 days. Please leave a comment if this is still a relevant issue, otherwise it will automatically be closed in 30 days.

@github-actions github-actions bot added the stale stale issue/PR as determined by actions bot label Jun 21, 2023
@github-actions github-actions bot added the abandoned abandoned issue/PR as determined by actions bot label Jul 22, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned abandoned issue/PR as determined by actions bot stale stale issue/PR as determined by actions bot
Projects
None yet
Development

No branches or pull requests

2 participants