From: Ana Celia Vila Verde (
Date: Fri Mar 02 2012 - 10:15:23 CST

Dear Stefan,

Something like this should get you started (mind you, I didn't debug
this so please test it carefully...):

# load your molecule, and then:
set rcut 4 ;#
distance cutoff
set noFrames [molinfo top get numframes] ;# get the total number of
frames for you simulation

set ions [atomselect top "type ####"] ;# replace the ### with
whatever keyword you use to select all the ions
set indIons [$ions get index] ;# get the atom
index of all your ions
set noIons [$ions num] ;# number of ions
$ions delete ;#
indispensable to save memory

set outfile [open "hydrationNumber.dat" "w" ]

#initialize variables
for {set frm 0} {$frm <$noFrames} {incr frm} {
   set cnt$frm 0

foreach ion $indIons {
     set sel [atomselect top "(type OW) and (within $rcut of index
$ion)] ;# assuming that your water oxygen atoms have type OW
     for {set frm 0} {$frm <$noFrames} {incr frm} {
         $sel frame $frm ; $sel update
         set noWaters [$sel num ] ;# get the number of atoms in your
         incr cnt$frm $noWaters
     $sel delete

puts $outfile "# average hydration number of the ions"
for {set frm 0} {$frm <$noFrames} {incr frm} {
   puts $outfile "$frm [expr {double([set cnt$frm])/double($noIons)} ]"

close $outfile



On 3/2/12 4:33 PM, wrote:
> Dear VMD users/developers
> I am performing a molecular dynamics of metal ions in water solution, but
> I do not know how to plot the coordination number of a single ion (the
> number of water molecules, or oxygen atoms, bonded to the ion within a
> distance cutoff) versus time. How could this be done using VMD?
> Thank you in advance.
> Stefan Kolev, PhD student in the university of Sofia.
> -----------------------------------------
> Интернет от MSAT Cable