I followed the instructions in the LAMMPS documentation to restart a simulation—writing a restart file at the end of the previous run and reading it in a new input script.
The simulation time is recorded in the thermo output. I noticed that upon restarting, the simulation time resets to zero rather than continuing from where the previous run left off. Could you please confirm whether this is the expected behavior?
Additionally, I would like to suggest a potential feature: supporting a GROMACS-style restart, where no new input script is needed, and the simulation can be resumed directly via command-line options. It would also be helpful if LAMMPS could append continued output—such as dump or log files—to those from the previous run.
Thank you very much for your time and consideration.
This is technically not possible due to the different architecture of the two codes. GROMACS is in comparison to LAMMPS a much simpler code and fully integrated, while LAMMPS is highly modular and much more complex. What is restartable in LAMMPS depends largely on the individual functionality and it is up to the authors of the individual contributed functionality, how much information is required to continue after a restart.
This is generally a bad idea. Please consider that the restart functionality is usually meant to be used during a simulation (see the “restart” command) to protect the calculation against crashes or timeouts, that can happen especially for large scale runs on high-end supercomputers. If a run is terminated prematurely, you can still continue from the last restart file (or the previous, if the crash happens during restarting and you were smart enough to use two alternating restarts or a series of restart files with the time step appended). In that case your output will likely be corrupted and contain data from timesteps past the last restart. Appending to such files would make it extremely difficult to repair them. Also handling many smaller files is much easier than one big file. Often there are file system limitations, if you have long trajectories. If needed, files can always be concatenated after the fact, but in general, it is considered a bad practice. Better to improve the analysis tool to process a list of files.
There are options in LAMMPS to append to files, but we mostly implemented them to shut up people that keep asking for them. Having this feature doesn’t make it a good idea.
I used write_restart and read_restart to continue my previous simulation. Could you please tell me in this case whether it is expected that the simulation time starts from 0 in the restart simulation?
Thanks very much for the information! This append option of dump_modify is indeed helpful. I noticed that OVITO now automatically loads dump files that have the same pattern in their names. For me, if only the dump file can be continued, it is helpful but not critical.
From my experience, GROMACS offers a very effective and easy-to-use restart feature. In most cases, the goal is simple—we just want the simulation to continue running longer. That approach minimizes the need to write new input scripts and makes restarts more convenient.
I don’t know, I never use restart file, only data file. But if you are curious, all the information is usually in the doc. For instance, you can check which information is stored in a LAMMPS restart file here read_restart command — LAMMPS documentation.
Thank you very much for your reply and detailed explanation!
I have a quick follow-up question. In my restart run, the simulation time in the thermo output starts from 0 instead of continuing from where the previous run ended. Is this the expected behavior?
Apologies if my suggestion earlier was naive—I may not fully understand the underlying complexity of LAMMPS. I mentioned the GROMACS-style restart feature because, in most cases, I think the purpose of restarting a simulation is simply to extend the simulation time (e.g., due to job wall-time limits). From that perspective, having a straightforward way to resume a simulation—without needing to write a new input script or adjust any settings—feels very convenient and effective.
I am referring to the simulation time reported by the time keyword in the thermo_style command. For example, in my initial run, the simulation time reached 228 ps when the simulation stopped at 500,000 steps. However, in the subsequent restart run, the simulation time starts from 0 instead of continuing from 228 ps. Is this the expected behavior?
This effort of writing a input file for restarts is tiny compared to the effort of chaperoning and analyzing simulations. Also, it gives you more control. Please keep in mind that LAMMPS is designed for running very large scale and parallel simulations. Preferences for such setups may be different than for your simulations.
At the moment, yes. Unless you are using fix dt/reset, you can easily emulate the desired behavior by defining an equal style variable and using v_time instead of time:
variable time equal dt*step
Otherwise, you can use the optional “time” keyword with the reset_timestep command. You just reset both properties to their last values.
Please note that it is best practice to organize your simulation data around timesteps and not simulation time.
I just checked the source code and have to revert this statement. It seems that the time property is written to restart files and read back, and I confirmed it by running a test.
Which LAMMPS version are you using?
If the time property is not restarted then either you are using a too old version of LAMMPS or you are making some mistake in your restart.
@Kelvin In future posts please always report your LAMMPS version and platform. This is also explained in the forum guidelines post. It can save people responding a lot of time.
Thank you for the reminder. I sincerely apologize for not including that information in my initial post, and I appreciate you pointing it out.
For future posts, I will make sure to include the LAMMPS version and other important information if needed. This will help in diagnosing issues more efficiently. Thanks again for your kind help with this post!
In general terms, a restart file is a binary snapshot, that preserves not only position and velocities, but also force terms, everything using double precision. This way, you continue right where you left, avoiding discontinuities in the energy landscape, like those you would get if you use your last dump or data fiile ((those snapchats do not save any Force information), so a complete recalculation must be done, using also less accurate information). Let me say also, that this is the reason why a restart file is not portable and it’s only to be used in the same platform it was created.
Thks said… maybe a “reset timestep N” Is what you need, being N the last step reached, write this line before the run command and that’s it. reset_timestep command — LAMMPS documentation
Hello,
Thanks for the reply!
The timestep is continued in the restart simulation. The simulation time is not, however, this is due to the version I am using is too old. I need to update to the recent version.