Re: center of mass calculation in the tcl interface

From: Aron Broom (broomsday_at_gmail.com)
Date: Sun Feb 24 2013 - 14:48:38 CST

I'm not sure, but maybe you could try to define $a2 differently. It seems
from your code that a2 is going to be a list of integers, whereas measure
is expecting a list of atoms (but I could easily be reading that wrong). I
haven't used tcl within NAMD much, but maybe something like:

set a2 [atomselect "serial 1 to 104"]
set center [measure center $a2 weight mass]

would work?

~Aron

On Sun, Feb 24, 2013 at 2:02 PM, Jacqueline Schmidt <
jacqueline_schmidt_1983_at_yahoo.com> wrote:

> Dear NAMD users,
> I am trying to use Tcl interface to add a steered MD velocity to a
> peptide. My system is running prior to SMD simulation for equilibration.
> Then I want to use the last configuration to pull my peptide 10 Ang upward.
> For that purpose I want to calculate the center of mass of the peptide at
> the zeroth step of smd simulation (last configuration from the
> equilibration steps).
>
> To do that, I am using a simple command "measure center $sel" at the
> beginning of my smd.tcl file (see below), but I get an error ** FATAL
> ERROR: wrong # args while executing "measure center $a2 weight mass **
>
> can anyone please help me?
>
> here is my smd.tcl
>
> # defining a group which includes peptide atoms
> set grp2 {}
> for {set j 1 } { $j <=104 } {incr j } {
> lappend grp2 $j
> }
> set a2 [addgroup $grp2]
>
> # set the output frequency, initialize the time counter
> set Tclfreq 10
> set t 0
>
> # force constant (kcal/mol/A^2)
> set k 20
>
> # pulling velocity (A/timestep)
> set v 0.0000025
>
> set outfilename rklpda_smd_tcl.out
> open $outfilename w
>
> ##*******error happens here**************
> set r20z [ lindex [ meausre center $a2 weight mass ] 2 ]
>
> proc calcforces {} {
>
> global Tclfreq t k v a2 r20z outfilename
> loadcoords coordinate
>
> set r2 $coordinate($a2)
> set r2z [lindex $r2 2]
>
> set f2x 0
> set f2y 0
> set f2z [expr $k*($v*$t-$r2z+$r20z)]
> lappend f2 $f2x $f2y $f2z
>
> addforce $a2 $f2
>
> set foo [expr $t % $Tclfreq]
> if { $foo == 0 } {
> set outfile [open $outfilename a]
> # calc time in ps
> set time [expr $t]
> puts $outfile "$time $r2z $f2z"
> close $outfile
> }
>
> incr t
> return
> }
>
>

-- 
Aron Broom M.Sc
PhD Student
Department of Chemistry
University of Waterloo

This archive was generated by hypermail 2.1.6 : Wed Dec 31 2014 - 23:20:56 CST