#!/bin/bash

if ! which gnuplot > /dev/null 2>&1
then
    echo 'gnuplot not found - skipping graph creation' >&2
    exit 1
fi

#\*----------------------Particle mass per unit volume------------------------*/
gnuplot<<EOF

    set terminal pngcairo enhanced color size 800,600 font "Arial,18"

    set output 'particleMassPerUnitVolume.png'

    set grid
    set key box
    set key spacing 1

    set xlabel 't [s]'
    set xrange [0:10]
    set ylabel 'Particle mass per unit volume [kg/m3]'

    plot '< paste ../postProcessing/probes/0/particle.gas ../postProcessing/probes/0/rho.gas ../postProcessing/probes/0/alpha.gas' u 1:(\$2*\$4*\$6) w l lw 3 lc rgb 'magenta' t 'Simulation',\
         x > 5 ? 0 : 0.0658 - 0.01316*x w l dt "-  -" lw 3 lc rgb 'black' t 'Analytical'

#\*----------------------------Retention ratio--------------------------------*/

    set output 'retentionRatio.png'

    set ylabel '{/Symbol a}^{gas}_{particle} \
/ {/Symbol a}^{gas}_{particle0} [-]'

    p = '../postProcessing/probes/0/particleVolumeFraction.gas'
    rP = 'probes/0/particleVolumeFraction.gas'

    stats p u 2 name 'statpVF' nooutput
    stats rP u 2 name 'statrPVF' nooutput

    plot p u 1:(\$2/statpVF_max) w l lw 3 lc rgb 'magenta' t 'Simulation' ,\
         rP u 1:(\$2/statrPVF_max) w l dt "-  -" lw 3 lc rgb 'black' t 'Reference',\

EOF
#------------------------------------------------------------------------------
