Re: About the command "set z [lindex $coorList($i) 2]".

From: Marcos Sotomayor (sotomayo_at_ks.uiuc.edu)
Date: Sun Apr 16 2006 - 18:33:04 CDT

Hi Boyang,

Lists usually start from zero, i.e.: x is the element #0, y is the element
#1 and z is the element #2. My guess is that this is the case for your
example, but you may want to check more carefully by printing out the
coordinates to a file.

Marcos

On Sun, 16 Apr 2006, Boyang Wang wrote:

> Hi all. I have a question about extracting z coordinate from a list of
  coordinates.
>
> In the configuration file sim_short.conf from the tutorial of pressure
  induced water flow, there is one line of command as follows,
>
> set z [lindex $coorList($i) 2]
>
> and this command line is to extract the z coordinate of the ith atom
  in the coorList. However, I don't see the reason of putting "2" at last.
  As z coordinate of an atom in the coorList should appear the last, which
  means I think it should be "3". I guess that the sequence of coordinates
  of an atom in the coorList should be x, y, z.
>
> Would anybody give me some advice?
>
> Thanks for your time!
>
> Boyang
>
> The sim_short.conf file contains a tclForcesScript, as follows,
>
> tclForces on
>
> tclForcesScript {
> set cellLengthZ 30.3962 ;# The length of the unit cell in the z-direction, should be the same as the value in "cellBasisVector3"
> set LowerBoundary -12.5
> set UpperBoundary 12.5
> set force {0 0 0.4}
> set watIdList {}
> for {set i 577} {$i<1320} {incr i 3} {
> lappend watIdList $i
> addatom $i
> }
> proc calcforces {} {
> global cellLengthZ LowerBoundary UpperBoundary force watIdList
> loadcoords coorList
> foreach i $watIdList {
> set z [lindex $coorList($i) 2]
> set z [expr $z-round($z/$cellLengthZ)*$cellLengthZ] ;# Translate this coordinate into its corresponding value in the original unit cell
> if {$z>$UpperBoundary || $z<$LowerBoundary} {
> addforce $i $force
> }
> }
> }
> }
>
>
>
>
>
>
> Boyang Wang,
> Email - bwang9_at_uic.edu
> Major - Phys. Chem.
> dept Chemistry,
> Univ Illinois, Chicago,
> 60607 IL US.
>
> ---------------------------------
> ÑÅ»¢1GÃâ·ÑÓÊÏä°Ù·Ö°Ù·ÀÀ¬»øÐÅ
> ÑÅ»¢ÖúÊÖ-ËÑË÷¡¢É±¶¾¡¢·ÀɧÈÅ

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:41:55 CST