0% found this document useful (0 votes)
9 views10 pages

Session3a Paper5

Uploaded by

Alex L
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

Session3a Paper5

Uploaded by

Alex L
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

The DLR ThermoFluidStream Library

Dirk Zimmer1 Michael Meißner1 Niels Weber1


1 German Aerospace Center (DLR), Germany
{dirk.zimmer,michael.meissner,niels.weber}@dlr.de

Abstract this paper implements such an alternative that is favorable


for many applications. It enables the modeler to formu-
This paper introduces the DLR Thermofluid Stream Li- late a system of thermofluid streams in a robustly solvable
brary: a free open-source library for the robust modeling form using only a few additional state variables.
of complex thermofluid architectures. Designed to be easy
While robustness is one major design target for the li-
to use, easy to adapt and enriched by a number of exam-
brary, the ability to adapt the library to specific needs is
ples, this library contains the fundamental components for
another one. The set of potential applications is very large
many different applications such as thermal management
and its elements may differ in their underlying assump-
of electric cars, power plants, or building physics.
tions. Hence any concise set of components cannot real-
Keywords: Thermal fluids, Thermal process systems, Ro-
istically be expected to provide full coverage. Instead, the
bust modeling, Heat exchangers, Open source software
library shall provide solid base components that are easy
1 Introduction to read and that can then be adapted to the specific needs
that are raised by the user’s application field.
Streams of thermofluids form the basis of many natural Robustness and adaptiveness are hence the two main
and technical systems. Power plants, environmental con- points what shall make the library competitive with al-
trol systems, refrigerators can all be represented as ther- ready existing solution in this domain such as other free,
modynamic processes where components such as pumps, commercial, or proprietary Modelica libraries (Casella
heat exchangers, or valves manipulate the stream of a 2005; Casella et al. 2006; Franke, Casella, Sielemann, et
working fluid flowing from the component inlet to its out- al. 2009; El Hefni and Bouskela 2014), or non-Modelica
let. A computationally very attractive formulation is to ex- M&S tools (EcosimPro 2021; Process Systems Enterprise
press this coupling of inlets and outlets by using algebraic 2021) or even our own previous solutions (Sielemann et
equations in the form: al. 2011). These libraries mostly represent either an alge-
braic modeling style or an ODE modeling style. The paper
Θout = g(Θin , ṁ, x) (1)
(Zimmer 2020) offers a comparison of our DAE-based ap-
with Θ being a tuple representing the thermodynamic proach to such modeling styles.
state of the medium, ṁ being the mass-flow rate and x But before we recapitulate the underlying robust com-
the internal state vector of the component (e.g. rotational putational scheme and take a look at the library, let us look
speed of a pump). at an introductory example.
Such an algebraic coupling (as simple as it may be) im-
1.1 Introductory example
plies a dramatic idealization of the actual underlying phys-
ical system. For instance, we implicitly assume that up- Figure 1 contains an example application of an automo-
stream changes in pressure and enthalpy take immediate tive battery, drive-chain and cabin thermal control system.
effect downstream. Not only may such an assumption be This represents a fairly complex system with several loops
completely inadequate under certain circumstances also and three different media. Amongst other items, there are
these idealizations give rise to highly non-linear equation several switches to change the flow topology and a vapor
systems where there might be multiple solutions or none cycle with two parallel evaporators. Although the example
at all. Even if there is a unique solution, it may be very itself is not part of the library, it is entirely build out of its
difficult to retrieve. components, some of which internally combine multiple
For these reasons, the modeling of thermofluid streams valve models to realize switches for bypasses and loops.
is rarely performed in purely algebraic fashion. The mod- For the sake of clarity, we have removed the control ele-
eler may want to break the algebraic system down to feasi- ments from the diagram.
ble complexity (for instance by adding volume elements), The model diagram depicts some important distinc-
the modeler may want to model thermal time-constants tions from the fluid library as part of the Modelica Stan-
(for instance by adding volume elements) or transport de- dard Library (MSL) (Franke, Casella, Sielemann, et al.
lay (for instance by adding volume elements). However, 2009). First of all, this library features dedicated mod-
for many applications, there is something more clever than els for junctions and splitters and abstains from (ab-)using
just adding volume elements. The library we present in the Modelica connector for this purpose. Second, the de-

DOI Proceedings of the 14th International Modelica Conference 225


10.3384/ecp21181225 September 20-24, 2021, Linköping, Sweden
226
port_PTC

« «
« «

«
«
«
N ... ... 2 1
1 2 ... ... N
«

A
«
1 2 ... ... N
A

B
B
1 2 ... ... N

«
«
«
The DLR ThermoFluidStream Library

«
«
«
port_DCDC B
N ... ... 2 1

A
B

B
A B
A

A
B

B B
port_batteryHeater port_battery
A A

September 20-24, 2021, Linköping, Sweden


port_driveChain

Proceedings of the 14th International Modelica Conference


port_charger

