# A Velocity of the center of mass for MD simulations

1. Dec 28, 2017

### xperrylinn

When calculating the center of mass for an MD simulation, I've seen a few codes that subtract the average velocity from each atoms velocity. I think the reasoning behind this is that you want the velocity of center of mass for the simulation to be zero, which I understand, but I don't understand computationally how subtracting the average velocity from each velocity achieves this.

2. Dec 28, 2017

### jbriggs444

Can you see that the [mass-weighted] average velocity is equal to the velocity of the center of mass?

3. Dec 28, 2017

### xperrylinn

I don't see that. This is how I'm seeing it:

mass-weighted average velocity = (sum each atom's momentum) / (num atoms)

velocity center of mass = (sum of each atom's momentum) / (total mass)

And if they are equal, how does help me understand my original question?

4. Dec 29, 2017

### jbriggs444

The correct way to compute a weighted average is to divide by the sum of the weights, not the count of items.