pckroon / pysmiles

A lightweight python-only library for reading and writing SMILES strings
Apache License 2.0
147 stars 21 forks source link

Use charges for determining valence #42

Closed pckroon closed 5 months ago

pckroon commented 5 months ago

Here I figure out the valence of atoms by assigning electrons to orbital shells, and figuring out with how many unpaired electrons we have left. Currently, I assume all paired electrons can be excited to higher shells, which deals with multivalent elements (S, P, ...). This does mean that N can also make 5 bonds if you ask it nicely. The real solution would be to figure out the balance between the excitation energy on one hand, and the electron unpairing + bond energy on the other, but that sounds really hard. So either we accept this slightly strange behaviour, or we limit this excitation to higher shells only. Further consideration: should the excitation be limited to just 2 electrons, to the next s-orbital?

Still a draft, since I need to iron out some failing tests.

fgrunewald commented 5 months ago

Things I feel like should raise Errors:

pckroon commented 5 months ago

I do like the idea of breaking on overvalence atoms, but I think that should be a separate PR