Figure 1. Example simulation of an automotive battery, drive-chain and cabin thermal control system. The glycol-water loop (magenta) is cooling battery, DC-DC converter, charger
and drive-chain. A four-way switch can split it into two separate loops instead of the combined loop that is shown. If needed, the loop is cooled by a radiator against fresh air (blue).
Additionally it can be cooled with a R134a vapor-cycle (orange). The vapor-cycle is also cooling air going to the vehicle cabin (green) and therefore contains two parallel evaporators,
that can independently be shut off by two valves when not in use. It is cooled against fresh air with a condenser. Furthermore, it contains receiver, accumulator and an expansion valve.
Battery and cabin-air can be heated with the battery heater and PTC respectively. Both heat exchangeers of the glycol loop can be bypassed if not in use. One of the fresh-air streams and
the cabin-air stream is supported by a fan, while the other fresh-air stream is driven purely by dynamic pressure from the vehicle speed.

10.3384/ecp21181225
DOI
Session 3A: Libraries

fault connector type is directional, clearly indicating the whereas p̂ is introduced as steady-mass flow pressure
direction of the stream. The library offers a solution for (since p̂ = p if d ṁ/dt = 0). Alongside a stream we ap-
undirected flows too but it is supposed to be used only proximate the thermodynamic state by using p̂ instead of
when inevitable. Third, the modeler shall break loops p, accepting a (mostly) small error for unsteady flow con-
(not merely bypasses, but actual loops) using volume ele- ditions. At each boundary we compensate the accumu-
ments. Mostly, this will happen anyway since actual loops lated difference between p̂ and p with the inertial pressure
need actual reservoirs but cases like the combined loops of r and accelerate the corresponding mass flow with respect
liquid cooling with its two reservoirs require an attentive to r.
modeler. This leads to a very favorable structure of the equation
The translated model contains of 49 states (eighteen of system where all non-linear computations can be brought
which are attributed to the discretized heat exchangers of into explicit form and the only system of equations in im-
the vapour cycle) and contains only four non-linear sys- plicit form is strictly linear. Hence a robust solution of
tems of size one that can each be locally attributed to one the system model can be reliably achieved supposing ro-
of the four volume components. The initialization prob- bust component and media models. More details on the
lem consists of two linear systems that are manipulated approach and also the handling of junctions and splitters
to size zero and poses no problem. The simulation is ro- in (Zimmer 2020).
bust and will run through various topology switches and Another way of looking at this approach is that we use
changing heat-loads, unless one of the media models is different spatial resolutions for p̂ and r. Whereas p̂ may be
driven out of its temperature or pressure ranges. resolved for each component, r is only resolved between
While some parameterization of all components will boundaries of the stream. This is mostly fine because the
have to be made to match measured data of an actual sys- impact of r on the thermodynamic state is typically low
tem, most components come with usable default param- (or even zero for steady flow conditions). However, should
eters, therefore even complex topologies can be quickly the impact of r become vital (unsteady cavitation might be
built up and simulate successfully. such a case), the modeler is advised to increase the spatial
resolution by adding more volume elements at the place
2 Robustness of concern.
2.1 Underlying methodology and assumptions 2.2 Implementation in Modelica
As suggested by its name a thermofluid stream is forming To implement this decomposition, we use a connector that
the central entity of this modeling approach. The stream is contains a pair of potential and flow variable. The flow is
thereby bound either by dedicated boundary models such naturally the mass flow rate and the corresponding poten-
as sources or sinks or by elements that represent a volume tial is the inertial pressure since it is the potential variable
of the medium. that determines the dynamics of the flow. The thermody-
Between these boundaries, the stream consists in a se- namic state is then transferred as a signal. Since we are
quence of components such as compressors, valves, etc. using the standard Modelica.Media library (Casella et al.
that may manipulate the thermodynamic state Θ. Shared 2006), using the state record of the media models seems a
among all these components is a common mass-flow rate. natural choice.
So all components alongside a stream uphold the mass- Listing 1. connectors for directed thermofluid streams
flow balance ṁin = −ṁout .
connector Inlet
The mass-flow rate is always a state variable of the sys-
replaceable package Medium;
tem. Each component of a stream expresses a differential SI.Pressure r;
equation of the form: flow SI.MassFlowRate m_flow;
input Medium.ThermodynamicState state;
d ṁ end Inlet;
L = −∆r (2)
dt
connector Outlet
Whereas r is denoted as inertial pressure and L is the in- replaceable package Medium;
ertance of the fluid. Please note that the inertance is solely SI.Pressure r;
defined by the geometry of the flow and independent of flow SI.MassFlowRate m_flow;
the thermodynamic state: output Medium.ThermodynamicState state;
end Outlet;
Z
L= ds/A The approach chosen here is thus similar to (Otter
(3)
et al. 2019) and a bit different to what has been de-
with s being the length of the flow and A its cross- scribed in (Zimmer, Bender, and Pollok 2018). Although
section area. We can make use of the inertial pressure r the library is approximating the thermodynamic state on
to decompose the general pressure gradient ∆p into the steady mass-flow pressure, this is not made explicit.
This means in practice that when one calls the func-
∆p = ∆ p̂ + ∆r (4) tion Medium.pressure(inlet.state), the return

DOI Proceedings of the 14th International Modelica Conference 227


10.3384/ecp21181225 September 20-24, 2021, Linköping, Sweden
The DLR ThermoFluidStream Library

