
%Analyssis of the different how the parameters in the cost funtion

clear all
clc
load('pc_feed_60_78_bar_n')

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.0022,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));

p=[-0.39,-1.0,0.0022,0.00044,0.00044];
scaled_cost(i,:)=cost_parameters(i,:).*p;
cost(i)=sum(scaled_cost(i,:));
end

figure(1)
hold on 
subplot(4,2,1)
plot(data_all.s13.p,   ...
    (data_all.cost_param.compwork_booster+data_all.cost_param.compwork_salesgas).*p(4))   %plotting pressure to sec7
xlabel('Pressure before expansion [bar]')
ylabel('Compression cost [NOK/h]')

subplot(4,2,2)  
plot(   data_all.s13.p,   data_all.cost_param.V_flow.*p(3))
xlabel('Pressure before expansion [bar]')
ylabel('Reboiler cost [NOK/h]')

subplot(4,2,3)  
plot(data_all.s13.p,     data_all.cost_param.B_flow.*-p(2))
xlabel('Pressure before expansion [bar]')
ylabel('Income bottom product [NOK/h]')

subplot(4,2,4)  
plot(data_all.s13.p,    data_all.cost_param.D_flow.*-p(1))
xlabel('Pressure before expansion [bar]')
ylabel('Income top product [NOK/h] ')

subplot(4,2,5)  
plot(data_all.s13.p,   data_all.D.x(3,:) )
xlabel('Pressure before expansion [bar]')
ylabel('CO2 D [mol frac.]')

subplot(4,2,6)  
plot(data_all.s13.p,     data_all.D.x(4,:))
xlabel('Pressure before expansion [bar]')
ylabel('Methane B [mol frac.]')

subplot(4,2,[7,8])  
plot(data_all.s13.p,     cost)
xlabel('Pressure before expansion [bar]')
ylabel('Total cost')


