From: Norman Geist (
Date: Wed Mar 02 2016 - 01:53:56 CST

No, currently you do not consider periodic boundary conditions. Maybe “measure bond” does, otherwise you would have to calculate the “shortest periodic distance” yourself similar to:


proc pmodulo {n m} {

return [expr $n - m * floor(1.0 * $n/$m)]



set Dx = [expr pmodulo( $x1 - $x2 + ($boxX/2) $boxX) – ($boxX/2)]

set Dy = [expr pmodulo( $y1 - $y2 + ($boxY/2) $boxY) – ($boxY/2)]

set Dz = [expr pmodulo( $z1 - $z2 + ($boxZ/2) $boxZ) – ($boxZ/2)]

D = [expr sqrt( ($Dx * $Dx) + ($Dy * $Dy) + ($Dz * $Dz) )]



Norman Geist


Von: [] Im Auftrag von Sangkha Borah
Gesendet: Dienstag, 1. März 2016 17:19
Betreff: vmd-l: Fwd: distance using pbc


Dear all,


I am trying to calculate the interatomic distances between various atom pairs in a small periodic system containing an oxoanion dissolved in 60 water molecules (the same is also true for a crystalline solid). The trajectory is wrapped about the origin. I wanted to use vmd/tcl script using pbctools


The main part of the script goes like --


package require pbctools

pbc set {12.42 12.42 12.42} -all

set outfile [open "test.dat" w]

set nf [molinfo top get numframes]

set ind1 [atomselect top "index 1"]

set ind4 [atomselect top "index 4"]

for {set i 0} {$i < $nf} {incr i} {

         $ind1 frame $i

         $ind4 frame $i

         set dis1_4 [veclength [vecsub [lindex [$ind4 get {x y z}] 0] [lindex [$ind1 get {x y z}] 0] ]]

         puts $outfile "$i \t $dis1_4 "



close $outfile



This script works!


But does it incorporate pbc while calculating the distance ?


My intuition is that it perhaps does not! At least the GUI version does not do it.


Am I correct ?


If so, is there any other way to do so , like the one "pbwithin" instead of within that is used to find the neighbours within a certain cutoff distance using pbc.


Please help to clear my doubts.






Sangkha Borah
IIT Guwahati, Assam, India