tool to build crude interface for vasp
[physik/posic.git] / vasp_tools / create_intf_crude
1 #!/bin/bash
2
3 si_file=$1
4 sic_file=$2
5
6 cnt_si_si=`sed -n 6p $si_file`
7 cnt_si_sic=`sed -n 6p $sic_file | awk '{ print $1 }'`
8 cnt_c_sic=`sed -n 6p $sic_file | awk '{ print $2 }'`
9
10 lc_si=`sed -n 2p $si_file`
11
12 x_si=`sed -n 3p $si_file | awk '{ print $1 }'`
13 x_sic=`sed -n 3p $sic_file | awk '{ print $1 }'`
14
15 h_si=`sed -n 5p $si_file | awk '{ print $3 }'`
16 h_sic=`sed -n 5p $sic_file | awk '{ print $3 }'`
17 h_sic=`echo $h_sic $x_si $x_sic | awk '{ print $1*$2/$3 }'`
18
19 ((tot_si=cnt_si_si+cnt_si_sic))
20
21 h_tot=`echo $h_si + $h_sic | bc`
22
23 ((offset=8))
24
25 # header:
26 sed -n 1,4p $si_file
27 echo " 0.00000 0.00000 $h_tot"
28 echo " $tot_si $cnt_c_sic"
29 sed -n 7,8p $si_file
30
31 # silicon atoms of si lattice (bottom)
32 ((cnt=1))
33 while [ $cnt -le $cnt_si_si ]; do
34         ((gl=cnt+offset))
35         line=`sed -n ${gl}p $si_file`
36         x=`echo $line | awk '{ print $1 }'`
37         y=`echo $line | awk '{ print $2 }'`
38         z=`echo $line | awk '{ print $3 }'`
39         nz=`echo $z $h_tot $h_si | awk '{ print $1*$3/$2 }'`
40         echo " $x $y $nz T T T"
41         ((cnt+=1))
42 done
43
44 # silicon atoms of sic lattice (top / 2nd fcc)
45 ((cnt=1))
46 while [ $cnt -le $cnt_si_sic ]; do
47         ((gl=cnt+offset+cnt_c_sic))
48         line=`sed -n ${gl}p $sic_file`
49         x=`echo $line | awk '{ print $1 }'`
50         y=`echo $line | awk '{ print $2 }'`
51         z=`echo $line | awk '{ print $3 }'`
52         nz=`echo $z $h_tot $h_si $h_sic | awk '{ print $1*$4/$2 + $3/$2 }'`
53         echo " $x $y $nz T T T"
54         ((cnt+=1))
55 done
56
57 # carbon atoms of sic lattice (top / 1st fcc <- odd counts)
58 ((cnt=1))
59 while [ $cnt -le $cnt_c_sic ]; do
60         ((gl=cnt+offset))
61         line=`sed -n ${gl}p $sic_file`
62         x=`echo $line | awk '{ print $1 }'`
63         y=`echo $line | awk '{ print $2 }'`
64         z=`echo $line | awk '{ print $3 }'`
65         nz=`echo $z $h_tot $h_si $h_sic | awk '{ print $1*$4/$2 + $3/$2 }'`
66         echo " $x $y $nz T T T"
67         ((cnt+=1))
68 done
69