value is the steady mass-flow pressure p̂ and not p. An zero-mass flow. Even stronger, we demand that each com-
explicit denotation of the steady mass-flow pressure sim- ponent can handle reverse flow in a well-natured man-
ply turns out to be too cumbersome and unpractical on the ner. This means that the equations should not (unneces-
existing media model base. Yet it is important to have the sarily) destabilize the system and if possible represent a
underlying approximation in mind. physically plausible behavior. Care has been taken that
Also a minor extension to the standard Media library is each component fulfills these robustness requirements.
needed to support our interface: a function is added that This is especially relevant for active components such as
retrieves the mass fraction for given thermodynamic state. compressors and turbines that add or substract power to
For this reason, the DLR Thermofluid Stream Library cur- a stream of fluid. Also heat-exchangers require careful
rently uses a modified copy of Modelica.Media. Once the modeling in this respect.
standard has been updated, the copy will be removed. Fur-
thermore, XRG Simulation GmbH provided media mod- 3 Library Overview
els of refrigerants and further media that are compatible to
our library.
3.1 Library structure
A classic component which has a single stream from The central entity of the library is the thermofluid stream
inlet to outlet can be build upon the following basemodel as described by the connector and the previously listed
that already contains the law for the inertial pressure gra- base-class. There will be boundaries for the stream. These
dient. are typically inlets and outlets but note that also volume
elements represent boundaries from the perspective of a
Listing 2. SISO basemodel stream. The inlet of a volume is an outlet of the stream
partial model SISOFlow and vice versa.
replaceable package Medium; The topology of the architecture is formed by splitters
parameter Utilities.Units.Inertance L = and junctions. Different from the fluid library in the MSL,
dropOfCommons.L;
there are extra components for this purpose and it is not
Inlet inlet(redeclare package Medium=
Medium); performed using connector equations. Finally, all those
Outlet outlet(redeclare package Medium= components that manipulate the working fluid of a stream
Medium); are collected under the term processes. Heat exchangers
protected and valves (or similar mechanism) for flow control are
outer DropOfCommons dropOfCommons; moved up to the highest level due to their significance.
equation
inlet.m_flow + outlet.m_flow = 0;
Hence the structure as in Figure 2 results.
der(inlet.m_flow) * L = inlet.r -
outlet.r;
end SISOFlow;

Although simplified w.r.t to the actual implementation,


the code also displays the use of a global "DropOfCom-
mons" model that is used to describe many generic pa-
rameters shared among many components. Among them
is a default value for the inertance because oftentimes a
replacement assumption is used and the corresponding dy-
namics is just seen as a way to reach the desired steady-
state solution (or steady mass flow to be more precise).
2.3 Initialization Figure 2. Overview of the library and its main packages
Per default, we use zero to initialize all mass flows.
The occuring gradients in inertial pressure then direct the Each of the packages contains a sub-package with cor-
mass-flow rates toward their natural equilibrium. This ap-responding test cases. An "Examples" package holds sev-
eral application examples for the library, that showcase the
proach is similar to ramping up a system from rest or plug-
ging it in to a pressure source. We have successfully ap- capabilities and can act as starting points for users. We use
plied this method to a variety of systems so far and can both the test cases, as well as the examples, for regression
confirm the applicability of this approach. The modeler testing during development of the library.
needs to put much less thought into the initialization of The strategy of the implemented library is that we want
to provide robust generic models with only a few pa-
its system. Nevertheless if desired, also other options are
available. rameters for a first iteration of modeling, such as cross-
and counter-flow heat exchangers with the ε-NTU method
2.4 Handling zero-mass flow (see Section 3.2.3). These kind of models will be de-
The initialization approach alone stipulates the require- tailed enough to capture the overall system behavior of a
ment that each component must be able to compute with wide range of applications and can act as placeholders for

228 Proceedings of the 14th International Modelica Conference DOI


September 20-24, 2021, Linköping, Sweden 10.3384/ecp21181225
Session 3A: Libraries

