openforcefield / openff-toolkit

The Open Forcefield Toolkit provides implementations of the SMIRNOFF format, parameterization engine, and other tools. Documentation available at http://open-forcefield-toolkit.readthedocs.io
http://openforcefield.org
MIT License
313 stars 92 forks source link

Gasteiger charge when converting molecule to topology #840

Closed yuanqing-wang closed 3 years ago

yuanqing-wang commented 3 years ago

Is your feature request related to a problem? Please describe. After upgrading to 0.7.0, it seems that every time I call molecule.to_topology it uses am1-bcc charges?

Describe the solution you'd like I still wish to use Gasteiger charges.

Describe alternatives you've considered

Additional context

j-wags commented 3 years ago

Hi @yuanqing-wang,

Hm, could you post your code that's causing this behavior? I think that the only way to get gasteiger charges in the OpenFF toolkit are:

1) calling molecule.assign_partial_charges('gasteiger') 2) changing a force field to have a ChargeIncrementModelHandler with partial_charge_method='gasteiger' 3) loading a file with gasteiger charges already assigned

(In some cases, I think that calling molecule.enumerate_stereoisomers with the RDKit backend may assign charges as well, but if that's a behavior that your workflow relies on, I'm sorry to say that we consider it a bug :-/ )

j-wags commented 3 years ago

Some thoughts: 1) It sounds like you may be updating from a very old version of the OpenFF toolkit (maybe 0.1.0 or earlier). Is that the case? If so, I can walk you through how to update your code. 2) molecule.to_topology should never assign partial charges, but forcefield.create_openmm_system(topology) will. If the molecule already has partial charges (maybe it was loaded with them?), then users can instruct the parameterization process to skip AM1-BCC by running forcefield.create_openmm_system(topology, charge_from_molecules=[molecule]).

yuanqing-wang commented 3 years ago

Thanks! Sorry I did realize that it was during create_openmm_system when the AM1-BCC charge was assigned. I can now bypass this by using charge_from_molecules and assigning just the formal charge.

but I do think it would be nice if we can have the chance to assign gasteiger charge without modifying the force field?