Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This shell script plots electron density of states from ORCA output file into txt data usable for plotting. It should work for any single-point calculation, but do not try using it for geometry jobs (i.e. where orbital energies are printed more than once)
- #There are no comments in code because I'm a bit lazy to write them, sorry :-)
- # (c) 2013 Evgeny Tikhonov; mail: lumbrius at gmail dot com
- Nel=`grep "Number of Electrons" $1 | awk '{print $6}'`
- IsOdd=`echo ${Nel}%2 | bc`
- if [ $IsOdd == 1 ];
- then
- Norb=`grep "Number of basis functions" $1 | awk '{print $6}'`
- Norb0=`echo ${Norb}-1 | bc`
- Norb0_2=`echo ${Norb0}+2 | bc`
- echo "function gauss(a,b,c,x){" > gauss_uks_o.awk
- echo " return a*exp(-(x-b)**2/(2*c))/sqrt(3.1415926535897932*2*c)" >> gauss_uks_o.awk
- echo "}" >> gauss_uks_o.awk
- echo "{" >> gauss_uks_o.awk
- echo " for (i=x0;i<=x1;i+=0.01)" >> gauss_uks_o.awk
- echo " print i\" \"gauss(\$1,\$2,w,i)" >> gauss_uks_o.awk
- echo "}" >> gauss_uks_o.awk
- echo "Give me threshold for electron energy in valence orbitals region [eV] (usually about -30eV is more than enough) and press [ENTER]:"
- read Emin
- grep -A${Norb0_2} "SPIN UP ORBITALS" $1 | tail -n${Norb} | awk -v nl=${Emin} '{if (($4 >= nl) && ($2 > 0) ) print $2" "$4}' > ./$1_list_a.tmp
- grep -A${Norb0_2} "SPIN DOWN ORBITALS" $1 | tail -n${Norb} | awk -v nl=${Emin} '{if (($4 >= nl) && ($2 > 0) ) print $2" "$4}' > ./$1_list_b.tmp
- echo "Give me gaussian broadening [eV] and press [ENTER]:"
- read Width
- X0=`echo \(${Emin}-$Width*5\)/1-1 | bc`
- X1=`tail -n1 ./$1_list_a.tmp | awk '{print $2}'`
- X2=`tail -n1 ./$1_list_b.tmp | awk '{print $2}'`
- [[ `echo ${X1}\>${X2}| bc` == 1 ]] && X1=$X1 || X1=$X2
- X1=`echo ${X1}/1+1 | bc`
- echo Occupied region start point X0=$X0
- echo Occupied region end point X1=$X1
- awk -f gauss_uks_o.awk -v w=${Width} x0=${X0} x1=${X1} ./$1_list_a.tmp > ./$1_unsorted_a.tmp 2>/dev/null
- awk -f gauss_uks_o.awk -v w=${Width} x0=${X0} x1=${X1} ./$1_list_b.tmp > ./$1_unsorted_b.tmp 2>/dev/null
- awk '{a[$1]+=$2}; END{for (i in a) print i" "a[i]}' ./$1_unsorted_a.tmp | LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 sort -g > ./$1.occ_a.txt
- awk '{a[$1]+=$2}; END{for (i in a) print i" "a[i]}' ./$1_unsorted_b.tmp | LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 sort -g > ./$1.occ_b.txt
- echo "Results for occupied states (spin up) should be in file $1.occ_a.txt"
- echo "Results for occupied states (spin down) should be in file $1.occ_b.txt"
- join ./$1.occ_a.txt ./$1.occ_b.txt | awk '{print $1" "$2+$3}' > ./$1.occ.txt
- echo "Results for occupied states (both spin channels) should be in file $1.occ.txt"
- echo "Give me threshhold for electron energy in free orbitals region [eV] (usually about 5eV is more than enough) and press [ENTER]:"
- read Emax
- grep -A${Norb0_2} "SPIN UP ORBITALS" $1 | tail -n${Norb} | awk -v nl=${Emax} '{if (($4 <= nl) && ( $2 < 1)) print $2" "$4}' > ./$1_list_a.tmp
- grep -A${Norb0_2} "SPIN DOWN ORBITALS" $1 | tail -n${Norb} | awk -v nl=${Emax} '{if (($4 <= nl) && ( $2 < 1)) print $2" "$4}' > ./$1_list_b.tmp
- cp gauss_uks_o.awk gauss_uks_f.awk
- sed -i 's/\$1/1/g' gauss_uks_f.awk
- X0=`head -n1 ./$1_list_a.tmp | awk '{print $2}'`
- X2=`head -n1 ./$1_list_b.tmp | awk '{print $2}'`
- [[ `echo ${X0}\<${X2}| bc` == 1 ]] && X0=$X0 || X0=$X2
- X0=`echo ${X0}/1-2 | bc`
- X1=`echo ${Emax}/1+1 | bc`
- echo Free region start point X0=$X0
- echo Free region end point X1=$X1
- awk -f gauss_uks_f.awk -v w=${Width} x0=${X0} x1=${X1} ./$1_list_a.tmp > ./$1_unsorted_a.tmp 2>/dev/null
- awk -f gauss_uks_f.awk -v w=${Width} x0=${X0} x1=${X1} ./$1_list_b.tmp > ./$1_unsorted_b.tmp 2>/dev/null
- awk '{a[$1]+=$2}; END{for (i in a) print i" "a[i]}' ./$1_unsorted_a.tmp | LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 sort -g > ./$1.free_a.txt
- awk '{a[$1]+=$2}; END{for (i in a) print i" "a[i]}' ./$1_unsorted_b.tmp | LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 sort -g > ./$1.free_b.txt
- echo "Results for occupied states (spin up) should be in file $1.free_a.txt"
- echo "Results for occupied states (spin down) should be in file $1.free_b.txt"
- join ./$1.free_a.txt ./$1.free_b.txt | awk '{print $1" "$2+$3}' > ./$1.free.txt
- echo "Results for occupied states should be in file $1.free.txt"
- rm ./$1_list_a.tmp
- rm ./$1_list_b.tmp
- rm ./$1_unsorted_a.tmp
- rm ./$1_unsorted_b.tmp
- else
- echo Even number of electrons found, going restricted Kohm-Sham mode
- Norb=`grep "Number of basis functions" $1 | awk '{print $6}'`
- Norb0=`echo ${Norb}-1 | bc`
- Norb0_4=`echo ${Norb0}+4 | bc`
- echo "function gauss(a,b,c,x){" > gauss_rks_o.awk
- echo " return a*exp(-(x-b)**2/(2*c))/sqrt(3.1415926535897932*2*c)" >> gauss_rks_o.awk
- echo "}" >> gauss_rks_o.awk
- echo "{" >> gauss_rks_o.awk
- echo " for (i=x0;i<=x1;i+=0.01)" >> gauss_rks_o.awk
- echo " print i\" \"gauss(\$1,\$2,w,i)" >> gauss_rks_o.awk
- echo "}" >> gauss_rks_o.awk
- echo "Give me threshold for electron energy in valence orbitals region [eV] (usually about -30eV is more than enough) and press [ENTER]:"
- read Emin
- grep -A${Norb0_4} "ORBITAL ENERGIES" $1 | tail -n${Norb} | awk -v nl=${Emin} '{if (($4 >= nl) && ($2 > 0) ) print $2" "$4}' > ./$1_list.tmp
- echo "Give me gaussian broadening [eV] and press [ENTER]:"
- read Width
- X0=`echo \(${Emin}-$Width*5\)/1-1 | bc`
- X1=`tail -n1 ./$1_list.tmp | awk '{print $2}'`
- X1=`echo ${X1}/1+1 | bc`
- echo Occupied region start point X0=$X0
- echo Occupied region end point X1=$X1
- awk -f gauss_rks_o.awk -v w=${Width} x0=${X0} x1=${X1} ./$1_list.tmp > ./$1_unsorted.tmp 2>/dev/null
- awk '{a[$1]+=$2}; END{for (i in a) print i" "a[i]}' ./$1_unsorted.tmp | LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 sort -g > ./$1.occ.txt
- echo "Results for occupied states should be in file $1.occ.txt"
- echo "Give me threshhold for electron energy in free orbitals region [eV] (usually about 5eV is more than enough) and press [ENTER]:"
- read Emax
- grep -A${Norb0_4} "ORBITAL ENERGIES" $1 | tail -n${Norb} | awk -v nl=${Emax} '{if (($4 <= nl) && ( $2 < 1)) print $2" "$4}' > ./$1_list.tmp
- cp gauss_rks_o.awk gauss_rks_f.awk
- sed -i 's/\$1/2/g' gauss_rks_f.awk
- X0=`head -n1 ./$1_list.tmp | awk '{print $2}'`
- X0=`echo ${X0}/1-2 | bc`
- X1=`echo ${Emax}/1+1 | bc`
- echo Free region start point X0=$X0
- echo Free region end point X1=$X1
- awk -f gauss_rks_f.awk -v w=${Width} x0=${X0} x1=${X1} ./$1_list.tmp > ./$1_unsorted.tmp 2>/dev/null
- awk '{a[$1]+=$2}; END{for (i in a) print i" "a[i]}' ./$1_unsorted.tmp | LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 sort -g > ./$1.free.txt
- echo "Results for occupied states should be in file $1.free.txt"
- rm ./$1_list.tmp
- rm ./$1_unsorted.tmp
- fi
Advertisement
Add Comment
Please, Sign In to add comment