From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Mon Apr 23 2007 - 14:00:35 CDT

On Tue, 24 Apr 2007, preeda wrote:

> Dear John and other VMD users,
>
> Thank you for your advice about using trace function to retrieve force
> data.
>
> I wrote a tcl file name "saveforce.tcl" to use trace function by calling
> vmd_frame, now force data can be printed out continuously during
> simulation runs but I can not save these force data into a file. Output
> file is created but nothing inside; it seems like a problem about
> opening and closing file channelId.

try opening in append mode from within the callback.
otherwise, you'll close it after the first call to it.

axel.

> Here is my code "saveforce.tcl"
>
> set pullatoms "index 1"
> set sel [atomselect top "$pullatoms"]
>
> set outfilename [open output.dat w]
>
> proc trace {} {
> global vmd_frame
> trace variable vmd_frame w IMD::tracetimestep
> }
>
> proc IMD::tracetimestep {args} {
> global cen sel outfilename
> set force [$sel get {ufx ufy ufz}]
> puts "force = $force"
> # output
> puts $outfilename "$force"
> close $outfilename
> }
>
> Do you know what I did wrong? Any advice will be greatly appreciated.
>
> Best Regards,
>
> Preeda
>

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.