% A - Opening Ratio in %
% M - Fixed or Floating (1 or 0)
% This function plots the normalized pressure drop of the model.
 
clear all
close all

% Global Variables initialized.
i=1;
j=1;
O = 0;
M = 0;

A = [0.5 0.7 1.0 1.5 2.0];
% ND1
T = [1.25 1.5 1.75 2 2.25 2.5 3];



for k = 1:length(A)
    for i = 1:length(T)
        if A(k) == 0.5 && T(i) == 1.25
        P2(i,k) = NaN;
        else
        [P2(i,k)] = PeakPressure(8,T(i),A(k),O,M);
        P2(i,k)= P2(i,k)./(1000*9.81*(0.08)); %Coefficient of Pressure  
        end
        
        L = SolveDispersionEquation(1.36,T(i),1);
        ND1(i) = L/0.225;
    end
end

% ND2

H = [5 6.5 8 9.5 11 14];

for k = 1:length(A)
    for i = 1:length(H)
        [P1(i,k)] = PeakPressure(H(i),2,A(k),O,M);
        P1(i,k)= P1(i,k)./(1000*9.81*(H(i)/100)); %Coefficient of Pressure  
        ND2(i) = (H(i)/100)/0.225;
    end
end


acon = aconfig('LineWidth',2,'Colormap',[0 0 0],'MarkerSize',10,'LineStyles','o:|x:|s:|d:|+:','FontSize',20,'fontWeight','bold','Grid',1);

afigure(acon)
subplot(2,1,1)
aplot(ND2,P1)
ylabel('$${C_p}$$','Interpreter','latex')
xlabel('H/D','Interpreter','latex')
ax = gca;
set(ax,'FontSize',20,'fontWeight','bold','ticklabelinterpreter','latex');
hold on

if M ==1
    %title('Normalized Fixed Model Pressure Drop')
    axis([0.2 0.7 0 0.7])
else
    %title('Normalized Floating Model Pressure Drop')
    axis([0.2 0.7 0 1.5])
end

lab1 = '$\alpha = 0.5 \%$';
lab2 = '$\alpha = 0.7 \%$';
lab3 = '$\alpha = 1.0 \%$';
lab4 = '$\alpha = 1.5 \%$';
lab5 = '$\alpha = 2.0 \%$';

legend(lab1,lab2,lab3,lab4,lab5,'Interpreter','latex')
legend('boxoff')

subplot(2,1,2)
aplot(ND1,P2)
ylabel('$${C_p}$$','Interpreter','latex')
xlabel('L/D','Interpreter','latex')
ax = gca;
set(ax,'FontSize',20,'fontWeight','bold','ticklabelinterpreter','latex');

lab1 = '$\alpha = 0.5 \%$';
lab2 = '$\alpha = 0.7 \%$';
lab3 = '$\alpha = 1.0 \%$';
lab4 = '$\alpha = 1.5 \%$';
lab5 = '$\alpha = 2.0 \%$';

legend(lab1,lab2,lab3,lab4,lab5,'Interpreter','latex')
legend('boxoff')

hold on

if M ==1
    axis([10 50 0 0.7])
else
    axis([10 50 0 1.5])
end
