7c9e490b9ea26e3202ee0a56c45291246a5a3d67
[physik/posic.git] / vasp_tools / e_form
1 #!/bin/bash
2
3
4 if [ $# = 2 ]; then
5
6 echo "Calculation of formation energy (Method 1, single species)"
7 echo "  Result: `basename $2`, Initial conf: `basename $1`"
8 echo
9
10 e1only=`./e_coh $1 | grep cohesive | grep only | awk '{ print $5 }'`
11 e2only=`./e_coh $2 | grep cohesive | grep only | awk '{ print $5 }'`
12 e1and=`./e_coh $1 | grep cohesive | grep and | awk '{ print $6 }'`
13 e2and=`./e_coh $2 | grep cohesive | grep and | awk '{ print $6 }'`
14 count=`./e_coh $2 | grep ^\ \ Si: | awk '{ print $6 }'`
15
16 echo "$e1only $e2only $count" | \
17         awk '{ print "  formation energy M1 (Si and C): "($2-$1)*$3 " eV" }'
18 echo "$e1and $e2and $count" | \
19         awk '{ print "  formation energy M1 (C only): "($2-$1)*$3 " eV" }'
20 echo
21
22 fi
23
24 if [ $# = 3 ]; then
25
26 echo "Calculation of formation energy (Method 2, two species)"
27
28 e3=`./e_coh $3 | grep cohesive | grep and | awk '{ print $6 }'`
29 sicnt=`./e_coh $3 | grep ^\ \ Si: | awk '{ print $2 }' | sed 's/,//'`
30 ccnt=`./e_coh $3 | grep ^\ \ Si: | awk '{ print $4 }' | sed 's/,//'`
31 et=`echo $e3 $sicnt $ccnt | awk '{ print $1*($2+$3) }'`
32 echo "  Interstitial configuration: `basename $3` -> $et"
33 e1=`./e_coh $1 | grep cohesive | grep and | awk '{ print $6 }'`
34 e2=`./e_coh $2 | grep cohesive | grep only | awk '{ print $5 }'`
35 echo "  Cohesive energies:"
36 echo "    `basename $1` -> $e1 ($sicnt)"
37 echo "    `basename $2` -> $e2 ($ccnt)"
38
39 ((count = sicnt + ccnt))
40
41 echo "$et $sicnt $e1 $ccnt $e2" | \
42         awk '{ print "  formation energy M2: "$1-$2*$3-$4*$5 " eV" }'
43 echo
44
45 fi
46