You are on page 1of 20

Compositional Modelling of Hydrodynamic

Plants in Simulink∗

Peter Niebert
VERIMAG, 2, av. de Vignate, Gières, France
May 26, 2000

Abstract
In this work, we report on efforts for building a prototype simulink
library for compositional modelling of hydrodynamic networks. The
work is inspired by a cooperation with the EDF, where the desire for
compositional modelling in a causal framework was exposed. The na-
ture of the dynamics of hydrodynamic systems itself is compositional,
and it is desirable to profit from this compositionality for modelling.
This can be of great importance for quick production of prototype
simulation models for understanding system dynamics.
We explain the modelling technique used and how it relates to
other approaches, give examples to indicate the construction of the
prototypic simulink library and comment on experiences gained with
this model.

1 Introduction
In this work, we consider the modelling hydro- and thermodynamic networks
as used for heat transport in thermal powerplants and other technical appli-
This work was supported in part by contract number 9853, “Application de la technique

de représentation en automate hybride aux diagrammes fonctionnels de contrôle-commande


des centrales à EDF” with ELECTRICITE DE FRANCE, and by EC Esprit-LTR Project
26270 VHS.

1
cations. The aim is to develop a compositional modelling framework on the
basis of the popular simulation package Simulink.
A huge variety of tools for the simulation of hydrodynamics in general
and hydrodynamic networks (as in the case study) in particular are avail-
able, often better suited to the domain than a general purpose simulator like
Matlab/Simulink. However, sometimes other aspects of the simulation envi-
ronment – such as the possibility to generate real time code or compatibility
with simulation models of other parts of the system – may make a particular
tool like Matlab/Simulink preferable to other tools.
A characteristic of modelling with Simulink is the underlying dataflow
model. Models are described by block diagrams, where bigger blocks are built
out of smaller blocks, and blocks are connected by signals, which impose a
direction on the influencing sizes of the system. A block realises a function,
transforming an input signal into an output signal, but possibly using and
changing an internal state. Therefore, often blocks are described as pure
functions in the Laplace transform.
The problem in modelling the phenomena occurring in hydraulic networks
is the lack of a direction of causality, i.e. usually the states of a component in
a hydrodynamic network will usually depend on the state of its neighboring
components and vice versa.
This phenomenon has long been known in the context of physical mod-
elling and different solutions have been chosen. One solution is to avoid flow
diagrams as modelling formalism on the whole and instead to use constraint
based modelling methods as in Modelica to specify the system with Kirchhoff
equations for steady state assumptions. The models obtained this way can
be translated back into block diagram models, but at a price. The resulting
models would not be easy to read.
If on the other hand one wants to stick to block diagrams as primary
specification formalism (and Simulink as corresponding tool), two options
arise: One tries to formulate the Kirchhoff equations as algebraic constraints,
which the simulator (integrator) would have to resolve dynamically. As the
number of connections in the system rises, this is no longer realistic.
Alternatively, one can model the hydrodynamic network in the flavor of
current-potential-equations, as has been developed in [2]. In that work, a
network theory is proposed for modelling processes as they occur in chemical
process control, but naturally the techniques can be applied to hydro- and
thermodynamic networks as well.
We will elaborate the concept for the current application in the following

2
sections and outline a prototype simulink library for hydraulic networks,
which we have developed on this basis.

2 Potential Current Vector Modelling


In this section, we outline the modelling method based on opposing potential
and current vectors as was proposed by Gilles in [2].
The purpose of the method is to obtain a compositional hybrid model
for multiphase hydraulic networks, but it is phrased in very general terms
applicable to a wide variety of physical phenomena. The meaning of com-
positionality here essentially is that the topology of the model consisting of
blocks and connections maps straightly onto the topology of the actual phys-
ical plant. Gilles furthermore proposes a hierarchical modelling technique
in that the different phases contained within a liquid in a container are in-
terconnected in a similar way as are the physical components on a higher
level.
A hydrodynamic network consists of components as containers, pipes,
pumps etc, and connections between these components. The ideology be-
hind this partitioning of the system is that the components contain mass
and energy in different forms whereas the connections define the interaction
between the contents of the components but do not contain mass or energy
themselves. Whether one wants to look at a valve as a component or as a
connection is a matter of presentation. Gilles proposes to look at valves as
connections and we follow this approach.
The modelling technique follows the idea that the potentials of the com-
ponents lead to a current between them through the connection. Thus in a
flow diagram model, the connection takes the potentials of the components
as inputs and computes a resulting current. The components take the cur-
rent as input and thus compute the change in potential. Figure 1 shows a
general example.
The potentials pi and currents Ii may of course be vectorial. The approach
allows compositional specification, because the physical preservation laws
need only be established locally, i.e. by the connection element (sum of energy
flows must equal zero) and by each component individually (the integration
of mass energy inflows and outflows determines the amount of energy within
the component).
A component itself may be unstructured, thus have its internal state

