Buildings.Fluid.FMI

Package with base classes that facilitate exporting models as an FMU

Information

This package contains blocks that serve as containers for exporting models from Buildings.Fluid as a Functional Mockup Unit (FMU).

This allows using models from Buildings.Fluid, add them to a block that only has input and output signals, but no acausal connectors, and then export the model as a Functional Mockup Unit. Models can be individual models or systems that are composed of various models. For more information, see the User's Guide.

Extends from Modelica.Icons.Package (Icon for standard packages).

Package Content

Name Description
Buildings.Fluid.FMI.UsersGuide UsersGuide User's Guide
Buildings.Fluid.FMI.FlowSplitter_u FlowSplitter_u Model of a flow splitter that can be exported as an FMU
Buildings.Fluid.FMI.Sink_T Sink_T Model of a sink with temperature for reverse flow as an input that can be exported as an FMU
Buildings.Fluid.FMI.Source_T Source_T Model of a boundary with mass flow rate, pressure and temperature as an input that can be exported as an FMU
Buildings.Fluid.FMI.Adaptors Adaptors Package with adaptors to connect models with fluid ports and models with signal ports
Buildings.Fluid.FMI.Conversion Conversion Package with blocks that convert between different connectors
Buildings.Fluid.FMI.ExportContainers ExportContainers Package with containers to export thermofluid flow models
Buildings.Fluid.FMI.Validation Validation Collection of validation models
Buildings.Fluid.FMI.Interfaces Interfaces Package with interfaces for models that serves as an FMU container
Buildings.Fluid.FMI.BaseClasses BaseClasses Package with base classes for Buildings.Fluid.FMI

Buildings.Fluid.FMI.FlowSplitter_u Buildings.Fluid.FMI.FlowSplitter_u

Model of a flow splitter that can be exported as an FMU

Buildings.Fluid.FMI.FlowSplitter_u

Information

Block that takes as an input the inflowing fluid at the port inlet and a vector of control signals for the mass flow rates u. The mass flow of all outlet ports i is set to the value of u[i] m_flow_nominal[i]. If the inflowing mass flow rate at the port inlet is not equal to the sum of u[i] m_flow_in[i], the simulation stops with an assert.

Assumptions and limitations

