From: hackbard Date: Wed, 27 Jan 2010 16:02:11 +0000 (+0100) Subject: added sip and dist calc for vasp results X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b12edd667bd8891f871975590d6fd45e843bd1e0;p=physik%2Fposic.git added sip and dist calc for vasp results --- diff --git a/vasp_tools/disp_calc b/vasp_tools/disp_calc new file mode 100755 index 0000000..253226f --- /dev/null +++ b/vasp_tools/disp_calc @@ -0,0 +1,144 @@ +#!/bin/bash + +file=$1 +init=$2 +atom=$3 + +if [ -n "$4" ]; then +ref=$4 +else +ref=$atom +fi +echo "atom number $ref is used as a reference ..." +echo + +scale=`sed -n 2p $file` + +X1=`sed -n 3p $file | awk '{ print $1 }'` +X2=`sed -n 3p $file | awk '{ print $2 }'` +X3=`sed -n 3p $file | awk '{ print $3 }'` + +Y1=`sed -n 4p $file | awk '{ print $1 }'` +Y2=`sed -n 4p $file | awk '{ print $2 }'` +Y3=`sed -n 4p $file | awk '{ print $3 }'` + +Z1=`sed -n 5p $file | awk '{ print $1 }'` +Z2=`sed -n 5p $file | awk '{ print $2 }'` +Z3=`sed -n 5p $file | awk '{ print $3 }'` + +export X1 X2 X3 +export Y1 Y2 Y3 +export Z1 Z2 Z3 + +((offset=8)) + +echo "final:" +echo "scale: $scale" +echo "X: $X1 $X2 $X3" +echo "Y: $Y1 $Y2 $Y3" +echo "Z: $Z1 $Z2 $Z3" + +((line1=atom+offset)) + +temp="`sed -n ${line1}p $1`" +xa=`echo $temp | awk '{ print $1 }'` +ya=`echo $temp | awk '{ print $2 }'` +za=`echo $temp | awk '{ print $3 }'` +echo "(x,y,z) = $xa $ya $za $scale" + +results=`echo "$xa $ya $za $scale" | \ + awk ' \ + BEGIN { + X1=ENVIRON["X1"]; X2=ENVIRON["X2"]; X3=ENVIRON["X3"] + Y1=ENVIRON["Y1"]; Y2=ENVIRON["Y2"]; Y3=ENVIRON["Y3"] + Z1=ENVIRON["Z1"]; Z2=ENVIRON["Z2"]; Z3=ENVIRON["Z3"] + } + { + X=sqrt(X1^2+X2^2+X3^2) + Y=sqrt(Y1^2+Y2^2+Y3^2) + Z=sqrt(Z1^2+Z2^2+Z3^2) + x=$1*X + if(x>1.0) + x-=1.0; + if(x<-1.0) + x+=1.0; + y=$2*Y + if(y>1.0) + y-=1.0; + if(y<-1.0) + y+=1.0; + z=$3*Z + if(z>1.0) + z-=1.0; + if(z<-1.0) + z+=1.0; + + print x*$4 " " y*$4 " " z*$4 + }'` + +xf=`echo $results | awk '{ print $1 }'` +yf=`echo $results | awk '{ print $2 }'` +zf=`echo $results | awk '{ print $3 }'` +echo "---> $xf $yf $zf" + +file=$init + +scale=`sed -n 2p $file` + +X1=`sed -n 3p $file | awk '{ print $1 }'` +X2=`sed -n 3p $file | awk '{ print $2 }'` +X3=`sed -n 3p $file | awk '{ print $3 }'` + +Y1=`sed -n 4p $file | awk '{ print $1 }'` +Y2=`sed -n 4p $file | awk '{ print $2 }'` +Y3=`sed -n 4p $file | awk '{ print $3 }'` + +Z1=`sed -n 5p $file | awk '{ print $1 }'` +Z2=`sed -n 5p $file | awk '{ print $2 }'` +Z3=`sed -n 5p $file | awk '{ print $3 }'` + +export X1 X2 X3 +export Y1 Y2 Y3 +export Z1 Z2 Z3 + +((offset=8)) + +echo +echo "initial:" +echo "scale: $scale" +echo "X: $X1 $X2 $X3" +echo "Y: $Y1 $Y2 $Y3" +echo "Z: $Z1 $Z2 $Z3" + +((line1=ref+offset)) + +temp="`sed -n ${line1}p $file`" +xa=`echo $temp | awk '{ print $1 }'` +ya=`echo $temp | awk '{ print $2 }'` +za=`echo $temp | awk '{ print $3 }'` +echo "(x,y,z) = $xa $ya $za $scale" + +results=`echo "$xa $ya $za $scale" | \ + awk ' \ + BEGIN { + X1=ENVIRON["X1"]; X2=ENVIRON["X2"]; X3=ENVIRON["X3"] + Y1=ENVIRON["Y1"]; Y2=ENVIRON["Y2"]; Y3=ENVIRON["Y3"] + Z1=ENVIRON["Z1"]; Z2=ENVIRON["Z2"]; Z3=ENVIRON["Z3"] + } + { + X=sqrt(X1^2+X2^2+X3^2)*$4 + Y=sqrt(Y1^2+Y2^2+Y3^2)*$4 + Z=sqrt(Z1^2+Z2^2+Z3^2)*$4 + print $1*X " " $2*Y " " $3*Z + }'` + +xi=`echo $results | awk '{ print $1 }'` +yi=`echo $results | awk '{ print $2 }'` +zi=`echo $results | awk '{ print $3 }'` +echo "---> $xi $yi $zi" + +echo +echo -en "displacement: " +echo $xf $yf $zf $xi $yi $zi | awk '{ print $1-$4 " " $2-$5 " " $3-$6 }' +echo + diff --git a/vasp_tools/dist_calc b/vasp_tools/dist_calc new file mode 100755 index 0000000..b397053 --- /dev/null +++ b/vasp_tools/dist_calc @@ -0,0 +1,88 @@ +#!/bin/bash + +file=$1 +atom=$2 +btom=$3 + +scale=`sed -n 2p $1` + +X1=`sed -n 3p $file | awk '{ print $1 }'` +X2=`sed -n 3p $file | awk '{ print $2 }'` +X3=`sed -n 3p $file | awk '{ print $3 }'` + +Y1=`sed -n 4p $file | awk '{ print $1 }'` +Y2=`sed -n 4p $file | awk '{ print $2 }'` +Y3=`sed -n 4p $file | awk '{ print $3 }'` + +Z1=`sed -n 5p $file | awk '{ print $1 }'` +Z2=`sed -n 5p $file | awk '{ print $2 }'` +Z3=`sed -n 5p $file | awk '{ print $3 }'` + +export X1 X2 X3 +export Y1 Y2 Y3 +export Z1 Z2 Z3 + +((offset=8)) + +echo "scale: $scale" +echo "X: $X1 $X2 $X3" +echo "Y: $Y1 $Y2 $Y3" +echo "Z: $Z1 $Z2 $Z3" +echo + +((line1=atom+offset)) +((line2=btom+offset)) + +temp="`sed -n ${line1}p $1`" +xa=`echo $temp | awk '{ print $1 }'` +ya=`echo $temp | awk '{ print $2 }'` +za=`echo $temp | awk '{ print $3 }'` + +echo "atom 1:" +echo $temp + +temp="`sed -n ${line2}p $1`" +xb=`echo $temp | awk '{ print $1 }'` +yb=`echo $temp | awk '{ print $2 }'` +zb=`echo $temp | awk '{ print $3 }'` + +echo "atom 2:" +echo $temp + +echo -en "distance: " +echo "$xa $ya $za $xb $yb $zb $scale" | \ + awk ' \ + BEGIN { + X1=ENVIRON["X1"]; X2=ENVIRON["X2"]; X3=ENVIRON["X3"] + Y1=ENVIRON["Y1"]; Y2=ENVIRON["Y2"]; Y3=ENVIRON["Y3"] + Z1=ENVIRON["Z1"]; Z2=ENVIRON["Z2"]; Z3=ENVIRON["Z3"] + } + { + X=sqrt(X1^2+X2^2+X3^2) + Y=sqrt(Y1^2+Y2^2+Y3^2) + Z=sqrt(Z1^2+Z2^2+Z3^2) + dx=$1-$4 + dy=$2-$5 + dz=$3-$6 + if(dx>1/2) + dx-=1 + if(dx<-1/2) + dx+=1 + if(dy>1/2) + dy-=1 + if(dy<-1/2) + dy+=1 + if(dz>1/2) + dz-=1 + if(dz<-1/2) + dz+=1 + dxt=dx*X1+dy*Y1+dz*Z1 + dyt=dx*X2+dy*Y2+dz*Z2 + dzt=dx*X3+dy*Y3+dz*Z3 + dist=sqrt(dxt^2+dyt^2+dzt^2) + dist*=$7 + print dist + }' + +echo +