3
pi pj
connecting
Ci element Cj
Ii Ij

Figure 1: Two connected components

quitrepresented by a few scalar variables (contained mass, energy, . . . ) or it


may have an internal structure. The internal structure then is given again by
components and interconnections on a lower level. A full hierarchy of mod-
elling levels is thus possible in a homogenous fashion. For instance, in Figure
2 the inner structure of a pipe is given by three segments. This approach

S1 S2 S3

Figure 2: A pipe consisting of three segments

is furthermore related to modelling in the style of finite element methods.


The unrealisable limit is a continuous vector field where the infinitesimally
small connections are represented by partial differential equations. We will
however always stick to the discrete structure indicated above.
At the bottom of the hierarchy we thus find unstructured atomic compo-
nents with scalar energy levels etc. Naturally, at this level we have to make
use of a simplified model of behaviour. It will have to take into account all
currents at the connections and assumptions about its behaviour. To come
up with simulation models, we will typically assume homogeneous distribu-
tion of mass, energy, etc. within an atomic component, as is usually done in
finite element modelling.
The latter assumption implies that the connections – while principally
bidirectional – will have to take into account the direction of flow of ma-

4
terial in a switched manner. Consider for instance the case that there is
water flowing from component 1 to component 2. Then the thermal energy
in component 2 results as immediate mixture of the thermal energy of the
container contents and the inflow, whereas the energy loss of component 1
depends only on the outflow but not the conditions within component 2.
The above way of modelling unavoidably introduces imprecisions rela-
tively to the the continuous modelling via partial differential equations: The
resulting behaviour of the model will usually differ from the behaviour of the
continuous model.
This means that only the last step in the modelling – the modelling of the
atomic components and connections differs from the modelling for simulation.
However, for purposes of simulation for technical applications, the introduced
error will often be small compared to the imprecisions of the actual physical
system. Robust control systems should not rely on these imprecisions in
order to function correctly.
In the following section, we explain in detail the mathematical model of
atomic components used for hydro- and thermodynamic networks.

3 Hydrodynamic Components and Connec-


tions
In the following we present a model for the behaviour of atomic components
or phases in a hydro- and thermodynamic network.effects.
Hundreds of years of hydrodynamics have produced a sophisticated ana-
lytic theory based on very simple mechanic laws and assumptions. For those
unfamiliar with hydrodynamic simulation models, it may come as a little sur-
prise that very little of this theory is needed for the compositional modelling.
This is simply due to the fact that the complexity dealt with by the analytic
theory results from the connections and is thus implicit in our formalism.
There is, however, one complicating factor which we have to take into ac-
count, which analytic theory can neglect, and that is the thermodynamics of
liquid water.

3.1 The basic physical model


The physical aspects of the state of a phase which we will take into account
are as follows:

5
• the kind of the phase: liquid water, vapour, air, etc.

• its volume and more generally the geometry of the component or the
phase;

• its mass;

• its potential energy given as kinetic energy, enthalpy (warmth), eleva-


tion (relative to the connections);

– The enthalpy can be represented as average temperature, as the


mass is given and the kind of the phase implies its specific heat
capacity.
– The potential energy is already represented by the geometry and
the mass (which is assumed to be homogeniously distributed in
the system).
– The kinetic energy is determined by the flow speeds at the con-
nections. Since we will keep track of the flows at the connections,
it need not be represented explicitely in the components.

We distinguish three kinds of connections: liquid connections, thermal


connections and phase connections. For connections of two components
which allow the flow of liquid as well as heat transfer by conduction, two
distinct connections would thus be required in the modelling. We will com-
pletely ignore heat transfer by diffusion due to different density.
For the liquid connection between two components, we state:

• There is a flow of mass and enthalpy.

