From: felmerino_at_uchile.cl
Date: Tue Nov 23 2010 - 13:12:23 CST
Hi Jacopo,
>From the error i guess that NAMD does not understand the -$force part, so it produces the "--17. something" number shown in the error which is not a floating point number. You should use something like vecscale $min * $force where min is -1. However, for a simple harmonic distance restraint i would use the colvars module. It is a lot less error prone.
best
Felipe
----Mensaje original----
De: sgrigna_at_sissa.it
Fecha: 23-11-2010 13:23
Para: <namd-l_at_ks.uiuc.edu>
Asunto: namd-l: Distance Restraint
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
This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:56:22 CST