Simple heat exchanger model problem on simscape

18 visualizzazioni (ultimi 30 giorni)
Hello,
I am trying to do a simple model of heat exchanger following the epsilon-NTU method. I tried different approach but none of them work. My last attempt is the following (with the help of other replies https://fr.mathworks.com/matlabcentral/answers/302891-problem-with-custom-simscape-heat-exchanger-model).
My model can simulate (in a wrong way) under special condition. If I change the initial value, nothing works anymore and even if I just change the priority level (without changing the associated value), nothing works anymore.
I looked and double check everything but I cannot find what is wrong with it...
Any help would be greatly appreciated !
PS: i attached the simulation file
component (Propagation = blocks) HX_model
% Heat Exchanger mod
% Based on the epsilon-NTU method
nodes
A1 = foundation.thermal_liquid.thermal_liquid; % A1:top
B1 = foundation.thermal_liquid.thermal_liquid; % B1:top
B2 = foundation.thermal_liquid.thermal_liquid; % B2:bottom
A2 = foundation.thermal_liquid.thermal_liquid; % A2:bottom
end
parameters
UA = {20000, 'J/s/K'};
HX_length = {5, 'm' }; % Pipe length
HX_section = {0.01, 'm^2'}; % Cross-sectional area
K1 = {0.01, 'bar*s/kg'}; % Coefficient of pressure drop fluid 1
K2 = {0.01, 'bar*s/kg'}; % Coefficient of pressure drop fluid 2
end
parameters(Access=protected)
mdot_min = { 0.0001, 'kg/s' }
end
variables (Access=protected)
mdot_A1 = { 0.01, 'kg/s' }; % Mass flow branch 1
mdot_B1 = { 0.01, 'kg/s' }; % Mass flow branch 2
mdot_A2 = { 0.01, 'kg/s' }; % Mass flow branch 1
mdot_B2 = { 0.01, 'kg/s' }; % Mass flow branch 2
Phi_A1 = {0, 'J/s'}; % Heat flow branch 1 port A
Phi_A2 = {0, 'J/s'}; % Heat flow branch 2 port A
Phi_B1 = {0, 'J/s'}; % Heat flow branch 1 port B
Phi_B2 = {0, 'J/s'}; % Heat flow branch 2 port B
Q = {0, 'J/s'}; % Heat flow between branches
rho1 = {1000, 'kg/m^3'};
rho2 = {1000, 'kg/m^3'};
u1 = {85, 'kJ/kg'};
u2 = {85, 'kJ/kg'};
end
variables
% Internal nodes
p1 = {1, 'bar' }; % Pressure of the liquid volume 1
T1 = {293.15, 'K' }; % Temperature of the liquid volume 1
p2 = {1, 'bar' }; % Pressure of the liquid volume 2
T2 = {293.15, 'K' }; % Temperature of the liquid volume 2
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
% Across variables
p_A1 = A1.p;
p_A2 = A2.p;
T_A1 = A1.T;
T_A2 = A2.T;
p_B1 = B1.p;
p_B2 = B2.p;
T_B1 = B1.T;
T_B2 = B2.T;
% Domain parameters for look up table only
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;
% Liquid properties table lookup upstream
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);
% Partial derivatives of internal energy
% with respect to pressure and temperature at constant volume
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;
% Calcul of heat capacity flow
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;
% Calcul of the ratio of minimum /maximum
Cr = min(C1,C2)/max(C1,C2)
% Calcul of Number of Transfer Unit
NTU = UA/min(C1,C2)
% Calcul of "efficiency"
epsilon = if Cr == 1, NTU/(1+NTU) else (1-exp(-NTU*(1-Cr)))/(1-Cr*exp(-NTU*(1-Cr))) end;
in
% table look up for solving
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);
% Mass balance equation
mdot_A1 + mdot_B1 == (p1.der/ beta1 - T1.der * alpha1) * rho1 * volume;
mdot_A2 + mdot_B2 == (p2.der/ beta2 - T2.der * alpha2) * rho2 * volume;
% Real heat exchanged (Q = epsilon Q_max)
Q == epsilon * min(C1,C2) * (T1 - T2);
% Heat transfer equation
-Q == C1 * (T_A1 - T_B1);
Q == C2 * (T_A2 - T_B2);
% Temperature fluid
T1 == (T_A1 + T_B1) / 2;
T2 == (T_A2 + T_B2) / 2;
% Energy balance equation for each fluid
Q + Phi_A1 + Phi_A2 == p1.der * dUdp1 + T1.der * dUdT1;
Q + Phi_B1 + Phi_B2 == p2.der * dUdp2 + T2.der * dUdT2;
% Pressure loss equation for each fluid
p_A1 - p_B1 == K1 * mdot_A1;
(p_B1+p_A1)/2 == p1;
p_A2 - p_B2 == K2 * mdot_A2;
(p_B2+p_A2)/2 == p2;
end
end
end
  3 Commenti
Sylvain Mathonniere
Sylvain Mathonniere il 3 Giu 2019
Ok, I manage to simulate better using the stiff ODE solver : ode15s. Automatically, simscape was selecting ode23t which did not perform well on my problem. Hope it helps other people as well.
Rohan Kokate
Rohan Kokate il 14 Ott 2020
I was trying to write a similar code and that was really helpful. Thanks!
However, I tried to validate your model with the HeatExchanger(TL) component and the results are not the same. I looked at the equations and everything looks perfect to me. I wonder what the reason might be? Also, the simple heat exhcanger energy balance doesn't seem to work for this model.
Q = mhCph(T1h-T2h) = mcCpc(T2c-T1c)
Can you please correct me if I'm missing something?
Thanks in advance!

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Thermal Liquid Library in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by