• This flow is sufficient to determine the change of mass and enthalpy in


the components.

• Enthalpy flows with the mass, and is thus determined by

– the mass flow;


– the direction of the mass flow;
– the temperature of the mass in the component, from which the
flow is going outwards.

6
For a thermal connection we assume that the two components are ther-
mally connected by a heat conducting medium.

• The flow of enthalpy through a thermal connection is determined by


its physical properties (e.g. conductivity, surface and thickness) and by
the temperature differences between the connected components.

• Thermal connections do not store heat. If the heat capacity of a ther-


mal connection plays a role than it should be modeled as a (solid)
component of its own right with two thermal connections to the adja-
cent components.

For the connection between a vapour phase and a liquid phase in an


atomic component, we state:

• There is a flow of mass (changing the phase, i.e. evaporating or con-


densating).

• With the mass, there is a flow of enthalpy as before.

• There is a “flow” of volume, i.e. the distribution of the volume of the


component between the liquid and the gazeous phase may change.

We have thus determined the essential variables for atomic components


as well as for the connections. What is missing is a mathematical precision
of the mutual dependency between components and connections.
Afterwards, we will go through some concrete examples.

3.2 The mutual dependency of components and con-


nections.
The dependency of the state of components relatively to the computed flows
of the connection is very simple: The flows integrated over time give the
states. The integration of the inflow of mass gives the mass, and the integra-
tion of the inflow of enthalpy gives the enthalpy. Thus the causal connection
from current to potential is straight forward.
The converse direction is much harder, and it is here that the unavoidable
modelling mistakes become visible. Put otherwise, it is here where modelling
decisions have to be taken. We have chosen the following approach:

7
• We make the mass flow a variable of the connection. The mass flows at
the connections of a pipe thus implicitely describe the kinetic energy
of the liquid in the pipe.
The development of the mass flow is then determined via the local
force, more precisely the force gradient at the connection. Given the
connection area and the definition of pressure as force per area, we
can thus determine the flow (in mass per second) as integration of the
average pressure gradient multiplied by the connection surface.
An important advantage of this modelling decision (instead of keeping
track of the acceleration and passing this information to the compo-
nents) is that it allows to close connections (set the flow to zero) without
delay. For the derivative, this would have to be modelled by a Dirac
pulse, which is not supported by Simulink.

• The second – and most crude – design decision coming into the picture
is how to determine the pressure gradient at the connection out of the
mass, temperature and geometry of the connected components.
We thus decided to determine the average pressure in the components
according to an equation of state for liquid water, i.e. a thermodynamic
law relating density, temperature and pressure of water. Such an equa-
tion of state gives us two functions, a function to calculate the density
of water from its temperature and pressure and dually its pressure out
of the temperature and the density. This is elaborated in Section 3.3.

• Since the density and temperature in a component is assumed to be


homogeneous, so is to be the pressure. This yealds a contradictory and
useless infinite pressure gradient at the connections. In reality also, the
pressure varies continuously at the connections of the components and
within the components.
Hence, we approximate the pressure gradient by assuming a linear vari-
ation of the pressure between the centers of the components (where we
assume the average pressure to hold). If one thinks about this in de-
tail, it gives rise to many contradictions. This is not the point, it is an
approximative estimate.

• The resulting design decision is to calculate the average pressure within


the compontents and pass this information together with the distance

8
from the gravitational center to the connection. Within the connection,
the corresponding information concerning both components is com-
bined by the assumption of a constant pressure gradient between the
centers of the components.
• All of the above is sufficient for the case of horizontal, frictionless and
passive pipes. For the case of pipes passing an elevation, for the case
where viscous friction is modelled, and for active components such as
pumps this is not sufficient.
From an analytic point of view, all of the above cases lead to a change in
pressure between the ends of a pipe. Friction makes the pressure drop
in the direction of the flow. An active pump raises the pressure in the
pumping direction, and gravity raises the pressure in the downwards
direction. In order to model these phenomena, we superimpose their
pressure effects over the mean pressure.
• The flow of enthalpy as mentioned follows the flow of mass. Within
the connection we thus first determine the direction of the flow and
from the temperature of the component with the outflow we derive the
enthalpy flow.
For thermal connections, the modelling technique is simpler, because the
transfer of heat uses a medium with a certain conductivity, thickness and
connection area. Using simple laws of thermal conduction, we thus determine
the enthalpy flow from the differences of temperatures.
This is consistent with the assumption of equally distributed temperature
within a component. Still, this contains the systematic modelling error, that
the change in thermal energy is immediately visible at all other connections
of a component as well.

