Is it possible to replace the atom information in the simulation box defined from one read_data command with another read_data command?

Hi Lammps developers,

I am trying to do a simulation using multiple read_data commands. From the documentation of read_data command, when the read_data command is used multiple times, one must use the ‘add’ keyword which can add/merge the new set of atom information with the old one defined from the previous read_data command. Instead of this, is it possible that one can wholly update/replace the old atomic information with the new one defined from the latest read_data command ?

Or is it possible that I can restart the whole simulation with the new atomic information via a loop or by other means ?

Thank you for reading about my problem. I hope I will get some help from you.

See read_dump command.

Wouldn’t this be a new simulation then?

You may replace coordinate information, but you cannot easily replace topology data.
Your description sounds a lot like you should be using the “clear” command and just repeat the entire rest of the input with a different data file (e.g. taken from a variable). After “clear” the simulation box and all system settings are deleted and reset to their defaults and then you can start over and use “read_data” without the “add” keyword.

Dear Lammps developers,

Thank you for your valuable suggestions. I have used the ‘clear’ command to solve my problem of using ‘read_data’ command multiple times without using any add keyword. But when I do this there is an error of 'Segmentation fault’. I found the similar kind of problem is discussed in the [Materials Science Community Discourse] page at Clear command trigger a segmentation fault. There, it is suggested that the source code should have small changes. Since the version of LAMMPS have changed from the time that the above question is posted, do you suggest a different solution for this 'Segmentation fault’ error?

For serious bugs like this, it’s always important to test on the latest patch release of LAMMPS, in this case 15Sep2022. What version of LAMMPS are you using?

Hi Michael Jacobs,

The version I have been using is : LAMMPS (23 Jun 2022)

That should be sufficiently recent. To investigate this further, a simple way to reproduce this segfault quickly and without much need to CPU resources is needed. So please try to simplify and shrink your system and input as much as possible (it does not need to be a meaningful system, just quickly reproduce the segfault) and provide the files and instructions on how to run it, so we can debug it and try to identify the cause of the segfault and possibly provide a fix.

Dear Axel Kohlmeyer,

Thank you so much for the suggestion. I have prepared the attached set of files with a vey simple system of 4 atoms, which reproduces the segfault error with ‘clear’ command in the exactly same way as the system I am working with. I have provided an executable named ‘job_executable’ which can be executed with ‘./job_executable’ command and provides the output files with the segfault error. Please let me know the instructions to solve this problem. Thank you so much.

Thanks for the files. The issue is that variables are not deleted with the clear command, but atomfile style variables depend on an internal fix which is deleted with clear and they are not redefined (similar to index variables). Thus you need to insert the commands:

variable nFx delete
variable nFy delete
variable nFz delete
variable naPE delete

before the clear command and the input should run as expected without a segmentation fault.

Dear Axel,

The problem is solved with your suggestion. Now My code is running via loop without interruption. Thank you so much for the help.