Computing angle between Z axis and plane of a molecule.

Skip to first unread message

Yogesh Sharma

Nov 8, 2021, 5:41:45 AM11/8/21
Hi I am trying to get the angle between HoH plane of water and z axis of my system over 100 ns simulation. 
How can I do this using mdanalysis. I would like to plot it against time or z coordinates. Can someone guide me through it? 

   with  regards
Yogesh Sharma

Quyen V. Vu

Nov 9, 2021, 5:53:28 AM11/9/21

You can do it by yourself if there is no optimized code available in MDAnalysis (I don't know).
This is very basic. Select water molecules of interest, compute the normal vector of the HOH plane, compute the angle between that normal vector and Z axis. 


You received this message because you are subscribed to the Google Groups "MDnalysis discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Yogesh Sharma

Dec 4, 2021, 5:37:08 AM12/4/21
to MDnalysis discussion
thank you for the response. i tried to use dipole moment vector for the calculation

I used dipwatch gui to get dipole vector for the molecule from mol2 file
# frame    dip_x     dip_y      dip_z    |dip|
0  -0.05827735364437103  -1.521030306816101  -0.7441486716270447  1.6943100925406684

Then i used orient package  to get (z) principle axis in vmd
set I [draw principalaxes $sel] 
set A [orient $sel [lindex $I 2] {0 0 1}]

further, I can use dotproduct to get the angle between both vectors

proc angle { a b } {
set am [veclength $a]
   set bm [veclength $b]
   set dotprod [vecdot $a $b]
   return [expr 57.2958 * acos($dotprod / ($am * $bm))]

Now I am confused about how to define the dipole vector and the vector corresponding to z only?
Can  you help me with some short script or something?

Oliver Beckstein

Dec 5, 2021, 3:13:14 PM12/5/21
to mdnalysis-discussion
Hi Yogesh Sharma,

Did you look into using MDAnalysis.analysis.waterdynamics ? You’ll have to read through the docs carefully and the papers that are referenced (the code was used in [Araya-Secchi2014] (water in a cavity) and [Milischuk2011] (water in a nanopore)).

Oliver Beckstein (he/his/him)

MDAnalysis – a NumFOCUS fiscally sponsored project

Reply all
Reply to author
0 new messages