# Why make\_ndx gives duplicates groups? ionic distance analysis

**URL:** https://gromacs.bioexcel.eu/t/why-make-ndx-gives-duplicates-groups-ionic-distance-analysis/2152
**Category:** User discussions
**Created:** [May 12, 2021, 8:36am UTC](https://gromacs.bioexcel.eu/t/why-make-ndx-gives-duplicates-groups-ionic-distance-analysis/2152 "2021-05-12T08:36:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mdigennaro](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mdigennaro](https://gromacs.bioexcel.eu/u/mdigennaro)
#### Post date: [May 12, 2021, 8:36am UTC](https://gromacs.bioexcel.eu/t/why-make-ndx-gives-duplicates-groups-ionic-distance-analysis/2152/1 "2021-05-12T08:36:30Z")

</div>

GROMACS version: 2021.1  
GROMACS modification: Yes/No

Dear users,  
I have a solvent + ionic system.  
The solvent has one group (TFS), so do the ions (TMP and LI).  
My goal is to analyse some quantities after the MD run, eg the average distance between ions. When trying to create the index list, I get the following:

```
$ gmx make_ndx -f md.gro
...
    0 System : 1304 atoms
    1 Other : 1303 atoms
    2 TFS : 15 atoms
    3 TMP : 1288 atoms
    4 LI : 1 atoms
    5 Ion : 1 atoms
    6 TFS : 15 atoms
    7 TMP : 1288 atoms
    8 LI : 1 atoms
...

```

First question: why do I have twice TFS, TMP and LI? Why do I have “Ion”?  
To get to this point I have basically followed [jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)’s tutorial on **[Lysozyme in Water](http://www.mdtutorials.com/gmx/lysozyme/index.html)** but with different molecules. Therefore: editconf, solvate, grompp, genion.

Is there a problem? Shall I combine them?  
If I accept the default and close make\_ndx, the index.ndx file has duplicates, eg.

```
[TFS]
   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[LI]
   1304

```

Moving on to the distance analysis, I would like to calculate the average distance between the ions:

```
gmx distance -f md.gro -n index.ndx
...
Available static index groups:
 Group 0 "System" (1304 atoms)
 Group 1 "Other" (1303 atoms)
 Group 2 "TFS" (15 atoms)
 Group 3 "TMP" (1288 atoms)
 Group 4 "LI" (1 atoms)
 Group 5 "Ion" (1 atoms)
 Group 6 "TFS" (15 atoms)
 Group 7 "TMP" (1288 atoms)
 Group 8 "LI" (1 atoms)

```

I type 2 and 4, getting the following Inconsistency:

```
Currently provided selections:
  1. 2
  2. 4
> Reading frames from gro file 'TFS in solvent in water', 1304 atoms.
...
Inconsistency in user input:
Selection 'TFS' does not evaluate into an even number of positions (there are 15 positions)

```

Could anyone give me some advice? I tried to couple the two ions at the make\_ndx step, but make\_ndx is quite cryptic to understand, and there is very little example apart from [jalemkul](https://gromacs.bioexcel.eu/u/jalemkul)’s tutorial.

```
> 2 & 4

Copied index group 2 'TFS'
Copied index group 4 'LI'
Merged two groups with AND: 15 1 -> 0
Group is empty

```

Thank you

Marco

---

<div class="post-metadata">

### Author: ![alevilla](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/alevilla/32/439_2.png) [@alevilla](https://gromacs.bioexcel.eu/u/alevilla)
#### Post date: [May 12, 2021, 12:50pm UTC](https://gromacs.bioexcel.eu/t/why-make-ndx-gives-duplicates-groups-ionic-distance-analysis/2152/2 "2021-05-12T12:50:23Z")

</div>

Hi

1. [gmx distance](http://manual.gromacs.org/documentation/current/onlinehelp/gmx-distance.html) calculates distances between (fix) pairs of positions as a function of time. For example to calculate the distance between atom 1 and atom 2 , you should provide an index file with the following groups  
[distance]  
1 2

It does not calculate the distance between two group.

There are several posts on the topic in the forum that may help you see for example [What is the difference between gmx distance, gmx mindist and gmx pairdist?](https://gromacs.bioexcel.eu/t/what-is-the-difference-between-gmx-distance-gmx-mindist-and-gmx-pairdist/649)

1. 

> [@mdigennaro](#):
>
> I would like to calculate the average distance between the ions:

an option is to calculate the rdf between the two ions with the tools gmx rdf

1. 

> [@mdigennaro](#):
>
> make\_ndx is quite cryptic to understand

On the prompt of gmx make\_ndx you can type h

> h

This will provide some help and examples  
An example is

> 2 | 4 & r 3-5  
> selects all atoms from group 2 and 4 that have residue numbers 3, 4 or 5

if you want to merge group 2 and 4 the command is : 2 | 4  
the command 2 & 4 will provide the atoms that are in common in both group (and correctly in your case is 0)

Best regards  
Alessandra

---

<div class="post-metadata">

### Author: ![mdigennaro](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mdigennaro](https://gromacs.bioexcel.eu/u/mdigennaro)
#### Post date: [May 14, 2021, 1:18pm UTC](https://gromacs.bioexcel.eu/t/why-make-ndx-gives-duplicates-groups-ionic-distance-analysis/2152/3 "2021-05-14T13:18:50Z")

</div>

Dear @alevilla thank you for your answer,

I still do not understand why in all utilities such as make\_ndx and distance I get 8 groups.  
It looks to me that System, Other+Ion and twice TFS+TMP+Li represent the same thing. Does this matter? is there some default value which I am messing up?

My topology file looks like this:

```
#include "path2/oplsaa.ff/forcefield.itp"
#include "path2/oplsaa.ff/ions.itp"
#include "path2/TFSI+.itp"
#include "path2/diglyme.itp"
[system]
TFS in solvent in water
[molecules]
;molecule name nr. 
TFS 1
DIG 43
LI 1

```

Thank you  
Marco

---

<div class="post-metadata">

### Author: ![alevilla](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/alevilla/32/439_2.png) [@alevilla](https://gromacs.bioexcel.eu/u/alevilla)
#### Post date: [May 18, 2021, 8:32am UTC](https://gromacs.bioexcel.eu/t/why-make-ndx-gives-duplicates-groups-ionic-distance-analysis/2152/4 "2021-05-18T08:32:08Z")

</div>

HI,  
When you run gmx make\_ndx, some default groups are automatically generated on pre-defined criteria. It can occur that some of those groups are identical. If those group do not fullfill your need, you can ignore them or delete them and create the one you need.  
Best regards  
Alessandra
