Merge branch 'leadoff'
[physik/posic.git] / diff_calc_script
1 #!/bin/sh
2
3 #
4 # calculate diffusion coefficient within a certain time period
5 # frank.zirkelbach@physik.uni-augsburg.de
6 #
7
8 do_it() {
9         echo "$3 `./diffusion_calc $1 | grep coefficients | \
10               awk '{ print $3 " " $4 " " $5 }'`" >> $2
11 }
12
13 if [ -d $1 ]; then
14         rm -f $1/diff_coeff.txt
15         echo "processing $1 ..."
16         for file in $1/*.save; do
17                 time="`basename $file | awk -F- '{ print $2 }' | \
18                        sed 's/\.save//'`"
19                 if [ ! -z "$3" ]; then
20                         [ "$time" -gt "$4" -o "$time" -lt "$3" ] && continue
21                 fi
22                 do_it $file $1/diff_coeff.txt $time
23         done
24 else
25         echo "not a valid directory -> $1"
26         exit
27 fi
28
29 # gnuplot
30
31 ddir=$1
32 dfile=$ddir/diff_coeff.scr
33
34 cat > $dfile <<-EOF
35 set autoscale 
36 unset log 
37 unset label 
38 set xtic auto 
39 set ytic auto 
40 set title 'Diffusion coefficients' 
41 set xlabel 't [fs]' 
42 set ylabel 'D [cm cm / s]'
43 set terminal postscript eps enhanced color solid lw 1 'Helvetica' 14 
44 set output '$ddir/diff_coeff.eps' 
45 EOF
46
47 echo -en "plot " >> $dfile
48
49 komma=0
50
51 if [ ! -z `echo $2 | grep a` ]; then
52         [ "$komma" = "1" ] &&
53                 echo -en ", " >> $dfile
54         echo -en "\"$1/diff_coeff.txt\" u 1:2 w l t \"a\"" >> $dfile
55         komma=1
56 fi
57
58 if [ ! -z `echo $2 | grep b` ]; then
59         [ "$komma" = "1" ] &&
60                 echo -en ", " >> $dfile
61         echo -en "\"$1/diff_coeff.txt\" u 1:3 w l t \"b\"" >> $dfile
62         komma=1
63 fi
64
65 if [ ! -z `echo $2 | grep t` ]; then
66         [ "$komma" = "1" ] &&
67                 echo -en ", " >> $dfile
68         echo -en "\"$1/diff_coeff.txt\" u 1:4 w l t \"t\"" >> $dfile
69 fi
70
71 echo -en "\n" >> $dfile
72
73 gnuplot $dfile
74