This is probably the simplest model of a heated/cooled pipe.
The equations "on paper" are:
min = mout
pin - pout = deltaP=K.min|min|
mout.hout = min.hin + Q
Representing the conservation of mass, momentum and energy.
To understand the implementation and the concept of stream connectors:
equation
section.
The fact is that in Modelica, for each stream connector you need to provide a value for the outgoing stream variable (h_outflow
in this case) when or if the mass flow leaves the connector.
In the pipe case it means that you must provide an expression for port_b.h_outflow
(obviously) and port_a.h_outflow
(for the case of flow reversal).
On the Github Wiki page on Stream connectors, I've provided one more example similar to this.