openmmforcefields icon indicating copy to clipboard operation
openmmforcefields copied to clipboard

Add virtual site support for OpenFF

Open jthorton opened this issue 5 years ago • 3 comments

Now that we have virtual site support in the OpenFF toolkit it would be good to extend the Smirnoff template generator to handle virtual sites which will allow QCEngine to also support these forcefields. I am happy to help out on this one to coordinate with the required QCEngine changes, tagging @trevorgokey and @j-wags for toolkit help.

jthorton avatar Nov 03 '20 14:11 jthorton

4- and 5-site water models are some of the simplest examples of SMIRNOFF virtual sites. A typical OpenFF installation includes (some variants of) TIP4P, TIP5P, and OPC. Scroll about halfway through the openff-forcefields README for the exact filenames. (Just pass them to openff.toolkit.ForceField like any other pre-installed force field.)

A more comprehensive sampling of parameters can be found in this Interchange example. This notebook covers ligands and more chemistry than just water. The toolkit also has an older example covering similar ground. If you're light on bedtime reading, some extra prose is here. These should, in total, provide a good starting point for each of the four virtual site types.

The implementation is unfortunately not so simple; though the OpenMM interface is quite simple, there's a lot of internal bookkeeping before that in an effort to make things flexible enough to also work in other engines. Going off of memory, a good chunk of the work worries about virtual particles having vdW interactions. But every use case I've seen has those zeroed out; >90% of the time people are only care about off-center charges. Another key detail is that Interchange only ever produces openmm.LocalCoordinatesSite from SMIRNOFF parameters, even though it seems overkill when OpenMM's simpler classes are sufficient. (The reasoning starts here and takes more than a few minutes to read through).

mattwthompson avatar Dec 02 '25 20:12 mattwthompson

Great, those look like good simple test cases.

If I'm understanding correctly, then, this should be easy for us to implement in openmmforcefields. Since SMIRNOFFTemplateGenerator relies on having OpenFF generate an OpenMM System and backing an OpenMM force field out of that, and OpenFF only generates OpenMM LocalCoordinatesSites, we need only to save the parameters of the LocalCoordinatesSites in the cached XML. This should then work for all of the current and any future virtual site types that OpenFF has. (It should be just as easy to support OpenMM's other virtual site types too, although I don't know if that's needed.)

epretti avatar Dec 02 '25 21:12 epretti

If you ever do decide to use other OpenMM VirtualSite classes, the most important one is probably ThreeParticleAverageSite. It can handle rigid water models like TIP4P-Ew and SWM4-NDP. And any solvated system with one of those water models will include a lot of virtual sites, so there can be a real benefit to using the less expensive virtual site type.

peastman avatar Dec 02 '25 23:12 peastman