#!/usr/bin/env bash

#edit these lines as needed
BGW_BIN="$HOME/BerkeleyGW/bin"

# put argument for number of procs here too if needed, e.g. -n 8
MPIRUN="mpirun"
###############################################################################
EPSILON="$BGW_BIN/epsilon.real.x"
SIGMA="$BGW_BIN/sigma.real.x"
EQP="$BGW_BIN/eqp.py"
KERNEL="$BGW_BIN/kernel.real.x"
ABSORPTION="$BGW_BIN/absorption.real.x"
SIG2WAN="$BGW_BIN/sig2wan.x"
WANNIER="$HOME/wannier90-1.2/wannier90.x" # optional
#
cd ./07-epsilon
$MPIRUN $EPSILON &> ./OUT.eps
cd ..
#
cd ./08-sigma
$MPIRUN $SIGMA &> ./OUT.sig
cd ..
#
$EQP eqp1 ./08-sigma/sigma_hp.log ./10-absorption/eqp_co.dat
#
cd ./09-kernel
$MPIRUN $KERNEL &> ./OUT.krn
cd ..
#
cd ./10-absorption
$MPIRUN $ABSORPTION &> ./OUT.abs
cd ..
#
cd ./11-sig2wan
# these steps can be run by hand in serial
$SIG2WAN &> ./OUT.sig2wan
$WANNIER silicon
# The syntax output by Wannier90 1.2 is considered obsolete by Gnuplot.
sed 's/set data style/set style data/' silicon_band.gnu | \
# Let's plot with DFT from ESPRESSO too, including a legend.
sed 's/set nokey//' | \
sed 's|plot "silicon_band.dat"|plot "silicon_band.dat" w l ti "GW", "../ESPRESSO/07-wannier/silicon_band.dat" w l ti "DFT"|' > silicon_bands2.gnu
gnuplot silicon_bands2.gnu
cd ..
#
