#!/bin/bash

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

gnuplot<<EOF

set linetype 1 lc rgb 'red'     lw 1 dt 1
set linetype 2 lc rgb 'blue'    lw 1 dt 1

set grid
set key outside below

#---PNG---
set terminal pngcairo color enhanced size 800,600

#---PID-Controller---
set output  'PIDcontroller.png'

POSFILE =  '../postProcessing/gasPosition/0/phaseStructureProperties.dat'
VELFILE =  '../postProcessing/inletVelocity/0/surfaceFieldValue.dat'

set xlabel  't'
set ylabel  'control variable: y_b'
set yrange  [0:0.9]
set ytics   nomirror
set y2label 'controlled variable: U_y'
set y2range [-0.2:0.2]
set y2tics
set x2zeroaxis

plot POSFILE u 1:3                               w l lt 1      t 'y_b'              , \
     0.45                                        w l lt 1 dt 2 t 'target position'  , \
     VELFILE u 1:3 '%lf (%lf %lf %lf)' axes x1y2 w l lt 2      t 'U_y'

EOF

#------------------------------------------------------------------------------
