compute msd and displacement with varying box size in case of a periodic box

Dear LAMMPS users and developers,

likely this question had already been asked, but I couldn't find something specific in the mailing list archive, so please forgive me, if I'm asking again.

In compute/msd and compute/displace the calculation for one dimension, in the case of a simple cubic box and the cm flag turned off, goes like follows:

dx = x + ix*Lx - xo

where x is the current position, ix is the image number, Lx is the current box length and xo is the position of the atom at the initialization time of compute/msd.

xo is calculated in the ctor like this:

xo = x_0 + ix_0 * Lx_0 .

Lx and Lx_0 may be different due to integration in NPT ensemble.
In the case the atom has not crossed any boundary since initialization of compute/msd (ix == ix_0) inserting xo gives:

dx = x-x_0 + ix*(Lx-Lx_0)

Which makes the displacement different for each image of the particle.
But shouldn't the displacement be independent of the image one is looking at?
The same holds for compute/displace.

Can someone please verify this or show me were I'm making an error of reasoning?

Thanks,
Richard

I agree with your eqs. And that the definition
of MSD is problematic when the periodic box size
is also changing over time. If the box size
doesn’t change much or atoms at time 0

don’t have large image flags then this isn’t an issue

(the common use case).

What do you suggest? Using Lx instead of Lx_0,

so that x0 is also a function of the current box size?

Steve