write_dump append file option?

Hi lammps peoples,

I am testing a potential function and I want to displace a set of atoms and calculate the force and potential energy as a function of that displacement. I have the displacement in a loop and I use the “run 0” command to get the energies, etc. I would like to animate a traj file so I can see that I am displacing things correctly. When I do a “write_dump” command after the “run 0” command, it just overwrites the last traj file. I am wondering if it would be possible to add an “append filename” option to write_dump similar to what is used in the print command so every write_dump in the loop writes to the same file.

Thanks!

Dave

Hi lammps peoples,

I am testing a potential function and I want to displace a set of atoms
and calculate the force and potential energy as a function of that
displacement. I have the displacement in a loop and I use the "run 0"
command to get the energies, etc. I would like to animate a traj file so I
can see that I am displacing things correctly. When I do a "write_dump"
command after the "run 0" command, it just overwrites the last traj file. I
am wondering if it would be possible to add an "append filename" option to
write_dump similar to what is used in the print command so every write_dump
in the loop writes to the same file.

​appending to a file is almost always a bad idea. especially on networked
file systems, there is always a risk of file corruption and then you might
lose everything. in your case, it is simple enough to have a loop variable
and write out a new file with a new name every time (keep in mind that the
variable expansion with a $ is done while LAMMPS is processing the input
file, so you don't need any support from the command for variables). those
files can be easily combined (in the right order) later.

axel.​

with that in mind, write dump supports all options that are also supported by the various dump commands and dump_modify options, too.
in fact, the write_dump command is for the most part a wrapper around dump, dump_modify, and undump, that just explicitly triggers writing one frame in between. so for every format, where “dump_modify append yes” is supported you may also use it with “write_dump”.

axel.

Thanks Axel,

Again, as usual, “read the manual” is the correct answer. I just hadn’t read deep enough. Also, I hadn’t considered the difficulties in an append file doing funny things over the file system. My system is small and I am running in serial on a workstation so the thought never crossed my mind. Thanks for the suggestions.

Dave