
%plot of how the different parameters in the cost funtion change 
%with one variable

clear all
clc
load('..\TC_col')

cost_parameters=data(2:end,1:5);
x=data(2:end,6:12);
c=data(2:end,13:20);
temp_profile=data(2:end,20:59);
merke=data(2:end,60);
c_param=[36; 78; -30; 2; -35; 0.01; 0.01;  1.6e6 ];     %c-c_param>=0

p=[-0.39,-1.0,0.022,0.00044,0.00044];

for i=1:length(cost_parameters(:,1))
c_diff(i,1)=-(c(i,1)-c_param(1));     
c_diff(i,2)=-(c(i,2)-c_param(2));   
c_diff(i,3)=(c(i,3)-c_param(3));   
c_diff(i,4)=(c(i,4)-c_param(4));   
c_diff(i,5)=-(c(i,5)-c_param(5));   
c_diff(i,6)=-(c(i,6)-c_param(6));
c_diff(i,7)=-(c(i,7)-c_param(7));
c_diff(i,8)=-(c(i,8)-c_param(8));


scaled_cost(i,:)=cost_parameters(i,:).*p;
cost(i)=sum(scaled_cost(i,:));
end

x_axis=x(:,6)'
x_label='Temperature col. bottom [*C]';
streng='Infeasable area'


fig=figure(1)
hold on 
subplot(4,2,1)
plot(x_axis,   ...
    (data_all.cost_param.compwork_booster+data_all.cost_param.compwork_salesgas).*p(4))   %plotting pressure to sec7
    xlabel(x_label)
    ylabel('Compression cost [NOK/h]')
    hold on
    plot([x_axis(4) x_axis(4)],get(gca,'YLim'),'r--')
    streng='Infeasable area'
    text(46,sum(get(gca,'YLim'))/2,streng,'Color','r')
subplot(4,2,2)  
    plot(  x_axis,   data_all.cost_param.V_flow.*p(3))
    xlabel(x_label)
    ylabel('Reboiler cost [NOK/h]')
    hold on
    plot([x_axis(4) x_axis(4)],get(gca,'YLim'),'r--')
    text(46,sum(get(gca,'YLim'))/3,streng,'Color','r')

subplot(4,2,3)  
    plot(x_axis,     data_all.cost_param.B_flow.*-p(2))
    xlabel(x_label)
    ylabel('Income B product [NOK/h]')
    hold on
    plot([x_axis(4) x_axis(4)],get(gca,'YLim'),'r--')
    text(46,sum(get(gca,'YLim'))/2,streng,'Color','r')

subplot(4,2,4)  
    plot(x_axis,    data_all.cost_param.D_flow.*-p(1))
    xlabel(x_label)
    ylabel('Income D [NOK/h] ')
    hold on
    plot([x_axis(4) x_axis(4)],get(gca,'YLim'),'r--')
    text(46,sum(get(gca,'YLim'))/2,streng,'Color','r')

subplot(4,2,5)  
    plot(x_axis,   data_all.D.x(3,:) )
    xlabel(x_label)
    ylabel('CO2 D [mol frac.]')
    hold on
    plot([x_axis(4) x_axis(4)],get(gca,'YLim'),'r--')
    text(46,sum(get(gca,'YLim'))/2,streng,'Color','r')

subplot(4,2,6)  
    plot(x_axis,     data_all.B.x(4,:))
    xlabel(x_label)
    ylabel('Methane B [mol frac.]')
    hold on
    plot([x_axis(4) x_axis(4)],get(gca,'YLim'),'r--')
    text(46,sum(get(gca,'YLim'))/2,streng,'Color','r')

subplot(4,2,[7,8])  
    plot(x_axis,    cost')
    xlabel(x_label)
    ylabel('Total cost [NOK/h]')
    hold on
    plot([x_axis(4) x_axis(4)],get(gca,'YLim'),'r--')
    text(46,sum(get(gca,'YLim'))/2,streng,'Color','r')
    %data=[cost_parameters,   x,   Temp_profile, merke]
%          1:5           6:12      13:51       52

% c(1,1)   Tower btm pressure
% c(1,2)    expansion pressure
% c(1,3)    Temperature stage 19
% c(1,4)    pressure drop column cold sep
% c(1,5)    Temperature befoure compressor
% c(1,6)    methane bottom
% c(1,7)    CO2 top
% c(1,8)    UA kJ/C*h

