openmm-plumed icon indicating copy to clipboard operation
openmm-plumed copied to clipboard

Restarting simulation from .xml file yields wrong timestamp on Plumed output

Open mdpoleto opened this issue 3 years ago • 4 comments

Hi,

I ran a metadynamics simulation on strides of 100ns each using OpenMM v7.5.1 + Plumed v2.7. Although I can successfully restart my simulation and Plumed continues outputting data as it should, the timestamp used seems to be incorrect.

I am restarting my simulation using the .xml state file outputted at 800ns. I am explicitly defining the correct "simulation.currentStep" and current time ("simulation.context.setTime()") before actually triggering the "simulation.step(nsteps)" command but Plumed still outputs a timestamp starting from 0.

Below there is a set of input files that should yield the error. This error only appears when I restart my simulation from the .xml state file. Loading from the checkpoint works just fine.

restart_timestamp.zip

Any ideas on this is highly appreciated. Thanks!

mdpoleto avatar Jul 14 '21 17:07 mdpoleto

OpenMM states files doesn't store the number of steps, just a simulation time. I guess, the rational is that OpenMM have variable-timestep integrators. So, when you restart a simulation from a XML file the new context starts counting steps from zero. Meanwhile, the checkpoint preserves entire context data. Probably @peastman can comment more on this.

On the other side, PLUMED assumes a fixed time step (https://github.com/openmm/openmm-plumed/blob/5406068b5a36b1208f1340180cfc5b8e4ee7aff9/platforms/cuda/src/CudaPlumedKernels.cpp#L155) and require to pass the number of steps (https://github.com/openmm/openmm-plumed/blob/5406068b5a36b1208f1340180cfc5b8e4ee7aff9/platforms/cuda/src/CudaPlumedKernels.cpp#L225).

This might be solved with the next release (https://github.com/openmm/openmm/issues/2655, https://github.com/openmm/openmm/issues/3191), but apart the wrong step count, PLUMED should work correctly after these restarts.

raimis avatar Jul 30 '21 11:07 raimis

I don't have any good solution for the current version. Having States record the step count should provide a straightforward solution. That's tentatively planned for inclusion in the next release.

peastman avatar Jul 30 '21 17:07 peastman

Thank you both for the clarification. I am not sure if this is a Plumed or a OpenMM-Plumed plugin kind of modification but I wonder if Plumed could re-read the current step number (or the simulation time) as defined by OpenMM the same way it reads the current atomic position. That way users can define the correct "simulation.currentStep" and current time ("simulation.context.setTime()") in the OpenMM script when restarting a simulation.

mdpoleto avatar Aug 05 '21 14:08 mdpoleto

After https://github.com/openmm/openmm/pull/3248 is merged and released, we can solve this issues.

raimis avatar Sep 16 '21 09:09 raimis