%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%                                              %%%%%
%%%%%                PERSTORP DATA                 %%%%%
%%%%%                                              %%%%%
%%%%%          Daniel Greiner Edvardsen            %%%%%
%%%%%                 IKP, NTNU                    %%%%%
%%%%%               June 14, 2011                  %%%%%
%%%%%                                              %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [T0 Tp Th11in Th1in Th2in Th3in Th11 Th1 Th2 Th3 T11_ T11 T1 T2 T3 m0 mh11 mh1 mh2 mh3 m11 m1 m2 m3 cp0 cp11 cp1 cp2 cp3 rho0 rho11 rho1 rho2 rho3 w0 w11 w1 w2 w3 wh11 wh1 wh2 wh3 ] = perstorp_data(k)

load 2010.mat;
      
%%%%% Convert hours to seconds %%%%%
h=3600;

%%%%% All temperatures in 'Celsius' %%%%%%

T0 = ti1053y(k); %Feed temperature
Tp = ti2106y(k); %End temperature

    % HOT temperature IN
    Th11in  = ti2362y(k);
    Th1in	= ti2303y(k);                              
    Th2in 	= fq2261y(k)/fq2064y(k) * ti2263y(k) +...  
              (1-fq2261y(k)/fq2064y(k))*ti2252y(k);           
    Th3in	= ti2352y(k);

    % HOT Temperature OUT
    Th11    = ti2021y(k);   
    Th1     = tc2043y(k);   
    Th2     = ti2031y(k);  
    Th3     = ti2011y(k);

    % COLD Temperatyre OUT
    T11_    = ti2024y(k);
    T11     = ti2042y(k);
    T1      = ti2044y(k);
    T2      = ti2034y(k);
    T3      = ti2014y(k);

%%%%% All heat capacities in 'J/kgK' %%%%%%

cp0      = (3728-3701.6)/50 ...  
          *(T0-50)+3701.6;      
cp11    = 4006;                
cp1     = 2827;                 
cp2     = 4216;                 
cp3     = (4166-4105)/60* ...   
          (T0-60)+4166;

%%%%%% Densities in 'kg/m^3' %%%%%%
rho0    = (1021-1054)/50*(T0-50)+1054;
rho1    = 1257;
rho2    = 926;
rho3    = (926-971.8)/60*(T0-60)+926;
rho11   = rho3;        
      
%%%%%% Volumetric flow rates in 'm^3/s' %%%%%%

v0      = fc2105y(k)/h;     
vh11    = fq2502y(k)/h;
vh1     = fc2304y(k)/h;
vh2     = fq2064y(k)/h;
vh3     = (fq2032y(k)-fq2558y(k))/h;
    
    %Using energy balances to calculate cold volume streams
    v11 = (Th11in-Th11)/(T11_-T0)*vh11*rho11/rho0*cp11/cp0;  
    v1  = (Th1in-Th1)/(T1-T11)*vh1*rho1/rho0*cp1/cp0;
    v2  = (Th2in-Th2)/(T2-T0)*vh2*rho2/rho0*cp2/cp0;
    v3  = (Th3in-Th3)/(T3-T0)*vh3*rho3/rho0*cp3/cp0;

%%%%%% Mass flow rates in 'kg/s' %%%%%%

m0      = v0  * rho0;
m11     = v11 * rho0;
m1      = v1  * rho0;
m2      = v2  * rho0;
m3      = v3  * rho0;

mh11    = vh11 * rho11;
mh1     = vh1  * rho1;
mh2     = vh2  * rho2;
mh3     = vh3  * rho3;

%%%%%% All mCps in 'W/K' (kg/s * J/kgK) %%%%%%

w0      = m0  * cp0;
w11     = m11 * cp0;
w1      = m1  * cp0;
w2      = m2  * cp0;
w3      = m3  * cp0;  

wh11    = mh11 * cp11;
wh1     = mh1  * cp1;
wh2     = mh2  * cp2;
wh3     = mh3  * cp3;




