############################
##acoustic scaling
############################
import math
from units import *

plot  = []
show_plot = True

height =  0.41
u_in_L = 0.05
u_in_phy = 1.5
nHeight = 400
dx = getdxFromnL(height,nHeight)
dt = getdt_acoustic(dx,u_in_L,u_in_phy)
pr_lp = getpress_p(dx,dt,1.0)

##velocity over time
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_velocity_p00001.res'],
#           row=[-5000,-1],col=[1,3],
#           convertPhy = True, xfac = 1.0, yfac = dx/dt, label='velocity at x=0.35',title='$u_y$ over time for outlet extrapolation, l/h=5 and nHeight=400',
#           xlabel ='timesteps', ylabel='$u_y(m/s)$', ls = 'k', startplot = True))
#
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_velocity_p00003.res'],
#           row=[-5000,-1],col=[1,3],
#           convertPhy = True, xfac = 1.0, yfac = dx/dt, ls = 'r', label='velocity at x=1.025',endplot =True, 
#           figname = 'velocityY_overtime_nH400_acousticScaling.png' ))

##FFT
#plot.append(dict(kind = 'FFT',data=['inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_velocity_p00001.res'],
#      row=[-2048,-1],col=[1,3],
#      convertPhy = True, xfac = dt, yfac = dx/dt, label = 'outlet_expol', title = 'FFT: velocity at x = 0.35 with outlet extrpolation, nH = 400, l/h=5',
#      startplot = True, endplot=True, figname='FFT_extrapolation_nH400.png'))

##deltaP
#plot.append(dict(kind = 'deltaP',data=[
#                                       'inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_density_p00000.res',
#                                       'inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_density_p00000.res'],
#          row=[-2000,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'k', label = 'l/h=5', title = 'Acoustic scaling:$\delta$P over time, outlet extrapolation nH=400 and l/h=2,3,5', 
#          xlabel = 'time', ylabel='$\Delta$ P', startplot=True))
#
#plot.append(dict(kind = 'deltaP',data=[
#                                       'inlet_ubb_outlet_expol/lh3/nH400/tracking/2D_probe_density_p00000.res',
#                                       'inlet_ubb_outlet_expol/lh3/nH400/tracking/2D_probe_density_p00000.res'],
#          row=[-2000,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'r', label = 'l/h=3'))
#
#plot.append(dict(kind = 'deltaP',data=[
#                                       'inlet_ubb_outlet_expol/lh2/nH400/tracking/2D_probe_density_p00001.res',
#                                       'inlet_ubb_outlet_expol/lh2/nH400/tracking/2D_probe_density_p00001.res'],
#          row=[-2000,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'b', label = 'l/h=2'))
#
#plot.append(dict(kind = 'drawline' , y = 2.46, 
#          ls = 'b--', label = 'lower_bound, $\Delta P = 2.46$'))
#
#plot.append(dict(kind = 'drawline',
#           y = 2.5, label = 'upper_bound, $\Delta P = 2.5$', ls = 'b-.', 
#           legend_loc = 1, endplot = True, figname = 'deltaP_expol_nH400_acousticScaling.png'))
#


