VMD加载GROMACS轨迹的速度信息与时间信息

类别:    标签: gmx vmd   阅读次数:   版权: (CC) BY-NC-SA

Sobereva曾给过一个tcl脚本, 用于解决VMD不能读入GROMACS轨迹速度信息的问题, 具体参考 使VMD读入Gromacs产生的trr轨迹中速度信息的方法. 最近我需要用到VMD的这个功能, 就稍微看了下tcl的语法, 在原代码的基础上改进了一点, 使其使用更简单. 同时结合Sobereva的另一段代码 使VMD播放轨迹时同步显示帧号, 在播放轨迹的同时显示出模拟时间.

下面模拟的是C20和C60分子的相撞过程, 播放轨迹时对每个原子根据速度大小进行着色.

使用方法

  1. 运行MD前将grompp.mdp文件中trr与xtc的输出频率设为相同
  2. 使用gmx traj -f traj.trr -ov抽取traj.trr轨迹文件中的速度, 默认存为veloc.xvg
  3. 使用VMD加载初始的conf.gro文件和traj.xtc轨迹文件(直接使用trr文件可能更简单, 但速度稍慢). 也可直接使用命令vmd conf.gro traj.xtc
  4. vt.tcl脚本复制到轨迹文件所在目录下
  5. VMD命令行窗口中执行source vt.tcl使脚本生效
  6. VMD命令行窗口中执行loadveloc即可加载veloc.xvg文件中的速度. 如果速度文件的名称不是veloc.xvg, 则使用loadveloc 速度文件名即可
  7. 如果播放轨迹时需要显示时间, 可在VMD命令行窗口中执行showtime. 执行showtime off则关闭时间显示. 默认的时间间隔为0.5 fs, 起始时间为0, 如需更改, 可使用showtime on 时间间隔 起始时间
  8. 播放轨迹时对每个原子根据速度大小进行着色, 可通过Graphics | Representations... | Coloring Method | trajectory | Velocity. 如需根据某一方向速度大小着色, 可使用User(x方向), User2(y方向), User3(z方向)
  9. 更改颜色方案, 可使用Graphics | Colors... | Color Scale | Method.

几点说明

vt.tcl脚本

vt.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
proc showtime { {opt on} {dtin 0.5} {t0in 0} } {
	global vmd_frame; global dt; global t0
	set dt $dtin
	set t0 $t0in
	if {$opt==on} {
		trace variable vmd_frame([molinfo top]) w traceframe
	} elseif {$opt==off} {
		draw delete all
		trace vdelete vmd_frame([molinfo top]) w traceframe
	}
}

proc traceframe {name elem ops} {
	global vmd_frame; global dt; global t0
 	draw delete all
	draw color white
	set time [format "%6.1f fs" [expr ($vmd_frame([molinfo top]) * $dt) + $t0]]
	draw text {0 -5 -5} "$time" size 4 thickness 4
}

proc loadveloc { {Fxvg veloc.xvg} } {
	set Mol  [atomselect top all]
	set Natm [$Mol num]
	set Nfrm [molinfo top get numframes]

	set Fxvg [open $Fxvg r]
	gets $Fxvg txt
	while {[string match {[\#@]*} $txt]} {
		gets $Fxvg txt
	}
	set txt [split $txt \t]

	for {set i 1} {$i<$Nfrm} {incr i} {
		$Mol frame $i
		set Vx {}; set Vy {}; set Vz {}
		for {set j 0} {$j<$Natm} {incr j} {
			lappend Vx [ lindex $txt [expr 3*$j+1] ]
			lappend Vy [ lindex $txt [expr 3*$j+2] ]
			lappend Vz [ lindex $txt [expr 3*$j+3] ]
		}

		$Mol set vx $Vx
		$Mol set vy $Vy
		$Mol set vz $Vz
		$Mol set user  $Vx
		$Mol set user2 $Vy
		$Mol set user3 $Vz

		gets $Fxvg txt
		set txt [split $txt \t]
	}

	close $Fxvg
}

评论

◆本文地址: , 转载请注明◆
◆评论问题: https://jerkwin.herokuapp.com/category/3/博客, 欢迎留言◆


前一篇: Martini实例教程:蛋白质
后一篇: TCL培训教程

访问人次(2015年7月 9日起): | 最后更新: 2024-04-16 06:38:20 UTC | 版权所有 © 2008 - 2024 Jerkwin