%%%%%%%%%%%%%%%%%
%%%% affichage vitesse de frottement et loi log
%%%%%%%%%%%%%%%%%

clear
close all;

delta=25.6;
vit_ref=39.54;
kappa=0.41;
hgazon=0.5;
densite=1000;

load parametres_rugosite.mat

% u_star=u_star*100;%vitesse de frottement en cm/s

u_star=0.0242*100;%vitesse de frottement en cm/s pirs fond du canal

d=d*100;%hauteur de déplacement en cm
z0=z0*100;%longueur de rugosité en cm
a_tau=a_tau*100;
b_tau=b_tau*10000;
z=z*100;
zcs=zcs*100;
U=U*100;
tau=tau*1e4;

dcs=zcs*ones(100,1);

U_fit=(u_star/kappa)*log((z-d)/z0);

f_fit=(1/z0)*z-(d/z0);

z_fit=linspace(0,23,100);

tau_fit=a_tau*z_fit+b_tau;

%% affichage 

%comparaison loi log / profil de vitesse moyenne 



H_hill=0.065;%en m

U_deb=0.3567405;% en m/s vitesse débitante
       
zm=z.*10^-2;

z_adim=zm./H_hill;

u_starm=u_star.*10^-2;

z0m=z0.*10^-2;

dm=d.*10^-2;

U_loglaw=(u_starm/kappa)*log((zm-dm)/z0m);

z_limit_loglaw=zcs.*10^-2;
z_adim_limit_law=z_limit_loglaw/H_hill;
  
z_lim_log=z_adim_limit_law*ones(100,1);



x_lim_log = 0.4:(1.15-0.4)/99:1.15;
y_lim_log = [0 6];   



figure('rend','painters','pos',[10 10 1400 800])
box on;

semilogy((U(3:200).*10^-2)./U_deb,z_adim(3:200),'bo');
hold on;
semilogy(U_loglaw./U_deb,z_adim,'-r');
semilogy(x_lim_log,z_lim_log,'--k');

    hy = ylabel('$z/H_1$','FontSize',40);
    hx = xlabel('$ \overline{u}/U_{flow}$','FontSize',40);
    set(hx,'interpreter','Latex','FontSize',40)
    set(hy,'interpreter','Latex','FontSize',40)
    xlim([x_lim_log(1) x_lim_log(end)])
    ylim([y_lim_log(1) y_lim_log(2)])
    set(gca, 'FontSize', 40);
    set(gca,'TickLabelInterpreter', 'Latex');
    yticks([0 1 2 3 4 5])    
    xticks([0.5 0.6 0.7 0.8 0.9 1 1.1]) 
    
leg=legend(['$exp$'],...
['$log \; law$'],...
['$limit \; log \; law$']);    

set(leg,'Interpreter','Latex','Fontsize',40);

% position légende
% exemple pos_leg =[x y width, height];
pos_leg = [0.215, 0.7, .1, .18];
set(leg, 'Position', pos_leg)


