本人目前想通过tcl脚本来计算结冰的速率,在群中咨询了之后,编写了一个通过O-O键来判断当前水分子是属于冰晶分子还是自由水分子的脚本,但是在加载到VMD之后出现了报错,以下是tcl脚本的具体内容,由于之前没有编写过tcl脚本还请大家指出错误,我自己的想法是:通过判断O-O之间的距离是否在2.5A内,在这个范围内则为水分子,不在则是冰晶分子,因为查到的1h冰晶的O-O键长为2.7A,最终获得自由水分子个数,模型中用的tip4p水分子。
set outfile [open growthrate.dat w]
set oxygen_sel [atomselect top "name OW"]
#在某一帧上进行循环
set nf [molinfo top get numframes]
proc analyze_frame {} {
global oxygen_sel outfile
set num_oxygen_atoms [$oxygen_sel num]
set frame_sum 0
for {set i 0} {$i < $num_oxygen_atoms} {incr i 1} {
set atom1 [$oxygen_sel get $i]
set neighbors [$oxygen_sel within 2.5 of $atom1]
set num_neighbors [llength $neighbors]
if {$num_neighbors > 1} {
incr frame_sum
}
}
puts $outfile $frame_sum
}
#在每一帧上进行循环
animate goto 0
for {set i 0} {$i < $nf } {incr i} {
animate goto $i
analyze_frame
}
#关闭文件
close $outfile
puts "All Done!"