Open JohannesKarwou opened 1 year ago
It's an interesting question. createMixedSystem()
was created with the assumption you'd be simulating a ligand with ML and everything else with MM. In that context, it makes sense to create a bonded force with no periodic boundary conditions to handle interactions within the ligand. And I think you're right that we should call setUsesPeriodicBoundaryConditions(True)
on the CustomBondForce. A PR would be welcome!
For your case, though, this is all unnecessary complexity. You don't need to separate out internal from external interactions. You really just need to create a CustomCVForce, add all the ML and MM forces to it, and set the energy expression to interpolate between them. You can copy everything you need from the existing code.
@peastman : Perhaps we can add functionality for easily simulating periodic ML systems into the next feature release?
createSystem()
works fine for periodic systems. createMixedSystem()
does too as long as the ML part is just a ligand. It also should work fine if interpolate=False
.
Thank you very much for these insights and the helpful comment!
I would have one additional (maybe stupid) question:
Is there a reason, why it is not recommended to have constraints and interpolate=True
(https://github.com/openmm/openmm-ml/issues/12#issuecomment-1040957453)? Because in my context, it would be nice to have at least cons=HBonds
for the MM and for the ML part using the option removeConstraints =False
.
Interpolating between MM and ML potentials is complicated, and I'm not sure all the possible combinations have been fully explored or thought out yet. You need to make sure both of them are valid. In your case you're simulating a water box. Most classical water models are designed to be fully rigid. That's how they were parametrized. You can make them flexible, but they may not do a good job of reproducing experimental quantities if you do. ML models are generally designed to be completely flexible with no constraints. It's possible there's a way you could add some constraints and still get realistic behavior, but that hasn't been studied much yet. At the very least, the constrained distances would likely need to be different from the ones in the classical water model.
The iterpolate
option was really created to support one particular use case: a protein-ligand binding simulation that's done mainly with a classical potential, and then at the end you run a much shorter calculation to correct the endpoints to ML accuracy for the ligand only. See https://www.biorxiv.org/content/10.1101/2020.07.29.227959v1.full.pdf. Other use cases would have other issues that may not be handled properly yet.
I would like to use the
OpenMM-ML
package to switch a complete waterbox from MM to ML description using thecreateMixedSystem()
functionality. I know that technically it is not made for that, but I wonder if that might - in theory - be possible. For the simulation, I’m using theCutoffPeriodic
option and set up the ML system the following way (I can provide a more detailed minimal example if needed):I believe that when using a cutoff, the
CustomBondForce
within theCustomCVForces
may cause issues in reproducing the Nonbonded Interaction for particles described only as ML atoms (https://github.com/openmm/openmm-ml/blob/c3d8c28eb92bf5c4b16efb81ad7a44b707fc5907/openmmml/mlpotential.py#LL298C14-L298C14). It seems that the PBC is not replicated for the ML portion of the system, which may not be problematic if only one small molecule is being treated by ML. However, when dealing with a system where all (or multiple) particles are described using ML (like the waterbox I would be interested in), this is not describing PBC correctly and leads to strange behavior of the box during the simulation (box blowing up). Therefore, I have created a Nonbonded Force using theopenmm.CustomNonbondedForce
according to the steps outlined in this discussion (https://github.com/openmm/openmm/issues/3281). In the context of theCustomCVForce
this might look like this:Using this approach, I have been able to reproduce the expected energies that would result from simulating the box using only MM (
ff.createSystem
) or only ML (potential.createSystem
).In your opinion, do you believe that this is a valid approach for transitioning a box from MM to ML? Or is there anything I am missing?