
clear all
close all
clc

load('sim_MinSelect_CEP.mat');
    

figure(56)
clf
subplot(322)
hold all
% plot(sim.t./3600,zeros(size(sim.Ju')),'k:')
% plot(sim.t./3600,0*ones(size(sim.t)),'k:')
plot(sim.t./3600,-(sim.Ju(1,:))+(sim.Ju(2,:)),'linewidth',1.4)
plot(sim.t./3600,-(sim.Ju(1,:))+(sim.Ju(3,:)),'linewidth',1.4)
plot(sim.t./3600,-(sim.Ju(1,:))+(sim.Ju(4,:)),'linewidth',1.4)
plot(sim.t./3600,-(sim.Ju(1,:))+(sim.Ju(5,:)),'linewidth',1.4)
plot(sim.t./3600,-(sim.Ju(1,:))+(sim.Ju(6,:)),'linewidth',1.4)
ylim([-1,1])
title('marginal GOR difference [kg/kg]','interpreter','Latex')
ylabel('$CV_i: \nu_i - \nu_{i+1}$','interpreter','Latex')
leg = legend({'$CV_1$','$CV_2$','$CV_3$','$CV_4$','$CV_5$'},'interpreter','Latex',...
    'location','best','Fontsize',10);
leg.NumColumns = 3;
axs = gca;
axs.TickLabelInterpreter = 'latex';
axs.FontSize = 14;

box on
grid on

subplot(323)
hold all
% plot(sim.t./3600,sim.meas.w_gl','linewidth',1.4)
plot(sim.t./3600,10.*ones(size(sim.t)),'k:','linewidth',1.4)
plot(sim.t./3600,(sim.meas.w_gl(1,:)+sim.meas.w_gl(2,:)+sim.meas.w_gl(3,:)+sim.meas.w_gl(4,:)+sim.meas.w_gl(5,:)+sim.meas.w_gl(6,:)),'k','linewidth',1.4)
box on
grid on
ylabel('$CV_6: \sum w_{gl_i}$','interpreter','Latex')
title( ' Total Gas lift rate [kg/s]','interpreter','Latex')
axs = gca;
axs.TickLabelInterpreter = 'latex';
axs.FontSize = 14;

subplot(325)
hold all
plot(sim.t./3600,0.25*ones(size(sim.t)),'k:')
plot(sim.t./3600,-sim.Ju(1,:),'k','linewidth',1.4)
% plot(sim.t./3600,sim.meas.w_to','k','linewidth',1.4)
% ylim([150,170])
box on
grid on
ylabel('$CV_6:\nu_6$','interpreter','Latex')
title( ' marginal GOR well 6 [kg/s]','interpreter','Latex')
xlabel ('$time $[h]','interpreter','Latex')
axs = gca;
axs.TickLabelInterpreter = 'latex';
axs.FontSize = 14;

subplot(321)
hold all
plot(sim.t./3600,sim.QgMax,'k:','linewidth',1.4)
plot(sim.t./3600,sim.meas.w_tg','k','linewidth',1.4)
ylim([20,30])
title( 'Total  gas [kg/s]','interpreter','Latex')
ylabel('$CV_6: \sum w_{pg_i}$','interpreter','Latex')
axs = gca;
axs.TickLabelInterpreter = 'latex';axs.FontSize = 14;
box on
box on
grid on

subplot(324)
hold all
plot(sim.t./3600,sim.meas.w_gl','linewidth',1.4)
title( 'Gas lift rate [kg/s]','interpreter','Latex')
box on
grid on
ylabel('$MV_i: w_{gl_i}$','interpreter','Latex')
leg = legend({'$MV_1$','$MV_2$','$MV_3$','$MV_4$','$MV_5$','$MV_6$'},'interpreter','Latex',...
    'location','best','Fontsize',10);
leg.NumColumns = 3;
axs = gca;
axs.TickLabelInterpreter = 'latex';
axs.FontSize = 14;

subplot(326)
hold all
plot(sim.t./3600,sim.meas.GOR_real','linewidth',1.4)
% ylim([20,30])
title( 'Gas-Oil-Ratio [kg/kg]','interpreter','Latex')
box on
grid on
ylabel('$d: GOR_{i}$','interpreter','Latex')
xlabel ('$time$ [h]','interpreter','Latex')
leg = legend({'$well_1$','$well_2$','$well_3$','$well_4$','$well_5$','$well_6$'},'interpreter','Latex',...
    'location','best','Fontsize',10);
leg.NumColumns = 3;
axs = gca;
axs.TickLabelInterpreter = 'latex';
axs.FontSize = 14;
