From: Andrés Morales (h.andres.m1986_at_gmail.com)
Date: Thu May 10 2012 - 18:40:58 CDT

Dear VMD users

I am trying to calculate an specific amount (electric potential) from data
extracted from a text file. The script works fine to calculate this value
for an specific point (specific values of x, y, z variables), but when I
tried to run it for a range of values it doesn't work. I used the following
script:

###################################
set file2 [open total.txt r]
set output2 [open campo.txt w];
puts $output2 "y z potencial"
set sum 0
for {set i -35 } {$i <= 35 } { incr i 5 } {
for {set j -30 } {$j <= 55 } { incr j 5 } {
set x1 0
set y1 [expr $i]
set z1 [expr $j]
while { [gets $file2 line2] != -1 } {
set dist [expr pow(([lindex $line2 1]-$x1)*([lindex $line2 1]-$x1) +
([lindex $line2 2]-$y1)*([lindex $line2 2]-$y1) + ([lindex $line2
3]-$z1)*([lindex $line2 3]-$z1),0.5)]
set campo [expr [lindex $line2 0] / abs($dist)]
set sum [expr $sum + $campo]
  }
puts $output2 "$i $j $sum"
}}
close $output2
#######################################

I got an output like this:

y z potencial
-35 -30 0.01074960712757333
-35 -25 0.01074960712757333
-35 -20 0.01074960712757333
-35 -15 0.01074960712757333
-35 -10 0.01074960712757333
-35 -5 0.01074960712757333
-35 0 0.01074960712757333
-35 5 0.01074960712757333
-35 10 0.01074960712757333
....

Does anybody know what is wrong and how I can solve it???

Thanks a lot

Andres