Buildings.Fluid.FMI.UsersGuide

User's Guide

Information

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 such as HVAC components, HVAC systems and thermal zones 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.

The main packages are as follows:

PackageDescription
Buildings.Fluid.FMI.ExportContainers

Package with blocks to export thermofluid flow components and systems.

To export an HVAC component or system with a single inlet and outlet port, instantiate Buildings.Fluid.FMI.ExportContainers.ReplaceableTwoPort with a replaceable model, or extend from Buildings.Fluid.FMI.ExportContainers.PartialTwoPort and add components.
See Buildings.Fluid.FMI.ExportContainers.Examples.FMUs.Fan and Buildings.Fluid.FMI.ExportContainers.Examples.FMUs.ResistanceVolume.

To export an HVAC system that serves a single thermal zone, extend from Buildings.Fluid.FMI.ExportContainers.HVACZone and add the HVAC system.
See Buildings.Fluid.FMI.ExportContainers.Examples.FMUs.HVACZone.

To export an HVAC system that serves multiple thermal zones, extend from Buildings.Fluid.FMI.ExportContainers.HVACZones and add the HVAC system.
See Buildings.Fluid.FMI.ExportContainers.Examples.FMUs.HVACZones.

To export a single thermal zone, extend from Buildings.Fluid.FMI.ExportContainers.ThermalZone and add the thermal zone.
See Buildings.Fluid.FMI.ExportContainers.Examples.FMUs.ThermalZone.

To export multiple thermal zones, extend from Buildings.Fluid.FMI.ExportContainers.ThermalZones and add the thermal zone models.
See Buildings.Fluid.FMI.ExportContainers.Examples.FMUs.ThermalZones.

Buildings.Fluid.FMI.Adaptors

Package with adaptors to connect models with fluid ports to blocks that have input and output signals.

Buildings.Fluid.FMI.Conversion

Package with blocks that convert between the signal connectors of Buildings.Fluid.FMI.Interfaces and the real input and output signal connectors of the Modelica Standard Library.

Buildings.Fluid.FMI.Interfaces

Package with composite connectors that have different input and output signals. These connectors are used to export FMUs, and they contain quantities such as mass flow rate, temperature, optional pressure, etc.

The package Buildings.Fluid.FMI.ExportContainers.Examples.FMUs contains various examples in which HVAC components, HVAC systems and thermal zones are exported as an FMU.

Typical use

Users who want to export a single thermofluid flow component, or a subsystem of thermofluid flow components, can use the block Buildings.Fluid.FMI.ExportContainers.ReplaceableTwoPort. This block has a fluid inlet, a fluid outlet, and a replaceable component that can be replaced with an HVAC component or system that has an inlet and outlet fluid port.

Users who want to export a whole HVAC system that serves a single thermal zone can do so by extending the partial block Buildings.Fluid.FMI.ExportContainers.HVACZone. The example Buildings.Fluid.FMI.ExportContainers.Examples.FMUs.HVACZone illustrates how this can be accomplished.
Similar export containers and examples are implemented for HVAC systems that serve multiple thermal zones.

Conversely, to export a thermal zone, users can extend the partial block Buildings.Fluid.FMI.ExportContainers.ThermalZone. The example Buildings.Fluid.FMI.ExportContainers.Examples.FMUs.ThermalZone illustrates how this can be accomplished.
Similar export containers and examples are implemented for models of multiple thermal zones.

Each example and validation model has a Dymola script that either simulates the model, or exports the model as an FMU. The script can be invoked from the pull down menu Commands -> Export FMU.

Options

In the Buildings.Fluid package, most models have 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.

Most 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 constant 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.ExportContainers.Examples.FMUs.IdealSource_m_flow.

Notes

Note the following when exporting HVAC component models as an FMU:

  1. 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.

  2. The model Buildings.Fluid.Movers.FlowControlled_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.Source_T, which takes as an input signal the mass flow rate.

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.PressureDrop 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.

References

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).