Open trevorgokey opened 4 years ago
It is a good idea for a sanity check here since we have to spend a few minutes in OpenMM before the exception is raised, so it would be good to just bail if we can detect it ourselves. This does prevent doing things like setting the charges to 0 and passing to OpenMM if we wanted to e.g. just calculate bond energy, and didn't want to run a somewhat expensive partial charge calculation.
With that said, I guess it hasn't been an issue with me personally since most of the molecules I've worked with have total_charge == 0
so the partial_charges have always matched when setting all to 0.
In the case of loading a mol2 file or something with partial charges, then this check should definitely be done in validation.
I agree -- Let's put this with our other special "what in the world is wrong with your mol2 file?" check: https://github.com/openforcefield/openforcefield/blob/master/openforcefield/utils/toolkits.py#L544-L545
mol2! The gift that keeps on giving!
Describe the bug When loading a malformed mol2 file where all bond orders are 1 and partial charges are present, the implied formal charge is different from the partial_charges.sum(), and
create_openmm_system
will raise an exception because of this.Essentially, from @jchodera:
To Reproduce
Output See #510 for full output of the
create_openmm_system
call. See the above description of the problem outputAdditional context First discussed in #510 Attached is a malformed mol2