From: Axel Kohlmeyer (
Date: Fri Jun 10 2005 - 02:17:32 CDT

On Thu, 9 Jun 2005 wrote:


EN> Unfortunately, I'm still having difficulty of a more subtle nature. Now
EN> that I know someone is reading :) I'll elaborate a bit more. Basically,

ok. great.

EN> what I want to do is use VMD to force a rescaling of the distance between
EN> certain parts of my system, and then call NAMD to do some brief energy
EN> minimization of the coordinates, and then repeat the process in a loop
EN> over my scaling parameter. At each step, a new coord frame is generated,
EN> and at the end the entire trajectory is saved. Here is the skeleton of the
EN> VMD script I'm trying to get to work (where the scaling is given by "L")...
EN> ---------------------------------------------------------------------------
EN> mol load psf $start_psf pdb $start_pdb
EN> set frame 0
EN> # initial coords are left as-is in frame 0; begin minimizing in next frame
EN> for {set L [expr $max - $del]} {$L >= $min} {set L [expr $L - $del]} {
EN> # add new frame to the trajectory, with coords copied from current frame
EN> animate dup frame $frame 0
EN> incr frame
EN> animate goto $frame
EN> # (modify coords of new frame...)
EN> # call NAMD to energy-minimize the new coords
EN> animate write pdb $temp_pdb beg $frame end $frame

i think here could be the problem. you should add 'waitfor all'
to the 'animate write' command, or else VMD will start writing the
files and _immediately_ continue executing the script thus creating
a race condition. i assume during the first loop this is not
biting you, since the parser needs more time to evaluate the
script, but from them on it should take advantage of the internal
caching of preparse code and thus the writing of the pdb file may
not be finished when your script calls NAMD the second time.

EN> set cell_size [expr 4.0 * $L]
EN> exec env NAMD_psf=$start_psf \
EN> NAMD_pdb=$temp_pdb \
EN> NAMD_outfile=$out_name \
EN> NAMD_minsteps=$namd_minsteps \
EN> NAMD_cell=$cell_size \
EN> namd2 +p1 $namd_configfile
EN> # replace coords of current frame with new (minimized) coords
EN> animate read pdb $out_name.coor beg $frame end $frame

for safety and the sake of consistency you should add an
'waitfor all' here as well.

EN> }

best regards,

Dr. Axel Kohlmeyer   e-mail:
Lehrstuhl fuer Theoretische Chemie          Phone: ++49 (0)234/32-26673
Ruhr-Universitaet Bochum - NC 03/53         Fax:   ++49 (0)234/32-14045
D-44780 Bochum
If you make something idiot-proof, the universe creates a better idiot.