% PROFILEPLOT.M %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Plot composition and temperature profiles

indmat();

x = xFinal;

x1 = x(im_x1);
x2 = x(im_x2);
x3 = x(im_x3);
x4 = x(im_x4);
x5 = x(im_x5);
x6 = x(im_x6);
x7 = x(im_x7);

main_col_D = [
    x3(1:coldata.Nt(3))'
    x4(1:coldata.Nt(4))'
    x7(1:coldata.Nt(7))'
    x5(1:coldata.Nt(5))'
    x6(1:coldata.Nt(6))'
    ];

main_col_S1 = [
    x3(coldata.Nt(3) + 1:2 * coldata.Nt(3))'
    x4(coldata.Nt(4) + 1:2 * coldata.Nt(4))'
    x7(coldata.Nt(7) + 1:2 * coldata.Nt(7))'
    x5(coldata.Nt(5) + 1:2 * coldata.Nt(5))'
    x6(coldata.Nt(6) + 1:2 * coldata.Nt(6))'
    ];

main_col_S2 = [
    x3(2 * coldata.Nt(3) + 1:3 * coldata.Nt(3))'
    x4(2 * coldata.Nt(4) + 1:3 * coldata.Nt(4))'
    x7(2 * coldata.Nt(7) + 1:3 * coldata.Nt(7))'
    x5(2 * coldata.Nt(5) + 1:3 * coldata.Nt(5))'
    x6(2 * coldata.Nt(6) + 1:3 * coldata.Nt(6))'
    ];

prefrac_D = [
    x1(1:coldata.Nt(1))'
    x2(1:coldata.Nt(2))'
    ];

prefrac_S1 = [
    x1(coldata.Nt(1) + 1:2 * coldata.Nt(1))'
    x2(coldata.Nt(2) + 1:2 * coldata.Nt(2))'
    ];

prefrac_S2 = [
    x1(2 * coldata.Nt(1) + 1:3 * coldata.Nt(1))'
    x2(2 * coldata.Nt(2) + 1:3 * coldata.Nt(2))'
    ];

figure();
plot(main_col_D);
hold on;
plot(main_col_S1);
plot(main_col_S2);
plot(1 - main_col_D - main_col_S1 - main_col_S2);
xlim([1 40]);
title('Main column');

figure();
plot(prefrac_D);
hold on;
plot(prefrac_S1);
plot(prefrac_S2);
plot(1 - prefrac_D - prefrac_S1 - prefrac_S2);
xlim([1 24]);
title('Prefractionator');

main_col_temp = [
    x(im_T3)'
    x(im_T4)'
    x(im_T7)'
    x(im_T5)'
    x(im_T6)'
    ];

prefrac_temp = [
    x(im_T3)'
    x(im_T1)'
    x(im_T2)'
    x(im_T6)'
    ];


figure();
plot(main_col_temp);
hold on;
plot(prefrac_temp,'--');
plot(6,main_col_temp(6),'o');
plot(6,341.9690,'rx');
plot(19,main_col_temp(19),'o');
plot(19,355.8309,'rx');
plot(33,main_col_temp(33),'o');
plot(33,379.6372,'rx');
plot(25,prefrac_temp(25),'o');
plot(25,368.2944,'rx');
title('Temperature profile');
xlim([1 40]);
legend('Main column','Prefractionator','Controlled temperatures','Temperature setpoints');