Re: tclforces: measure distances in NAMD 2.6b2 ?

From: Axel Kohlmeyer (
Date: Sun Jul 25 2010 - 18:43:59 CDT

On Sat, Jul 24, 2010 at 10:46 PM, Sebastian Stolzenberg
<> wrote:

dear sebastian,

> Dear All,
> I am bound to use NAMD version 2.6b2.
> For a tclforcescript, could anybody kindly tell me
> how I can measure a distance between two atoms?

through tcl math with expr?

> Unfortunately, the functions:
> veclength
> veclength2
> vecdist
> as described in the VMD tutorial don't work, though they work in different
> NAMD versions.

please note, that neither of those functions are standard
tcl functions, but extensions in VMD, that have been added
to NAMD as well.

> (e.g.:
> FATAL ERROR: Setting parameter veclength2 from script failed!
> )
> [expr sqrt (2)]
> seems to work, yet I am afraid using [expr sqrt( sum(...)) may slow things
> down.

the only wait to avoid this, is to upgrade to a newer version.
that would give you many other bugfixes and performance
enhancements, too.

otherwise you are stuck an could, for example adapt the script
code that is in lib/abf/vectors.tcl. the only possible optimization
would be to add curly braces and thus reduce one unneeded
step of variable expansion: e.g. use
set retval [expr {$retval + $term * $term}]
instead of
set retval [expr $retval + $term * $term]

> Are there alternative functions I can use?

if you cannot recompile, there is no alternative.


> Thank You so much,
> Sebastian
> PS:
> **************
> these are the commands I use in the tclforcescript:
> set dist        [veclength2 $distvec]
> #set dist       [vecdist $distvec [vecsub $distvec $distvec ]]

Dr. Axel Kohlmeyer
Institute for Computational Molecular Science
Temple University, Philadelphia PA, USA.

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