Mean square displacement and Periodic boundary.

Dear All,

I am trying to calculate calculate mean square displacement by my own (fortran) code using atom coordinates computed by Lammps. My problem is about "periodic boundary" and would like to ask you for help. It is that the (r(i)-r(0))^2 (vs time) (here r(i) is the position of particle at time (i)) increases in a period of time and then it decreases and increases again. (see figure attached)
1. Do I need to limit my consideration in one period time?
2. If I want to plot (r(i)-r(0))^2 vs time in a very long time. Did any one do it before? (I guess that I need to know how many times the particle move out and enter the simulation box)

Any suggestion is highly appreciated.

Thanks,

XC

MSD_Figure.doc (60 KB)

For a periodic system, calculation of the MSD
has to account for atoms crossing the boundaries,
Assuming you have dumped atom positions
fairly frequently, your post-processing code
can figure that out, and add/subtract box
lengths from an atom's coords to get the
true position (as if the boundary did not exist).
You can also ask LAMMPS to dump the
"image" flags of the atom, which are exactly
that quantity.

Steve