#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]"
标签:atomselect,set,dist,index,VMD,原子,到面,TCL,top
From: https://blog.csdn.net/weixin_44620047/article/details/143589422