clear all
close all
load v01_bif_data.mat;
load v1_4d_ss_data.mat;
load olgav5_bif.mat;

clc
y1_olga_min(1:4) = y1_olga_ss(1:4);
y1_olga_max(1:4) = y1_olga_ss(1:4);


y2_olga_min(1:4) = y2_olga_ss(1:4);
y2_olga_max(1:4) = y2_olga_ss(1:4);

y3_olga_min(1:4) = y3(1:4);
y3_olga_max(1:4) = y3(1:4);

z_olga = z_olga*100;
figure(3)
clf
rect = [0, 0, 15, 20];
set(gcf,'Color',[1,1,1],'PaperUnits','centimeters','PaperSize',[15 20],'PaperPosition',rect)
set(gcf,'Color',[1,1,1])
set(gca,'FontSize',10)

subplot(3,1,1)
set(gca,'FontSize',10,'OuterPosition',[0  2/3  1  1/3])
hold on
plot(z_olga,y1_olga_min,'--b','Linewidth',1);
plot(100*zs,y1min,'r','Linewidth',1);
legend('OLGA reference model','New low-order model','FontSize',8)
plot(z_olga,y1_olga_max,'--b','Linewidth',1);
plot(100*zs,y1max,'r','Linewidth',1);
plot(z_olga,y1_olga_ss,'--b','Linewidth',1);
plot(100*zs,y1,'r','Linewidth',1);
box on
title('a) Pressure at inlet of pipeline (\itP\rm_{in})','FontSize',12,'FontWeight','normal','FontName','Times');
ylim([58 85]) 
xlim([0 100])
ylabel('\itP\rm_{in} [bar]','FontSize',12,'FontName','Times')
xlabel('valve opening, \itZ\rm_1 [%]','FontSize',12,'FontName','Times')

subplot(3,1,2)
set(gca,'FontSize',10,'OuterPosition',[0  1/3  1  1/3])
hold on
plot(z_olga,y2_olga_min,'--b','Linewidth',1);
plot(100*zs,y2min,'r','Linewidth',1);
legend('OLGA reference model','New low-order model','FontSize',8)
plot(z_olga,y2_olga_max,'--b','Linewidth',1);
plot(100*zs,y2max,'r','Linewidth',1);
plot(z_olga,y2_olga_ss,'--b','Linewidth',1);
plot(100*zs,y2,'r','Linewidth',1);
box on
title('b) Pressure at top of riser (\itP\rm_{rt})','FontSize',12,'FontWeight','normal','FontName','Times');
ylabel('\itP\rm_{rt} [bar]','FontSize',12,'FontName','Times')
ylim([50 61])
xlim([0 100])
xlabel('valve opening, \itZ\rm_1 [%]','FontSize',12,'FontName','Times')

subplot(3,1,3)
set(gca,'FontSize',10,'OuterPosition',[0  0  1  1/3])
hold on
plot(z_olga,w_olga_min,'--b','Linewidth',1);
plot(100*zs,y3min,'r','Linewidth',1);
legend('OLGA reference model','New low-order model','FontSize',8)
plot(z_olga,w_olga_max,'--b','Linewidth',1);
plot(100*zs,y3max,'r','Linewidth',1);
plot(z_olga,9*ones(size(z_olga)),'--b','Linewidth',1);
plot(100*zs,y3,'r','Linewidth',1);
box on
title('c) Outlet mass flow (\itw\rm_{out})','FontSize',12,'FontWeight','normal','FontName','Times');
ylabel('\itw\rm_{out} [kg/s]','FontSize',12,'FontName','Times')
ylim([0 50])
xlim([0 100])
xlabel('valve opening, \itZ\rm_1 [%]','FontSize',12,'FontName','Times')
print -depsc C:\Users\jahansha\Documents\SPE_Journal\Figures\new_Bif 
%%
disp('P1ss')
y1_olga_ss(end)-y1(end)
100*(y1_olga_ss(end)-y1(end))/y1_olga_ss(end)
disp('P2ss')
y2_olga_ss(end)-y2(end)
100*(y2_olga_ss(end)-y2(end))/y2_olga_ss(end)
disp('Wss')
9-y3(end)
100*(9-y3(end))/9

disp('P1max')
y1_olga_max(end)-y1max(end)
100*(y1_olga_max(end)-y1max(end))/y1_olga_max(end)
disp('P2max')
y2_olga_max(end)-y2max(end)
100*(y2_olga_max(end)-y2max(end))/y2_olga_max(end)
disp('Wmax')
w_olga_max(end)-y3max(end)
100*(w_olga_max(end)-y3max(end))/w_olga_max(end)

disp('P1min')
y1_olga_min(end)-y1min(end)
100*(y1_olga_min(end)-y1min(end))/y1_olga_min(end)
disp('P2min')
y2_olga_min(end)-y2min(end)
100*(y2_olga_min(end)-y2min(end))/y2_olga_min(end)
disp('Wmin')
w_olga_min(end)-y3min(end)
100*(w_olga_min(end)-y3min(end))/w_olga_min(end)