From: Vermaas, Joshua (Joshua.Vermaas_at_nrel.gov)
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?

-Josh

On 2018-06-29 16:19:19-06:00 owner-vmd-l_at_ks.uiuc.edu wrote:

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 (https://www-s.ks.uiuc.edu/Research/namd/mailing_list/namd-l.2013-2014/2915.html.gov%7C0a18338b41eb44b0d3bb08d5de0e5ac7%7Ca0f29d7e28cd4f5484427885aee7c080%7C0%7C0%7C636659075595930247&sdata=%2B3PVKd0UlUYiW2y%2BwN5oEEicayr7%2B5IjtoCh%2FSGnl1A%3D&reserved=0> and https://www-s.ks.uiuc.edu/Research/namd/mailing_list/namd-l.2015-2016/1064.html.gov%7C0a18338b41eb44b0d3bb08d5de0e5ac7%7Ca0f29d7e28cd4f5484427885aee7c080%7C0%7C0%7C636659075595930247&sdata=oU91SFTZJOBr%2BweGFBWx6QXx5%2FjnNkcMKqXlt7CoqEE%3D&reserved=0>) 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?
TIA
Mike

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