From: Mike McCallum (mmccallum_at_PACIFIC.EDU)
Date: Fri Jun 29 2018 - 16:01:56 CDT

Hi there,

I am trying to apply a distance-based selection to a velocity DCD file. I’m calculating instantaneous temperature of a collection of molecules in my system, and I did find a TCL script posted ( and which helps me do exactly that. My problem is that my selections are distance-based, so I need the regular DCD file to make those selections. I’m pretty much a novice at TCL, but what I’m trying to do is open two copies of the same system in VMD using the same PSF; a velDCD in molid 0, and a DCD in molid 1. I then use the [atomselect n (selection)] command. I’m having trouble figuring out how to pass the index from the DCD set to the velDCD set.

set all [atomselect 0 all frame $frame]
set sel [atomselect 1 “sqr(x)+sqr(y)+sqr(z) <= sqr(30)” frame $frame]

The critical part of the temperature call is this foreach:
foreach m [$sel get mass] v [$sel get {x y z}] id [$sel get index] {

The index is the same between the two molids, of course, but it’s picking out the positions from the DCD rather than the velocities from the velDCD.

I can guess that I need to use the ‘id [$sel get index]’ to create a list of the IDs, and then I could loop over those ids, but they will be non-consecutive. Should I just do that and then test to skip the non-pertinent ones? Or loop over all, and test to see if they satisfy the query?

Is there an elegant way to include the index in the selection query, in the ‘foreach m…’ statement?


C. Michael McCallum
Department of Chemistry, UOP
mmccallum .at. pacific .dot. edu (209) 946-2636 v / (209) 946-2607 fax