Simulink - two variables assigned to a flow path

I would like to model and study a simple hydronic system with a handful of pipes randomly branching and merging. I would randomly assign and vary the flow rates and temperatures of the fluid and I would like to observe how those properties change throughout the network.
The two parameters are governed by two simplest expressions, based on whether a node is merging or diverting: q_1 + q_2 = q_3, and q_1 * t_1 + q_2 * t_2 = q_3 * t_3, where q is the flow, and t is the temperature.
I imagine Simscape can do this but it looks like an overkill, and I would like to try and model this by hand in Simulink instead so I can learn the basics better. What would be the best approach to simulate this in Simlink? I am not asking for ready models, just a guidance for which direction to pursue. Everything I tried so far makes me think I need to model parallel flow paths, one for the flow rate q and the other for the temperature t, but I'm wondering if there is a simpler way to combine them inside a common function, or something like that.

2 commentaires

Well, if you are not using Simscape Fluids, if you are doing it directly in Simulink, then the easiest approach might be to model the network as an electrical network. For example, model increasing cross-sectional area of each pipe as the reciprocal of resistance.
I don't even need to size the pipes, do anything with velocities or pressure drops, etc. The only thing I'm after is how the temperature of a pipe/section changes in different parts of the network as flows merge and divert, and that is driven by the flow rate and temperature that I would explicitly assign.

Connectez-vous pour commenter.

Réponses (2)

Yifeng Tang
Yifeng Tang le 6 Mai 2026 à 19:00

0 votes

Hi Milos,
Merging is easy, but diverting isn't, as the latter can't be determined solely based on the inputs to this block.
When merging, you have two sets of inputs, Q1/T1 and Q2/T2. The outputs, Q3 and T3 can be calculated fairly easily as Q3 = Q1 + Q2 and T3 = (Q1*T1+Q2*T2)/(Q3). Conservation of mass & energy, basically.
When diverting, assuming Q3/T3 are inputs, it's reasonable to say T1 = T3 and T2 = T3, but Q1 and Q2 are underdetermined. In reality, Q1 and Q2 depends on what's connected to them, i.e. the flow resistance downstream. In an input/output modeling paradiam, you won't be able to do this without a feedback from downstream, something like a downstream pressure. And keeping doing this, you'll soon deviate from your initial goal: not having to model pressure drop, etc. You can of course "guess" a ratio for Q1 & Q2, but that may not be right :(

2 commentaires

Milos Krsmanovic
Milos Krsmanovic le 10 Mai 2026 à 22:41
Thank you for your reply Yifeng. Perhaps there is another important piece of information I should add. The network is ultimately one big closed loop. The flow rates (and the temperatures) are defined in sufficient number of branches to allow the software to incur the flow rate from a downstream diverging branch. Not sure if that would help but that's how the thing would be set up. So what I effectively need is some sort of iterator that would go through all the branches and sum up/divide the flow, and then iterate again to calculate the temperatures.
Yifeng Tang
Yifeng Tang le 13 Mai 2026 à 18:35
I would suggest that you try to do this with a small, closed loop. This will allow you to see if there is any "hole" in the causality.

Connectez-vous pour commenter.

Milos Krsmanovic
Milos Krsmanovic le 15 Mai 2026 à 2:30

0 votes

Coming back to my originating question, which approach should I take? Should I model parallel flow paths, one for the flow rate q and the other for the temperature t? Or is there a way to combine them by writing a function? And how would I set off the simulation that would iteratively go through all branches (even if their number is small)?

Catégories

En savoir plus sur Foundation and Custom Domains dans Centre d'aide et File Exchange

Produits

Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by