• Outreach

From: Olaf Lenz (olenz_at_fias.uni-frankfurt.de)
Date: Thu Aug 09 2007 - 10:19:22 CDT

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

My first question is: why do you have to write this yourself? The radial
pair distribution function extension (Main -> Extensions -> Radial Pair
Distibution Function g(r)) provides all that you need.

Anyway, here is a solution to your problem:

Christopher Stiles wrote:
> set wat_sel [atomselect top "water and (z > \$NT_min and z < \$NT_max and
> sqrt((x*x) + (y*y)) < \$NT_radius and sqrt((x*x) + (y*y)) > \$NT_radius_old)”]

The problem is that this statement will create the atom selection and
substitute the Tcl-variables \$NT_radius etc. ONCE when the above
statement is executed. It will NOT care about the values of \$NT_radius when
\$wat_sel update
is called later on.

So I suppose that you will have to put the atom selection into the loop
so that a new one is created for every value of the Tcl variables, as
seen below.
Note that this will create lots of selections, so you might want to
delete some of the selections (something like \$sel delete, but I'm not
sure, look into the UG).

Also note that this is definitely one of the most inefficient ways to
compute the radial density, because for every bin, ALL atoms have to be
reiterated.
Also,
[lindex [lindex \$l \$i] \$j]
can be written as
[lindex \$l \$i \$j]
.

############################
set nt [atomselect top "resid 1"]
set NT_min [lindex [lindex [measure minmax \$nt] 0] 2]
set NT_max [lindex [lindex [measure minmax \$nt] 1] 2]
set num_frames [molinfo top get numframes]
set x_list {}
set y_list {}

set step_size 7.5

set holder 0

set wat_sel [atomselect top "water and (z > \$NT_min and z < \$NT_max
and sqrt((x*x) + (y*y)) < \$NT_radius and sqrt((x*x) + (y*y)) >

for {set i 0} {\$i < \$num_frames} {incr i} {
\$wat_sel frame \$i
\$wat_sel num
\$wat_sel update
set holder [ expr { \$holder + [ \$wat_sel num ] } ]
}