## ShortPipeShort pipe |

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Fluid libraries have components with two ports that store neither mass nor energy and fulfill the momentum equation between their two ports, e.g., a short pipe. In most cases this means that an equation is present relating the pressure drop between the two ports and the mass flow rate from one to the other port. Since no mass or energy is stored, no differential equations for thermodynamic variables are present. A component model of this type has therefore usually the following structure (see also the implementation in Modelica.Media.Examples.Utilities.ShortPipe):

modelShortPipeimportSI=Modelica.SIunits;importModelica.Media.Examples.Utilities; // parameters defining the pressure drop equationreplaceable packageMedium = Modelica.Media.Interfaces.PartialMedium "Medium model"annotation(choicesAllMatching =true); Utilities.FluidPort_a port_a (redeclare packageMedium = Medium); Utilities.FluidPort_b port_b (redeclare packageMedium = Medium); SI.Pressure dp = port_a.p - port_b.p "Pressure drop"; Medium.BaseProperties medium_a "Medium properties in port_a"; Medium.BaseProperties medium_b "Medium properties in port_b";equation// define media models of the ports medium_a.p = port_a.p; medium_a.h = port_a.h; medium_a.Xi = port_a.Xi; medium_b.p = port_b.p; medium_b.h = port_b.h; medium_b.Xi = port_b.Xi; // Handle reverse and zero flow (semiLinear is a built-in Modelica operator) port_a.H_flow =semiLinear(port_a.m_flow, port_a.h, port_b.h); port_a.mXi_flow =semiLinear(port_a.m_flow, port_a.Xi, port_b.Xi); // Energy, mass and substance mass balance port_a.H_flow + port_b.H_flow = 0; port_a.m_flow + port_b.m_flow = 0; port_a.mXi_flow + port_b.mXi_flow = zeros(Medium.nXi); // Provide equation: port_a.m_flow = f(dp)endShortPipe;

The **semiLinear**(..) operator is basically defined as:

semiLinear(m_flow, ha, hb) = if m_flow ≥ 0 then m_flow*ha else m_flow*hb;

that is, it computes the enthalpy flow rate either from the port_a or from the port_b properties, depending on flow direction. The exact details of this operator are given in ModelicaReference.Operators.'semiLinear()'. Especially, rules are defined in the Modelica specification that m_flow = 0 can be treated in a "meaningful way". Especially, if n fluid components (such as pipes) are connected together and the fluid connector from above is used, a linear system of equations appear between medium1.h, medium2.h, medium3.h, ..., port1.h, port2.h, port3.h, ..., port1.H_flow, port2.H_flow, port3.H_flow, .... The rules for the semiLinear(..) operator allow the following solution of this linear system of equations:

- n = 2 (two components are connected):

The linear system of equations can be analytically solved with the resultmedium1.h = medium2.h = port1.h = port2.h 0 = port1.H_flow + port2.H_flow

Therefore, no problems with zero mass flow rate are present. - n > 2 (more than two components are connected together):

The linear system of equations is solved numerically during simulation. For m_flow = 0, the linear system becomes singular and has an infinite number of solutions. The simulator could use the solution t that is closest to the solution in the previous time step ("least squares solution"). Physically, the solution is determined by diffusion which is usually neglected. If diffusion is included, the linear system is regular.