Modelling a layer of water crossed by a water circulation.

12 vues (au cours des 30 derniers jours)
Lucas DELACHARLERIE
Lucas DELACHARLERIE le 16 Avr 2023
Commenté : Hyuk Choi le 11 Déc 2023
Hello,
I want to create a custom layered tank block. My model does not work so I first established a model of a layer of water crossed by a water circulation.
by making an enthalpy balance
by applying newton's law
With
l the mass capacity of water,
ρ its density,
h the height of the water layer,
S its section,
T its temperature,
Q the incoming heat flux
hn newton's coefficient
Text the outside temperature
Sext the surface exposed to the air
Ta incoming water temperature,
Tb of the outgoing one
and ma and mb the massive incoming and outgoing flows.
And I code this as:
A.p == p0
B.p == A.p + hauteurT*g*rho
T1der == der(T1)
mdot_A + mdot_B == 0
B.T == T1
Q_H == h*2*(longueur+largeur)*hL* (H.T - T1)
cp*rho * hL * section * T1der ==Q_H+Phi_A+Phi_B
The full code is attached.
I'm using this montage to try out my code (also attached)
But I get:
An error occurred while running the simulation and the simulation was terminated
Caused by:
['test/Solver Configuration']: At time 0.000000, one or more assertions are triggered. See causes for specific information.
Temperature at port A must be less than or equal to Maximum valid temperature. The assertion comes from:
Block path: test/Pipe (TL)
Assert location:
o (location information is protected)
o (location information is protected)
Temperature at port B must be greater than or equal to Minimum valid temperature. The assertion comes from:
Block path: test/Pipe (TL)
Assert location:
o (location information is protected)
o (location information is protected)
One of my concerns in the design of my code is the meaning of the variables Phi_A and Phi_B, therefore the energy of the fluid. I used them to replace my terms in . But that seems very inappropriate to me.
I'm completely lost. I have been struggling for several weeks to make my project work. And no one around me can help me. Does someone have an idea ?

Réponse acceptée

Yifeng Tang
Yifeng Tang le 8 Mai 2023
Hi Lucas,
Check out the attached modified .ssc file and a simple test harness. I keep most of the equations from constant volume chamber, and tried to modify the pressure equation for the height and gravity effect.
The fact that you made p_I an intermediate instead of a variable, leads to the problem. The convection port connection has an equation underneath that equate the pressures at the port, and since p_I is part of the equation for A.p and B.p, the system of equations needs the p_I to also be a variable (changes with time).
Another thing I believe needed to be fixed is that the work done by the gravity needs to be part of the energy balance equation. I put an additional term in the equation in the attached .ssc file. There is an open tank (TL) block in Simscape Fluids, and you may refer to its governing equation for energy balance and note the mdot*g*h term.
Good luck and happy modeling!

Plus de réponses (3)

Yifeng Tang
Yifeng Tang le 28 Avr 2023
For the thermal liquid and almost all other fluids domains, you'll see a "port_convection" connection in the component block. Check out the source code of a foundation library pipe (not the one you have in the model) or a constant volume chamber. Towards the end, you should see such a snippet of code. Follow that and define the behavior at the port. If the problem remains after you implement that, please update the model files and we can take another look.
Here is some information on why port behavior needs special treatment and the related numerical scheme: https://www.mathworks.com/help/hydro/ug/simscape-fluids-numerical-scheme.html

Lucas DELACHARLERIE
Lucas DELACHARLERIE le 7 Mai 2023
Thanks, that clarifies a lot for me. So I tried to start from the constant volume chamber code. The basic code works fine for one input and one output in my case. So I modified it to add my assumptions: pressure independent of temperature, no expansion. I got the attached code. It is therefore very similar to the one I had before.
The equations are:
A.p == p_I;
B.p == p_I+hauteur*g*rho_I;
% Assume no thermal resistance
H.T == T_I;
derT==der(T_I);
% Mass conservation
- derT*alpha_I * rho_I * volume == mdot_A + mdot_B;
% Energy conservation
derT*dUdT == Phi_A + Phi_B + Q_H;
And the convection port code :
components (ExternalAccess = none)
convection_A = foundation.thermal_liquid.port_convection(flow_area = area_A, length_scale = sqrt(4*area_A/pi));
convection_B = foundation.thermal_liquid.port_convection(flow_area = area_B, length_scale = sqrt(4*area_B/pi));
end
connections
connect(A, convection_A.port)
connect(B, convection_B.port)
end
% Equate variables for internal component that calculates energy convection at port A
equations
convection_A.mdot == mdot_A;
convection_A.Phi == Phi_A;
convection_A.u_I == u_I;
convection_B.mdot == mdot_B;
convection_B.Phi == Phi_B;
convection_B.u_I == u_I;
end
The problem is that there are 24 variables for 25 equations. I don't see what to change.
I saw that in other codes such as local restriction or flow resistance there was this line in the internal convection part:
convection_A.u_I == convection_B.u_I;
It doesn't have much to do with my modeling but I tried anyway. And by making this modification, I fall back exactly on the error of my first code.

Lucas DELACHARLERIE
Lucas DELACHARLERIE le 14 Mai 2023
Great, it works really well. I understand that I had missed part of the functioning of matlab.
But this model is not my final goal. I would like to make a stratified tank. That's why I already wanted to succeed in modeling a water stratum. The pattern I'm trying to implement is that a tank is decomposed into strata. The incoming fluid is placed in a layer according to its temperature by a conditional test. The layer of water that has the temperature closest to the incoming fluid receives this fluid.
And actually I feel like the stratified tank modeling that I'm trying to follow is behavioral modeling that mimics what happens while the water layer modeling that I have is modeling of physical causes. Am I wrong ?
Anyway, I tried to model what I described and without success. But I wonder before continuing to spend more time on it, if matlab is designed for that?
  2 commentaires
Yifeng Tang
Yifeng Tang le 15 Mai 2023
Starting around 39:00, the speaker will discuss how he used Simscape language to model a stratified storage tank. Hope that gives you some ideas.
Hyuk Choi
Hyuk Choi le 11 Déc 2023
Was your stratification modeling implementation successful?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Upgrading Hydraulic Models to Use Isothermal Liquid Blocks dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by