clc
clear all
%
% =========================================================================
%                                CONSTANTS
% =========================================================================
%
% Densities [kg/m3]
rho_h = 912.892;                    % Hot water (p = 1500000 Pa, T = 155 °C)
rho_c = 959.049;                    % Cold water (p = 1500000 Pa, T = 100 °C)
%
% Specific heat capacities [J/kg*K]
cph = 4321.56;                      % Hot water (p = 1500000 Pa, T = 155 °C)
cpc = 4213.84;                      % Cold water (p = 1500000 Pa, T = 100 °C)
%
% =========================================================================
%                          MAIN HEAT EXCHANGERS
% =========================================================================
% General data      
A = 74.6;               % Heat transfer area [m2]
Vh_tot = 3*0.0889;      % Hot side volume [m3]
Vc_tot = 3*0.1164;      % Cold side volume [m3]
N = 10;                 % Number of cells (NB! Fixed)
%
% Heat transfer coefficients [W/m2*K]
h_h	= 9796.0889611035;  % Hot side
h_c = h_h;              % Cold side
UA_calc = 0.5*h_h*A;
%
% Hot side
V_i_h = Vh_tot/N;	% Hot side cell volume [m3]
A_i_h = A/N;        % Hot side cell area [m2]
%
% Cold side
V_i_c = Vc_tot/N;	% Cold side cell volume [m3]
A_i_c = A/N;		% Cold side cell area [m2]
%
% Wall
V_w = A*0.005;      % Wall volume [m3] (assuming 5 mm thickness)
rho_w = 8030;       % Wall density [kg/m3] (AISI 304)
cp_w = 5030;        % Wall heat capacity [J/kg*K] (AISI 304)
V_i_w = V_w/N;		% Volume of a single wall segment [m3]
A_i_w = A/N;		% Area of a single wall segment [m2]
%
% =========================================================================
%                           INITIAL CONDITIONS
% =========================================================================
% Heat exchangers - Initial temperatures [°C]
Th0 = [58.2004;
       56.4717;
       54.4670;
       52.0953;
       49.3353;
       46.3380;
       43.1856;
       40.1037;
       37.1469;
       34.5342];
Tw0 = [57.3481;
       55.6334;
       53.5077;
       50.9439;
       48.0263;
       44.8928;
       41.7061;
       38.6220;
       35.7771;
       33.2735];
Tc0 = [55.4567;
       53.4936;
       51.0055;
       48.2690;
       45.2510;
       42.1852;
       39.1650;
       36.3565;
       33.8457;
       31.7160];