Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ##Read the OUTCAR and print distances between atoms atA and atB
- atA=1
- atB=5
- ########################## routines ###########################
- distance()
- {
- x1=$1 ; y1=$2 ; z1=$3
- x2=$4 ; y2=$5 ; z2=$6
- dist=`echo "scale=6; sqrt( ($x1-$x2)^2+($y1-$y2)^2+($z1-$z2)^2 )" | bc`
- echo $dist
- }
- ###############
- findelem()
- {
- filename=$3
- element=`awk -v i=$1 -v j=$2 'FNR == i {print $j}' $filename`
- echo $element
- }
- ###############################################################
- if [[ -e tempZc.dat ]]; then
- rm tempZc.dat
- fi
- if [[ -e tempZh.dat ]]; then
- rm tempZh.dat
- fi
- if [[ -e tempchdist.dat ]]; then
- rm tempchdist.dat
- fi
- iternum=`cat OUTCAR | grep -c "TOTAL-FORCE"`
- vacref=286.87753
- dist=0
- cat OUTCAR | grep "without entropy=" | awk -v p=$vacref '{print $7*1+p}' > tempener.dat
- for index in `seq 1 $iternum`;
- do
- cat OUTCAR | grep -m$index -A15 "TOTAL-FORCE" | tail -14 > tempcoord.dat
- ptzco=`tail -9 tempcoord.dat | awk '{i=3;{sum[i]+=$i}} END {printf sum[i]/NR "\t"}'`
- xh=`findelem $atA 1 tempcoord.dat`
- yh=`findelem $atA 2 tempcoord.dat`
- zh=`findelem $atA 3 tempcoord.dat`
- xc=`findelem $atB 1 tempcoord.dat`
- yc=`findelem $atB 2 tempcoord.dat`
- zc=`findelem $atB 3 tempcoord.dat`
- chdist=`distance $xh $yh $zh $xc $yc $zc`
- echo $chdist >> tempchdist.dat
- echo "scale=6; $zc-$ptzco " | bc >> tempZc.dat
- echo "scale=6; $zh-$ptzco " | bc >> tempZh.dat
- done
- paste tempener.dat tempZc.dat tempZh.dat tempchdist.dat> values.dat
- nl values.dat > temp.dat
- sed -e 's/\t/ /g' < temp.dat > values.dat
- rm tempchdist.dat
- rm tempcoord.dat
- rm tempener.dat
- rm tempZc.dat
- rm tempZh.dat
- rm temp.dat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement