Merge branch 'leadoff'
[physik/posic.git] / vasp_tools / e_coh
diff --git a/vasp_tools/e_coh b/vasp_tools/e_coh
new file mode 100755 (executable)
index 0000000..f32283f
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+file=$1
+
+[ -d $1 ] && file=$1/OUTCAR
+
+echo "parsing file $file ..."
+
+sicnt=`grep 'ions per' $file | awk '{ print $5 }'`
+ccnt=`grep 'ions per' $file | awk '{ print $6 }'`
+[ -z $ccnt ] && ccnt=0
+((total=sicnt+ccnt))
+echo "  Si: $sicnt, C: $ccnt, total: $total"
+
+cutoff=`grep ENCUT $file | awk '{ print $3 }' | awk -F. '{ print $1 }'`
+echo "  cutoff: $cutoff eV"
+
+pawpp=`grep POTCAR $file | tail -1 | awk '{ print $2 }'`
+if [ "$pawpp" = "PAW_GGA" ]; then
+       ext=_paw_gga
+       echo "  GGA and PAW"
+fi
+if [ "$pawpp" = "PAW" ]; then
+       ext=_paw
+       echo "  LDA and PAW"
+fi
+if [ "$pawpp" = "US" ]; then
+       help=`grep GGA $file | grep eV | tail -1 | awk '{ print $1i }'`
+       if [ -z $help ]; then
+               ext=_gga
+       echo "  GGA and PP"
+       else
+               ext=""
+       echo "  LDA and PP"
+       fi
+fi
+
+cnt=0
+tcnt=0
+
+energy=`grep energy\ without $file | tail -1 | awk '{ print $8 }'`
+
+sifile=free_atoms/si_free_${cutoff}${ext}/OUTCAR
+cfile=free_atoms/c_free_${cutoff}${ext}/OUTCAR
+
+if [ ! -f $sifile ]; then
+       echo
+       echo "$sifile not found ..."
+       echo
+       exit
+fi
+
+if [ ! -f $cfile ]; then
+       echo
+       echo "$cfile not found ..."
+       echo
+       exit
+fi
+
+free_si=`grep energy\ without $sifile | tail -1 | awk '{ print $8 }'`
+free_c=`grep energy\ without $cfile | tail -1 | awk '{ print $8 }'`
+echo "  Si correction: $free_si eV, C correction: $free_c eV"
+
+#echo "-> $energy | $total | $sicnt | $ccnt | $free_si | $free_c <-"
+echo $energy $total | \
+       awk '{ print "  total e: " $1 " eV, per atom: " $1/$2 " eV"}'
+echo "$energy $sicnt $ccnt $free_si $free_c" | \
+       awk '{ print "  cohesive energy (Si and C): " ($1-$2*$4-$3*$5)/($2+$3) " eV, " $1-$2*$4-$3*$5 " eV" }'
+echo "$energy $sicnt $free_c" | \
+       awk '{ print "  cohesive energy (C only): " ($1-$2*$3)/$2 " eV, " $1-$2*$3 " eV" }'
+#echo "$energy $total $free_si_250" | \
+#      awk '{ print "  cohesive energy (Si only 250): " ($1-$2*$3)/$2 " eV" }'
+#echo "$energy $sicnt $free_c_650" | \
+#      awk '{ print "  cohesive energy (C only 650): " ($1-$2*$3)/($2) " eV" }'
+#echo "$energy $sicnt $ccnt $free_si_650 $free_c_650" | \
+#      awk '{ print "  cohesive energy (Si and C 650): " ($1-$2*$4-$3*$5)/($2+$3) " eV" }'
+#echo "$energy $total" | \
+#      awk '{ print "  Si:C -> cohesive energy: "$1/$2 " eV" }'
+
+echo
+