How to change the binary format of a restart file to a data file?

Hello All,

reading the documents I was able to produce the read_start file. There was a helpful video on youtube taught it in a very clear way:
Restart Command in LAMMPS - YouTube
My problem is I am having a hard time figuring out how to change the binary format to data file format. in the lammps document there is a recommended two line command

read_restart restartfile [remap]
write_data datafile keyword value …

which I am confused how to implement. here are the last few lines of my code:

dump mydmp cnt custom 100 tmp.lammpstrj xs ys zs c_temp

restart 100 file.restart
#write_restart out.rst
???read_restart restartfile [remap]

run 10000

Could you please help me figuring out where the place of these two commands should be in the input file and what does remap mean? Is there an input file example you know that shows applied the the recommended “read_restart restartfile [remap]” command in?

If you’re just looking to output a data file, you can use write_data in your input script. There’s no need to write and read a restart file. Restart files are great for running long simulations that may be interrupted for whatever reason, as you can restart them with less hassle.

If you have a restart file that you created, and you only want to convert it to a datafile, you can simply run (from Section 4.2. Command-line options)

lmp -restart2data out.rst

Note that you may not be able to convert a restart file to a data file if it was created on another machine, because the restart files are binary and architecture-dependent.

Concerning the remap option, it’s no longer implemented in the stable version of LAMMPS for the read_restart command, and should probably be taken out of the doc page for the command-line option.

(Note for @akohlmey: the read_restart doc page also mentions a “flag” in the call signature at the top.)

1 Like

Thank you so much. very helpful.

I tried it " lmp -restart2data file.restart.8000" and I am getting the error: “command not found: lmp”
I tried "lmp_serial -restart2data file.restart.8000
" and I am getting:
Invalid flag in force field section of restart file

Where did you get this restart file? Are you certain it’s not corrupted or truncated?

Also, can you please tell us your LAMMPS version (should be at the top of your output)?

It’s also important that the LAMMPS version that was used to write the file is the same as the version used to read it.

Thanks for the note. There was an option, remap, that was removed recently because the behavior it enabled is now the default. The word “flag” was left by accident. Since we have started to document when flags were added, changed, or removed, I’ve added a deprecation note for that. This way people using older version of LAMMPS but reading the current documentation can notice discrepancies.

1 Like

I generated the restart file myself , and wanted to change the format using the same version of lammps I am generating the file. My lammps version is : LAMMPS (23 Jun 2022). Thank you.

Have you tried a different restart file in the series, like timestep 7000? It’s possible that 8000 was truncated or corrupted and can’t be read.

Without a small(!) example input deck that can exactly reproduce the issue you are seeing, and a protocol of the commands you execute with the resulting log file output it is not easy to help you.

Tens of thousands of people are using restart files in LAMMPS regularly and have no problems (otherwise there would be more people reporting the same issue than just you), so there has to be something not quite right in what you are doing or you are using some LAMMPS feature that very few people use. But to identify which happens, we need to be able to reproduce it first.