780dd9395f8c1bf61cced874331da888b331d879
[physik/posic.git] / vasp_tools / outcar2moldyn
1 #!/bin/bash
2
3 rm -rf video
4 mkdir -p video
5
6 sicnt=`grep 'ions per' OUTCAR | awk '{ print $5 }'`
7 ccnt=`grep 'ions per' OUTCAR | awk '{ print $6 }'`
8
9 ((total=sicnt+ccnt))
10
11 echo "parsing OUTCAR file ..."
12 echo "  Si: $sicnt, C: $ccnt, total: $total"
13
14 cnt=0
15 tcnt=0
16
17 cx=1.0
18 cy=1.0
19 cz=0.8
20
21 sed -n -e '/POSITION/,/total/p' OUTCAR | \
22         grep -v POS | grep -v total | grep -v -- ^\ - | \
23         while read x y z fx fy fz; do
24
25         time=`printf "%05d" $tcnt`
26         echo -en "$tcnt/$cnt "
27         [ "$cnt" = "0" ] && \
28                 echo "# P $total $time <$cx,$cy,$cz>" > \
29                         video/atomic_conf_$time.xyz
30
31         type="Si"
32         color="Yellow"
33         force=`echo "sqrt($fx*$fx+$fy*$fy+$fz*$fz)" | bc`
34         if [ $cnt -ge $sicnt ]; then
35                 type="C"
36                 color="Gray"
37         fi
38         echo "$type $x $y $z $color $force" >> \
39                 video/atomic_conf_$time.xyz
40         
41         ((cnt+=1))
42         if [ $cnt -eq $total ]; then
43                 cnt=0
44                 ((tcnt+=1))
45                 echo
46         fi
47 done
48
49 echo
50