VMD计算原子到面的最短距离,TCL脚本

#calculate the distance between atom and planes in the trajectory# 

 set result [open dist-h-mental.txt w]
 set nframe [molinfo top get numframes]
 #目标原子
 set p [atomselect top "index 48"]
 #组成平面的三个原子
 set a [atomselect top "index 44"]
 set b [atomselect top "index 45"]
 set c [atomselect top "index 46"]
 set sum 0
 #遍历每一帧
 for {set i 0} {$i<$nframe} {incr i 1} {
 $p frame $i
 $a frame $i
 $b frame $i
 $c frame $i
 $p update
 $a update
 $b update
 $c update
 #计算向量 ba 和 bc
 set vecba [vecsub [measure center $b] [measure center $a]]
 set vecbc [vecsub [measure center $b] [measure center $c]]
 #计算法向量及其长度
 set normal [veccross $vecba $vecbc ]
 set normal_length [veclength $normal]
 #计算向量pa
 set target_to_plane [vecsub [measure center $p] [measure center $a]]
 #计算距离
 set distance [ expr abs([vecdot $target_to_plane $normal]) / $normal_length]
 puts $result "$i $distance"
 set sum [expr $sum+$distance]
 }
 close $result
 puts "the average diatance is : [expr double($sum)/$nframe]"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值