Gmx gangle and index selections

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?


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

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?

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?

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

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?

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