-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathharm_vs_init.sh
executable file
·51 lines (38 loc) · 1.18 KB
/
harm_vs_init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
echo "Usage: harm_vs_init.sh startstep endstep natoms"
nsteps=$(tac output | grep F= -m1 | awk '{print $1}')
echo "Found $nsteps usable steps."
step0=500
natoms=64
thisdiff=0
diff=0
if [ $1 ] ; then
step0=$1
fi
if [ $3 ] ; then
natoms=$3
fi
if [ $2 ] ; then
if [ $2 -lt $nsteps ] ; then
nsteps=$2
else
echo "Simulation too short for given endstep. Using maximum value of $nsteps."
fi
fi
echo "Endstep: $nsteps, Step0: $step0, nAtoms: $natoms"
grep -e initio -e F= output > tmpout
cat tmpout | head -n $((2*nsteps+2)) > tmpout2
cat tmpout2| tail -n $((2*(nsteps-step0)+10)) > tmpout
for i in $(seq -f '%5.f' $step0 1 $nsteps) ; do
line=$(grep " $i T=" -B1 tmpout | head -n1 )
harm=$(echo $line | awk '{print $4}')
init=$(echo $line | awk '{print $2}')
thisdiff=$(echo "(($init)-($harm))" | sed s/[eE]+*/*10^/ | sed s/[eE]+*/*10^/ | bc)
#echo "(($init)-($harm))" | sed s/[eE]+*/*10^/ | sed s/[eE]+*/*10^/
diff=$(echo $diff+$thisdiff | bc)
echo "$thisdiff $harm $init" >> ener_diff_harm_init.txt
#echo $i $diff $init $harm
done
totaldiff=$(echo "$diff/($nsteps-$step0)/$natoms" | bc -l)
echo "Final average difference is $totaldiff eV"
rm tmpout tmpout2