From: John Stone (johns_at_ks.uiuc.edu)
Date: Wed Nov 26 2014 - 23:45:10 CST

Hi,
  A few points. DCD files store coordinates in single precision only,
not double precision. Restart files are often double precision,
but most trajectory formats are only single precision. The various
"measure" routines in VMD are dominated by single precision since that's
how VMD also stores atomic coordinates associated with trajectory
frames currently. Tcl math routines are mostly double precision,
so there will be differences in rounding, vector length normalization,
etc if you invoke routines that are doing math in the more conventional
Tcl way. In any case, since your atomic coordinates in VMD are currently
only stored in single precision, that's all you should expect from
most distance measurements and the like. Since floating point is
non-associative, any change in the order of operations (even a tiny one)
can cause the results of two otherwise comparable calculations to differ,
so your results are exactly what I would expect to see.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Wed, Nov 26, 2014 at 04:06:03PM -0800, Gianluca Interlandi wrote:
> Dear vmd list,
>
> I noticed that I get slightly different results when I measure the
> distance between two atoms using "measure bond" vs by measuring the length
> of the vector between the two atoms. The difference is usually after the
> 4th decimal after the period. I read in the frames from a NAMD DCD and I
> use, e.g.,:
>
> set index1 [[atomselect top "name CA and resid 1"] get index]
> set index2 [[atomselect top "name CA and resid 2"] get index]
> measure bond {$index1 $index2} frame 100
>
> which returns "12.263489723205566"
>
> But if I calculate the length of the vector between the two atoms with:
>
> set sel1 [atomselect top "name CA and resid 1" frame 100]
> set sel2 [atomselect top "name CA and resid 2" frame 100]
> set res1 [lindex [$sel1 get {x y z}] 0]
> set res2 [lindex [$sel2 get {x y z}] 0]
> veclength [vecsub $res2 $res1]
>
> I get "12.26349001762006"
>
> Just wondering how come I get two slightly different results? The frames
> are read from a DCD file that should be double precision. Which of the two
> methods should be in theory more precise?
>
> Thanks!
>
> Gianluca
>
> -----------------------------------------------------
> Gianluca Interlandi, PhD gianluca_at_u.washington.edu
> +1 (206) 685 4435
> http://artemide.bioeng.washington.edu/
>
> Research Assistant Professor at the Department of Bioengineering
> at the University of Washington, Seattle WA U.S.A.
> -----------------------------------------------------

-- 
NIH Center for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
http://www.ks.uiuc.edu/~johns/           Phone: 217-244-3349
http://www.ks.uiuc.edu/Research/vmd/