User's Guide
This user's guide describes the FMI package (Wetter et al., 2015). The FMI package has been implemented to facilitate the export of thermofluid flow models as Functional Mockup Units (FMUs). This allows to export thermofluid flow models as FMUs so that they can be imported in other simulators. To export thermofluid flow components, a Modelica block is needed in order for the model to only have input and output signals rather than fluid connectors, as fluid connectors do not impose any causality on the signal flow.
This package implements such blocks and its connectors, and it provides thermofluid flow components that can be exported as an FMU. It also implements examples that illustrate how these components can be connected with each other. The blocks can be used to encapsulate various acausal thermofluid flow models. The package Buildings.Fluid.FMI.Examples contains system models in which multiple of these containers are connected to form a complete model. This package is meant as an illustration and for testing the connectivity of these containers. If one were to use actual FMU rathern than the input-output blocks, then one would export these input-output blocks as FMUs and build a similar system model in the target simulator.
The connectors that define the input and output signals of the FMUs can be found in the package Buildings.Fluid.FMI.Interfaces.
Users who want to export a single thermofluid flow component, or a subsystem of thermofluid flow components, can use the block Buildings.Fluid.FMI.TwoPortComponent.
The package
Buildings.Fluid.FMI.Examples.FMUs
contains various examples that demonstrate how
thermofluid flow components and subsystems
can be exported as FMUs.
Each model has a Dymola script that exports the FMU.
The script can be invoked from the pull
down menu Commands -> Export FMU
.
In the
Buildings.Fluid package,
most models a boolean parameter called allowFlowReversal
.
If set to true
, then the flow can be in either direction,
otherwise it needs to be from the inlet to the outlet port.
This parameter is also used in the
Buildings.Fluid.FMI package.
The package was designed in such a way that an FMU,
if exported with allowFlowReversal=false
has as input the mass flow rate,
pressure and fluid properties of the inflowing fluid. The outputs
are the outlet mass flow rate, outlet pressure and the fluid
properties of the outflowing medium. This allows simulators
such as Ptolemy II
to evaluate the FMUs in the direction of the mass flow by first
setting all inputs, then evaluating the model equations,
and finally retrieving the
outputs before proceeding the simulation with the next downstream
component.
If allowFlowReversal=true
, then the connectors have additional
signals for the properties of the fluid if it flows backwards.
All components have a boolean parameter use_p_in
.
If use_p_in=true
, then the pressure is used from the
connector, and based on the mass flow rate, the outlet pressure
is computed and assigned to the outlet connectors.
If use_p_in=false
, then the pressure as declared
by the contant p_default
of the medium model is
used, and the component computes no pressure drop.
Setting use_p_in=false
therefore leads to fewer
equations, but it requires a component that specifies the mass
flow rate, such as
Buildings.Fluid.FMI.Examples.FMUs.IdealSource_m_flow.
Note the following when exporting FMUs:
For models with control volumes,
the mass balance must be configured using
massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState
when used with the media
Buildings.Media.Air.
Otherwise, the translation stops with the error
The model requires derivatives of some inputs as listed below: 1 inlet.p
The reason is that for Buildings.Media.Air, mass is proportional to pressure and pressure is proportional to density. Hence, dm/dt requires dp/dt, but the time derivative of the pressure is not an input to the model.
For Buildings.Media.Water, this setting is not needed as the mass is independent of pressure.
The model Buildings.Fluid.FixedResistances.FlowMachine_m_flow cannot be exported as an FMU. This is because it assignes the mass flow rate. However, the input connector Buildings.Fluid.FMI.Interfaces.Inlet already declares the mass flow rate as an input. Therefore, the mass flow rate is overdetermined. As a fall back, if a user needs to set the mass flow rate, he/she can do so by using Buildings.Fluid.FMI.IdealSource_m_flow, which takes as an input signal the mass flow rate. If this differs from the mass flow rate of the inlet connector, the simulation will stop with an error.
When connecting fluid flow components in a loop, be careful to avoid circular assignments for example for the temperature, as these can of course not be simulated. An example of such an ill-posed problem is to connect the outlet of Buildings.Fluid.FixedResistances.FixedResistanceDpM to its inlet. In this situation, neither pressure, nor mass flow rate or temperature can be computed. To model such loops, a control volume with a dynamic energy balance must be presented, and the medium needs to be compressible.
Michael Wetter, Marcus Fuchs and Thierry Stephane Nouidui.
Design choices for thermofluid flow components and systems that are exported as Functional Mockup Units.
Proc. of the 11th International Modelica Conference,
p. 31-41,
Versailles, France, September 2015.
Extends from Modelica.Icons.Information (Icon for general information packages).