[lammps-users] fix msd substract out center of mass motion

Hi. I want to do some sensitive diffusion measurements on some smallish systems and subtract out the center of mass motion (which I believe is induced by the Langevin thermostat?). Will the following work?

1) In fix_msd.h define

double xcmorig[3]

2) In fix_msd.cpp's constructor, add a line


3) In fix_msd.cpp's End of Step, add

double xcm[3];

and change

       dx = x[i][0] + xbox*xprd - xoriginal[i][0];
       dy = x[i][1] + ybox*yprd - xoriginal[i][1];
       dz = x[i][2] + zbox*zprd - xoriginal[i][2];


       dx = x[i][0] + xbox*xprd - xoriginal[i][0] - (xcm[0] - xcmorig[0]);
       dy = x[i][1] + ybox*yprd - xoriginal[i][1] - (xcm[1] - xcmorig[1]);
       dz = x[i][2] + zbox*zprd - xoriginal[i][2] - (xcm[2] - xcmorig[2]);

Will that handle things correctly, or will there be complications if e. g. the center if mass crosses a periodic boundary? Or am I overlooking something else?

I would think someone has done the subtracting out the center of mass motion before.


You can use fix recenter if you want the com of the whole system
to stay in one place. You can see logic like you have below
in several other places within LAMMPS if you search for ybox -
fix msd, fix tmd, fix rigid, etc