component (Propagation = blocks) HX
nodes
A1 = foundation.thermal_liquid.thermal_liquid;
B1 = foundation.thermal_liquid.thermal_liquid;
B2 = foundation.thermal_liquid.thermal_liquid;
A2 = foundation.thermal_liquid.thermal_liquid;
end
outputs
heat = { 0.0, 'J/s' };
end
parameters
U = {200, 'W/(m^2)/K'};
A = {10, 'm^2' };
HX_length = {5, 'm' };
HX_section = {0.01, 'm^2'};
K1 = {0.01, 'bar*s/kg'};
K2 = {0.01, 'bar*s/kg'};
dynamic_compressibility = simscape.enum.onoff.on;
end
parameters(Access=protected)
mdot_min = { 0.0001, 'kg/s' }
end
variables (Access=protected)
mdot_A1 = { 0.01, 'kg/s' };
mdot_B1 = { 0.01, 'kg/s' };
mdot_A2 = { 0.01, 'kg/s' };
mdot_B2 = { 0.01, 'kg/s' };
Phi_A1 = {0, 'J/s'};
Phi_A2 = {0, 'J/s'};
Phi_B1 = {0, 'J/s'};
Phi_B2 = {0, 'J/s'};
rho_A1 = {1000, 'kg/m^3'};
rho_A2 = {1000, 'kg/m^3'};
rho_B1 = {1000, 'kg/m^3'};
rho_B2 = {1000, 'kg/m^3'};
T_A1 = {293.15, 'K'};
T_B1 = {293.15, 'K'};
T_A2 = {293.15, 'K'};
T_B2 = {293.15, 'K'};
rho1 = {1000, 'kg/m^3'};
rho2 = {1000, 'kg/m^3'};
u1 = {85, 'kJ/kg'};
u2 = {85, 'kJ/kg'};
u_A1 = {85, 'kJ/kg' };
u_A2 = {85, 'kJ/kg' };
u_B1 = {85, 'kJ/kg' };
u_B2 = {85, 'kJ/kg' };
Q = {1000, 'J/s'};
end
variables
p1 = {value = {1, 'bar'}, priority = priority.high};
T1 = {value = {293.15, 'K'}, priority = priority.high};
p2 = {value = {1, 'bar'}, priority = priority.high};
T2 = {value = {293.15, 'K'}, priority = priority.high};
end
branches
mdot_A1 : A1.mdot -> *;
mdot_B1 : B1.mdot -> *;
mdot_A2 : A2.mdot -> *;
mdot_B2 : B2.mdot -> *;
Phi_A1 : A1.Phi -> *;
Phi_A2 : A2.Phi -> *;
Phi_B1 : B1.Phi -> *;
Phi_B2 : B2.Phi -> *;
end
equations
let
p_A1 = A1.p;
p_A2 = A2.p;
p_B1 = B1.p;
p_B2 = B2.p;
T1_TLU = A1.T_TLU;
p1_TLU = A1.p_TLU;
T2_TLU = A2.T_TLU;
p2_TLU = A2.p_TLU;
cp1_TLU = A1.cp_TLU;
cp2_TLU = A2.cp_TLU;
rho1_TLU = A1.rho_TLU;
rho2_TLU = A2.rho_TLU;
u1_TLU = A1.u_TLU;
u2_TLU = A2.u_TLU;
alpha1_TLU = A1.alpha_TLU;
alpha2_TLU = A2.alpha_TLU;
beta1_TLU = A1.beta_TLU;
beta2_TLU = A2.beta_TLU;
k1_cv = A1.k_cv;
k2_cv = A2.k_cv;
max_aspect_ratio_A1 = A1.max_aspect_ratio;
max_aspect_ratio_B1 = B1.max_aspect_ratio;
max_aspect_ratio_A2 = A2.max_aspect_ratio;
max_aspect_ratio_B2 = B2.max_aspect_ratio;
max_conduction_length_A1 = max_aspect_ratio_A1 * sqrt(4*HX_section/pi);
max_conduction_length_B1 = max_aspect_ratio_B1 * sqrt(4*HX_section/pi);
max_conduction_length_A2 = max_aspect_ratio_A2 * sqrt(4*HX_section/pi);
max_conduction_length_B2 = max_aspect_ratio_B2 * sqrt(4*HX_section/pi);
G_A1 = ...
if le(HX_length/2, max_conduction_length_A1), ...
k1_cv*HX_section/(HX_length/2) ...
else ...
k1_cv*HX_section/max_conduction_length_A1 ...
end;
G_B1 = ...
if le(HX_length/2, max_conduction_length_B1), ...
k1_cv*HX_section/(HX_length/2) ...
else ...
k1_cv*HX_section/max_conduction_length_B1 ...
end;
G_A2 = ...
if le(HX_length/2, max_conduction_length_A2), ...
k2_cv*HX_section/(HX_length/2) ...
else ...
k2_cv*HX_section/max_conduction_length_A2 ...
end;
G_B2 = ...
if le(HX_length/2, max_conduction_length_B2), ...
k2_cv*HX_section/(HX_length/2) ...
else ...
k2_cv*HX_section/max_conduction_length_B2 ...
end;
mdot_abs_A1 = sqrt(mdot_A1^2 + 4*G_A1^2);
mdot_abs_B1 = sqrt(mdot_B1^2 + 4*G_B1^2);
mdot_abs_A2 = sqrt(mdot_A2^2 + 4*G_A2^2);
mdot_abs_B2 = sqrt(mdot_B2^2 + 4*G_B2^2);
step_plus_A1 = (1 + mdot_A1/mdot_abs_A1)/2;
step_plus_B1 = (1 + mdot_B1/mdot_abs_B1)/2;
step_minus_A1 = (1 - mdot_A1/mdot_abs_A1)/2;
step_minus_B1 = (1 - mdot_B1/mdot_abs_B1)/2;
step_plus_A2 = (1 + mdot_A2/mdot_abs_A2)/2;
step_plus_B2 = (1 + mdot_B2/mdot_abs_B2)/2;
step_minus_A2 = (1 - mdot_A2/mdot_abs_A2)/2;
step_minus_B2 = (1 - mdot_B2/mdot_abs_B2)/2;
u_in_A1 = tablelookup(T1_TLU, p1_TLU, u1_TLU, A1.T, p_A1, interpolation=linear, extrapolation=linear);
u_out_A1 = u1;
u_in_B1 = tablelookup(T1_TLU, p1_TLU, u1_TLU, B1.T, p_B1, interpolation=linear, extrapolation=linear);
u_out_B1 = u1;
u_in_A2 = tablelookup(T2_TLU, p2_TLU, u2_TLU, A2.T, p_A2, interpolation=linear, extrapolation=linear);
u_out_A2 = u2;
u_in_B2 = tablelookup(T2_TLU, p2_TLU, u2_TLU, B2.T, p_B2, interpolation=linear, extrapolation=linear);
u_out_B2 = u2;
pv_A1 = mdot_A1/mdot_abs_A1 * p_A1/rho_A1;
pv_B1 = mdot_B1/mdot_abs_B1 * p_B1/rho_B1;
pv_A2 = mdot_A2/mdot_abs_A2 * p_A2/rho_A2;
pv_B2 = mdot_B2/mdot_abs_B2 * p_B2/rho_B2;
cp1 = tablelookup(T1_TLU, p1_TLU, cp1_TLU, T1, p1, interpolation=linear, extrapolation=linear);
cp2 = tablelookup(T2_TLU, p2_TLU, cp2_TLU, T2, p2, interpolation=linear, extrapolation=linear);
beta1 = tablelookup(T1_TLU, p1_TLU, beta1_TLU, T1, p1, interpolation=linear, extrapolation=linear);
beta2 = tablelookup(T2_TLU, p2_TLU, beta2_TLU, T2, p2, interpolation=linear, extrapolation=linear);
alpha1 = tablelookup(T1_TLU, p1_TLU, alpha1_TLU, T1, p1, interpolation=linear, extrapolation=linear);
alpha2 = tablelookup(T2_TLU, p2_TLU, alpha2_TLU, T2, p2, interpolation=linear, extrapolation=linear);
volume = HX_length * HX_section;
h1 = u1 + p1/rho1;
dUdT1 = (cp1 - h1*alpha1) * rho1 * volume;
dUdp1 = (rho1*h1/beta1 - T1*alpha1) * volume;
h2 = u2 + p2/rho2;
dUdT2 = (cp2 - h2*alpha2) * rho2 * volume;
dUdp2 = (rho2*h2/beta2 - T2*alpha2) * volume;
cv_1 = cp1 - beta1 * alpha1^2 * T1 / rho1;
cv_2 = cp2 - beta2 * alpha2^2 * T2 / rho2;
C1 = (abs(mdot_A1) + mdot_min) / abs(abs(mdot_A1) + mdot_min) * (abs(mdot_A1) + mdot_min) * cp1;
C2 = (abs(mdot_A2) + mdot_min) / abs(abs(mdot_A2) + mdot_min) * (abs(mdot_A2) + mdot_min) * cp2;
Cr = min(C1,C2)/max(C1,C2)
NTU = U*A/min(C1,C2)
epsilon = if Cr == 1, NTU/(1+NTU) else (1-exp(-NTU*(1-Cr)))/(1-Cr*exp(-NTU*(1-Cr))) end;
in
rho_A1 == tablelookup(T1_TLU, p1_TLU, rho1_TLU, T_A1, p_A1, interpolation=linear, extrapolation=linear);
rho_B1 == tablelookup(T1_TLU, p1_TLU, rho1_TLU, T_B1, p_B1, interpolation=linear, extrapolation=linear);
rho_A2 == tablelookup(T2_TLU, p2_TLU, rho2_TLU, T_A2, p_A2, interpolation=linear, extrapolation=linear);
rho_B2 == tablelookup(T2_TLU, p2_TLU, rho2_TLU, T_B2, p_B2, interpolation=linear, extrapolation=linear);
Phi_A1/mdot_abs_A1 == step_plus_A1*u_in_A1 - step_minus_A1*u_out_A1 + pv_A1;
Phi_B1/mdot_abs_B1 == step_plus_B1*u_in_B1 - step_minus_B1*u_out_B1 + pv_B1;
Phi_A2/mdot_abs_A2 == step_plus_A2*u_in_A2 - step_minus_A2*u_out_A2 + pv_A2;
Phi_B2/mdot_abs_B2 == step_plus_B2*u_in_B2 - step_minus_B2*u_out_B2 + pv_B2;
u_A1 == step_plus_A1*u_in_A1 + step_minus_A1*u_out_A1;
u_B1 == step_plus_B1*u_in_B1 + step_minus_B1*u_out_B1;
u_A2 == step_plus_A2*u_in_A2 + step_minus_A2*u_out_A2;
u_B2 == step_plus_B2*u_in_B2 + step_minus_B2*u_out_B2;
u_A1 == tablelookup(T1_TLU, p1_TLU, u1_TLU, T_A1, p_A1, interpolation=linear, extrapolation=linear);
u_B1 == tablelookup(T1_TLU, p1_TLU, u1_TLU, T_B1, p_B1, interpolation=linear, extrapolation=linear);
u_A2 == tablelookup(T2_TLU, p2_TLU, u2_TLU, T_A2, p_A2, interpolation=linear, extrapolation=linear);
u_B2 == tablelookup(T2_TLU, p2_TLU, u2_TLU, T_B2, p_B2, interpolation=linear, extrapolation=linear);
rho1 == tablelookup(T1_TLU, p1_TLU, rho1_TLU, T1, p1, interpolation=linear, extrapolation=linear);
rho2 == tablelookup(T2_TLU, p2_TLU, rho2_TLU, T2, p2, interpolation=linear, extrapolation=linear);
u1 == tablelookup(T1_TLU, p1_TLU, u1_TLU, T1, p1, interpolation=linear, extrapolation=linear);
u2 == tablelookup(T2_TLU, p2_TLU, u2_TLU, T2, p2, interpolation=linear, extrapolation=linear);
if dynamic_compressibility == simscape.enum.onoff.off
mdot_A1 + mdot_B1 == 0;
mdot_A2 + mdot_B2 == 0;
Q == epsilon * min(C1,C2) * (T1 - T2);
-Q + Phi_A1 + Phi_B1 == T1.der * cv_1 * rho1* volume;
Q + Phi_A2 + Phi_B2 == T2.der * cv_2 * rho2* volume;
else
mdot_A1 + mdot_B1 == (p1.der/ beta1 - T1.der * alpha1) * rho1 * volume*0.00000001;
mdot_A2 + mdot_B2 == (p2.der/ beta2 - T2.der * alpha2) * rho2 * volume*0.00000001;
Q == epsilon * min(C1,C2) * (T1 - T2);
-Q + Phi_A1 + Phi_B1 == p1.der * dUdp1 + T1.der * dUdT1;
Q + Phi_A2 + Phi_B2 == p2.der * dUdp2 + T2.der * dUdT2;
end
p_A1 - p1 == K1 * mdot_A1;
p_B1 - p1 == K1 * mdot_B1;
p_A2 - p2 == K2 * mdot_A2;
p_B2 - p2 == K2 * mdot_B2;
heat == Q;
end
end