3.3 Equation of state for liquid water


Thermodynamics (among other subjects) provides equations of state. The
equation of state for an ideal gas is prominent in every introduction to
physics: p = ρRS T , where p is the pressure, ρ the density, T the absolute
temperature and RS a specific gas constant (depending on the molecular
mass of the gas).
Less well known to the general scientific public are equations of state for
substances other than ideal gases, in particular for liquids. The assumption of

9
incompressibility of liquids like water is indeed inconsistent with an equation
of state.
Nevertheless, equations of state for water have been formulated to de-
scribe the relation of the three sizes (pressure, density, temperature) within
certain ranges. These equations are approximations using certain assump-
tions on the form of the equation and have several coefficients (playing a
similar role as RS for an ideal gas) which have been determined by curve
fitting experimentally obtained triples.
For the purpose of demonstrating the feasability of the approach, we
have chosen to use a simple equation, the UNESCO equation of state for
seawater (IES80). The reason for chosing this equation was an available
matlab function for computing the density from pressure, temperature and
salinity.
We set salinity to zero and for the resulting simplified function we also
(using a computer algebra system) computed the inverse function to deter-
mine the pressure from density and temperature at salinity zero.
As its name saysm this equation is meant to approximate the equation of
state for water at conditions which occur in the seas of earth. Its applicability
is thus limited and the choice is a compromise.
There are, however, other approximations available such as the recently
published [3], which claims to be very exact over a wide range of pressures
and temperatures.
The matlab code for computing the pressure is given in the appendix.

4 The Matlab/Simulink models


A Simulink library is a collection of reusable Simulink blocks. Using drag
and drop they can be included in a model. If the library link, i.e. the link
from the block in the model to the library component persists, then changes
to the block in the library will also affect the instance of the block in the
model.
In the library at the time of writing, we have a collection of atomic compo-
nents, i.e. pipes in some variations (with and without friction, with a thermal
connection), forks, i.e. components with three and with four connections, ba-
sic versions of a valve and a pump, a pressure source. It has blocks for liquid
as well as for thermal connections.
And it contains a few structured blocks, such as a heating (which is a

10
pipe to which energy can be added to heat it) and a counter-current heat
exchanger. These blocks are included as demonstration of the possibility
to compose a collection of locally connected components to a subsystem
independently from the rest of the system.
Most components in the library are masked and allow the specification of
some parameters, typically physical dimensions of the component as well as
information about the initial state (initial temperature and pressure).
Completely lacking at the moment are gaseous phases. As a compensa-
tion, there is a components called water column which represents the liquid
phase of an cylinder open to atmospheric pressure and with a liquid connec-
tion at the bottom.
In the following subsections we show some examples of components in
the library to explain its structure. We assume basic familiarity with block
diagrams.
A complete print of the library is attached in the appendix.

4.1 A frictionless pipe


In Figure 3, the Simulink model of a frictionless pipe is depicted. It is
specified by its diameter, length and elevation (deltaheight). It takes two
vectorial inputs to represent the inflows of mass and thermal energy at the
ends of the pipe. Outflows are represented as negative inflows.
The inflows are added and then integrated to obtain the internal state of
the component, its mass and enthalpy. “Enthalpy” is represented as mass (in
kg) times temperature (in degrees Celsius). Since the substance is assumed
to be plain water with known properties, this information is sufficient and
easy to compute.
The block named transformation transforms mass, enthalpy and volume
to density (mass per volume) temperature (“enthalpy” per mass), and pres-
sure calculated by a matlab function from temperature and density.
The gravitational center of the pipe is found in the middle, at length/2.
Pressure, temperature and this distance from the middle are then combined
to output vectors.
Since the pipe rises from end 1 to end 2, hydrostatics tells us that there is
a pressure drop from end 1 to end 2. This pressure drop is superimposed over
the medium pressure and added to or substracted from the output pressures
accordingly.

11
massinit

initial mass

1 enthalpy flow 1
Demux
1
In1 mass flow 1
mass pressure
s
mass volume volume temperature

enthalpy density
1 transformation
2 Demux enthalpy flow 2
s
In2 mass flow 2
enthalpy

