Error in tank block while creating stratified tank with multiple tanks blocks

5 visualizzazioni (ultimi 30 giorni)
Hi,
I have built a solar water heater and I want to model it in simscape. I need to model a stratified tank to improve the model but I didn't find any block in the standard library neither in the community. Before creating mine, I want to try modelling a stratified tank by splitting it in several tank blocks.
Find below the project file and here is a screen of my tank assembly:
And I've got :
=== Simulation (Elapsed: 10 sec) ===
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
['CapteurVerre_test_variable7_echec/Solver Configuration']: At time 0.020166, one or more assertions are triggered. See causes for specific information.
The assertion comes from:
Block path: CapteurVerre_test_variable7_echec/Tank (TL)5
Assert location:
o (location information is protected)
The rub is that i don't know where does the error come from.
Thank for your help.

Risposta accettata

Lucas DELACHARLERIE
Lucas DELACHARLERIE il 18 Feb 2023
Modificato: Lucas DELACHARLERIE il 18 Feb 2023
Finally it was not a good idea to use blocks since it did not correctly model the behavior of a stratified tank. I saw that there were a lot of posts from people who had tried to create the code for a laminated tank. I give you what I did :
component stratifiedTank
% Stratified Tank
% This block implements a stratified tank from the modelling proposed in https://iopscience.iop.org/article/10.1088/1742-6596/2173/1/012005/pdf and adapted by myself
nodes
A = foundation.thermal_liquid.thermal_liquid ;% A:top
B = foundation.thermal_liquid.thermal_liquid ; % B:bottom
H = foundation.thermal.thermal;% H:top
end
parameters
section = {1,"m^2"}; %Section
largeur = {1,"m"};%Largeur
longueur = {1,"m"}; %Longueur
h = {50,"W/(m^2*K)"}; % Coefficient de convection thermique eau/eau
hauteurT = {1,"m"};
Tini1 = {290,"K"};
Tini2 = {290,"K"};
Tini3 = {290,"K"};
cp = {4184,"J/(kg*K)"}
rho = {1000,"kg/m^3"}
end
outputs
out1 = {0,"K"};% T1:bottom
out2 = {0,"K"};% T2:top
out3 = {0,"K"};% T3:top
end
variables
T1 = Tini1;
T2 = Tini2;
T3 = Tini3;
mdot_A = {0, 'kg/s'}; % Mass flow rate into port A
Phi_A = {0, 'kW' }; % Energy flow rate into port A
Q_H = {0, 'kW' }; % Heat flow rate into port H
mdot_B = {0, 'kg/s'}; % Mass flow rate into port B
Phi_B = {0, 'kW' }; % Energy flow rate into port B
mdot1 = {0,"kg/s"}
mdot2 = {0,"kg/s"}
mdot3 = {0,"kg/s"}
F1c = 0
F2c= 0
F3c = 0
F1l = 0
F2l = 0
F3l = 0
T1der = {0,"K/s"}
T2der = {0,"K/s"}
T3der = {0,"K/s"}
end
branches
mdot_A : A.mdot -> *;
mdot_B : B.mdot -> *;
Phi_A : A.Phi -> *;
Phi_B : B.Phi -> *;
Q_H : H.Q -> *;
end
intermediates
g = {9.81,"m/s^2"};
hL = hauteurT/3
end
equations
out1 == T1;
out2 == T2;
out3 == T3;
B.p == A.p + hauteurT*g*rho;
if A.T >= T1
F1c == 1
else
F1c == 0
end
if T1 >= A.T && A.T > T2
F2c == 1
else
F2c == 0
end
if T2 >= A.T && A.T > T3
F3c == 1
else
F3c == 0
end
if B.T<= T3
F3l == 1
else
F3l == 0
end
if T3<B.T && B.T<= T2
F2l == 1
else
F2l == 0
end
if T1<B.T && B.T<= T2
F1l == 1
else
F1l == 0
end
mdot1 == 0
mdot3 == 0
mdot2 == mdot_A*F1c-mdot_B*(F2l+F3l)
T1der == der(T1)
T2der==der(T2)
T3der == der(T3)
mdot_A + mdot_B == 0
% Energy conservation
0 == Phi_A + Phi_B+Q_H
Q_H == h*2*(longueur+largeur)*hL* (3*H.T - T1-T2-T3)
rho*hL*section*cp*(T1der+T2der+T3der) == Q_H
if mdot2 <0
rho * hL * section * T1der== h*2*(longueur+largeur)*hL/cp* (H.T - T1) + F1c * mdot_A * (A.T - T1) + F1l * mdot_B * (B.T - T1) + mdot2*(T1-T2)
else
rho * hL * section * T1der == h*2*(longueur+largeur)*hL/cp * (H.T - T1) + F1c * mdot_A * (A.T - T1) + F1l * mdot_B * (B.T - T1)
end
if mdot2 > 0
if mdot3 <0
rho * hL * section * T2der == h*2*(longueur+largeur)*hL/cp * (H.T - T2) + F2c * mdot_A * (A.T - T2) + F2l * mdot_B * (B.T - T2) + mdot3*(T2-T3) + mdot2 * (T1-T2)
else
rho * hL * section * T2der == h*2*(longueur+largeur)*hL/cp * (H.T - T2) + F2c * mdot_A * (A.T - T2) + F2l * mdot_B * (B.T - T2) + mdot2 * (T1-T2)
end
else
if mdot3 <0
rho * hL * section * T2der == h*2*(longueur+largeur)*hL/cp * (H.T - T2) + F2c * mdot_A * (A.T - T2) + F2l * mdot_B * (B.T - T2) + mdot3*(T2-T3)
else
rho * hL * section * T2der == h*2*(longueur+largeur)*hL/cp * (H.T - T2) + F2c * mdot_A * (A.T - T2) + F2l * mdot_B * (B.T - T2)
end
end
if mdot2 >0
rho * hL * section * T3der == h*2*(longueur+largeur)*hL/cp * (H.T - T3) + F3c * mdot_A * (A.T - T3) + F3l * mdot_B * (B.T - T3) + mdot3*(T2-T3)
else
rho * hL * section * T3der == h*2*(longueur+largeur)*hL/cp * (H.T - T3) + F3c * mdot_A * (A.T - T3) + F3l * mdot_B * (B.T - T3)
end
end
end

Più risposte (2)

TheHandyman Roberto
TheHandyman Roberto il 13 Feb 2023
I did some tests on your model. I ended up identifying that the problem actually came from the pipe. In fact, the error is raised by the tank preceding the pipe. I noticed that the error did not depend on the presence of the pipe but on its characteristics. It's quite strange. In any case, with the default parameters of the pipe it works but by modifying them the error appears again. I don't know if anyone can shed some light on this?

Lucas DELACHARLERIE
Lucas DELACHARLERIE il 14 Feb 2023
I think I found the error. In fact, it is quite simply that the upper tank empties into the lower tank. However, the model is not physically possible. The water that comes out of the bottom tank teleports into the top tank at a rate that usually compensates for the loss. However, the pipe reduces this flow and when the flow is too low, the water accumulates in the lower tank which has no guard preventing infinite filling.

Categorie

Scopri di più su General Applications in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by