From: hackbard Date: Mon, 5 Oct 2009 12:18:30 +0000 (+0200) Subject: added search bonds file ... X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=0723b4e314a1885b68865086788f6d89fb2b7f13;p=physik%2Fposic.git added search bonds file ... --- diff --git a/vasp_tools/search_bonds b/vasp_tools/search_bonds new file mode 100755 index 0000000..9b08543 --- /dev/null +++ b/vasp_tools/search_bonds @@ -0,0 +1,123 @@ +#!/bin/bash + +file=$1 +len=$2 +delta=$3 +tA=$4 +tB=$5 + +echo +echo "usage:" +echo "$0 " +echo +echo "args: $@" +echo + +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 + +nsi=`sed -n 6p $file | awk '{ print $1 }'` +nc=`sed -n 6p $file | awk '{ print $2 }'` + +((nt=nsi+nc)) + +((offset=8)) +((count=1)) + +echo "found $nt atoms: Si = $nsi / C = $nc" + +while [ "1" ]; do + + if [ $count -le $nsi ]; then + typea=S + else + typea=C + fi + + if [ "$tA" != "$typea" ]; then + ((count+=1)) + [ $count -gt $nt ] && break + continue + fi + + ((line=count+offset)) + + temp="`sed -n ${line}p $1`" + xa=`echo $temp | awk '{ print $1 }'` + ya=`echo $temp | awk '{ print $2 }'` + za=`echo $temp | awk '{ print $3 }'` + + ((ic=1)) + while [ "1" ]; do + ((il=ic+offset)) + if [ $line != $il ]; then + if [ $ic -le $nsi ] ; then + typeb=S + else + typeb=C + fi + if [ "$typeb" != "$tB" ]; then + ((ic+=1)) + [ $ic -gt $nt ] && break + continue + fi + tmpb="`sed -n ${il}p $1`" + xb=`echo $tmpb | awk '{ print $1 }'` + yb=`echo $tmpb | awk '{ print $2 }'` + zb=`echo $tmpb | awk '{ print $3 }'` + + echo "$xa $ya $za $xa $yb $zb $scale $len $delta" | \ + awk ' \ + BEGIN { + xa=0; xb=0; + dx=0; dy=0; dz=0; dist=0 + 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"] + } + { + xa=$1*X1+$2*Y1+$3*Z1 + ya=$1*X2+$2*Y2+$3*Z2 + za=$1*X3+$2*Y3+$3*Z3 + xb=$4*X1+$5*Y1+$6*Z1 + yb=$4*X2+$5*Y2+$6*Z2 + zb=$4*X3+$5*Y3+$6*Z3 + dx=xa-xb + dy=ya-yb + dz=za-zb + dist=sqrt(dx^2+dy^2+dz^2) + dist*=$7 + if((dist>=($8-$9))&&(dist<=($8+$9))) { + print $1 " " $2 " " $3 + print $4 " " $5 " " $6 " (" dist ")" + } + }' + fi + + ((ic+=1)) + [ $ic -gt $nt ] && break + + done + + ((count+=1)) + [ $count -gt $nt ] && break + +done + +echo "done" +