The mass flow rates at all outlet ports must be non-negative. Reverse flow is not yet implemented. If either of these limitations are violated, then the model stops with an error.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the component
MassFlowRatem_flow_nominal[nout]m_flow_nominal( each min=0)Nominal mass flow rate for each outlet [kg/s]
Integernoutnout( ...Number of outlets
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
InletinletFluid inlet
Outletoutlet[nout]Fluid outlet
input RealInputu[nout]Control signal for the mass flow rates [1]

Modelica definition

block FlowSplitter_u "Model of a flow splitter that can be exported as an FMU" extends Modelica.Blocks.Icons.Block; replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal[nout]( each min=0) "Nominal mass flow rate for each outlet"; parameter Boolean allowFlowReversal = true "= true to allow flow reversal, false restricts to design direction (inlet -> outlet)"; parameter Integer nout(min=1) "Number of outlets"; parameter Boolean use_p_in=true "= true to use a pressure from connector, false to output Medium.p_default"; Interfaces.Inlet inlet( redeclare final package Medium = Medium, final allowFlowReversal=allowFlowReversal, final use_p_in=use_p_in) "Fluid inlet"; Interfaces.Outlet outlet[nout]( redeclare each final package Medium = Medium, each final allowFlowReversal=allowFlowReversal, each final use_p_in=use_p_in) "Fluid outlet"; Modelica.Blocks.Interfaces.RealInput u[nout]( each unit="1") "Control signal for the mass flow rates"; protected final parameter Modelica.SIunits.MassFlowRate mAve_flow_nominal= sum(m_flow_nominal)/nout "Average nominal mass flow rate"; protected Buildings.Fluid.FMI.Interfaces.FluidProperties bacPro_internal( redeclare final package Medium = Medium) "Internal connector for fluid properties for back flow"; Buildings.Fluid.FMI.Interfaces.MassFractionConnector X_w_out_internal = 0 "Internal connector for mass fraction of backward flow properties"; initial equation for i in 1:nout loop assert(m_flow_nominal[i] > 0, "Nominal mass flow rate must be bigger than zero."); end for; equation for i in 1:nout loop assert(u[i] >= 0, "Control signal must be non-negative."); // Dymola 2015 FD01 (on Linux 64) does not automatically // remove the conditional equation below. We thus have to manually check // if use_p_in is true before connecting the inlet and outlet pressures. if use_p_in then connect(inlet.p, outlet[i].p); end if; outlet[i].m_flow = u[i]*m_flow_nominal[i]; connect(outlet[i].forward, inlet.forward); end for; // As reverse flow is not supported, we assign // default values for the inlet.backward properties bacPro_internal.T = Medium.T_default; connect(bacPro_internal.X_w, X_w_out_internal); bacPro_internal.C = zeros(Medium.nC); // Conditional connector connect(bacPro_internal, inlet.backward); end FlowSplitter_u;

Buildings.Fluid.FMI.Sink_T Buildings.Fluid.FMI.Sink_T

Model of a sink with temperature for reverse flow as an input that can be exported as an FMU

Buildings.Fluid.FMI.Sink_T

Information

Model of a sink that takes as an input the medium properties temperature, mass fractions (if Medium.nXi > 0) and trace substances (if Medium.nC > 0). These properties are used during reverse flow.

For a system of components with the connectors of the Buildings.Fluid.FMI package, this component is required to set the medium properties for the reverse flow.

If the parameter use_p_in is set to true, then the model has an output connector p. This can be used to obtain the pressure of the sink, which may be needed to iteratively solve for the mass flow rate.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
input RealInputT_inPrescribed boundary temperature [K]
input RealInputX_w_inPrescribed boundary composition [1]
input RealInputC_in[Medium.nC]Prescribed boundary composition
InletinletFluid port
output PressureOutputpPressure [Pa]

Modelica definition

model Sink_T "Model of a sink with temperature for reverse flow as an input that can be exported as an FMU" extends Modelica.Blocks.Icons.Block; replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; parameter Boolean use_p_in = true "= true to use a pressure from connector, false to output Medium.p_default"; parameter Boolean allowFlowReversal = true "= true to allow flow reversal, false restricts to design direction (inlet -> outlet)"; Modelica.Blocks.Interfaces.RealInput T_in(unit="K", displayUnit="degC", min=0) "Prescribed boundary temperature"; Modelica.Blocks.Interfaces.RealInput X_w_in(unit="1") if Medium.nXi > 0 "Prescribed boundary composition"; Modelica.Blocks.Interfaces.RealInput C_in[Medium.nC] "Prescribed boundary composition"; Interfaces.Inlet inlet( redeclare final package Medium = Medium, final allowFlowReversal=allowFlowReversal, final use_p_in=use_p_in) "Fluid port"; Buildings.Fluid.FMI.Interfaces.PressureOutput p if use_p_in "Pressure"; protected Buildings.Fluid.FMI.Interfaces.FluidProperties bacPro_internal( redeclare final package Medium = Medium) "Internal connector for fluid properties for back flow"; Buildings.Fluid.FMI.Interfaces.PressureOutput p_in_internal "Internal connector for pressure"; output Buildings.Fluid.FMI.Interfaces.MassFractionConnector X_w_in_internal "Internal connector for mass fraction of forward flow properties"; equation // Conditional connector for flow reversal connect(inlet.backward, bacPro_internal); connect(bacPro_internal.X_w, X_w_in_internal); if allowFlowReversal and Medium.nXi > 0 then connect(X_w_in_internal, X_w_in); else X_w_in_internal = 0; end if; if allowFlowReversal then bacPro_internal.T = T_in; bacPro_internal.C = C_in; else bacPro_internal.T = Medium.T_default; bacPro_internal.C = fill(0, Medium.nC); end if; // Propagate pressure to output signal connector // using conditional connectors if use_p_in then connect(inlet.p, p_in_internal); else p_in_internal = Medium.p_default; end if; connect(p, p_in_internal); end Sink_T;

Buildings.Fluid.FMI.Source_T Buildings.Fluid.FMI.Source_T

Model of a boundary with mass flow rate, pressure and temperature as an input that can be exported as an FMU

Buildings.Fluid.FMI.Source_T

Information

Model of a source that takes as an input the mass flow rate, pressure and the medium properties temperature, mass fractions (if Medium.nXi > 0) and trace substances (if Medium.nC > 0).

For a system of components with the connectors of the Buildings.Fluid.FMI package, this component is required to set the pressure and the mass flow rate of the system.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
replaceable package MediumModelica.Media.Interfaces.Pa...Medium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
input RealInputm_flow_inPrescribed mass flow source [kg/s]
input PressureInputp_inPrescribed boundary pressure [Pa]
input RealInputT_inPrescribed boundary temperature [K]
input RealInputX_w_inPrescribed boundary composition [1]
input RealInputC_in[Medium.nC]Prescribed boundary composition
OutletoutletFluid port

Modelica definition

model Source_T "Model of a boundary with mass flow rate, pressure and temperature as an input that can be exported as an FMU" extends Modelica.Blocks.Icons.Block; replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium in the component"; parameter Boolean allowFlowReversal = true "= true to allow flow reversal, false restricts to design direction (inlet -> outlet)"; parameter Boolean use_p_in = true "= true to use a pressure from connector, false to output Medium.p_default"; Modelica.Blocks.Interfaces.RealInput m_flow_in(unit="kg/s") "Prescribed mass flow source"; Buildings.Fluid.FMI.Interfaces.PressureInput p_in if use_p_in "Prescribed boundary pressure"; Modelica.Blocks.Interfaces.RealInput T_in(unit="K", displayUnit="degC", min=0) "Prescribed boundary temperature"; Modelica.Blocks.Interfaces.RealInput X_w_in(unit="1") if Medium.nXi > 0 "Prescribed boundary composition"; Modelica.Blocks.Interfaces.RealInput C_in[Medium.nC] "Prescribed boundary composition"; Interfaces.Outlet outlet( redeclare final package Medium = Medium, final allowFlowReversal=allowFlowReversal, final use_p_in=use_p_in) "Fluid port"; protected Buildings.Fluid.FMI.Interfaces.PressureOutput p_in_internal "Internal connector for pressure"; Buildings.Fluid.FMI.Interfaces.MassFractionConnector X_w_in_internal "Internal connector for mass fraction of forward flow properties"; initial equation assert(Medium.nXi < 2, "The medium must have zero or one independent mass fraction Medium.nXi."); equation // Conditional connect statements for pressure if use_p_in then connect(p_in, p_in_internal); else p_in_internal = Medium.p_default; end if; connect(outlet.p, p_in_internal); // Conditional connectors for mass fraction if Medium.nXi > 0 then connect(X_w_in_internal, X_w_in); else X_w_in_internal = 0; end if; connect(outlet.forward.X_w, X_w_in_internal); outlet.m_flow = m_flow_in; outlet.forward.T = T_in; outlet.forward.C = C_in; end Source_T;