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: