From: hackbard Date: Tue, 23 Mar 2010 16:31:15 +0000 (+0100) Subject: added avg disp calc tool (dirty) X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=00f8603554b2ad3546d916bcc816e4a2e4441f9d;p=physik%2Fposic.git added avg disp calc tool (dirty) --- diff --git a/vasp_tools/avg_disp b/vasp_tools/avg_disp new file mode 100755 index 0000000..bd0a3d2 --- /dev/null +++ b/vasp_tools/avg_disp @@ -0,0 +1,99 @@ +#!/bin/bash + +file=$1 +init=$2 + +sicnt=`sed -n 6p $file | awk '{ print $1 }'` +ccnt=`sed -n 6p $file | awk '{ print $2 }'` +((cnt=sicnt+ccnt)) + +((offset=8)) + +((count=1)) + +x=0 +y=0 +z=0 + +while [ $count -le $cnt ]; do + + ((ln=count+offset)) + + temp="`sed -n ${ln}p $file`" + xa=`echo $temp | awk '{ print $1 }'` + ya=`echo $temp | awk '{ print $2 }'` + za=`echo $temp | awk '{ print $3 }'` + + temp="`sed -n ${ln}p $init`" + xi=`echo $temp | awk '{ print $1 }'` + yi=`echo $temp | awk '{ print $2 }'` + zi=`echo $temp | awk '{ print $3 }'` + + results=`echo $xa $ya $za $xi $yi $zi | awk '{ + xa=$1 + if($1<0.0) + xa=$1+1.0 + if($1>1.0) + xa=$1-1.0 + ya=$2 + if($2<0.0) + ya=$2+1.0 + if($2>1.0) + ya=$2-1.0 + za=$3 + if($3<0.0) + za=$3+1.0 + if($3>1.0) + za=$3-1.0 + + xi=$4 + if($4<0.0) + xi=$4+1.0 + if($4>1.0) + xi=$4-1.0 + yi=$5 + if($5<0.0) + yi=$5+1.0 + if($5>1.0) + yi=$5-1.0 + zi=$6 + if($6<0.0) + zi=$6+1.0 + if($6>1.0) + zi=$6-1.0 + + dx=xa-xi + dy=ya-yi + dz=za-zi + + if(dx>0.5) + dx-=1 + else if(dx<-0.5) + dx+=1 + if(dy>0.5) + dy-=1 + else if(dy<-0.5) + dy+=1 + if(dz>0.5) + dz-=1 + else if(dz<-0.5) + dz+=1 + + print dx " " dy " " dz + }'` + + dx=`echo $results | awk '{ print $1 }'` + dy=`echo $results | awk '{ print $2 }'` + dz=`echo $results | awk '{ print $3 }'` + + x=`echo $x $dx | awk '{ print $1+$2 }'` + y=`echo $y $dy | awk '{ print $1+$2 }'` + z=`echo $z $dz | awk '{ print $1+$2 }'` + + ((count+=1)) + +done + +((count-=1)) +echo $x $y $z $count | awk '{ print $1/($4*3) " " $2/($4*3) " " $3/($4*3) }' +