From: Vermaas, Joshua (
Date: Fri Jun 29 2018 - 18:28:58 CDT

Hi Mike,

Your velocity variable (v) is coming from $sel, which is based on your coordinate DCD, so yeah, its doing the wrong thing. This is how I'd approach it:

set coordsel [atomselect 1 sqr(x)+sqr(y)+sqr(z) <= sqr(30)]
for { set frame 0 } { $frame < [molinfo 0 get numframes] } { incr frame } {
$coordsel frame $frame
$coordsel update
set velsel [atomselect 0 "index [$coordsel get index]" frame $frame]
set m [$velsel get mass]
set v [$velsel get {x y z}]
#Do what I need to do...

$velsel delete

I'm super puzzled by what you are trying to do though. What is so special about being 30 Angstroms from the center?


On 2018-06-29 16:19:19-06:00 wrote:

Hi there,
I am trying to apply a distance-based selection to a velocity DCD file. Im 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. Im pretty much a novice at TCL, but what Im 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. Im 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 its 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