Imagine a fluid component, a pipe, with a typical pressure drop correlation depending on flow rate, friction factor and geometry. The fluid is a liquid. The inlet pressure boundary condition is specified. What do typical Modelica fluid components do to prevent negative (below vacuum) pressure as the pressure drops along their length? How does the logic work if I specify an inlet pressure, but the requirement to have at least vacuum pressure at the outlet demands a higher inlet pressure? Does Modelica throw an error?
The short answer is: "yes, the Modelica compiler throws an error".
A more detailed answer
Usually, Modelica pressure drop components (pipes, valves, flow resistances) do not consider limitations in the fluid properties as they can basically work with any type of fluid, constrained by a medium interface (e.g., PartialMedium
or PartialCondensingGasses
). Moreover, the equations normaly describe the relationship between flow and pressure difference.
When you experience errors related to negative pressure, they often orgininate from the medium model which specifies a range of validity — not necessarily for the pressure itself, though, but perhaps for the temperature range. For an (isenthalpic) valve with a fixed flow rate, inlet pressure and inlet enthalpy, causing a negative outlet pressure (as you describe), the resulting outlet temperature may also become negative. In that case the error could be caused by a violation of the minimum allowed temperature of the medium model.
In practical modelling, it can be beneficial to use pump models which have a finite energy input to the system, rather than fixed flow boundary components like Modelica.Fluid.Sources.MassFlowSource_T
which are infinitely powerful. For example, if you use the latter against a closed*) valve the flow source will, by all means, force the prescribed flow through the valve causing an immense pressure drop, resulting in very high upstream pressure or very low (possibly negative) downstream pressure, depending on the model configuration.
*) note that most Modelica valve models deliberately have a small leakage even when they are closed.
On the other hand, if you run a pump model at full speed against a closed valve the pump will operate at the "shutoff point" of the pump curve which is well-defined and doesn't result in pressure limit violations.
As a final comment, if the pressure (becoming negative) is defined as the type Modelica.Units.SI.AbsolutePressure
, it has a minimum allowed value of 0 Pa. If this is violated, the Modelica compiler (Dymola, OpenModelica) may throw an error or warning.
Generally speaking, you can use three out of four possible boundary conditions in Modelica fluid models. The examples below show a pipe model with two boundary conditions.
Pressure (and temperature/enthalpy) is specified upstream and downstream. Thus, the differential pressure is provided and flow through the pipe is calculated in the pipe model.
The upstream flow and downstream pressure are provided. The upstream pressure is calculated in the pipe model.
The upstream pressure and downstream flow are provided and the downstream pressure is calculated in the pipe model. That is the case that may lead to a negative downstream pressure.
This is the fourth configuration which is not allowed for two reasons
The flow is over-determined since both flow sources will "fight" against each other
No reference pressure is provided. The pipe equations only deal with pressure differences.