Compute center of mass using wrapped coordinates

Dear LAMMPS developers,

I would like to use the spherical binning to calculate the local density and pressure for a droplet simulation. It will be a droplet with both liquid and vapour phase in a periodic simulation box, but only a very little particles will be presented in the vapour phase. To do the spherical binning, the center of the mass of the droplet would need to be placed at the center. For a large droplet, the center of mass will not be drifted much from the middle, while for a small droplet it would drift a bit from the middle (not too far away). What I found from literature is that the center of mass of the droplet (or entire system, if not many vapor particles) is recentered at every a few timesteps.

I think this can be done in LAMMPS: if I can use the wrapped coordinates to compute the center of mass, and then use “fix recenter”, although the recenter is done at every timestep. I did a search through the LAMMPS mailing list, I found Stan asked a similar question before and Steve commented it should be fine to do this for all atoms in a system. (http://lammps.sandia.gov/threads/msg28439.html) I then modified the codes in Group::xcm() as Stan mentioned it. I changed from “cmone[0] += unwrap[0] * massone; …” to “cmone[0] += x[i][0] * massone; …”, for all three cmone. The thermodynamics results (energy, temperature, etc…) are the same in both original and modified LAMMPS, when no “fix recenter” is applied. When using “fix recenter” to kept the center of mass at the middle, I found the thermodynamics values drifted and diverged after a few thousand steps. I think this should be expected due to the numerical errors of shifting the coordinates.

I want to double check with you to see if the modification I made in LAMMPS are truly valid, just in case I miss something. For example, would the newly computed center of mass affect any important fix functions (fix nvt, npt and etc) in LAMMPS? If this works, it will also provide a bit more information to people who want to do the similar thing in LAMMPS. I would really appreciate it if you can give me some comments.

Thank you for your time.

Regards,
Pengyu

Dear LAMMPS developers,

I would like to use the spherical binning to calculate the local density
and pressure for a droplet simulation. It will be a droplet with both
liquid and vapour phase in a periodic simulation box, but only a very
little particles will be presented in the vapour phase. To do the spherical
binning, the center of the mass of the droplet would need to be placed at
the center. For a large droplet, the center of mass will not be drifted
much from the middle, while for a small droplet it would drift a bit from
the middle (not too far away). What I found from literature is that the
center of mass of the droplet (or entire system, if not many vapor
particles) is recentered at every a few timesteps.

I think this can be done in LAMMPS: if I can use the wrapped coordinates
to compute the center of mass, and then use "fix recenter", although the
recenter is done at every timestep. I did a search through the LAMMPS
mailing list, I found Stan asked a similar question before and Steve
commented it should be fine to do this for all atoms in a system. (
http://lammps.sandia.gov/threads/msg28439.html) I then modified the codes
in Group::xcm() as Stan mentioned it. I changed from "cmone[0] +=
unwrap[0] * massone; ..." to "cmone[0] += x[i][0] * massone; ...", for
all three cmone. The thermodynamics results (energy, temperature, etc...) are
the same in both original and modified LAMMPS, when no "fix recenter" is
applied. When using "fix recenter" to kept the center of mass at the
middle, I found the thermodynamics values drifted and diverged after a few
thousand steps. I think this should be expected due to the numerical errors
of shifting the coordinates.

I want to double check with you to see if the modification I made in
LAMMPS are truly valid, just in case I miss something. For example, would
the newly computed center of mass affect any important fix functions (fix
nvt, npt and etc) in LAMMPS? If this works, it will also provide a bit
more information to people who want to do the similar thing in LAMMPS. I
would really appreciate it if you can give me some comments.

​your modification to the source code is not recommended. it ​will break
quite a few features in LAMMPS that depend on xcm() using unwrapped
coordinates. it doesn't make sense either, since using unwrapped
coordinates is the only meaningful way to compute the center of mass. with
wrapped coordinates you will get unphysical jumps when atoms pass through
periodic boundaries. that is clearly not what you want.

if you are using fix recenter you should use the "shift all" option to
maintain your droplet at its initial C.O.M position, but recenter *all*
atoms.
be careful with this setup and monitor your system, as fix recenter will
suppress any total system momentum and its resulting drift, which can lead
to incorrectly computed temperatures, and in the worst case to a "flying
icecube syndrome". a droplet in vapor system is more susceptible to this
than, say, a solid in liquid system.

an alternative would be to use fix spring with the tether option to attach
your droplet with a suitably chose force constant to a fixed location in
space. this has the disadvantage of adding a (small) arbitrary force, but
it does not hide the flying icecube problem (in fact, it makes it less
likely to happen).

​axel.​

Dear Axel,

Thank you for your advise. They are very useful!

Many thanks,
Pengyu