# Calculate com velocity

Dear all,

I tried to calculate center of mass velocity by following command with post processing.

variable momx atom vxmass
variable momy atom vy
mass
variable momz atom vz*mass
variable ma atom mass

compute totalm all reduce sum v_ma
compute comvx all reduce sum v_momx
compute comvz all reduce sum v_momz
compute comvy all reduce sum v_momy

However, the output momentum comvx, comvz and comvy are too small. The total momentum component comvx is even smaller than the sum of velocity compoent, which I believe is wrong since the mass is always larger than 1. Could anyone give me some advice?

Thank you.

Dear all,

I tried to calculate center of mass velocity by following command with post
processing.

variable momx atom vx*mass
variable momy atom vy*mass
variable momz atom vz*mass
variable ma atom mass

compute totalm all reduce sum v_ma
compute comvx all reduce sum v_momx
compute comvz all reduce sum v_momz
compute comvy all reduce sum v_momy

However, the output momentum comvx, comvz and comvy are too small. The
total momentum component comvx is even smaller than the sum of velocity
compoent, which I believe is wrong since the mass is always larger than 1.
Could anyone give me some advice?

a) why don't you simply do?

variable vcmx equal vcm(all,x)
variable vcmy equal vcm(all,y)
variable vcmz equal vcm(all,z)

b) ...and even if you insist on computing this by yourself, you only
want to have one compute reduce for efficiency reasons, since you do
the same reduction operation for all of them. reductions are
synchronization points and thus negatively affect parallel performance

c) the argument about the sum of the velocities and the mass >1
doesn't doesn't make sense. it is trivial to construct a counter
example: consider a simple diatomic with two different masses that
rotates about its COM. the sum of the velocities will oscillate
between a negative and positive maximum, but the velocity of the
center of mass is zero.

axel.

Anytime you have a multi-stage formula, I suggest

you debug it one step at a time, by outputting

the intermediate values. And remember that

thermo output may or may not be normalized

by the number of atoms, depending on units.

Steve