total energies printed out too
[physik/posic.git] / vasp_tools / e_coh
1 #!/bin/bash
2
3 file=$1
4
5 [ -d $1 ] && file=$1/OUTCAR
6
7 echo "parsing file $file ..."
8
9 sicnt=`grep 'ions per' $file | awk '{ print $5 }'`
10 ccnt=`grep 'ions per' $file | awk '{ print $6 }'`
11 [ -z $ccnt ] && ccnt=0
12 ((total=sicnt+ccnt))
13 echo "  Si: $sicnt, C: $ccnt, total: $total"
14
15 cutoff=`grep ENCUT $file | awk '{ print $3 }' | awk -F. '{ print $1 }'`
16 echo "  cutoff: $cutoff eV"
17
18 pawpp=`grep POTCAR $file | tail -1 | awk '{ print $2 }'`
19 if [ "$pawpp" = "PAW_GGA" ]; then
20         ext=_paw_gga
21         echo "  GGA and PAW"
22 fi
23 if [ "$pawpp" = "PAW" ]; then
24         ext=_paw
25         echo "  LDA and PAW"
26 fi
27 if [ "$pawpp" = "US" ]; then
28         help=`grep GGA $file | grep eV | tail -1 | awk '{ print $1i }'`
29         if [ -z $help ]; then
30                 ext=_gga
31         echo "  GGA and PP"
32         else
33                 ext=""
34         echo "  LDA and PP"
35         fi
36 fi
37
38 cnt=0
39 tcnt=0
40
41 energy=`grep energy\ without $file | tail -1 | awk '{ print $8 }'`
42
43 sifile=free_atoms/si_free_${cutoff}${ext}/OUTCAR
44 cfile=free_atoms/c_free_${cutoff}${ext}/OUTCAR
45
46 if [ ! -f $sifile ]; then
47         echo
48         echo "$sifile not found ..."
49         echo
50         exit
51 fi
52
53 if [ ! -f $cfile ]; then
54         echo
55         echo "$cfile not found ..."
56         echo
57         exit
58 fi
59
60 free_si=`grep energy\ without $sifile | tail -1 | awk '{ print $8 }'`
61 free_c=`grep energy\ without $cfile | tail -1 | awk '{ print $8 }'`
62 echo "  Si correction: $free_si eV, C correction: $free_c eV"
63
64
65 echo $energy $total | \
66         awk '{ print "  total e: " $1 " eV, per atom: " $1/$2 " eV"}'
67 echo "$energy $sicnt $ccnt $free_si $free_c" | \
68         awk '{ print "  cohesive energy (Si and C): " ($1-$2*$4-$3*$5)/($2+$3) " eV, " $1-$2*$4-$3*$5 " eV" }'
69 echo "$energy $sicnt $free_c" | \
70         awk '{ print "  cohesive energy (C only): " ($1-$2*$3)/$2 " eV, " $1-$2*$3 " eV" }'
71 #echo "$energy $total $free_si_250" | \
72 #       awk '{ print "  cohesive energy (Si only 250): " ($1-$2*$3)/$2 " eV" }'
73 #echo "$energy $sicnt $free_c_650" | \
74 #       awk '{ print "  cohesive energy (C only 650): " ($1-$2*$3)/($2) " eV" }'
75 #echo "$energy $sicnt $ccnt $free_si_650 $free_c_650" | \
76 #       awk '{ print "  cohesive energy (Si and C 650): " ($1-$2*$4-$3*$5)/($2+$3) " eV" }'
77 #echo "$energy $total" | \
78 #       awk '{ print "  Si:C -> cohesive energy: "$1/$2 " eV" }'
79
80 echo
81