Modelling a layer of water crossed by a water circulation.
4 次查看(过去 30 天)
显示 更早的评论
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 ?
0 个评论
采纳的回答
Yifeng Tang
2023-5-8
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!
0 个评论
更多回答(3 个)
Yifeng Tang
2023-4-28
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
0 个评论
Lucas DELACHARLERIE
2023-5-14
2 个评论
Yifeng Tang
2023-5-15
This can be done! Check out this webinar video: https://www.mathworks.com/company/events/videos/hvac-modeling-simulation-with-simulink-and-simscape-1668107646362.html
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!