#!/bin/bash
#
# source functions
#
# for f in `ls ${HOME}/scripts/sh-funcs/*.sh 2>/dev/null`;do . $f;done

# mv  -f ./energy.dat ./energy.dat.OLD

# for i in 15 25 35 45 55 65 75 85
# # for i in 15
# do :
# ecutrho=$(echo "$i*8"|bc -l)
# sed -E -e's|@ECUT@|'$i'|' -e's|@RHO@|'$ecutrho'|' scf.in.in > scf.in
# rm -rf ./tmp
# mpirun pw.x < scf.in 2>&1 |tee  scf-$i.out

# read d d d d nrg rest < <(egrep '! *total energy' scf-$i.out)
# echo ${i} ${nrg} >> ./energy.dat

# done # for i...

mpirun pw.x < relax.in 2>&1 |tee  relax.out

# # catch converging cell constant to be plotted
# egrep -A 1 'new lattice vectors' relax.out |\
#       egrep -v 'new lattice vectors' |\
#       egrep '[0-9]' > cell-constant.dat

# catch converging unit cell volume and convert to fcc lattice constant
egrep -A 1 'Ekin =' relax.out |\
egrep 'new unit-cell volume' |\
sed -e's|^.*= *||' |\
sed -e's| .*$||' > cell-constant.dat

exit