tempinit
initial enthalpy 1
initial temperature
Out1

length/2

halflength

deltaheight 0.5
9.81
pressure drop due to rise distribute
grav. acceleration (m/s^2)

2
Out2

Figure 3: A frictionless pipe

4.2 Liquid and thermal connections


In Figure 4, a liquid connection is shown. It takes two vectorial inputs, triples
of pressure, temperature and distance and outputs two vectorial outputs of
dimension two (mass flow, enthalpy flow).
First, the pressure gradient is calculated, then multiplied by the connec-
tion area to give the force gradient. The integration of the force gradient
gives the mass flow.
To determine the enthalpy flowing with the mass, the direction of flow is
first determined and the temperature of the component with the outflow is
chosen and multiplied with the mass flow.
The thermal connection shown in Figure 5 simply takes a temperature
difference and transforms it according to the conductivity lambda of the
medium, the area A, the thickness length of the medium and finally the
heat capacity of water to an enthalpy flow.

12
vectorial inputs: pressure temperature distance

[p1]
In1 [p2]
1 Demux [T1]
signals 1 2 Demux [T2]
[d1] signals 2
In2 [d2]
[d1]

[d2]

1 [T1]
[p1]
s
force gradient [T2]
[p2] negative pressure gradient flow flow temperature
enthalpy flow −1 1
Out1
A qinit Gain
2
connection area initial flow
Out2

Figure 4: A liquid connection

1
T1

2
−1 1
T2
Out1
enthalpy flow Gain
(lambda*A)/(length*cwater) 2
Out2

Figure 5: A thermal connection

13
4.3 Example: A countercurrent heater
As an example of a complex component, Figure 6 shows a countercurrent
heat exchanger. It is modelled by two pipes of three segments, which are
connected by liquid connections. The parallel segments are linked by thermal
connections.
Supposing that a hot current flows through the upper branch from left
to right and a cold current flows through the lower branch from right to left,
then the resulting heat exchange will be stronger due to higher temperature
differences along the pipes (i.e. in the segments) than if the currents both
flow in the same direction.

OutA1
1 2
OutA2
Out1

Out2

In1

In2

Out1

Out2

In1

In2

Out1

Out2
liquid liquid
pipe with friction pipe with friction pipe with friction
connect connect
and thermal connection and thermal connection and thermal connection
Out1

Out2

Out1

Out2
In1

In2

In3

In1

In2

In3

In1

In2

In3
InA2
1 2
InA1
T1

T2

T1

T2

T1

T2
thermal thermal thermal
connect connect connect
Out1

Out2

Out1

Out2

Out1

OutB1 Out2

3 4
Out1

Out2

In1

In2

Out1

Out2

In1

In2

Out1

Out2
OutB2
liquid liquid
pipe with friction pipe with friction pipe with friction
connect connect
and thermal connection and thermal connection and thermal connection
Out1

Out2

Out1

Out2
In1

In2

In3

In1

In2

In3

In1

In2

In3

InB2
3 4
InB1

Figure 6: A counter current heat exchanger

5 Practical aspects of executing the simula-


tion models
In the following, we address some practical issues related to the simulation
models in Simulink.

14
5.1 Appropriate Integration Methods
The modelling technique proposed here is meant for easy compomisition of
understandable simulink models. Unfortunately, the simulation models have
properties which sometimes make the simulation, i.e. numerical integration
slow (not generally suited for the generation of real time code). Neverthe-
less, some measures can be taken which help to come up with sufficiently
performing models.
A key problem in the modelling technique is due to the presence of oscil-
lations of relatively high frequency with relatively low amplitude, which do
not contribute to the macroscopic behaviour of the models. Models with this
property are called stiff. A variable step integrator thus has to reduce the
step size to deal with the high frequency disturbancies unless they vanish to
a magnitude below integration precision.
We usually obtained the best results using Simulinks integration method
ode15s with maximum order 2.
The oscillations are due to the modelling of compressibility, which we
introduced in order to obtain models compositionally. Intuitively, these os-
cillations are due to a discrepancy between the pressure as calculated from
density and the pressure which reflects the macroscopic state of the system
(macroscopic flows, . . . ).
The phenomenon typically occurs at the beginning of a simulation, where
the originally specified pressure (and derived density) is ill chosen, i.e. re-
quires an immediate and strong change of the global system state. This
becomes visible by strongly oscillating pressures and slow integration. Usu-
ally, the oscillation disappears after a short period (simulation time) due to
various aspects of friction in the system. Then the microscopic oscillation
becomes insignificant and the pressure exposes only the macroscopic oscil-
lations. Correspondingly, the integration step size remains large and the
simulation is fast.
For reuse of the simulation model, the results of a first run can be used to
improve the guess of the initial pressure by estimating the mean amplitude
of the microscopic oscillation. A second simulation will then expose a much
shorter period of microscopic oscillation.
Alternatively, a steady state analysis could be used to find better guesses
of the initial parameters.

