[lammps-users] Problems when adding my own code similar to the displace_atoms command.

Dear all,

I want to add some code to LAMMPS that has functionality similar to the displace_atoms command. My command takes a group-ID and some numerical parameters as input, and then it displaces each of the atoms in that group according to a complicated formula which depends on the position of each atom.

In short, the command does this:
- Calculates some numerical expressions due to the input parameters of the command
- Loops through all the atoms of the simulation, and finds the atoms that are in the desired group
- For each atom in the desired group: Find the coordinates (x, y, z) of that atom -> calculate a displacement (dx, dy, dz) of that atom according to a formula -> add that displacement to the atom's coordinates (x+dx, y+dy, z+dz)

I just copied the contents of the displace_atoms files and then filled in my own code at the appropriate spots, in order to do the correct error checking before and after I displace the atoms.

When using my command to displace the atoms before a simulation run, it works perfectly. However, if I try to make it perform several, stepwise displacements by using a loop in my simulation run, I get some weird results. This is an example of how the run-part of my input script is:

yes, it is OK to do this. It is no different than a script like

my_command ...
run 1000
my_command ...
run 1000
my_command ...
run 1000
my_command ...
run 1000
...

Apparently your new command has some issues with running correctly
based on the current state of the particles. One thing you may certainly
need to do is insure displaced particles end up on the correct processor,
and that periodic BC are handled correctly. The displace_atoms command
has logic for this.

Steve