I am sure this has been asked here before but I can't seem to find any link that can help me with my particular problem.
I am using tcl scripting within vmd to do a quick analysis.
package require pbctoolsset wat [atomselect top "segid HETA"]set pbcbox [pbc get -now]set Lz [lindex [lindex $pbcbox 0] 2]set Qwat 0puts [$wat get charge]foreach i{$wat get z} j{$wat get charge} {set $Qwat [expr $Qwat + $j * ($i + 0.5 * $Lz) / $Lz]}#puts $Qwat
When I run this script, I get the error:Where atomselect 0 shows that it set wat fine, 100.608742 is the length of the box Lz and it is finding the charge for each atom (there are 4 atoms each with a negative charge).
However it is failing on this foreach loop where I am wanting it to iterate by location and charge at the same time. So line 1 in list 1 and line 1 in list 2. I have tried each syntax iteration I could think of but I cannot seem to get this expression to work within the foreach loop.
What am I doing incorrectly here?