##density
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,4],
#           convertPhy = True, xfac = 1.0, yfac = 1.0, label='l/h=5',title='Acoustic scaling:density over x, outlet extrapolation nH=400 and l/h=2,3,5',
#           xlabel ='x', ylabel='$u_y (m/s)$', ls = 'k',startplot=True))
#
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh3/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,4],
#           convertPhy = True, xfac = 1.0, yfac = 1.0, label='l/h=3', ls = 'r-'))
#
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh2/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,4],
#           convertPhy = True, xfac = 1.0, yfac = 1.0, label='l/h=2', ls = 'b-.',endplot=True, figname = 'density_expol_nH400_acousticScaling.png'))
#
#
###x-velocity
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,5],
#           convertPhy = True, xfac = 1.0, yfac = dx/dt, label='l/h=5',title='Acoustic scaling:$u_x$ over x, outlet extrapolation nH=400 and l/h=2,3,5',
#           xlabel ='x', ylabel='$u_y (m/s)$', ls = 'k',startplot=True))
#
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh3/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,5],
#           convertPhy = True, xfac = 1.0, yfac = dx/dt, label='l/h=3', ls = 'r-'))
#
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh2/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,5],
#           convertPhy = True, xfac = 1.0, yfac = dx/dt, label='l/h=2', ls = 'b-.',endplot=True, figname = 'velocityX_expol_nH400_acousticScaling.png'))
#
#
###y-velocity
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,6],
#           convertPhy = True, xfac = 1.0, yfac = dx/dt, label='l/h=5',title='Acoustic scaling:$u_y$ over x, outlet extrapolation nH=400 and l/h=2,3,5',
#           xlabel ='x', ylabel='$u_y (m/s)$', ls = 'k',startplot=True))
#
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh3/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,6],
#           convertPhy = True, xfac = 1.0, yfac = dx/dt, label='l/h=3', ls = 'r-'))
#
#plot.append(dict(kind = 'xy',data=['inlet_ubb_outlet_expol/lh2/nH400/tracking/2D_line_p*500*3.res'],
#           row=[1,-1],col=[1,6],
#           convertPhy = True, xfac = 1.0, yfac = dx/dt, label='l/h=2', ls = 'b-.',endplot=True, figname = 'velocityY_expol_nH400_acousticScaling.png'))


##deltaP extrapolation for different resolution
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH50/tracking/2D_probe_density_p00000.res'],
#          row=[-500,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'k', label = 'nHeight = 50', title = '$\Delta$ P different nHeight with extrapolation outlet and l/h=5', 
#          xlabel = 'time', ylabel='$\Delta$ P', startplot = True))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH100/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH100/tracking/2D_probe_density_p00000.res'],
#          row=[-500,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'r', label = 'nHeight = 100'))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH150/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH150/tracking/2D_probe_density_p00000.res'],
#          row=[-500,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'b', label = 'nHeight = 150'))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH200/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH200/tracking/2D_probe_density_p00000.res'],
#          row=[-500,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'y', label = 'nHeight = 200'))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH300/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH300/tracking/2D_probe_density_p00000.res'],
#          row=[-500,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'm', label = 'nHeight = 300'))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_density_p00000.res'],
#          row=[-500,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'g', label = 'nHeight = 400'))
#
#plot.append(dict(kind = 'drawline', y = 2.46, ls = 'b--', label = 'lower_bound, $\Delta P = 2.46$' ))
#
#plot.append(dict(kind = 'drawline', y = 2.5, label = 'upper_bound, $\Delta P = 2.5$', ls = 'b-.', endplot=True, figname = 'deltaP_expol_nH400_nH.png' ))


##deltaP for l/h=5 and nHeight=50, 200 for differnt outlet
plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH50/tracking/2D_probe_density_p00000.res'],
          row=[-1000,-1],col=[1,2,3],
          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'k--', label = 'extrapolation, nHeight = 50', title = '$\Delta$ P for l/h=5 and different nHeight and outlet BC',
          startplot = True,
          xlabel = 'time', ylabel='$\Delta$ P'))

plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_dnt/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_dnt/lh5/nH50/tracking/2D_probe_density_p00000.res'],
           row=[-1000,-1],col=[1,2,3],
           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'r--', label = 'do-nothing'))

plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_pab/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_pab/lh5/nH50/tracking/2D_probe_density_p00000.res'],
           row=[-1000,-1],col=[1,2,3],
           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'g--', label = 'pab'))

plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_eq/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_eq/lh5/nH50/tracking/2D_probe_density_p00000.res'],
           row=[-1000,-1],col=[1,2,3],
           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'y--', label = 'eq'))

#nH400
plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH400/tracking/2D_probe_density_p00000.res'],
          row=[-1000,-1],col=[1,2,3],
          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'k', label = 'extrapolation, nHeight = 400'))

plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_dnt/lh5/nH400/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_dnt/lh5/nH400/tracking/2D_probe_density_p00000.res'],
           row=[-1000,-1],col=[1,2,3],
           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'r', label = 'do-nothing'))

plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_pab/lh5/nH400/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_pab/lh5/nH400/tracking/2D_probe_density_p00000.res'],
           row=[-1000,-1],col=[1,2,3],
           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'g', label = 'pab'))

plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_eq/lh5/nH400/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_eq/lh5/nH400/tracking/2D_probe_density_p00000.res'],
           row=[-1000,-1],col=[1,2,3],
           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'y', label = 'eq'))

plot.append(dict(kind = 'drawline', y = 2.46, ls = 'b--', label = 'lower_bound, $\Delta P = 2.46$' ))

plot.append(dict(kind = 'drawline', y = 2.5, label = 'upper_bound, $\Delta P = 2.5$', ls = 'b-.', endplot=True, figname = 'deltaP_outlet_nH.png' ))
#
#plot.append(dict(kind = 'drawline',data=['inlet_ubb_outlet_expol/lh3/nH150/tracking/2D_probe_density_p00000.res'],
#           row=[-500,-1],col=[1,2], y = 2.46, ls = 'b--', label = 'lower_bound', startplot = False ))
#
#plot.append(dict(kind = 'drawline',data=['inlet_ubb_outlet_expol/lh5/nH150/tracking/2D_probe_density_p00000.res'],
#           row=[-500,-1],col=[1,2], y = 2.5, label = 'upper_bound', ls = 'b--', startplot=False ))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH100/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH100/tracking/2D_probe_density_p00000.res'],
#          row=[-500,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'k', label = 'expolation', title = '$\Delta$ P for different outflow boundary condition for l/h=5 and nHeight = 100', 
#          xlabel = 'time', ylabel='$\Delta$ P'))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_dnt/lh5/nH100/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_dnt/lh5/nH100/tracking/2D_probe_density_p00000.res'],
#           row=[-500,-1],col=[1,2,3],
#           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'r', label = 'do-nothing', startplot = False))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_pab/lh5/nH100/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_pab/lh5/nH100/tracking/2D_probe_density_p00000.res'],
#           row=[-500,-1],col=[1,2,3],
#           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'g', label = 'pab', startplot = False))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_eq/lh5/nH100/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_eq/lh5/nH100/tracking/2D_probe_density_p00000.res'],
#           row=[-500,-1],col=[1,2,3],
#           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'y', label = 'eq', startplot = False))
#
#
#plot.append(dict(kind = 'drawline',data=['inlet_ubb_outlet_expol/lh3/nH100/tracking/2D_probe_density_p00000.res'],
#           row=[-500,-1],col=[1,2], y = 2.46, ls = 'b--', label = 'lower_bound', startplot = False ))
#
#plot.append(dict(kind = 'drawline',data=['inlet_ubb_outlet_expol/lh5/nH100/tracking/2D_probe_density_p00000.res'],
#           row=[-500,-1],col=[1,2], y = 2.5, label = 'upper_bound', ls = 'b--', startplot=False ))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_expol/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_expol/lh5/nH50/tracking/2D_probe_density_p00000.res'],
#          row=[-500,-1],col=[1,2,3],
#          convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'k', label = 'expolation', title = '$\Delta$ P for different outflow boundary condition for l/h=5 and nHeight = 50', 
#          xlabel = 'time', ylabel='$\Delta$ P'))
#
##plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_dnt/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_dnt/lh5/nH50/tracking/2D_probe_density_p00000.res'],
##           row=[-500,-1],col=[1,2,3],
##           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'r', label = 'do-nothing', startplot = False))
#
##plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_pab/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_pab/lh5/nH50/tracking/2D_probe_density_p00000.res'],
##           row=[-500,-1],col=[1,2,3],
##           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'g', label = 'pab', startplot = False))
#
#plot.append(dict(kind = 'deltaP',data=['inlet_ubb_outlet_eq/lh5/nH50/tracking/2D_probe_density_p00000.res','inlet_ubb_outlet_eq/lh5/nH50/tracking/2D_probe_density_p00000.res'],
#           row=[-500,-1],col=[1,2,3],
#           convertPhy = True, xfac = 1., yfac = pr_lp, ls = 'y', label = 'eq', startplot = False))
#
#