higher-fidelity models in later design stages. Since these class. Different implementations of f in child classes al-
high-fidelity models will vary for each specific application low for pumps, compressors, turbines, fans or other turbo
the modeler will have to implement them for their specific components and for different levels of fidelity. Note that
use-case. Equation 5 holds no assumption on the specific thermody-
namic process of the turbo-component (e.g. compression /
3.2 On specific components expansion with a fixed isentropic coefficient), since differ-
3.2.1 Volume models ent processes can be implemented by different functions f
Volume models take a special role in the thermofluid- in Equation 5a.
stream approach, as they should be used to break alge- Equation 5b can be replaced by a boundary condition
braic loops for circular fluid flow, isolating the non-linear on ω, when the angular dynamics of the component is not
equation systems locally between the different compo- of interest.
nents (Zimmer 2019a). Each closed fluid loop should con- Equation 5c is additionally normalized for low mass-
tain at least one volume model. flow, effectively limiting |∆h|. If the fluids enthalpy is in-
We provide volume models with one or multiple inlets creased in the component, any work the fluid cannot take
with or without flexible walls, as well as reservoir, ac- on is dumped onto a heat-port. If enthalpy is taken from
cumulator and receiver models, which are also volumes the fluid (e.g. in a turbine) τs is reduced to still fulfill Equa-
and can be used to break loops. All of these are derived tion 5c in case of normalization, limiting the work that can
from base classes of volumes making it easy to implement be taken out of the fluid.
additional specialized volume models if required by the 3.2.3 Heat exchangers
modeler. The base classes define three differential con- For heat exchange between two fluids, two different ap-
servation equations xvolume = (M,U, Mi ) with M, U, and proaches are used in this library. For applications with
Mi , being the mass, inner energy and mass of the different single-phase fluids on both sides, the ε-NTU method is
mass fractions in a mixture respectively. For maximum implemented. For fluids with phase transition (for exam-
flexibility, volumes offer a broad range of options, like re- ple refrigerants), the heat exchanger is discretized in mul-
moving inlet or outlet, or adding a heat-port, as well as tiple heat exchanging elements.
different initialization methods.
In order to avoid very fast, undampened oscillations ε-NTU method
between two or more directly coupled volumes or other When the outlet temperatures of the heat exchanger are
boundaries, a damping term on the change of mass con- not known a priori, the ε-NTU method is most conve-
tained by the volume (Zimmer 2019b) is implemented in nient. It provides relatively simple correlations for dif-
all volumes. Contrary to an artificial flow resistance on the ferent types of heat exchangers (counter-flow, cross-flow,
inlet or outlet, the damping term does not affect the steady- parallel-flow, etc.). The effectiveness ε of a heat ex-
state solution since it acts only on the change of mass in changer is defined as the ratio between the actual and the
the volume. Nonetheless, the damping can be switched off maximum heat flow rate:
by modifying the volumes parameters. With this damping,
directly coupled boundaries may still result in very fast os- Q̇ Q̇
ε= = (6)
cillations, but at least the dynamics are damped and should Q̇max Cmin ∆Tmax
be well manageable for a stiff-system solver. If possible
though, direct coupling of volumes to other volumes or To obtain the maximum possible heat flow rate, the heat
boundaries should be avoided. capacity rates C = cp ṁ on both sides (hot/cold) of the
heat exchanger are compared. The side with the smaller
3.2.2 Turbo components heat capacity rate (C = Cmin ) needs less energy to ex-
All components that transfer work between a mechanical perience the maximum temperature difference (∆Tmax =
flange and the fluid share a common partial model "Par- Th,in − Tc,in ).
tialTurboComponent" governed by Equation 5 With those quantities, the so called Number of Transfer
Units (NTU) can be calculated:
(∆p, τs ) = f (ṁ, ω, Θin ) (5a)
kA
J ω̇ = τ − τs (5b) NTU = (7)
Cmin
∆h = τs ∗ ω/ṁ (5c)
where k is the overall heat transfer coefficient and A is
where ∆p is the pressure gain over the component, ω is the the surface area for heat transfer. For any heat exchanger
angular velocity, J the moment of inertia, τ the torque ap- it can be shown that (Schlünder et al. 1997):
plied to the flange, τs the torque needed to maintain static
operation in the current conditions and ∆h the specific en- ε = f (NTU,Cr ) (8)
thalpy the fluid gains from inlet to outlet.
Equation 5a represents the pressure/torque characteris- This means the effectiveness ε of the heat exchanger is
tic of the component and is not implemented in the partial a function of the dimensionless number of transfer units

DOI Proceedings of the 14th International Modelica Conference 229


10.3384/ecp21181225 September 20-24, 2021, Linköping, Sweden
The DLR ThermoFluidStream Library

and the ratio of the minimal and maximal heat capacity


rate Cr = CCmax
min
. For each type of heat exchanger, a specific
relation can be found in literature, for example (Incropera
et al. 2007). For cross-flow heat exchangers with both flu-

thermalConductor[]
ids unmixed, the effectiveness can be obtained by:

G=G/nCells
  
1
ε = 1 − exp NTU 0.22 exp[−Cr NTU 0.78 ] − 1 (9)
Cr

This correlation and similar ones for counter-flow are


implemented in the library.
To determine the thermodynamic state at the outlet of
the heat exchanger, the approach is slightly modified to
our purpose. To avoid non-linear equation systems, espe- Figure 3. Cell model of discretized heat exchanger
cially when connecting multiple heat exchangers in series,
it is beneficial to use the outlet enthalpy as a state. There-
fore the efficiency of the heat exchanger is formulated in is coupled to the outlet mass flow (ṁin = −ṁout ). While
terms of specific enthalpy: this assumption neglects the change of enthalpy attributed
to dM/dt for changing densities, in our experience it does
not change the result drastically while reducing the prob-
∆h = ε∆hmax = εc p ∆Tmax (10a) lem’s complexity. Now, the energy balance of each ele-
h = h − ∆h;
out in (10b) ment is stated in the following form:
∂h ∂p
And thus the actual heat flow rate can be obtained from: M = Q̇ + ṁ(hin − h) +V (13)
∂t ∂t
Q̇ = ṁ∆h (11) where h is the specific enthalpy at the outlet of the el-
ement. For the sake of robustness, the change of pres-
To become a state variable, the outlet enthalpy hout is sure in the fluid is neglected in the energy equation (13)
filtered with a first order term with time constant τfilter : (V ∂∂tp = 0) and therefore the pressure input is not required
to be smooth.
∂ hout
τfilter = hin − ∆h − hout (12) The convective heat transfer from or to the fluid is cal-
∂t culated as follows:
The thermodynamic state is eventually retrieved from
the specific outlet enthalpy hout to prevent the creation of Q̇ = UA(TheatPort − Tsurface ) (14)
non-linear equation systems.
where U is the coefficient of heat transfer and A the
Discretized Heat Exchanger surface area. In general, a detailed calculation of the
When condensation and evaporation become relevant in a coefficient of heat transfer is not trivial. Hence we of-
heat exchanger, a method is needed that is able to han- fer a pragmatic approach exploiting that the coefficient
dle phase transition. Generally there are two main ap- of heat transfer U can be stated in terms of the Nusselt-
proaches suitable for this application: the moving bound- Number (Incropera et al. 2007) which in turn depends on
ary approach and the discretization of the heat exchanger the Reynolds number (presuming forced convection):
into a finite number of elements. In this library, the latter UL
is implemented because it promises very robust behaviour Nu = = CRem Prn (15)
λ
and can easily be understood.
The discretized heat exchanger consists of N heat con- with the characteristic length L and the conductivity of
ducting elements on each side of the fluid. They are con- the fluid λ . The values of the coefficient C and the expo-
nected via a thermal conductor from the MSL. The num- nents m and n are dependent on geometry and flow char-
ber of discretization elements can be set by the modeler. acteristics. Since the Reynolds number is proportional to
Figure 3 shows how the single elements are connected the mass flow ṁ, we can derive a simple scaling law based
to each other. The fluid ports are arranged in terms of a on the Reynolds exponent m:
counter-flow heat exchanger.
|ṁ| m
 
When dividing the heat exchanger in several elements, U = Unom (16)
it is advantageous to model them in a way that no oscilla- ṁnom
tions occur when multiple elements are connected to each For turbulent flow the Reynolds exponent m is equal to
other. To this end, the mass in each element is assumed 0.8. The coefficient of heat transfer for the multiphase el-
to be quasistationary (M = ρV ) and the inlet mass flow ement has to be estimated differently. It is determined by

230 Proceedings of the 14th International Modelica Conference DOI


September 20-24, 2021, Linköping, Sweden 10.3384/ecp21181225
Session 3A: Libraries

the actual phase in each discretization element, therefore it very practical and are using the sensors mostly in this way,
is dependent on the vapor quality. According to the single which is why the actual signal output is conditionally re-
phase, for each phase (liquid, vapor, two-phase) a nom- moved by default.
inal coefficient of heat transfer can be set and the actual
coefficient is calculated accordingly:
 mc
degC 20.11
|ṁ|
Uliq = Uliq,nom
ṁnom
(17a) bar 0.96
Uvap = Uvap,nom

|ṁ|
me
(17b)
(kg/s)4.45
ṁnom
Utp = Utp,nom (17c)
Figure 4. Exemplary sensor displaying three quantities
The Reynolds exponents for normalisation of the heat
transfer coefficient for evaporation (me = 0.5) and con-
densation (mc = 0.4) are taken from (Yan and Lin 1999b) 3.3 Specific solution for undirected flows
and (Yan and Lin 1999a). In the two-phase region, a con-
Within the library we provide a package containing com-
stant coefficient of heat transfer is assumed. Furthermore
ponents that can have undirected flows. It is similarily
a minimum value for the coefficient of heat transfer Umin is
structured to the main library but contains less compo-
introduced to ensure heat transfer at zero mass flow. The
nents. For these components however, the direction of
coefficient of heat transfer on the two-phase side of the
mass-flow does not need to be known a-priori and is deter-
heat exchanger depends on the actual phase. Therefore
mined dynamically during the simulation. The approach
the vapor quality χ has to be calculated in each element,
for undirected stream-dominated flow simulation was in-
using the dew and bubble enthalpies of the fluid:
troduced in (Zimmer 2019a). Note that this approach is
h − hbubble still stream-dominated and, while we continue to demand
χ= (18) robustness for low and zero mass-flow, the results may not
hdew − hbubble
be valid for these conditions. The undirected simulations
The coefficient of heat transfer used in the two-phase are therefore interesting for applications where non-zero
elements thus is formulated as a function of the vapor mass-flow operating points are present for both flow direc-
quality U(χ). For smooth transition between different tions while the switching dynamics between mass-flow di-
coefficients during phase change, an interpolation is ap- rections are not of interest. In practice, this will be the case
plied. The definition of the vapor quality (Equation 18) al- for many applications, like a combined vapor-cycle/heat-
lows it to go below zero (when subcooled) and above one pump.
(when superheated). This allows the interpolation to be
When the direction of mass-flow is reversed, the flow
formulated across the phase boundaries and avoids jump-
of information is reversed with it. Therefore a undirected
ing in those critical regions. The test models for a con-
connector carries information about the thermodynamic
denser and evaporator show robust and valid behavior of
state in both directions: forward and rearward (see List-
the discretized heat exchanger, although the performance
ing 3).
is highly dependent on the number of discrete elements.
Section 3.3 contains a corresponding application example.
Listing 3. Two connectors for undirected flows
3.2.4 Valve models connector Thermalplug_fore
Valve characteristics can be very important for the con- replaceable package Medium;
trol design and the control authority. The library hence SI.Pressure r;
flow SI.MassFlowRate m_flow;
features different types with different pressure gradient input Medium.State state_rearwards;
curves. Also some functional valve models are directly output Medium.State state_forewards;
combined with splitter models in order to facilitate topo- end thermalplug_fore;
logical changes in complex architectures (Figure 1).
connector Thermalplug_rear
3.2.5 Sensor models replaceable package Medium;
All implemented sensor models can be used in two ways. SI.Pressure r;
flow SI.MassFlowRate m_flow;
Firstly, they output the measured signal as a RealOutput
input Medium.State state_forewards;
as it is common for Modelica sensor models. Addition- output Medium.State state_rearwards;
ally, they display the current signal value during simula- end thermalplug_rear;
tion using the DynamicSelect command (see Figure 4).
This enables the user to get a fast, intuitive understand- Each component also computes its influence on the
ing of the current state of the simulation without the need state in both the forward and backward direction (see
for displaying any signal curve. We found the second use Equation 19).

DOI Proceedings of the 14th International Modelica Conference 231


10.3384/ecp21181225 September 20-24, 2021, Linköping, Sweden
The DLR ThermoFluidStream Library

Θout,fw = gfw (Θin,fw , ṁ, x)


(19)
Θout,bw = gbw (Θin,bw , ṁ, x) « « «

N......2 1
1 2 ......N
«

1 2 ......N
N......2 1
« « « «
« « « «
When connecting these undirectional components in a
complex topology, junctions and splitters cannot be distin-
guished and become generic nodes. The implementation
of a node has to avoid cyclic dependencies of the signal
flow as well as to provide a regularization around the zero- B

B
mass flow regime. It is thus almost a re-implementation

A
A

B
of the Modelica stream connector (Franke, Casella, Ot-
ter, et al. 2009). Unfortunately the regularization of the
stream connector semantics is numerically vague and also
not subject to a regularization parameter. The width of
the regularization scheme may however play an impor-
tant role in situations of flow reversal and also influences
the eigenvalues of the system. Hence a proper option for

A
parametrization is needed and the Modelica stream con- Figure 5. Example of a reversible heatpump that contains two
nector itself could thus not be used for this library. Here, undirected heat exchangers. The operating mode of the cycle
the default value of the regularization width is specified by can be switched during simulation.
the dropOfCommons.
It is strongly advisable to use undirected components
only when the flow-direction is really unknown. Knowing boundary conditions for the air side and the compressor
the direction a priori is a too valuable piece of informa- and the cycle can be reversed during simulation.
tion to throw away. For instance, using directed compo-
nents helps avoiding spurious loops (those which appear
3.4 Specific solution for dynamic pressure
in the connection graph but are never realized by the fluid The dynamic pressure arises from the macroscopic motion
flow) and the need to cut those loops. Also creating mod- of the fluid. Its computation for a given mass flow rate
els that work in both directions is not always reasonable hence requires also information on the geometry. Typi-
and certainly creates often code that is needlessly com- cally the cross-section area is used to compute the veloc-
plex. Please note that we provide also adapters between ity:
directed and undirected stream networks. These can be
used to isolate parts of the network that require undirected ṁ
v=
flow, and keep the rest directed. Aρ
An example architecture that contains undirected com- The dynamic pressure q is then
ponents is given in Figure 5. It shows a reversible heat-
pump as it can be used for residential air conditioning. The ṁ2
specialty of this system is that the direction of the refrig- q = ρ/2v2 =
2ρA2
erant flow can be reversed. The heat exchangers can thus
act as evaporator or condenser according to the current cy- If the dynamic pressure is vital for each part of the sys-
cle operation. In cooling mode (blue arrows), the indoor tem, it is a natural choice to include the cross-section area
unit acts as an evaporator and the outdoor unit (blue) acts in the connector and specify the geometry at each compo-
as a condenser. Thus the heat is absorbed from the inside nent. However, we do not think that this represents the
air and rejected to the outside. In heating mode (red ar- majority of use-cases for our library. Many thermody-
rows) the cycle is reversed which makes the indoor unit namic processes are adequately described without needing
the condenser and the outdoor unit the evaporator. Hence the dynamic pressure. Its occurrence is mostly confined to
the heat is absorbed from the outside and rejected to the special sub-systems like ram-air inlets, venturi pumps, or
inside. The system is built out of a combination of undi- diffusors. Under this presumption, the need to describe the
rected and directed components. It consists of a undi- geometry in all components does more harm than good.
rected phase separator (receiver) and two separate meter- Providing a localized solution for the dynamic pressure
ing devices (magenta). This allows us to control the super- seems to be the most useful approach. In this way, it can be
heating temperature after the evaporator in both operating considered when needed and ignored otherwise. Hence,
modes. In practice, the change of flow direction is carried we introduce special boundaries for entering and exiting a
out by a reversing valve. In our example we control the zone where dynamic pressure is considered. One side of
flow direction by a system of valves and undirected junc- this boundary expresses the static pressure for a specified
tions (yellow). The example simulates robustly with fixed velocity assumption whereas the other side computes the

232 Proceedings of the 14th International Modelica Conference DOI


September 20-24, 2021, Linköping, Sweden 10.3384/ecp21181225
Session 3A: Libraries

velocity resulting from mass flow-rate, density and cross- 4.2 Adapt to your own needs: A use case
section area. The boundary then assigns a pressure differ-
While many use-cases can be simulated by the libraries
ence so that the total pressure balance is upheld. A typical
standard components, many others will require special-
use of such a boundary is its use of ram-air going through
ized components. The relative flat implementation style
a heat exchanger as in a car as shown in Figure 1.
enables the modeler to easily implement own components
A typical component that uses dynamic pressure is a and adapt the library for their needs. An example for this
nozzle that accelerates (or decelerates) a fluid. In case the is provided in Figure 6. It depicts a simulation model for
fluid is diffused an increase in mass-flow rate will increase an espresso machine.
the outlet pressure. Hence a correct formulation of the
boundary conditions is needed because otherwise the in-
ertial dynamics of the fluid may destabilize the system. A

environment
corresponding example of the Venturi-effect is part of the

K
T=25 °C
library.

thermalResistor
4 Easy-to-read, easy-to-adapt

R=2 K/W

brewingHead
4.1 General modeling style of components

500 J/K
In general, the library is structured by a flat hierarchy, lim-
iting the use of partial models, functions and packages to
only those cases with high usefulness. This is done in- PTC

tentionally to increase the readability and understandabil-


ity of the individual components while still utilizing the
might of object-oriented modeling when it is of benefit.

A
Components are implemented to provide a formula-

B
B
tion of Equation 1 in explicit form, whenever feasible.
Nonetheless, sometimes certain quantities that are re-
quired to compute the outlet state Θout depend not only on
the inlet state Θin mass-flow ṁ and component state x, but
also on the outlet state itself. An example is the change
in dynamic pressure, that depends on the outlet density.
B

This typically results in systems of non-linear equations


A

within the component. While the stream-dominated ap-


proach still manages to keep the non-linear systems sep-
B

A
arated in small local ones, for general simulation speed
and the real-time application of the library, even small
non-linear systems are undesirable. Therefore we decided
to avoid non-linear equation systems larger than size 1.
Figure 6. Example of a model with individualized component
This can be achieved by reformulating the equations in
models. This model simulates an espresso machine composed of
a manner and/or applying simplifications until the com- water source and pump (green), boiler, water and steam outlets
ponents’ non-linear equation systems drop to the desired (blue), brewing head with cycling water (yellow) and valve, cof-
size, or by introducing the problematic quantity as an ar- fee strainer and cups (magenta). Cold water enters the machine
tificial state within the component x̃, effectively imple- through a source at atmospheric pressure and gets pressurized by
menting a fast low-pass on it, as it was done in subsub- a pump to 8.5 bar. Part of the water goes through a control valve
section 3.2.3. While the latter solution avoids simplifica- into a boiler, where the pressure is regulated by heating through
tions, it introduces additional artificial states, whose time- a PTC and the water level is controlled by the valve. For this
constants have to be chosen with care. While this is not an purpose the boiler outputs both of these quantities. From the
boiler, steam or boiling water can exit if the corresponding valve
ideal solution, when done right the result is a fast running
is opened. The boiler is in thermal contact to a secondary small
and accurate simulation, with only local non-linear sys- volume from which water cycles to the brewing head and back,
tems of maximum size 1. For hard real-time applications heating up the brewing head. If the machine is at temperature,
the remaining non-linear systems can still be resolved by the valve in front of the coffee strainer is opened and water flows
adding additional states in the corresponding components. from the pump into the cups, picking up heat in the secondary
While implementing the models, we documented the volume and the brewing head.
sources of equations, as well as the simplifications and
mental models for the components in code and the doc- While many standard components are used, the sinks
umentation annotation. Furthermore, intuitive icons pro- for steam and boiling water, the coffee strainer, the cups
vide a good readability of the high-level models. and the boiler are specialized components. All except the

DOI Proceedings of the 14th International Modelica Conference 233


10.3384/ecp21181225 September 20-24, 2021, Linköping, Sweden
The DLR ThermoFluidStream Library

boiler are internally composed of standard components References


and only implement a specialized icon. The coffee strainer
Casella, Francesco (2005). “Object-Oriented Modelling & Sim-
consists of a flow resistance and each cup contains a flow
ulation of Power Plants with Modelica”. In: Proceedings of
resistance and a sink, as well as a variable to track the the 44th IEEE Conference on Decision and Control (Seville,
level of coffee in the cup. The two sinks for steam and Spain), pp. 7597–7602.
water only update the image of the original sink. Casella, Francesco et al. (2006). “The Modelica Fluid and Me-
Contrastingly, the boiler, while derived from the stan- dia library for modeling of incompressible and compress-
dard volume, is a fully individual component. It has one ible thermo-fluid pipe networks”. In: Proc. 5th International
inlet and implements the conservation equations for mass Modelica Conference (Vienna, Austria), pp. 559–568.
and energy similar to a normal volume, but contains two EcosimPro (2021-08-03). FLUIDAPRO. URL: https : / / www .
heat-ports and two specialized outlets with states on the ecosimpro.com/products/fluidapro/.
El Hefni, Baligh and Daniel Bouskela (2014). “Dynamic mod-
bubble- and dew-line respectively, instead of one normal
elling of a Condenser with the Thermo SysPro Library”. In:
outlet. Additionally, liquid level and pressure are output Proceedings of the 10th International ModelicaConference
as real numbers and a different icon is implemented. (Lund, Sweden), pp. 1113–1122.
Franke, Rüdiger, Francesco Casella, Martin Otter, et al. (2009).
5 Concluding remarks “Stream Connectors – An Extension of Modelica for Device-
Oriented Modeling of Convective Transport Phenomena”. In:
5.1 Library source and terms of use Proceedings of the 7th Modelica Conference (Como, Italy),
The library is available on GitHub: pp. 108–121.
github.com/DLR-SR/ThermofluidStream Franke, Rüdiger, Francesco Casella, Michael Sielemann, et al.
It is available under the 3-Clause BSD License. It has (2009). “Standardization of Thermo-Fluid Modeling in Mod-
elica.Fluid”. In: Proceedings of the 7th Modelica Conference
been developed using Dymola and is based on Modelica
(Como, Italy), pp. 122–131.
3.2.3. Pendantic checking has been applied to all compo- Incropera, Frank et al. (2007). Fundamentals of heat and mass
nents in order to improve cross-tool compatibility. Com- transfer. Wiley New York.
patibility with Open Modelica and Modelon Impact has Otter, Martin et al. (2019). “Thermodynamic Property and Fluid
been achieved to a large degree and is documented in cor- Modeling with Modern Programming Language Constructs”.
responding issues on GitHub. In: Proceedings of the 13th International Modelica Confer-
If you publish work that is based on this library, please ence (Regensburg, Germany).
cite this paper and (Zimmer 2020). We also welcome feed- Process Systems Enterprise (2021-08-03). gPROMS. URL:
back in form of issues raised on GitHub. Also when you www.psenterprise.com/products/gproms.
Schlünder, Ernst-Ulrich et al. (1997). VDI-Wärmeatlas: Berech-
have positive feedback, you can feel free to raise an issue
nungsblätter für den Wärmeübergang. 8. überarb. und erw.
to share your experience. Have fun! Aufl. Springer.
5.2 Future Work Sielemann, Michael et al. (2011). “Optimization of an un-
conventional environmental control system architecture”. In:
We will keep maintaining this library and improving its SAE International Journal of Aerospace 4.2.
components. Apart from having robust models, hard real- Yan, Yi-Yie and Tsing-Fa Lin (1999a). “Condensation heat
time capability, suitable control design as well as various transfer and pressure drop of refrigerant R-134a in a small
forms of health monitoring are our main research and de- pipe”. In: International journal of heat and mass transfer
velopment interests. 42.4, pp. 697–708.
Yan, Yi-Yie and Tsing-Fa Lin (1999b). “Evaporation heat trans-
Acknowledgements fer and pressure drop of refrigerant R-134a in a plate heat
exchanger”. In: Journal of Heat Transfer 121.1.
This work has been partially supported by the Helmholtz Zimmer, Dirk (2019a). “Robust Simulation of Stream-
Gemeinschaft in frame of the research project for on- Dominated Thermo-Fluid Systems: From Unidirectional to
board diagnosis. Hence we would also like to thank the Bidirectional Applications”. In: EUROSIM Congress 2019
team of Robert Bosch GmbH for feedback and motivat- (Logroño, Spain).
ing use-case scenarios. Further thanks goes to Chistopher Zimmer, Dirk (2019b). “Towards hard real-time simulation of
complex fluid networks”. In: Proceedings of the 13th In-
Laughman from Mitsubishi Electronic Research Center
ternational Modelica Conference (Regensburg, Germany),
for providing encouraging feedback. Also the work of pp. 579–587.
Tobias Krenz form TU Darmstadt offered a valuable per- Zimmer, Dirk (2020). “Robust object-oriented formulation of di-
spective. We are still grateful to Airbus and our former rected thermofluid stream networks”. In: Mathematical and
colleagues Dr. Alexander Pollok and Dr. Daniel Ben- Computer Modelling of Dynamical Systems 26.3, pp. 204–
der who were pioneering the new methodology. Also we 233.
like to thank our colleague Dr. Peter Eschenbacher for Zimmer, Dirk, Daniel Bender, and Alexander Pollok (2018).
his valuable modeling experience on valves and pumps. “Robust Modeling of Directed Thermofluid Flows in Com-
Thankfully, the Open Modelica team supported us with plex Networks”. In: Proceedings of the 2nd Japanese Model-
respect to tool compatibility and Stefan Wischhusen from ica Conference (Tokyo, Japan), pp. 39–48.
XRG generously provided additional media models.

234 Proceedings of the 14th International Modelica Conference DOI


September 20-24, 2021, Linköping, Sweden 10.3384/ecp21181225

You might also like