#!/bin/bash
#
################################################################################
#
# Bash script for plotting the calculated energy using gnuplot.
# Useful for checking convergence of a calculation.
#
# @Pasquale Pavone  (2010, October, 8)
#_______________________________________________________________________________

pointsize=0.9

if   [ -f 'energy-vs-strain' ]; then
     inpf='energy-vs-strain'
     xlab='Lagrangian strain'

elif [ -f 'energy-vs-displacement' ]; then
     inpf='energy-vs-displacement'
     xlab='Displacement u [alat]'

elif [ -f 'energy-vs-volume' ]; then
     inpf='energy-vs-volume'
     xlab='Volume [Bohr^3]'
fi

if [ -f 'gnu-input' ]; then
    rm gnu-input
fi

cat>>gnu-input<<***
 set ter pos landscape enhanced color solid lw 2
 set out 'gnu.ps'
 set multiplot   
 set data sty lp
#set xtics 0.02
 set mxtics 0
 set grid 
 set key o r
 set key spacing 1.5 
 set key box
 set nokey
#===============================================
 set size    0.86, 0.83
 set origin  0.05, 0.05
 set yr [$1:$2]
 set xr [:]
 set title "$3"  0,-0.8  font "Helvetica,18"
 set xlabel "$xlab"  0.0,0.0 font "Helvetica,18"     
 set ylabel "Energy [Hartree]" 0.0,0.0 font "Helvetica,18"
 set xtics font "Helvetica,16"
 set ytics font "Helvetica,16"
 plot '$inpf' u 1:2 pt 7 ps $pointsize lt 1 lw 2 title ''    
#===============================================
 unset multiplot  
 quit
***
gnuplot < gnu-input
rm gnu-input
#-----------------------------------------------------------------------
#convert gnu.ps -rotate 90 $1-vs.png
#-----------------------------------------------------------------------

