Plot 3D mode vectors in VMD

From Computational Biophysics and Materials Science Group
Revision as of 16:22, 14 May 2014 by Kevin (Talk | contribs) (Created page with " ######################################### ## Description: TCL script for drawing mode vectors as arrows considering contribution from each modes ## Author: Kevin May 2014 ...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#########################################
## Description: TCL script for drawing mode vectors as arrows considering contribution from each modes
## Author: Kevin May 2014
## Usage: source draw_modes.tcl
## Input: idv.dat (individual contribution of modes)
##        vec.dat (mode vectors)
##        .xyz (coordinate of CG sites at the frame you interested, usually the last)
## Output: graphical plots
## Units:
## Other Notes:
#########################################

proc vmd_draw_arrow {mol start end} {
    # an arrow is made of a cylinder and a cone
    set middle [vecadd $start [vecscale 0.9 [vecsub $end $start]]]
    graphics $mol cylinder $start $middle radius 0.35
    graphics $mol cone $middle $end radius 0.55
}


set natoms 40
set nmodes 8

for {set i 1} {$i <= $natoms} {incr i} {
        set fi [open "idv.dat" r]
        set ff [open "vec.dat" r]
        set fc [open "unsym+last.xyz" r]

        set nlines 1
        set sumv [veczero]

        for {set nlines 1} {$nlines <= [expr $natoms*$nmodes]} {incr nlines} {
                if {$nlines<=$i} {gets $fc start}
                gets $ff vector
                if {[expr ($nlines-$i)%$natoms] != 0} {continue}
                if {[expr ($nlines-$i)%$natoms] == 0} {
                        gets $fi idv
                        set vector [vecscale $vector $idv]
                        set sumv [vecadd $sumv $vector]
                }

                if {[expr ($nlines-$i)/$natoms+1]==$nmodes} {set sumv [vecscale $sumv 200]}

                set end [vecadd $start $sumv]
                draw color ochre
                #puts "$i $nlines $idv $start $end"
                draw arrow $start $end
        }

}