Bash scripts: Difference between revisions
Jump to navigation
Jump to search
(15 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
===generate_inputs_1.sh ( | = Hexagonal-BN tutorial = | ||
===generate_inputs_1.sh (GW ecut_X and nbnd_X convergence input fles) === | |||
#!/bin/bash | #!/bin/bash | ||
# | |||
# NGsBlkXp and BndsRnXp convergence input files | |||
# | |||
bands='10 20 30 40' | bands='10 20 30 40' | ||
blocks='1 2 3 4 5' | blocks='1 2 3 4 5' | ||
for i in ${bands} | # | ||
for i in ${bands} ; do | |||
for j in ${blocks}; do | |||
sed -e "s/1 | 10/1 | $i/g" gw_ppa.in > tmp$i | sed -e "s/1 | 10/1 | $i/g" gw_ppa.in > tmp$i | ||
sed -e "s/NGsBlkXp= 1/ NGsBlkXp= $j/g" tmp$i > gw_ppa_$i'b_'$j'Ry.in' | sed -e "s/NGsBlkXp= 1/ NGsBlkXp= $j/g" tmp$i > gw_ppa_$i'b_'$j'Ry.in' | ||
rm tmp* | rm tmp* | ||
done | |||
done | |||
===parse_qps.sh (parse QP energies)=== | |||
#! /bin/bash | |||
# | |||
# parse QP energies from output files calculated with BndsRnXp bands | |||
# and put them in files ordered by NGsBlkXp | |||
# | |||
label=10b | |||
fileout=10b.dat | |||
# | |||
file_list=`ls o-${label}_* ` | |||
# | |||
echo "# ecut NumG QP1 QP2" > $fileout | |||
for file in $file_list; do | |||
# | |||
ecut=` grep "NGsBlkXp" $file | awk '{print $4}' ` | |||
numG=` grep "used" $file |awk '{print $5}'` | |||
qp1=` cat $file | grep "^ *7 *8" | awk '{print $3+$4}' ` | |||
qp2=` cat $file | grep "^ *7 *9" | awk '{print $3+$4}' ` | |||
# | |||
echo $ecut $numG $qp1 $qp2 >> $fileout | |||
done | |||
===generate_inputs_2.sh (Gbnd convergence input files)=== | ===generate_inputs_2.sh (GW Gbnd convergence input files) === | ||
#!/bin/bash | #!/bin/bash | ||
# | |||
# Gbnd convergence input files | |||
# | |||
bands='10 20 30 40 50 60 70 80' | bands='10 20 30 40 50 60 70 80' | ||
for i in ${bands} | for i in ${bands} | ||
do | |||
sed -e "s/1 | 40/1 | $i/g" gw_ppa_30b_3Ry.in > gw_ppa_Gbnd$i'.in' | |||
done | |||
=== | ===generate_inputs_3.sh (Real axis convergence input files)=== | ||
#!/bin/bash | #!/bin/bash | ||
bands='10 | bands='10 50 100 150 200 250' | ||
for i in ${bands} | for i in ${bands} | ||
do | do | ||
Line 31: | Line 62: | ||
done | done | ||
== Links | = Silicon Tutorial = | ||
=== parse_gap.sh (to parse the gap corrections) === | |||
#!/bin/bash | |||
if [ ! -f GAMMA/References/$1 ] | |||
then | |||
echo "File not found" | |||
exit | |||
fi | |||
rm -f $2 | |||
kpts='GAMMA 2x2x2 4x4x4 6x6x6 8x8x8' | |||
NK=(1 8 64 216 512) | |||
j=0 | |||
for i in ${kpts} | |||
do | |||
VBMo=`grep " 1.000" $i/References/$1 | grep " 4.0000" | grep " 0.000" | awk '{print $3}'` | |||
VBM=`grep " 1.000" $i/References/$1 | grep " 4.0000" | grep " 0.000" | awk '{print $4}'` | |||
CBMo=`grep " 2.576" $i/References/$1 | grep " 5.000" | awk '{print $3}'` | |||
CBM=`grep " 2.576" $i/References/$1 | grep " 5.000" | awk '{print $4}'` | |||
case "$1" in | |||
*-01HF*) | |||
echo ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk '{print $1 " " $5-$3 }' >> "$2" | |||
;; | |||
*-Cohsex*) | |||
echo ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk '{print $1 " " $4+$5 }' >> "$2" | |||
;; | |||
esac | |||
j=`expr $j + 1` | |||
done | |||
= Hydrogen chain tutorial = | |||
=== launch_xcrysden.sh === | |||
#! /bin/sh | |||
# | |||
if [ $# != 1 ] ; then | |||
echo $0 "o- file" | |||
exit 0 | |||
fi | |||
twoD=`echo $1 |grep '2d'` | |||
threeD=`echo $1 |grep '3d'` | |||
if test -n "$twoD" ; then | |||
cp $1 file.xsf | |||
xcrysden -s ../Xcrysden_scripts2D.xcrysden | |||
rm -f file.xsf | |||
fi | |||
if test -n "$threeD" ; then | |||
cp $1 file.xsf | |||
xcrysden -s ../Xcrysden_scripts/3D.xcrysden | |||
rm -f file.xsf | |||
fi | |||
= Links = | |||
* [[Tutorials|Back to tutorials menu]] | * [[Tutorials|Back to tutorials menu]] | ||
Latest revision as of 07:40, 7 April 2021
Hexagonal-BN tutorial
generate_inputs_1.sh (GW ecut_X and nbnd_X convergence input fles)
#!/bin/bash # # NGsBlkXp and BndsRnXp convergence input files # bands='10 20 30 40' blocks='1 2 3 4 5' # for i in ${bands} ; do for j in ${blocks}; do sed -e "s/1 | 10/1 | $i/g" gw_ppa.in > tmp$i sed -e "s/NGsBlkXp= 1/ NGsBlkXp= $j/g" tmp$i > gw_ppa_$i'b_'$j'Ry.in' rm tmp* done done
parse_qps.sh (parse QP energies)
#! /bin/bash # # parse QP energies from output files calculated with BndsRnXp bands # and put them in files ordered by NGsBlkXp # label=10b fileout=10b.dat # file_list=`ls o-${label}_* ` # echo "# ecut NumG QP1 QP2" > $fileout for file in $file_list; do # ecut=` grep "NGsBlkXp" $file | awk '{print $4}' ` numG=` grep "used" $file |awk '{print $5}'` qp1=` cat $file | grep "^ *7 *8" | awk '{print $3+$4}' ` qp2=` cat $file | grep "^ *7 *9" | awk '{print $3+$4}' ` # echo $ecut $numG $qp1 $qp2 >> $fileout done
generate_inputs_2.sh (GW Gbnd convergence input files)
#!/bin/bash # # Gbnd convergence input files # bands='10 20 30 40 50 60 70 80' for i in ${bands} do sed -e "s/1 | 40/1 | $i/g" gw_ppa_30b_3Ry.in > gw_ppa_Gbnd$i'.in' done
generate_inputs_3.sh (Real axis convergence input files)
#!/bin/bash bands='10 50 100 150 200 250' for i in ${bands} do sed -e "s/ETStpsXd= 100/ETStpsXd=$i/g" gw_ff.in > gw_ff$i'.in' done
Silicon Tutorial
parse_gap.sh (to parse the gap corrections)
#!/bin/bash if [ ! -f GAMMA/References/$1 ] then echo "File not found" exit fi rm -f $2 kpts='GAMMA 2x2x2 4x4x4 6x6x6 8x8x8' NK=(1 8 64 216 512) j=0 for i in ${kpts} do VBMo=`grep " 1.000" $i/References/$1 | grep " 4.0000" | grep " 0.000" | awk '{print $3}'` VBM=`grep " 1.000" $i/References/$1 | grep " 4.0000" | grep " 0.000" | awk '{print $4}'` CBMo=`grep " 2.576" $i/References/$1 | grep " 5.000" | awk '{print $3}'` CBM=`grep " 2.576" $i/References/$1 | grep " 5.000" | awk '{print $4}'` case "$1" in *-01HF*) echo ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk '{print $1 " " $5-$3 }' >> "$2" ;; *-Cohsex*) echo ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk '{print $1 " " $4+$5 }' >> "$2" ;; esac j=`expr $j + 1` done
Hydrogen chain tutorial
launch_xcrysden.sh
#! /bin/sh # if [ $# != 1 ] ; then echo $0 "o- file" exit 0 fi twoD=`echo $1 |grep '2d'` threeD=`echo $1 |grep '3d'` if test -n "$twoD" ; then cp $1 file.xsf xcrysden -s ../Xcrysden_scripts2D.xcrysden rm -f file.xsf fi if test -n "$threeD" ; then cp $1 file.xsf xcrysden -s ../Xcrysden_scripts/3D.xcrysden rm -f file.xsf fi