openmm / openmm-ml

High level API for using machine learning models in OpenMM simulations
Other
80 stars 25 forks source link

Dynamics failing for pure ML system #33

Closed wiederm closed 2 years ago

wiederm commented 2 years ago

Hi everyone!

I have been following the example outlined in the test and wanted to run a short MD simulation with these systems. This works great with the potential.createMixedSystem, but I ran into issues using a pure ANI system created with potential.createSystem since the simulation blows up within a few fs.

Am I missing something? Is this not the intended use case for createSystem? I have attached a sample script to reproduce the error.

peastman commented 2 years ago

Your script uses an undefined variable stepsize for the integrator's step size. I set it to 0.001 ps and the script ran without problem. I monitored the potential energy and it seemed stable for at least a few hundred time steps. What step size are you using?

wiederm commented 2 years ago

Sorry, I missed that. I am using a 1 fs time step. I have saved the trajectory that is generated when I run this script as a dcd file and attached it (with the pdb and the updated script). Could you please double-check that the trajectory that is generated on your side with this script looks normal?

example.zip

peastman commented 2 years ago

I see the problem. The input PDB file describes a periodic system, but createSystem() doesn't copy the box vectors from the topology over to the system it creates. As a result, the DCDReporter wraps all the coordinates to the wrong box shape. I'll fix that. In the mean time, you can work around it by setting the box vectors like this:

ml_system.setDefaultPeriodicBoxVectors(*pdb.topology.getPeriodicBoxVectors())
peastman commented 2 years ago

The fix is in #34.

wiederm commented 2 years ago

That's great! Thank you for your help and the quick fix!