Re: TCL: can't use floating-point value as operand of "-"

From: li (zlee_at_ustc.edu)
Date: Mon Sep 27 2004 - 21:57:12 CDT

Thank you,sir.below is my script:
BTW,when k is reduced to 14.4, simulation ran well.

# Atoms selected for force application

set id1 [atomid AGLU 1 O42]
set grp1 {}
lappend grp1 $id1
set a1 [addgroup $grp1]

set a2 [addgroup {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
141 142 143 144 145 146 }]

set id3 [atomid AGLU 1 O44]
set grp3 {}
lappend grp1 $id3
set a3 [addgroup $grp1]

set id4 [atomid AGLU 1 O46]
set grp4 {}
lappend grp4 $id4
set a4 [addgroup $grp4]

set Tclfreq 10000
set t 0

# contraint points

set c1x -0.402
set c1y -2.458
set c1z -4.444

set c2x 0.0
set c2y 0.0
set c2z 0.0

set c3x 0.285
set c3y -3.602
set c3z 3.589

set c4x 1.043
set c4y 3.758
set c4z 3.171

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

# pulling velocity (A/timestep)
set v 0.0000001

set outfilename bd1_tcl.out
open $outfilename w

proc calcforces {} {
  global Tclfreq t k v a1 a2 a3 a4 c1x c1y c1z c2x c2y c2z c3x c3y c3z c4x c4y c4z outfilename

  # get coordinates

  loadcoords coordinate
  
  set r1 $coordinate($a2)
  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]
  
  set r3 $coordinate($a2)
  set r3x [lindex $r3 0]
  set r3y [lindex $r3 1]
  set r3z [lindex $r3 2]
  
  set r4 $coordinate($a2)
  set r4x [lindex $r4 0]
  set r4y [lindex $r4 1]
  set r4z [lindex $r4 2]

  # calculate forces
  
  
  set f1x 0
  set f1y [expr $k*($c1y-$r1y)]
  set f1z [expr $k*($c1z-$r1z)]
  

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

  set f3x 0
  set f3y [expr $k*($c3y-$r3y)]
  set f3z [expr $k*($c3z-$r3z)]

  set f4x 0
  set f4y [expr $k*($c4y-$r4y)]
  set f4z [expr $k*($c4z-$r4z)]
  
   lappend f1 $f1x $f1y $f1z
   lappend f2 $f2x $f2y $f2z
   lappend f3 $f3x $f3y $f3z
   lappend f4 $f4x $f4y $f4z
  
  
  
  
  
  
  # apply forces
  addforce $a1 $f1
  addforce $a2 $f2
  addforce $a3 $f3
  addforce $a4 $f4
  
  # output

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

Replyed From: li <zlee_at_ustc.edu>

> What sort of tcl script are you running? Can you send it along for people
> to look at?
>
>
> I could be wrong, but isn't there a bug somewhere in the force analysis
> routines?
>
> Brian
>
> On Mon, 27 Sep 2004, li wrote:
>
> > Dear all:
> > NAMD (version 2.5,Linux-i686 cluster) simulation often ceases with end like this:
> >
> > TCL: can't use floating-point value as operand of "-"
> > FATAL ERROR: can't use floating-point value as operand of "-"
> > while executing
> > "expr $k*($c2y-$r2y)"
> > (procedure "calcforces" line 38)
> > invoked from within
> > "calcforces"
> > Stack Traceback:
> > [0] _ZN15GlobalMasterTcl9calculateEv+0x21b [0x81c8103]
> > [1] _ZN12GlobalMaster11processDataEPiS0_P6VectorS2_S2_S0_S0_S2_S0_S0_S2_+0x6f [0x81c16df]
> > [2] _ZN18GlobalMasterServer11callClientsEv+0x428 [0x81c3384]
> > [3] _ZN18GlobalMasterServer8recvDataEP20ComputeGlob
> >
> >
> > would you please show me the possbile reason?
> > Thanks in advance!

--
USTC Alumni Email System 

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:37:53 CST