LBL logo

Buildings.Fluid.FMI.Examples.FMUs

Collection of models that can be exported as FMUs

Information

This package demonstrates how to configure thermofluid flow models so that they can be exported as FMUs.

In Dymola, to export the models as an FMU, select from the pull down menu Commands - Export FMU.

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

Package Content

Name Description
Buildings.Fluid.FMI.Examples.FMUs.Fan Fan FMU declaration for a fixed resistance
Buildings.Fluid.FMI.Examples.FMUs.FixedResistanceDpM FixedResistanceDpM FMU declaration for a fixed resistance
Buildings.Fluid.FMI.Examples.FMUs.FlowSplitter_u FlowSplitter_u FMU declaration for a flow splitter
Buildings.Fluid.FMI.Examples.FMUs.HeaterCooler_T HeaterCooler_T FMU declaration for an ideal heater or cooler with prescribed outlet temperature
Buildings.Fluid.FMI.Examples.FMUs.HeaterCooler_u HeaterCooler_u FMU declaration for an ideal heater or cooler with prescribed heat flow rate
Buildings.Fluid.FMI.Examples.FMUs.Humidifier_u Humidifier_u FMU declaration for an ideal humidifier
Buildings.Fluid.FMI.Examples.FMUs.IdealSource_m_flow IdealSource_m_flow FMU declaration for a fixed resistance
Buildings.Fluid.FMI.Examples.FMUs.MixingVolume MixingVolume Container to export a control volume as an FMU
Buildings.Fluid.FMI.Examples.FMUs.ResistanceVolume ResistanceVolume Container to export a flow resistance and control volume as an FMU
Buildings.Fluid.FMI.Examples.FMUs.TwoPortPassThrough TwoPortPassThrough FMU declaration for a block that simply passes all the inputs to the outputs

Buildings.Fluid.FMI.Examples.FMUs.Fan Buildings.Fluid.FMI.Examples.FMUs.Fan

FMU declaration for a fixed resistance

Buildings.Fluid.FMI.Examples.FMUs.Fan

Information

This example demonstrates how to export an FMU with a fluid flow component. The FMU has an instance of Buildings.Fluid.FixedResistances.FlowMachine_dp.

See Buildings.Fluid.FMI.UsersGuide for why there is no model that exports Buildings.Fluid.Movers.FlowMachine_m_flow.

Extends from Buildings.Fluid.FMI.TwoPortComponent (Container to export thermofluid flow models with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
MassFlowRatem_flow_nominal0.01Nominal mass flow rate [kg/s]
Pressuredp_nominal500Pressure drop at nominal mass flow rate [Pa]
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
InletinletFluid inlet
OutletoutletFluid outlet
input RealInputdp_inPrescribed pressure rise [Pa]

Modelica definition

block Fan "FMU declaration for a fixed resistance" extends Buildings.Fluid.FMI.TwoPortComponent( redeclare replaceable package Medium = Buildings.Media.Air, redeclare final Movers.FlowControlled_dp com( final m_flow_nominal=m_flow_nominal, final dynamicBalance=false, final filteredSpeed=false)); parameter Modelica.SIunits.MassFlowRate m_flow_nominal=0.01 "Nominal mass flow rate"; parameter Modelica.SIunits.Pressure dp_nominal(displayUnit="Pa")=500 "Pressure drop at nominal mass flow rate"; Modelica.Blocks.Interfaces.RealInput dp_in(min=0, final unit="Pa") "Prescribed pressure rise"; equation connect(dp_in, com.dp_in); end Fan;

Buildings.Fluid.FMI.Examples.FMUs.FixedResistanceDpM Buildings.Fluid.FMI.Examples.FMUs.FixedResistanceDpM

FMU declaration for a fixed resistance

Buildings.Fluid.FMI.Examples.FMUs.FixedResistanceDpM

Information

This example demonstrates how to export an FMU with a fluid flow component. The FMU has an instance of Buildings.Fluid.FixedResistances.FixedResistanceDpM.

Extends from Buildings.Fluid.FMI.TwoPortComponent (Container to export thermofluid flow models with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
MassFlowRatem_flow_nominal0.01Nominal mass flow rate [kg/s]
Pressuredp_nominal100Pressure drop at nominal mass flow rate [Pa]
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
InletinletFluid inlet
OutletoutletFluid outlet

Modelica definition

block FixedResistanceDpM "FMU declaration for a fixed resistance" extends Buildings.Fluid.FMI.TwoPortComponent( redeclare replaceable package Medium = Buildings.Media.Air, redeclare final Buildings.Fluid.FixedResistances.FixedResistanceDpM com( final m_flow_nominal=m_flow_nominal, final dp_nominal=if use_p_in then dp_nominal else 0)); parameter Modelica.SIunits.MassFlowRate m_flow_nominal=0.01 "Nominal mass flow rate"; parameter Modelica.SIunits.Pressure dp_nominal=100 "Pressure drop at nominal mass flow rate"; end FixedResistanceDpM;

Buildings.Fluid.FMI.Examples.FMUs.FlowSplitter_u Buildings.Fluid.FMI.Examples.FMUs.FlowSplitter_u

FMU declaration for a flow splitter

Buildings.Fluid.FMI.Examples.FMUs.FlowSplitter_u

Information

This example demonstrates how to export an FMU with a fluid flow component. The FMU is an instance of Buildings.Fluid.FMI.FlowSplitter_u.

Extends from Buildings.Fluid.FMI.FlowSplitter_u (Container to export a flow splitter as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
MassFlowRatem_flow_nominal[nout]{0.1,0.2}Nominal mass flow rate for each outlet [kg/s]
Integernout2Number of outlets
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default

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 "FMU declaration for a flow splitter" extends Buildings.Fluid.FMI.FlowSplitter_u( redeclare replaceable package Medium = Buildings.Media.Air, nout=2, m_flow_nominal={0.1, 0.2}, allowFlowReversal(start=false)); end FlowSplitter_u;

Buildings.Fluid.FMI.Examples.FMUs.HeaterCooler_T Buildings.Fluid.FMI.Examples.FMUs.HeaterCooler_T

FMU declaration for an ideal heater or cooler with prescribed outlet temperature

Buildings.Fluid.FMI.Examples.FMUs.HeaterCooler_T

Information

This example demonstrates how to export an FMU with a heater that takes as an input signal the leaving fluid temperature. The FMU has an instance of Buildings.Fluid.HeatExchangers.HeaterCooler_T.

Extends from Buildings.Fluid.FMI.TwoPortComponent (Container to export thermofluid flow models with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
HeatFlowRateQ_flow_maxHeatModelica.Constants.infMaximum heat flow rate for heating (positive) [W]
HeatFlowRateQ_flow_maxCool-Modelica.Constants.infMaximum heat flow rate for cooling (negative) [W]
MassFlowRatem_flow_nominal0.01Nominal mass flow rate [kg/s]
Pressuredp_nominal0Pressure [Pa]
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
InletinletFluid inlet
OutletoutletFluid outlet
input RealInputTSetSet point temperature of the fluid that leaves port_b [K]
output RealOutputQ_flowHeat added to the fluid (if flow is from port_a to port_b) [W]

Modelica definition

block HeaterCooler_T "FMU declaration for an ideal heater or cooler with prescribed outlet temperature" extends Buildings.Fluid.FMI.TwoPortComponent( redeclare replaceable package Medium = Buildings.Media.Air, redeclare final Buildings.Fluid.HeatExchangers.HeaterCooler_T com( final m_flow_nominal=m_flow_nominal, final dp_nominal=if use_p_in then dp_nominal else 0, final Q_flow_maxHeat=Q_flow_maxHeat, final Q_flow_maxCool=Q_flow_maxCool, final energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState)); parameter Modelica.SIunits.HeatFlowRate Q_flow_maxHeat=Modelica.Constants.inf "Maximum heat flow rate for heating (positive)"; parameter Modelica.SIunits.HeatFlowRate Q_flow_maxCool=-Modelica.Constants.inf "Maximum heat flow rate for cooling (negative)"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal=0.01 "Nominal mass flow rate"; parameter Modelica.SIunits.Pressure dp_nominal(displayUnit="Pa")=0 "Pressure"; Modelica.Blocks.Interfaces.RealInput TSet(unit="K", displayUnit="degC") "Set point temperature of the fluid that leaves port_b"; Modelica.Blocks.Interfaces.RealOutput Q_flow(unit="W") "Heat added to the fluid (if flow is from port_a to port_b)"; equation connect(com.TSet, TSet); connect(com.Q_flow, Q_flow); end HeaterCooler_T;

Buildings.Fluid.FMI.Examples.FMUs.HeaterCooler_u Buildings.Fluid.FMI.Examples.FMUs.HeaterCooler_u

FMU declaration for an ideal heater or cooler with prescribed heat flow rate

Buildings.Fluid.FMI.Examples.FMUs.HeaterCooler_u

Information

This example demonstrates how to export an FMU with a heater that takes as an input signal the normalized heat flow rate. The FMU has an instance of Buildings.Fluid.HeatExchangers.HeaterCooler_u.

The mass dynamics has been set to massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState. See the user's guide for the rationale.

Extends from Buildings.Fluid.FMI.TwoPortComponent (Container to export thermofluid flow models with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
MassFlowRatem_flow_nominal0.01Nominal mass flow rate [kg/s]
Pressuredp_nominal0Pressure [Pa]
HeatFlowRateQ_flow_nominal100Heat flow rate at u=1, positive for heating [W]
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
InletinletFluid inlet
OutletoutletFluid outlet
input RealInputuControl input [1]

Modelica definition

block HeaterCooler_u "FMU declaration for an ideal heater or cooler with prescribed heat flow rate" extends Buildings.Fluid.FMI.TwoPortComponent( redeclare replaceable package Medium = Buildings.Media.Air, redeclare final Buildings.Fluid.HeatExchangers.HeaterCooler_u com( final m_flow_nominal=m_flow_nominal, final dp_nominal=if use_p_in then dp_nominal else 0, final Q_flow_nominal=Q_flow_nominal, massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState)); parameter Modelica.SIunits.MassFlowRate m_flow_nominal=0.01 "Nominal mass flow rate"; parameter Modelica.SIunits.Pressure dp_nominal(displayUnit="Pa")=0 "Pressure"; parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal=100 "Heat flow rate at u=1, positive for heating"; Modelica.Blocks.Interfaces.RealInput u(min=0, max=1, unit="1") "Control input"; equation connect(com.u, u); end HeaterCooler_u;

Buildings.Fluid.FMI.Examples.FMUs.Humidifier_u Buildings.Fluid.FMI.Examples.FMUs.Humidifier_u

FMU declaration for an ideal humidifier

Buildings.Fluid.FMI.Examples.FMUs.Humidifier_u

Information

This example demonstrates how to export an FMU with a humidifier that takes as an input signal the normalized mass flow rate of water that will be added to the medium. The FMU has an instance of Buildings.Fluid.MassExchangers.Humidifier_u.

The mass dynamics has been set to massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState. See the user's guide for the rationale.

Extends from Buildings.Fluid.FMI.TwoPortComponent (Container to export thermofluid flow models with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
MassFlowRatem_flow_nominal0.01Nominal mass flow rate [kg/s]
Pressuredp_nominal0Pressure [Pa]
TemperatureT293.15Temperature of water that is added to the fluid stream (used if use_T_in=false) [K]
MassFlowRatemWat_flow_nominal0.01*0.005Water mass flow rate at u=1, positive for humidification [kg/s]
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
InletinletFluid inlet
OutletoutletFluid outlet
input RealInputuControl input [1]

Modelica definition

block Humidifier_u "FMU declaration for an ideal humidifier" extends Buildings.Fluid.FMI.TwoPortComponent( redeclare replaceable package Medium = Buildings.Media.Air, redeclare final Buildings.Fluid.MassExchangers.Humidifier_u com( final m_flow_nominal=m_flow_nominal, final dp_nominal=if use_p_in then dp_nominal else 0, final mWat_flow_nominal=mWat_flow_nominal, final T=T, massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, final energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState)); parameter Modelica.SIunits.MassFlowRate m_flow_nominal=0.01 "Nominal mass flow rate"; parameter Modelica.SIunits.Pressure dp_nominal(displayUnit="Pa")=0 "Pressure"; parameter Modelica.SIunits.Temperature T = 293.15 "Temperature of water that is added to the fluid stream (used if use_T_in=false)"; parameter Modelica.SIunits.MassFlowRate mWat_flow_nominal=0.01*0.005 "Water mass flow rate at u=1, positive for humidification"; Modelica.Blocks.Interfaces.RealInput u(min=0, max=1, unit="1") "Control input"; equation connect(com.u, u); end Humidifier_u;

Buildings.Fluid.FMI.Examples.FMUs.IdealSource_m_flow Buildings.Fluid.FMI.Examples.FMUs.IdealSource_m_flow

FMU declaration for a fixed resistance

Buildings.Fluid.FMI.Examples.FMUs.IdealSource_m_flow

Information

This example demonstrates how to export an FMU that sets the mass flow rate.

Extends from Buildings.Fluid.FMI.TwoPort (Container to export a thermofluid flow model with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium 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
InletinletFluid inlet
OutletoutletFluid outlet
input RealInputm_flow_inPrescribed mass flow rate [kg/s]

Modelica definition

block IdealSource_m_flow "FMU declaration for a fixed resistance" extends Buildings.Fluid.FMI.TwoPort( redeclare replaceable package Medium = Buildings.Media.Air); Modelica.Blocks.Interfaces.RealInput m_flow_in(final unit="kg/s") "Prescribed mass flow rate"; equation assert(abs(inlet.m_flow-outlet.m_flow) < 1E-2, "The mass flow rate of port_a and port_b is not conserved. This indicates a wrong configuration of your system model."); outlet.m_flow = m_flow_in; outlet.p = inlet.p; // We use connect statements, in particular // because outlet.backward and inlet.backward // is removed if allowFlowReversal=false connect(inlet.forward, outlet.forward); connect(outlet.backward, inlet.backward); end IdealSource_m_flow;

Buildings.Fluid.FMI.Examples.FMUs.MixingVolume Buildings.Fluid.FMI.Examples.FMUs.MixingVolume

Container to export a control volume as an FMU

Buildings.Fluid.FMI.Examples.FMUs.MixingVolume

Information

This example demonstrates how to export an FMU with a control volume. The FMU has an instance of Buildings.Fluid.MixingVolumes.MixingVolume.

The mass dynamics has been set to massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState. See the user's guide for the rationale.

Extends from TwoPort (Container to export a thermofluid flow model with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
VolumeV1Volume [m3]
MassFlowRatem_flow_nominal0.01Nominal mass flow rate [kg/s]
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
InletinletFluid inlet
OutletoutletFluid outlet

Modelica definition

block MixingVolume "Container to export a control volume as an FMU" extends TwoPort(redeclare package Medium = Buildings.Media.Air); parameter Modelica.SIunits.Volume V=1 "Volume"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal=0.01 "Nominal mass flow rate"; protected Buildings.Fluid.FMI.InletAdaptor bouIn( redeclare final package Medium=Medium, final allowFlowReversal=allowFlowReversal) "Boundary model for inlet"; Buildings.Fluid.FMI.OutletAdaptor bouOut( redeclare final package Medium=Medium, final allowFlowReversal=allowFlowReversal) "Boundary component for outlet"; Buildings.Fluid.MixingVolumes.MixingVolume vol( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final allowFlowReversal=allowFlowReversal, final V=V, nPorts=2, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState) "Control volume"; equation connect(inlet, bouIn.inlet); connect(bouOut.outlet, outlet); connect(bouIn.p, bouOut.p); connect(bouIn.port_b, vol.ports[1]); connect(vol.ports[2], bouOut.port_a); end MixingVolume;

Buildings.Fluid.FMI.Examples.FMUs.ResistanceVolume Buildings.Fluid.FMI.Examples.FMUs.ResistanceVolume

Container to export a flow resistance and control volume as an FMU

Buildings.Fluid.FMI.Examples.FMUs.ResistanceVolume

Information

This example demonstrates how to export an FMU with a flow resistance and a control volume. The FMU has an instance of Buildings.Fluid.FixedResistances.FixedResistanceDpM and Buildings.Fluid.MixingVolumes.MixingVolume.

The mass dynamics has been set to massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState. See the user's guide for the rationale.

Extends from TwoPort (Container to export a thermofluid flow model with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium in the component
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default
VolumeV1Volume [m3]
MassFlowRatem_flow_nominal0.01Nominal mass flow rate [kg/s]
Pressuredp_nominal100Nominal pressure drop [Pa]
Assumptions
BooleanallowFlowReversaltrue= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Connectors

TypeNameDescription
replaceable package MediumMedium in the component
InletinletFluid inlet
OutletoutletFluid outlet

Modelica definition

block ResistanceVolume "Container to export a flow resistance and control volume as an FMU" extends TwoPort(redeclare package Medium = Buildings.Media.Air); parameter Modelica.SIunits.Volume V=1 "Volume"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal=0.01 "Nominal mass flow rate"; parameter Modelica.SIunits.Pressure dp_nominal=100 "Nominal pressure drop"; Modelica.Blocks.Sources.RealExpression dpCom(y=res.port_a.p - res.port_b.p) if use_p_in "Pressure drop of the component"; protected Buildings.Fluid.FMI.InletAdaptor bouIn( redeclare final package Medium=Medium, final allowFlowReversal=allowFlowReversal, final use_p_in=use_p_in) "Boundary model for inlet"; Buildings.Fluid.FMI.OutletAdaptor bouOut( redeclare final package Medium=Medium, final allowFlowReversal=allowFlowReversal, final use_p_in=use_p_in) "Boundary component for outlet"; Modelica.Blocks.Math.Feedback pOut if use_p_in "Pressure at component outlet"; FixedResistances.FixedResistanceDpM res( redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final dp_nominal=if use_p_in then dp_nominal else 0, final allowFlowReversal=allowFlowReversal) "Flow resistance"; Buildings.Fluid.MixingVolumes.MixingVolume vol( nPorts=2, redeclare final package Medium = Medium, final m_flow_nominal=m_flow_nominal, final allowFlowReversal=allowFlowReversal, final V=V, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState) "Control volume"; equation connect(inlet, bouIn.inlet); connect(bouOut.outlet, outlet); connect(pOut.u1, bouIn.p); connect(pOut.y, bouOut.p); connect(res.port_b, vol.ports[1]); connect(bouIn.port_b, res.port_a); connect(dpCom.y, pOut.u2); connect(vol.ports[2], bouOut.port_a); end ResistanceVolume;

Buildings.Fluid.FMI.Examples.FMUs.TwoPortPassThrough Buildings.Fluid.FMI.Examples.FMUs.TwoPortPassThrough

FMU declaration for a block that simply passes all the inputs to the outputs

Buildings.Fluid.FMI.Examples.FMUs.TwoPortPassThrough

Information

This example demonstrates how to export an FMU that simply passes all its inputs to its outputs. Such an FMU could for example be used in a block diagram as a place-holder for another FMU that provides an actual implementation of a component.

Extends from Buildings.Fluid.FMI.TwoPort (Container to export a thermofluid flow model with two ports as an FMU).

Parameters

TypeNameDefaultDescription
replaceable package MediumPartialMediumMedium 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
InletinletFluid inlet
OutletoutletFluid outlet

Modelica definition

block TwoPortPassThrough "FMU declaration for a block that simply passes all the inputs to the outputs" extends Buildings.Fluid.FMI.TwoPort( redeclare replaceable package Medium = Buildings.Media.Air); equation connect(inlet, outlet); end TwoPortPassThrough;

Automatically generated Mon Jul 13 14:24:20 2015.