# Does gmx use the center of mass(COM) to calculate the MSD？

**URL:** <https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968>\
**Category:** User discussions\
**Tags:** analysis-tools\
**Created:** [April 15, 2021, 9:04am UTC](https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968 "2021-04-15T09:04:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![littlema](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@littlema](https://gromacs.bioexcel.eu/u/littlema)\
**Post date:** [April 15, 2021, 9:04am UTC](https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968/1 "2021-04-15T09:04:57Z")

</div>

GROMACS version:2020.2  
GROMACS modification: NO  
Dear all,  
I want to know if the Gromacs use the **COM** in the **gmx msd**? Because I get some different results. My procedure is as follows:

1. make an index file for an ion(PF6) useing gmx make\_ndx

2. using the command:  
gmx msd -f xxx.trr -s xxx.tpr -n index.ndx **-b 0 -e 1** (just the 0-1ps for the selected one PF6 )  
And I get the MSD at t=1.0ps of the one selected PF6.

3. I get the COM of the selected the PF6 using **gmx traj** at t=0, t=1.0ps, and I get the MSD via these COM. But the MSD produced by 2 step is different from the step 3 .

---

<div class="post-metadata">

**Author:** ![pjohansson](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/pjohansson/32/316_2.png) [@pjohansson](https://gromacs.bioexcel.eu/u/pjohansson)\
**Post date:** [April 15, 2021, 12:57pm UTC](https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968/2 "2021-04-15T12:57:12Z")

</div>

Hi,

perhaps the `-mol` flag is what you want? If your group is a single molecule it will calculate the MSD of its center-of-mass.

Edit: However, if you want the center-of-mass MSD of a group which is several molecules, I don’t think that is possible out of the box.

Regards,  
Petter

---

<div class="post-metadata">

**Author:** ![littlema](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@littlema](https://gromacs.bioexcel.eu/u/littlema)\
**Post date:** [April 15, 2021, 1:30pm UTC](https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968/3 "2021-04-15T13:30:26Z")

</div>

@pjohansson  
Dear Petter,  
Thank you so much. maybe I don’t express my question clearly.  
I computed the MSD for an ion, not a group. I get the COM of **a** PF6 by gmx traj, and then I get the ( **R** (t=1ps)- **R** (t=0ps) )^2 for **this ion** (merely for this PF6 ion, not all PF6s in the box) by hand, which is different from the one produced by gmx. So I just wonder if gmx use COM or other algorithm？  
I just want to know the reason.

---

<div class="post-metadata">

**Author:** ![pjohansson](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/pjohansson/32/316_2.png) [@pjohansson](https://gromacs.bioexcel.eu/u/pjohansson)\
**Post date:** [April 15, 2021, 6:06pm UTC](https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968/4 "2021-04-15T18:06:18Z")

</div>

Ah. `gmx msd` calculates the average (individual) MSD of all atoms in the group, not of the COM.

---

<div class="post-metadata">

**Author:** ![kevinboyd](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kevinboyd](https://gromacs.bioexcel.eu/u/kevinboyd)\
**Post date:** [April 16, 2021, 12:05am UTC](https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968/5 "2021-04-16T00:05:23Z")

</div>

That’s correct - if you want a mol COM diffusion coefficient, you need to use the -mol option, but IIRC that doesn’t give you per-mol MSD plots, just the overall diffusion coefficient.

That said, I’d expect the diffusion of PF6 would be reasonably well modeled by just the central P, particularly at longer taus. So if you want a 1:1 comparison, I’d suggest comparing gmx traj on the individual atom to gmx msd on the individual atom.

---

<div class="post-metadata">

**Author:** ![littlema](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@littlema](https://gromacs.bioexcel.eu/u/littlema)\
**Post date:** [April 16, 2021, 2:15am UTC](https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968/6 "2021-04-16T02:15:38Z")

</div>

> [@pjohansson](#):
>
> Ah. `gmx msd` calculates the average (individual) MSD of all atoms in the group, not of the COM.

Oh， I see, Thank you so much! Best wishes with you! (^\_^)

---

<div class="post-metadata">

**Author:** ![littlema](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@littlema](https://gromacs.bioexcel.eu/u/littlema)\
**Post date:** [April 16, 2021, 2:16am UTC](https://gromacs.bioexcel.eu/t/does-gmx-use-the-center-of-mass-com-to-calculate-the-msd/1968/7 "2021-04-16T02:16:16Z")

</div>

Many thanks! Best wishes!(^\_^)

LM
