# Gmx gangle and index selections

**URL:** https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063
**Category:** User discussions
**Created:** [November 9, 2020, 6:26pm UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063 "2020-11-09T18:26:54Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Sotadebastos](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@Sotadebastos](https://gromacs.bioexcel.eu/u/Sotadebastos)
#### Post date: [November 9, 2020, 6:26pm UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/1 "2020-11-09T18:26:54Z")

</div>

GROMACS version: gmx\_2019  
GROMACS modification: Yes/No  
Here post your question

Dear users.

I want to calculate the orientation of a molecule respect to the z axis of the simulation box. In order to do this I define a vector between two atoms of the molecule, let us call them A1 and A2.

When I run the gmx gangle command I tell GROMACS to take two group selections in the index file: one with all the A1 atoms of the desired molecule, another group with all the A2 atoms. As the number of molecules I have is odd I am facing this error:

Inconsistency in user input: Number of positions in selection 1 in the first group not divisible by 2

Does GROMACS need A1 and A2 atoms to be in the same group? When you define the vector gmx gangle asks for two groups selections so I don’t see the problem with having even number of A1 nad A2 atoms. Any help for dealing with this?

Best  
David

---

<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: [November 10, 2020, 8:09am UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/2 "2020-11-10T08:09:18Z")

</div>

Hi,  
I understand that you want to calculate the angle between a vector (representing the protein) and z-axis. In this case, you can use the option -g2 z while g1 is the vector representing the protein. To describe such a vector you need a selection with a pair of position or pairs of position (if you have more vectors).  
Best regards  
Alessandra

---

<div class="post-metadata">

### Author: ![MarceloAlbuquerque](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@MarceloAlbuquerque](https://gromacs.bioexcel.eu/u/MarceloAlbuquerque)
#### Post date: [November 11, 2021, 8:53pm UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/3 "2021-11-11T20:53:07Z")

</div>

I see what you mean, but how do I set these vectors in practical terms? If I understood, in the case I would need 2 groups, let’s say, a group with atoms A and another group with atoms B, which form a molecule AB, as Sotadebastos said. Do I need to use gmx make\_ndx with these atoms, or just provide them to the option -group1?

---

<div class="post-metadata">

### Author: ![Yogesh](https://avatars.discourse-cdn.com/v4/letter/y/49beb7/32.png) [@Yogesh](https://gromacs.bioexcel.eu/u/Yogesh)
#### Post date: [November 30, 2021, 9:22am UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/4 "2021-11-30T09:22:51Z")

</div>

Dr. Alevilla  
what if i have to compute angle between dipole vector and z axis  
lets say oriented like

# frame dip\_x dip\_y dip\_z |dip|

0 -0.05827735364437103 -1.521030306816101 -0.7441486716270447 1.6943100925406684

for dipoles there will be no atom selection. What can i do in this case?

---

<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: [November 30, 2021, 10:41am UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/5 "2021-11-30T10:41:45Z")

</div>

Hi,  
I am not sure if gmx dipoles do that, but you can just apply the relation |mu|cos(angle)=mu\_z to the component that gmx dipoles provides as output  
I hope it helps  
Alessandra

---

<div class="post-metadata">

### Author: ![Yogesh](https://avatars.discourse-cdn.com/v4/letter/y/49beb7/32.png) [@Yogesh](https://gromacs.bioexcel.eu/u/Yogesh)
#### Post date: [December 6, 2021, 2:35pm UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/6 "2021-12-06T14:35:41Z")

</div>

Dr. Alevilla  
I used h2order for getting water dipole orientation with respect to z, that worked perfectly. Is it possible to customize the code for dipole vector of other ligands?  
for example as i specified here  
**# frame dip\_x dip\_y dip\_z |dip|**  
**0 -0.05827735364437103 -1.521030306816101 -0.7441486716270447 1.6943100925406684**  
I went through h2order.cpp file. but couldn’t find where vectors are specified in the c++ script. It should be easy and safe to modify for other ligands as well. suggestions?

---

<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: [December 10, 2021, 10:06am UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/7 "2021-12-10T10:06:13Z")

</div>

Hi,  
If it helps, the water molecule dipole is defined in line 171 of h2order.cpp.  
\Alessandra

---

<div class="post-metadata">

### Author: ![agustin.zavala](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@agustin.zavala](https://gromacs.bioexcel.eu/u/agustin.zavala)
#### Post date: [August 21, 2023, 2:47pm UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/8 "2023-08-21T14:47:40Z")

</div>

hello, so I understand that the first vector is defined by two atoms, used as the bottom and top ends of the vector. Is it possible to define a vector with a group of many atoms? like, their principal vector

---

<div class="post-metadata">

### Author: ![reaham](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@reaham](https://gromacs.bioexcel.eu/u/reaham)
#### Post date: [February 11, 2025, 3:34pm UTC](https://gromacs.bioexcel.eu/t/gmx-gangle-and-index-selections/1063/9 "2025-02-11T15:34:00Z")

</div>

How to specify a pair of positions please (exact format)?
