Re: Simple TCL (Forces) question - defining bond vector

From: Jeff Wereszczynski (jmweresz_at_umich.edu)
Date: Thu Dec 06 2007 - 11:43:45 CST

I believe this syntax should work:

set bond2 [vecadd $p($aid1) [vecscale -1 $p($aid2)] ]

Jeff

On Dec 6, 2007 10:33 AM, Jim Pfaendtner <jpfaendt_at_hec.utah.edu> wrote:

> Dear NAMD-L,
>
> I am trying easily to define a vector between two atoms inside of a
> TCL forces script. Taking a cue from the tutorial I have written this:
>
> .. intro stuff defining aid1 and aid2 ...
>
> addatom $aid1
> addatom $aid2
> proc calcforces {} {
>
> global aid1 aid2 k
> loadcoords p
> set bond [getbond $p($aid1) $p($aid2)]
>
> ###
> set bond2 [please help me here :) ]
> ###
> addenergy [expr $k*$bond*$bond]
> set force [vecscale [expr -$k*2] $bond2]
> addforce $aid1 $force
> addforce $aid2 $force
> }
> }
>
> I know that bond2 needs to be a vector that is simply equal to:
> $p($aid1) - $p($aid2) but I can't get the syntax right and I struck
> out searching.
>
> Could someone please suggest the correct syntax for defining a new
> vector as the difference of two other vectors?
>
> Thanks very much,
> Jim
>
>
>

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:45:40 CST