Eastsheng's Wiki

VMD 基本操作

2019-01-22 18:11:28

[toc]

VMD使用

VMD Linux 安装

1
2
3
4
5
6
7
wget http://www.ks.uiuc.edu/Research/vmd/vmd-1.9.3/files/final/vmd-1.9.3.bin.LINUXAMD64-CUDA8-OptiX4-OSPRay111p1.opengl.tar.gz
tar -vxzf vmd-1.9.3.bin.LINUXAMD64-CUDA8-OptiX4-OSPRay111p1.opengl.tar.gz
cd vmd-1.9.3/
./configure LINUXAMD64
./configure
cd src
sudo make install

VMD TkConsole常用命令

  • 设定盒子边界类命令:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    pbc box -style lines # 显示box
    pbc box -width 2 # 改变lines宽
    pbc box -color white # 改变lines颜色
    set cell [pbc set {10.0 10.0 10.0} -all] # 设置边界
    pbc box -center origin -shiftcenter {-1 -1 0} #移动盒子
    pbc box -center origin -color black -width 1.0 -center com
    pbc box -on
    pbc wrap
    pbc wrap -shiftcenterrel {0 0 0.95}

  • 视角切换
    1
    2
    3
    rotate x by 90
    rotate y by 90
    rotate z by 90
  • 读取lammpsdata
    1
    topo readlammpsdata lammps.data

输出高清图片

  • File>>Render...>>Tachyon
  • Figure.bat文件内内容:
    1
    "..\VMD\tachyon_WIN32.exe" vmdscene.dat -aasamples 100 -mediumshade -trans_vmd -res 1024 742 -format BMP -o Figure.bmp

输出透明图片

  • 安装POV-Ray

  • linux: POV-Ray

  • image-20231217002804420

  • windows:

    1
    pvengine64 vmdscene.pov +UA +A +W3000 +H2000
  • linux:

    1
    povray vmdscene.pov +UA +A +W3000 +H2000

如果出来背景还不是透明的, 把display里 depth cueing 取消选择。

输出Video

  • 输出帧图片:
    1
    Extensions>>Visualizations>>Movie Maker
  • 组合图片成视频
  • VideoMach

TCL命令

计算z方向的氢键Hbonds_cal_z.tcl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#TCL VMD script to calculate Avg No. of HBonds for given Acceptor and Donor groups in the z direction 
#
#Authour : KAPAKAYALA ANJI BABU
# IIT KANPUR, INDIA.
#Modified by : Dongsheng Chen
#USAGE : Open VMD/Extensions - Tk console then execute script as " source hbonds_direction_z.tcl"
#
#OUTPUT Files :: hbonds-details_new.dat ; which contains details of all given Donor & Acceptor atoms.
# hbonds-z.dat ; which contains z position vs No.of Hbonds.

#set outfile [open "hbonds-details-all.dat" w]
#set hbzfile [open "hbonds-all-z.dat" w]
#set hbzfile [open "hbonds-wat-wat-z.dat" w]
set hbzfile [open "hbonds-wat-sdbs-z.dat" w]
set n [ molinfo top get numframes]
set sum 0
for {set i 901} {$i <= $n} {incr i} {
for {set j -34} {$j <=94} {incr j} {
set k [expr $j]
#set D [atomselect top "all and z<[expr $k+0.5] and z>=$k" frame $i]
set D [atomselect top "type 411 to 412 and z<[expr $k+0.5] and z>=$k" frame $i]
#set A [atomselect top "all" frame $i]
#set A [atomselect top "type 411 to 412" frame $i]
#set A [atomselect top "resid 1606 1607 3108 3109" frame $i]
#set A [atomselect top "resid 1606 1607 1608 1609 3110 3111 3112 3113" frame $i]
set A [atomselect top "resid 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125" frame $i]
set D_list [$D get {resname type serial }]
set A_list [$A get {resname type serial }]
set lists [measure hbonds 3.5 30 $D $A]
set atoms [lindex $lists 0]
set Num [llength $atoms]

##---------Writing OUTPUT----------------------#
#puts $outfile "========================================"
#puts $outfile "Frame :: $i "
#puts $outfile "DONARS_list ::\n$D_list"
#puts $outfile ""
#puts $outfile "Acceptors_list ::\n$A_list"
#puts $outfile ""
##puts "Hbonds List :: $lists"
##set HBnum [llength $lists ]
#puts ""
##puts "No. of Hbonds :: $HBnum"
#puts $outfile "HB Atoms:: $atoms"
#puts $outfile ""
#puts $outfile "No. of Hbonds:: $Num"
puts $hbzfile "$i $k [expr $k+0.5] $Num"
puts "$i $k [expr $k+0.5] :: No. of Hbonds = $Num"
#------------------Calculating Avg HBonds--------#
set sum [expr $sum + $Num ]
#puts "Sum :: $sum"
}}
set Hbavg [expr $sum/$i]
#puts $hbfile "Ang Hbonds :: $Hbavg"
puts "===================================="
puts "Ang Hbonds :: $Hbavg"
puts "===================================="
$D delete
$A delete
#close $outfile
close $hbzfile
#lsort -unique [$sel get resname]
#==========================================================#
# Written By ANJI BABU KAPAKAYALA #
# Modifed By Dongsheng Chen #
#==========================================================#
  • 导入轨迹后在VMD TkConsole中使用source Hbonds_cal_z.tcl命令执行该代码

常用命令

proc

  • procprocedure的简称,类似于python中的函数定义def
1
2
3
4
# proc 函数名 {参数x 参数y}{函数过程}
proc add {x y} {
return [expr $x+$y] # expr将参数做表达式处理
}

incr

1
2
3
4
5
6
set  x 5
# 5
incr x 10 #相当于给x加10
# 15
incr x #相当于给x加1
# 16

puts

  • 相当于pythonprint
1
puts "welcome to TkConsole!"

llength

  • 相当于pythonlen,返回列表的元素个数
    1
    2
    llength {a b c d e}
    # 5

lindex

  • 从列表中获得元素
    1
    2
    3
    4
    lindex {a b c d}
    # a b c d
    lindex {a b c d} 2
    # c

参考