Re: Tcl "loadtotalforces" question (forces never seem to be saved)

From: Christopher Calderon (calderon_at_rice.edu)
Date: Sun Feb 17 2008 - 14:52:23 CST

Jerome,

My complete tcl script is pasted below the dotted line. It is very
likely that i am just messing something up in my script. If it is a
bug in this version, please also let me know (again work arounds are
also very welcome.).

Chris

---------------------------------------------------------------------------------------------------------------------------------------------

#Pick end points (make sure molecule and box are such that pulling is
in the "long" box direction z)

set id1 [atomid TIT 1 CA]
set grp1 {}
lappend grp1 $id1
set a1 [addgroup $grp1]

set id2 [atomid TIT 89 CA]
set grp2 {}
lappend grp2 $id2
set a2 [addgroup $grp2]

# set the output frequency, initialize the time counter
set Tclfreq 10
set t 0

# contraint points (fix these based on the atom coordinates @ time zero)

set c1x 0.0
set c1y 0.0
set c1z 0.0

set c2x 0.0
set c2y 0.0
set c2z 43.0

# force constant (kcal/mol/A^2)
set k 7.2

# pulling velocity (A/timestep)
set v 0.0005

set outfilename da_smd_tcl.out
open $outfilename w

proc calcforces {} {

  global Tclfreq t k v a1 a2 c1x c1y c1z c2x c2y c2z outfilename

  # get coordinates

  loadcoords coordinate

  set r1 $coordinate($a1)
  set r1x [lindex $r1 0]
  set r1y [lindex $r1 1]
  set r1z [lindex $r1 2]

  set r2 $coordinate($a2)
  set r2x [lindex $r2 0]
  set r2y [lindex $r2 1]
  set r2z [lindex $r2 2]

        

  # calculate forces

  set f1x [expr 100*($c1x-$r1x)]
  set f1y [expr 100*($c1y-$r1y)]
  set f1z [expr 100*($c1z-$r1z)]
  lappend f1 $f1x $f1y $f1z

  set f2x [expr $k*($c2x-$r2x)]
  set f2y [expr $k*($c2y-$r2y)]
  set f2z [expr 0*($c2z+$v*$t-$r2z)]
  lappend f2 $f2x $f2y $f2z

  # apply forces

  addforce $a1 $f1
  addforce $a2 $f2

  loadtotalforces pp
  #print "$r1x and $rr1x $pp"
  if {$t>50} {
  if {[array exists pp]} {
  print "$Force success"
  } else {
  print "Forces Failure (after waiting for 50 timesteps)"
     }
  }

  # output

  set foo [expr $t % $Tclfreq]
  if { $foo == 0 } {
      set outfile [open $outfilename a]
      set time [expr $t/1]
      puts $outfile "$time $r2z $f2z"
      close $outfile
  }
  incr t
  return
}

On Feb 17, 2008 1:52 PM, Jerome Henin <jhenin_at_cmm.chem.upenn.edu> wrote:
> Chris,
> Can you send your complete TclForces script to the list?
> Thanks,
> Jerome
>
>
> On Feb 17, 2008 2:06 PM, Christopher Calderon <calderon_at_rice.edu> wrote:
> > Jerome,
> >
> > Thanks for the quick response, however i just downloaded version
> > "NAMD_2.6b2_Win32-i686" and i still have the same problem.
> >
> > it seems that for some reason the forces from the previous step are
> > never stored (or if they are, the tcl script simply cannot find them).
> > having the total forces added to the "steered" atom is important in
> > the analysis i would like to do, so any work around in getting this
> > info would be appreciated (i.e. i am not committed to using the
> > "loadtotalforces" command).
> >
> > Thanks,
> > Chris
> >
> >
> > On Feb 17, 2008 12:39 PM, Jerome Henin <jhenin_at_cmm.chem.upenn.edu> wrote:
> > > Hi Chris,
> > > I think it was just bad luck - if I remember correctly, that feature
> > > was first included in NAMD 2.6b2.
> > >
> > > I'll take the occasion to remind our fellow NAMD users to always give
> > > the latest version a try if problems arise! And of course, when
> > > reporting the problem, state which version you are using, as Chris
> > > did.
> > >
> > > Best,
> > > Jerome
> > >
> > >
> > > On Feb 17, 2008 12:51 PM, Christopher Calderon <calderon_at_rice.edu> wrote:
> > > > Dear NAMD users,
> > > >
> > > > I noticed that some others have posted question related to
> > > > "loadtotalforces", but i cannot seem to get the posted solutions to
> > > > work either. My problem is in calling this loadtotalforces command in
> > > > a tcl script (the two lines below contained in my "calcforces"
> > > > procedure).
> > > >
> > > > -----------------------------------------------------------------------------------------------------------------
> > > >
> > > > loadtotalforces pp
> > > > if {[array exists pp]} {
> > > > print "Coordinate success"
> > > > } else {
> > > > print "Coordinate Failure"
> > > > }
> > > >
> > > > loadcoords pp
> > > > if {[array exists pp]} {
> > > > print "Force success"
> > > > } else {
> > > > print "Force Failure"
> > > > }
> > > >
> > > > -----------------------------------------------------------------------------------------------------------------
> > > >
> > > > the loadcoords prints "Success" at every timestep whereas the
> > > > loadtotalforces command prints "Failure" for each time step. do you
> > > > need to do something either in the input file or in the tcl script to
> > > > let namd know to save the forces from previous time steps for a
> > > > loadtotalforces call?
> > > >
> > > > i am using namd 2.6b1 and i have encountered this problem on both unix
> > > > and windows versions of this code. any help in getting this to work
> > > > would be appreciated.
> > > >
> > > > thanks,
> > > > chris
> > > >
> > > >
> > >
> > >
> >
>
>

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 05:20:54 CST