%script for reading and plotting the excel results

%results=xlsread('M:\Diplom\kaibel_test_results_working_prefrac_split.xls',
%'sheet1','b7:bf35');


%Extracting results from the excel worksheet:
reflux=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','b7:b20');
tempprofilecolumn1=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','c7:ao20');
tempprofilecolumn2=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','ap7:bi20');
heatduty=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','bj7:bj20');
prodstreamD=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','bk7:bn20');
prodstreamS1=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','bo7:br20');
prodstreamS2=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','bs7:bv20');
prodstreamB=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','bw7:bz20');
nstage=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','ci7:ci7');
prodstream_frac_sum=xlsread('M:\Diplom\kaibel_59stages_reflux12.xls','sheet1','ck7:ck20');


%Defining which variables/runs/results to use:
enter=1;

if enter==1;
%x=[6];
x=6
l=length(x);

reflux_original = reflux;
tempprofilecolumn1_original = tempprofilecolumn1;
tempprofilecolumn2_original = tempprofilecolumn2;
heatduty_original = heatduty;
prodstreamD_original = prodstreamD;
prodstreamS1_original = prodstreamS1;
prodstreamS2_original = prodstreamS2;
prodstreamB_original = prodstreamB;
prodstream_frac_sum_original = prodstream_frac_sum;


reflux=[];
tempprofilecolumn1=[];
tempprofilecolumn2=[];
heatduty=[];
prodstreamD=[];
prodstreamS1=[];
prodstreamS2=[];
prodstreamB=[];
prodstream_frac_sum=[];


    for i=1:l;
    
        reflux(i,:) = reflux_original(x(i),:);
        tempprofilecolumn1(i,:) = tempprofilecolumn1_original(x(i),:);
        tempprofilecolumn2(i,:) = tempprofilecolumn2_original(x(i),:);
        heatduty(i,:) = heatduty_original(x(i),:);
        prodstreamD(i,:) = prodstreamD_original(x(i),:);
        prodstreamS1(i,:) = prodstreamS1_original(x(i),:);
        prodstreamS2(i,:) = prodstreamS2_original(x(i),:);
        prodstreamB(i,:) = prodstreamB_original(x(i),:);
        prodstream_frac_sum(i,:) = prodstream_frac_sum_original(x(i),:);
        
    end    
end

    
[runs,nstage1]=size(tempprofilecolumn1);
[runs,nstage2]=size(tempprofilecolumn2);

n1=(1:nstage1);
n2=(1:nstage2);

nsplittop=8;        %the plate where the TOP connect streams are connected (on column 1).
nsplittbottom=31;   %the plate where the BOTTOM connect streams are connected (on column 1).

n2stage_rel_to_1_temp=linspace(nsplittop+1,nsplittbottom-1,length(n2));
n2stage_rel_to_1=[(1:nsplittop) n2stage_rel_to_1_temp (nsplittbottom:nstage1)];

tempprofilecolumn2_1=[tempprofilecolumn1(:,1:nsplittop) tempprofilecolumn2 tempprofilecolumn1(:,nsplittbottom:nstage1)];

plotit=2;




if plotit==1
    figure;
    hold on;
    plot(n1,tempprofilecolumn1(1,:),'-b',n1,tempprofilecolumn1(2,:),'-.k',n1,tempprofilecolumn1(3,:),'--r');
    plot(n2stage_rel_to_1,tempprofilecolumn2_1(1,:),'-b',n2stage_rel_to_1,tempprofilecolumn2_1(2,:),'-.k',n2stage_rel_to_1,tempprofilecolumn2_1(3,:),'--r');
    legend(['reflux=',num2str(reflux(1)),''],['reflux=',num2str(rv(2)),''],['reflux=',num2str(rv(3)),''])
    hold off;

elseif plotit==2;
    figure;
    hold on;
    plot(n1,tempprofilecolumn1,'-.b');
    plot(n2stage_rel_to_1,tempprofilecolumn2_1,'-b');
    legend(['reflux=',num2str(reflux(x)),'']);
    hold off;
 
else
    plot(reflux,prodstream_frac_sum,'-b'),xlabel('Reflux (L/D)'),ylabel('Sum x')
    plot(reflux,heatduty,'-b'),xlabel('Reflux (L/D)'),ylabel('Heat duty (V) [W]') %legend('Boil-up');

end
