I am trying to write a Lammps script where I want to add and remove particles. To do that, I use the following fixes:
fix 4 o deposit 20 2 100 29494 region rdep near 2.0 vz -0.005 -0.005 units box
fix 5 o evaporate 100 100 reva 49892
where the regions are defined earlier on (essentially I remove particles that cross a z threshold). In my script, I also have a dump command:
dump 1 all xyz 100 pt_o_deposit.xyz
I have noticed that everything goes well as long as particles are added. However, as soon as one is removed via fix evaporate, I get a segmentation fault: e.g.,
free(): invalid pointer 0x40d3a73b!
600 286.27749 329.67952 -53505.866 363.52234 -53142.344 427
This does not happen when the dump command is removed (in fact the error occurs when the dump is invoked, i.e., every 100 steps).
I know the xyz format is not very flexible when it comes to varying number of atoms. So, I could get rid of it.
However, I have some scripts that use xyz files with varying N to postprocess them so I can visualize the system with VMD.
Any help would be appreciated. Thanks.