#!/usr/bin/env bash

#
PW="$HOME/espresso-5.0/bin/pw.x"
PP="$HOME/espresso-5.0/bin/pp.x"
SURFACE="$HOME/BerkeleyGW/bin/surface.x"
AVERAGE="$HOME/BerkeleyGW/Visual/average.py"
PW2BGW="$HOME/espresso-5.0/bin/pw2bgw.x"

# put argument for number of procs here too if needed, e.g. -n 8
MPIRUN="mpirun"
#
cd ./1-scf
$MPIRUN $PW -in ./in &> ./out
$MPIRUN $PP -in ./in_pp1 &> ./out_pp1
$MPIRUN $PP -in ./in_pp2 &> ./out_pp2
$MPIRUN $PP -in ./in_pp3 &> ./out_pp3
$SURFACE ./surface.par &> ./surface.out
$AVERAGE ./velec.cube cube faces 0.5 0.5 0.5 &> ./velec_avg_face.out
$AVERAGE ./vtot.cube cube volume &> ./vtot_avg_vol.out
rm ./*.wfc*
cd ..
#
cd ./2-nscf
$MPIRUN $PW -in ./in &> ./out
$MPIRUN $PW2BGW -in ./in_pw2bgw &> ./out_pw2bgw
rm ./*.wfc*
cd ..
#
