# Problem in finding MSD for center of mass of a molecule

**URL:** <https://gromacs.bioexcel.eu/t/problem-in-finding-msd-for-center-of-mass-of-a-molecule/6234>\
**Category:** User discussions\
**Tags:** analysis-tools\
**Created:** [April 19, 2023, 7:02am UTC](https://gromacs.bioexcel.eu/t/problem-in-finding-msd-for-center-of-mass-of-a-molecule/6234 "2023-04-19T07:02:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saiqa](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@saiqa](https://gromacs.bioexcel.eu/u/saiqa)\
**Post date:** [April 19, 2023, 7:02am UTC](https://gromacs.bioexcel.eu/t/problem-in-finding-msd-for-center-of-mass-of-a-molecule/6234/1 "2023-04-19T07:02:33Z")

</div>

Hi  
I am trying **To calculate the Mean Squared Displacement (MSD) of the Center of Mass (COM) of a LI ions molecule in PEO-LiTFSI system (15 peo chains, 15 TFSI molecules and 15 LI ions total 1-9720 atoms) over all points in the trajectory separated by the corresponding time in Gromacs. Here are the steps which i followed:**

1. Generate a trajectory: Run a molecular dynamics simulation of your system and generate a trajectory file (.xtc or .trr) and a topology file (.tpr).

2. Select the TFSI: Create an index file (.ndx) which contains the index of the all atoms of 15 LI (index starting from 9706-9720) that you I want to analyze using the following command

gmx make\_ndx -f system.gro -o LI\_index.ndx

1. Calculate COM: Use “gmx traj” command to calculate the center of mass (COM) coordinate of the lithium ion and save it in a .xtc file using command

gmx traj -s system.tpr -f system.xtc -n li\_index.ndx -com -nojump -o LI\_com\_output.xtc

Now this Li\_com\_ouput.xtc contains only 15 atoms.

But after this when i tried to calculate Calculate MSD: Use “gmx msd” command to calculate MSD of the lithium ion COM coordinate by using this command  
gmx msd -f LI\_com\_output.xtc -s system.tpr -n LI\_index.ndx -mol -trestart 10000

The following errors appears:  
gmx msd -f LI-com-output.xtc -s md.tpr -n li-index.ndx -mol -trestart 10000  
:-) GROMACS - gmx msd, 2022.3 (-:

Executable: /home/user/gromacs/bin/gmx  
Data prefix: /home/user/gromacs  
Working dir: /media/user/My Book/GROMACS/PEO90-LI-V2/PEOLI-15  
Command line:  
gmx msd -f LI-com-output.xtc -s md.tpr -n li-index.ndx -mol -trestart 10000

Available static index groups:  
Group 0 “LI” (15 atoms)  
Specify any number of selections for option ‘sel’  
(Selections to compute MSDs for from the reference):  
(one per line, for status/groups, ‘help’ for help, Ctrl-D to end)

> 0  
> Selection ‘0’ parsed  
> Reading file md.tpr, VERSION 2022.3 (single precision)  
> Reading file md.tpr, VERSION 2022.3 (single precision)  
> Reading frame 0 time 0.000

* * *

Program: gmx msd, version 2022.3  
Source file: src/gromacs/pbcutil/mshift.cpp (line 117)

Fatal error:  
Molecule in topology has atom numbers below and above natoms (1).  
You are probably trying to use a trajectory which does not match the first 1  
atoms of the run input file.  
You can make a matching run input file with gmx convert-tpr.

#################  
then i used gmx convert-tpr -s md.tpr -n li-index.ndx -o li.tpr  
to modify topology containing only lithium. and got this result  
Command line:  
gmx convert-tpr -s md.tpr -n li-index.ndx -o li.tpr

Reading file md.tpr, VERSION 2022.3 (single precision)  
Group 0 ( LI) has 15 elements  
There is one group in the index  
Will write subset LI of original tpx containing 15 atoms  
Reduced ilist BONDS from 4245 to 0 entries  
Reduced ilist ANGLES from 17925 to 0 entries  
Reduced ilist RBDIHS from 20475 to 0 entries  
Reduced ilist LJ14 from 20475 to 0 entries  
Reduced ilist CONSTR from 5430 to 0 entries  
Reduced block excls from 9720 to 15 index-, 105870 to 15 a-entries  
#######################

after using the modified topology for MSD calculation i got this error.

Inconsistency in user input:  
Invalid index group references encountered  
Group ‘LI’ cannot be used in selections, because it contains negative atom  
indices and/or references atoms not present (largest allowed atom index is  
15).

Now should i modify my LI-index.ndx now? starting randomly 1-15? my original LI-Index.ndx contains lithium index starting from 9706-9720.???

---

<div class="post-metadata">

**Author:** ![saiqa](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@saiqa](https://gromacs.bioexcel.eu/u/saiqa)\
**Post date:** [April 19, 2023, 7:08am UTC](https://gromacs.bioexcel.eu/t/problem-in-finding-msd-for-center-of-mass-of-a-molecule/6234/2 "2023-04-19T07:08:33Z")

</div>

Even I also tried to give a random index file starting from 1-15 and running the gmx msd command, i still got this error

gmx msd -f LI-com-output.xtc -s li.tpr -n li-index1.ndx -mol -trestart 10000  
:-) GROMACS - gmx msd, 2022.3 (-:

Available static index groups:  
Group 0 “LI” (15 atoms)  
Specify any number of selections for option ‘sel’  
(Selections to compute MSDs for from the reference):  
(one per line, for status/groups, ‘help’ for help, Ctrl-D to end)

> 0  
> Selection ‘0’ parsed  
> Reading file li.tpr, VERSION 2022.3 (single precision)  
> Reading file li.tpr, VERSION 2022.3 (single precision)  
> Reading frame 0 time 0.000

* * *

Program: gmx msd, version 2022.3  
Source file: src/gromacs/selection/selectioncollection.cpp (line 901)  
Function: void gmx::SelectionCollection::evaluate(t\_trxframe\*, t\_pbc\*)

Inconsistency in user input:  
Trajectory has less atoms (1) than what is required for evaluating the  
provided selections (atoms up to index 15 are required).

Now the problem is with trajectory file.  
How i can match all three trajectory file for COM of LI, topology file for all LI, and index file