15
5.2 Importance of friction
As has been mentioned in the previous section, the microscopic oscillations
due to the modelled compressibility of water consume computation time,
unless they disappear due to friction.
While models without friction usually have a simpler look, their simu-
lation with our approach is not neccessarily more efficient. The calculation
overhead due to computations of friction factors etc. is merited by reduced
microscopic oscillation and a consequently much bigger integration step size.
Thus, unless the behaviour of systems without friction is explicitly re-
quested, including friction is a better idea.

5.3 Potential for increased performance


The calculation of pressure from density is the most frequently called func-
tion in the simulation, most certainly contributing substancially to the com-
putation time requirements: Currently, it is realised as a Matlab function
calculating several polynomials of degree upto 16. Execution of matlab func-
tions is slow and the degree of the polynomial is not justified by the precision
of the approximation.
The formula used to calculate pressure from water temperature and den-
sity is derived by precisely inverting the IES80 equation of state, which orig-
inally had a much lower degree.
Hence, there are two aspects, by which the calculation of the pressure can
be speeded up:

• Improving the formula(s) to calculate approximatively the equation of


state of water. For instance, there is a recent proposal in [3] for a new
and very precise equation of state.

• Realising the formulas as compiled c-functions to interact with Matlab.

5.4 Pitfalls in designing simulink models


We have designed the Simulink hydro- and thermodynamic library with the
aim of optical transparency to avoid modelling errors.
However, due to limitations of Simulink, it is still possible to compose
models which are not faulty at first sight:

16
• Among the most likely errors to occur is an inconsistency of the param-
eters of the two components linked by a connection and the parameter
of the connection itself. It is currently not detected, whether the values
– in particular the area of the connection – are inconsistent.
If they are not, then usually the simulation will produce strange results
and it is not easy to spot the source of the error.
This problem could be solved by making the connection area an output
parameter of the component, so that the connection can compare the
two connection areas and raise an alarm (and stop the simulation), if
they differ.

• The current implementation does not test for over- and underflows of
containers (i.e. water columns). Overflows will just be ignored, under-
flows with negative signs will not produce meaningful results.
Again, testing for error conditions of this kind in the component and
halting the simulation would be an acceptable solution.

6 Modelling Alternatives
The modelling method we presented is not the only option for compositional
modelling. In this section, we address two other approaches, one similar is
spirit (connection-component modelling), the other classical analytical.
Since we started with the connection-component style modelling we present
in Section 6.2 on the basis of analytical models, we will first discuss the clas-
sical approach.

6.1 Alternative 1: Kirchhoff Equations


Analytic fluid dynamics for onedimensional networks uses a network theory
similar to electric circuits and is based on the following physical assumptions:

• The incompressibility and equally distributed mass (density) within a


liquid.

• The forces working on the liquid are described by pressure (force per
area), gravity, and resistance caused by viscous friction.

