[Computing MSD values by interval]

Dear LAMMPS users,

I am trying to compute the MSD of a groups of atoms. I do not want the MSD along the simulation only but also the MSD between “thermo” prints as if they were independent simulations. I am not sure how to do it with LAMMPS.

I though I found an inefficient way of doing it, but it has to be wrong, as the difference between the total MSD between two “thermo” prints is bigger than the MSD values of the interval. The group has only one atom so this is impossible taking into account the triangle inequality.


and this means

d(p1, p0) - d(p2, p0) > d(p1, p2)

This is how I get the total the global MSD:

compute msd some_group msd

variable Msd equal c_msd[4]

thermo ${thermo_steps}

thermo_style custom v_Msd

run ${total_steps}

Now to retrieve MSD value of the interval, I use a different “compute” command every time I print with thermo:

compute msd some_group msd

variable Step equal step

variable Msd equal c_msd[4]

variable Msd_interval equal c_msd_step[4]

thermo 0

thermo_style custom v_Msd v_Msd_interval

label msd_loop

compute msd_step some_group msd

run ${thermo_steps}

uncompute msd_step

if “{Step} < {total_steps}” then “jump SELF msd_loop”

How could improve this?


You can probably get what you need using the related compute displace/atom.

Your way of doing it is reasonable. LAMMPS will not re-zero the initial

coords for computing the MSD every N steps, nor will it store many starting

points (too much memory).

If each atom moves a distance 1 in x in 100 steps,

then the MSD at time 1 = 1, MSD at time 2 = 4.

But the MSD between 1 and 2 is only 1.

So 4 - 1 > 1. If I understand your formula

you say that should never happen.

The S in MSD means squared, so I think it can?


Dear Steve and Aidan,

You are right of course. At some point of my train of thoughts the squared displacement became the euclidean distance.

Many thanks to both for your replies and time,