计算化学公社

标题: 求助VMD如何添加周期性边界条件计算原子间距 [打印本页]

作者
Author:
MXM    时间: 2021-8-6 19:03
标题: 求助VMD如何添加周期性边界条件计算原子间距
大家好,我想用VMD后处理得到周期性结构里面两个原子之间的距离变化情况,自己参考https://www.ks.uiuc.edu/Research ... st/vmd-l/27057.html 的脚本运行了一下,但是报错,missing operator at _@_ in expression "...0359296798706 + (6/2) _@_6) - (6/2)"
(parsing expression "pmodulo( -1.3447715044...")invoked from within"expr pmodulo( $x1 - $x2 + ($boxX/2)  $boxX) - ($boxX/2)"
    ("for" body line 26)
初学TCL,不知道怎么解决,麻烦大家帮忙看看:

package require pbctools
pbc set {6 6 8} -all
set outfile [open "test.dat" w]
set nf [molinfo top get numframes]
set ind24 [atomselect top "index 24"]
set ind32 [atomselect top "index 32"]         
set boxX 6
set boxY 6
set boxZ 8

for {set i 0} {$i < $nf} {incr i} {
         $ind24 frame $i
         $ind32 frame $i
         set x1 [$ind24 get {x}]
         set y1 [$ind24 get {y}]
         set z1 [$ind24 get {z}]
         set x2 [$ind32 get {x}]
         set y2 [$ind32 get {y}]
         set z2 [$ind32 get {z}]
         proc pmodulo {n m} {
         return [expr $n - $m * floor(1.0 * $n/$m)]
        }

         set Dx   [expr pmodulo( $x1 - $x2 + ($boxX/2)  $boxX) - ($boxX/2)]
         set Dy   [expr pmodulo( $y1 - $y2 + ($boxY/2) $boxY) - ($boxY/2)]
         set Dz   [expr pmodulo( $z1 - $z2 + ($boxZ/2) $boxZ) - ($boxZ/2)]
         set D    [expr sqrt( ($Dx * $Dx) + ($Dy * $Dy) + ($Dz * $Dz) )]
         puts $outfile "$i \t $D "     
}
close $outfile










欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3