17
The interplay of the different force, together with the law of preser-
vation of energy, lead to the well-known Bernoulli equation, which
however comes in many variations depending on the detail of physi-
cal modeling. E.g. under the assumption of constant density, in the
absence of viscous friction, and under the assumption of steady state
(i.e. no changes in the flow direction), the Bernoulli equation takes the
2 p
simple form: v2g +z + ρg = const, where v is the vectorial velocity of flow
at a particular point in the liquid, g is the gravitational acceleration,
z is the elevation relative to an arbitrarily chosen reference height, p is
the pressure at this point and ρ is the density of the liquid.
Taking furthermore the force accelerating the liquid as a whole into
account (which is zero under the R assumption of steady flow), the equa-
2 p
tion is changed to v2g + z + ρg + g1 dvdtx dx = const, where dvdtx is the local
acceleration of the flow with time.
Furthermore, the force of resistance can/has to be added. Viscous fric-
tion follows complex physical laws, in particular, Newtonian liquids ex-
pose a non-continuous transition from laminar to turbulent flow, where
the resistance force is stronger under conditions of turbulent flow.
A compositional modelling technique on this basis thus describes the re-
lations of pressures and mass flow within a component individually and then
adds the global constraints, Kirchhoff laws, that
• The pressure at a connection is identical for the connected components.
• The sum of the flows of mass (and enthalpy) at a connection equals
zero.
A model described in this way is not directly suitable for simulation (nu-
meric integretation). A static preparation phase is required beforehand as is
done for instance by Dymola. A Modelica library for hydrodynamics specified
in this way is freely available [1].

6.2 Alternative 2: incompressible water, mass-spring


connections
In search for a similarly compositional modelling technique for the flow di-
agram based user interface of Simulink, we have investigated the possibility
of imposing the Kirchhoff laws by connection components, which

18
• Take the flows of the connected components as input.

• Calculate a pressure as output and regulate it so that the sum of the


flows approaches zero.
A naive approach is to try to impose this by an algebraic constraint.
This however, is bound to fail, not only because the algorithms used by
Simulink in order to treat algebraic loops are not capable of achieving dynam-
ically what the analytic approach mentioned in Section 6.1 does statically,
but also, because the system has singularities whereever a switching (opening
or closing of a valve, starting the system from a resting position) occurs.
On the other hand, the pressure can also be adapted dynamically with an
intuitive model of a flexible connection in mind. The connection is specified
by:

• an initial pressure and initial mass. These serve as initial guess of the
pressure at the vertex in the network and as an intuitive measure for
the flexibility of the connection. The less mass is involved, the more
rigid is the connection.

• integration of the flows at the connection to determine the mass in the


connection.

• A simple minded approximation for the compressibility of water to


calculate from initial pressure and mass and current mass the current
pressure.
The resulting system as a consequence does not always respect the Kirch-
hoff law that the sum of the flows equals zero. Sometimes there will be a
small inflow into the connection (and the pressure will rise), sometimes a
small outflow (and the pressure will drop). Usually however, the sum of
flows will be small compared to the individual flows which means that the
flows are essentially passed through the connection as Kirchhoff requires.
Technically, the integrator used can be seen as a controller aimed to
keep the the inflow into the connection at zero (where the Kirchhoff law is
satisfied). It can furthermore be refined to behave better in simulations.
The experience with this modelling technique, although physically less
intuitive then the technique based on potential current vector modelling, are
quite acceptable. Moreover, within the components the analytic laws for
inhomogenous pressure distribution due to gravity, acceleration and friction

19
can be maintained. As a consequence, the models of the components are a
bit more involved, i.e. analytical, and the simulation results will be closer to
analytic models.
Moreover, the description of the components as functions is inverse: they
take pressures as inputs and compute currents as outputs. The technique
can thus be seen as dual to potential current vector modelling.

7 Conclusions
We have elaborated a way of compositionally modelling hydro- and ther-
modynamic networks with Simulink flow diagrams in the spirit of potential
current vector modelling. The resulting Simulink library prototype can be
used to rapidly compose reference models of such networks.
The emphasis is on rapid prototyping, as a consequence the resulting sim-
ulation models will not perform optimally. Moreover, some physical aspects
have been incorporated into the formalism which often play a minor role in
practice. We consider its main uses in experimenting with models before
actually taking the effort of developing an efficient model and for didactic
presentation of models.

References
[1] H. Elmquist et al. Modelica – A unified object-oriented language for
physical systems modelling, 1999. TUTORIAL and RATIONALE.

[2] Ernst Dieter Gilles. Netzwerktheorie verfahrenstechnischer prozesse.


Chemie Ingenieur Technik, 69(8197):1053–1065, 1997. Übersichtsbeitrag.

[3] C.A. Jeffery and P.H.Austin. A new analytic equation of state for liquid
water. Journal of Chemical Physics, 1999.

[4] The Math Works Inc. Simulink – Dynamic System Simulation for MAT-
LAB, 1999.

[5] Hung V. Vu and Ramin Esfandiari. Dynamic Systems: Modeling and


Analysis. McGraw - Hill, 1996.

20