Re: Distance Restraint

From: Bo Liu (boliu_at_ks.uiuc.edu)
Date: Tue Nov 23 2010 - 11:16:42 CST

Hi Jacopo,

Have you tried *extraBonds *option for the distance restraint, which is a
new feature in NAMD 2.7.
Check this out: http://www.ks.uiuc.edu/Research/namd/2.7/ug/node26.html

Hope it helps.

Bo

Extra bonded terms are enabled via the following options:

   - *extraBonds *[image: $ <$] enable extra bonded terms? [image: $ >$]
   *Acceptable Values: *on or off
   *Default Value: *off
   *Description: *Specifies whether or not extra bonded terms are present.

   - *extraBondsFile *[image: $ <$] file containing extra bonded terms [image:
   $ >$]
   *Acceptable Values: *file
   *Description: *File containing extra bonded terms. May be repeated for
   multiple files.

The extra bonds file(s) should contain lines of the following formats:

   - bond <atom> <atom> <k> <ref>
   - angle <atom> <atom> <atom> <k> <ref>
   - dihedral <atom> <atom> <atom> <atom> <k> <ref>
   - improper <atom> <atom> <atom> <atom> <k> <ref>
   - # <comment ...>

In all cases <atom> is a *zero-based* atom index (the first atom has index
0), <ref> is a reference distance in Å (bond) or angle in degrees (others),
and <k> is a spring constant in the potential energy function[image: $ U(x)
= k (x-x_{ref})^2$].

On Tue, Nov 23, 2010 at 10:23 AM, Jacopo Sgrignani <sgrigna_at_sissa.it> wrote:

> Dear Namd users
> i'm new to NAMD and i would like to use an harmonic restraint between to
> atoms.
> I found a script in this list:
>
> # Scripting
> # switch on tclforces
> tclforces on
> # Call tcl force
>
> tclforcesScript {
>
> # Set atom index
> set at1 25371
> set at2 8186
> addatom $at1
> addatom $at2
>
> # Set costant force and eq. dist. V=-0.5*K(r-ro)^2
> set k 050.0
> set r0 6.000
> print " TCLFORCE ACTION "
>
> # Call procedure
> proc calcforces {} {
> # set change variable
> global at1 at2 k r0
> # load coordinates
> loadcoords c
> # set distance for atom 1 and atom 2
> set r12 [vecsub $c($at2) $c($at1) ]
> set r [veclength $r12 ]
> # set unit vector
> set n0 [vecnorm $r12]
> # Force: F=-dV/dr
> set force [expr $k*($r-$r0)]
>
> # set vector force for atom 1 and atom 2
> set f1 [vecscale $force $n0 ]
> set f2 [vecscale -$force $n0 ]
> # add force f1 and f2 to atoms
> addforce $at1 $f1
> addforce $at2 $f2
>
> }
>
> # Ther is a definition of subroutine veclenght and vecnorm
> # Returns: the vector length
>
> proc veclength {v} {
> set retval 0
> foreach term $v {
> set retval [expr $retval + $term * $term ]
> }
> return [expr sqrt($retval)]
> }
> # Returns: the normal vector
> proc vecnorm {v} {
> set sum 0
> foreach term $v {
> set sum [expr $sum + $term*$term]
> }
> set sum [expr sqrt($sum)]
> set retval {}
> foreach term $v {
> lappend retval [expr $term / $sum]
> }
> return $retval
> }
> }
>
> But now i get this error:
>
> TCL: Running for 700 steps
> TCL: expected floating-point number but got "--17.996288924"
> FATAL ERROR: expected floating-point number but got "--17.996288924"
> while executing
> "vecscale -$force $n0 "
> (procedure "calcforces" line 16)
> invoked from within
> "calcforces"
> ------------- Processor 0 Exiting: Called CmiAbort ------------
> Reason: FATAL ERROR: expected floating-point number but got
> "--17.996288924"
> while executing
> "vecscale -$force $n0 "
> (procedure "calcforces" line 16)
> invoked from within
> "calcforces"
>
>
> Could anybody help me?
>
> Thanks
>
> Jacopo
>
>

-- 
========================================
Bo Liu
Theoretical and Computational Biophysics Group
3027 Beckman Institute
University of Illinois at Urbana-Champaign
405 N. Mathews
Urbana, IL 61801
http://www.ks.uiuc.edu/~boliu
========================================

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:54:47 CST