# the atom moved from one side of the periodic condition to the other one

Dear LAMMPs community:

I am new to LAMMPS and doing MD simulations for reactions, but with my own developed potential energy surface (I used atomic_style atom, therefore). In the simulations, I want to use some distance criterion to terminate the trajectory. However, the system is periodic, and the cartesian coordinates are allowed to go from inside the box to the outside. Then in this way, the cartesian coordinates might be not the real ones, and the calculated distance criterion is not the truly correct one. So do you have suggestions for me to get the truly correct cartesian coordinates? See also below for my relevant input script. Thanks in advance.

Best regards,
Jun

compute z1comp N1 property/atom z
compute zmax1 N1 reduce max c_z1comp

compute z2comp N2 property/atom z
compute zmax2 N2 reduce max c_z2comp

compute x1comp N1 property/atom x
compute xmax1 N1 reduce max c_x1comp
compute y1comp N1 property/atom y

compute ymax1 N1 reduce max c_y1comp

compute x2comp N2 property/atom x
compute xmax2 N2 reduce max c_x2comp
compute y2comp N2 property/atom y
compute ymax2 N2 reduce max c_y2comp

variable nndist equal sqrt((c_xmax1-c_xmax2)^2+(c_ymax1-c_ymax2)^2+(c_zmax1-c_zmax2)^2)
fix STOP all halt 1 v_nndist > 2.78 error soft
fix debug all print 10 “N2 distance is \${nndist}”

Sounds like you’re looking for the unwrapped coordinates. For a given atom with coordinates x, y, and z with image flags ix, iy, iz the equations to get the unwrapped coordinates (ux, uy, uz) are:
ux = x + ix * xlen
uy = y + iy * ylen
uz = z + iz * zlen

where xlen, ylen, and zlen are the lengths of the simulation box.

Will

And those unwrapped coords are available
to your input script. E.g. you could define
a variable that uses them and use a check
on that variable to halt a simulation.

Steve