Advertisement
karamaz0v

script to monitor VASP run

Apr 3rd, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.67 KB | None | 0 0
  1. #!/bin/bash
  2. ##Read the OUTCAR and print distances between atoms atA and atB
  3. atA=1
  4. atB=5
  5.  
  6.  
  7. ########################## routines ###########################
  8. distance()
  9. {
  10.  x1=$1 ; y1=$2 ; z1=$3
  11.  x2=$4 ; y2=$5 ; z2=$6
  12.  
  13.  dist=`echo "scale=6; sqrt( ($x1-$x2)^2+($y1-$y2)^2+($z1-$z2)^2 )" | bc`
  14.  echo $dist
  15. }
  16. ###############
  17. findelem()
  18. {
  19.  filename=$3
  20.  element=`awk -v i=$1 -v j=$2 'FNR == i {print $j}' $filename`
  21.  echo $element
  22. }
  23. ###############################################################
  24.  
  25. if [[ -e tempZc.dat ]]; then
  26.  rm tempZc.dat
  27. fi
  28. if [[ -e tempZh.dat ]]; then
  29.  rm tempZh.dat
  30. fi
  31. if [[ -e tempchdist.dat ]]; then
  32.  rm tempchdist.dat
  33. fi
  34.  
  35. iternum=`cat OUTCAR | grep -c "TOTAL-FORCE"`
  36. vacref=286.87753
  37.  
  38. dist=0
  39.  
  40. cat OUTCAR | grep "without entropy=" | awk -v p=$vacref '{print $7*1+p}' > tempener.dat
  41.  
  42.  
  43. for index in `seq 1 $iternum`;
  44. do
  45.   cat OUTCAR | grep -m$index -A15 "TOTAL-FORCE" | tail -14 > tempcoord.dat
  46.   ptzco=`tail -9 tempcoord.dat | awk '{i=3;{sum[i]+=$i}} END {printf sum[i]/NR "\t"}'`
  47.  
  48.   xh=`findelem $atA 1 tempcoord.dat`
  49.   yh=`findelem $atA 2 tempcoord.dat`
  50.   zh=`findelem $atA 3 tempcoord.dat`
  51.  
  52.   xc=`findelem $atB 1 tempcoord.dat`
  53.   yc=`findelem $atB 2 tempcoord.dat`
  54.   zc=`findelem $atB 3 tempcoord.dat`
  55.  
  56.   chdist=`distance $xh $yh $zh $xc $yc $zc`
  57.   echo $chdist >> tempchdist.dat
  58.   echo "scale=6; $zc-$ptzco " | bc  >> tempZc.dat
  59.   echo "scale=6; $zh-$ptzco " | bc  >> tempZh.dat
  60. done
  61.  
  62. paste tempener.dat tempZc.dat tempZh.dat tempchdist.dat> values.dat
  63. nl values.dat > temp.dat
  64. sed -e 's/\t/      /g' < temp.dat > values.dat
  65.  
  66.  
  67. rm tempchdist.dat
  68. rm tempcoord.dat
  69. rm tempener.dat
  70. rm tempZc.dat
  71. rm tempZh.dat
  72. rm temp.dat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement