LBL logo

Buildings.Fluid.FMI.Examples

Collection of models that illustrate model use and test models

Information

This package contains examples for the use of models that can be found in Buildings.Fluid.FMI.

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

Package Content

Name Description
Buildings.Fluid.FMI.Examples.FlowSplitter_u FlowSplitter_u Flow splitter
Buildings.Fluid.FMI.Examples.HeaterFan HeaterFan Heater and fan in series, model configured to allow flow reversal
Buildings.Fluid.FMI.Examples.HeaterFanPressureDriven HeaterFanPressureDriven Heater and fan in series, model configured to allow flow reversal and pressure driven flow rate
Buildings.Fluid.FMI.Examples.HeaterFan_noReverseFlow HeaterFan_noReverseFlow Heater and fan in series, model configured to not allow flow reversal
Buildings.Fluid.FMI.Examples.FMUs FMUs Collection of models that can be exported as FMUs

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

Flow splitter

Buildings.Fluid.FMI.Examples.FlowSplitter_u

Information

This example demonstrates how to configure a model with a flow splitter.

For this example, the model is not exported as an FMU. However, the thermofluid flow models are wrapped using input/output blocks.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
MassFlowRatem_flow_nominal0.1Nominal mass flow rate [kg/s]
Booleanuse_p_infalse= true to use a pressure from connector, false to output Medium.p_default
Assumptions
BooleanallowFlowReversalfalse= true to allow flow reversal, false restricts to design direction (inlet -> outlet)

Modelica definition

model FlowSplitter_u "Flow splitter" extends Modelica.Icons.Example; package Medium = Buildings.Media.Air "Medium model"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal=0.1 "Nominal mass flow rate"; parameter Boolean use_p_in = false "= true to use a pressure from connector, false to output Medium.p_default"; parameter Boolean allowFlowReversal = false "= true to allow flow reversal, false restricts to design direction (inlet -> outlet)"; Modelica.Blocks.Sources.Constant uSpl(k=1.0) "Control signal for heater"; Source_T sou( redeclare package Medium = Medium, use_p_in=use_p_in, allowFlowReversal = allowFlowReversal) "Source for mass flow rate and pressure"; Modelica.Blocks.Sources.Constant m_flow(k=m_flow_nominal*3) "Mass flow rate"; Modelica.Blocks.Sources.Constant pIn(k=100000) "Inlet pressure"; Modelica.Blocks.Sources.Constant TIn(k=293.15) "Inlet temperature"; Modelica.Blocks.Sources.Constant X_w_in(k=0.01) "Inlet mass fraction"; Modelica.Blocks.Sources.Constant C[Medium.nC](each k=0.01) if Medium.nC > 0 "Trace substances for forward flow"; FMUs.FlowSplitter_u floSpl( redeclare package Medium = Medium, use_p_in=use_p_in, allowFlowReversal=allowFlowReversal); equation connect(m_flow.y, sou.m_flow_in); connect(sou.p_in, pIn.y); connect(TIn.y, sou.T_in); connect(C.y, sou.C_in); connect(X_w_in.y, sou.X_w_in); connect(floSpl.inlet, sou.outlet); connect(floSpl.u[1], uSpl.y); connect(floSpl.u[2], uSpl.y); end FlowSplitter_u;

Buildings.Fluid.FMI.Examples.HeaterFan Buildings.Fluid.FMI.Examples.HeaterFan

Heater and fan in series, model configured to allow flow reversal

Buildings.Fluid.FMI.Examples.HeaterFan

Information

This example demonstrates how to configure a model with a heater and a fan that causes a pressure rise in the air stream. Note that the mass flow rate and the absolute pressure are set by the component sou. Therefore, the fan simply increases the pressure of the medium, and it also computes how much power is needed for this pressure rise, which is an input to the fan model.

For a model with that computes the mass flow rate based on the pressure drop, see Buildings.Fluid.FMI.Examples.HeaterFanPressureDriven.

For this example, the models are not exported as FMUs. However, the thermofluid flow models are wrapped using input/output blocks.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
MassFlowRatem_flow_nominalQ_flow_nominal/1000/10Nominal mass flow rate [kg/s]
PressureDifferencedp_nominal2000Pressure [Pa]
HeatFlowRateQ_flow_nominal1000Heat flow rate at u=1, positive for heating [W]
Booleanuse_p_intrue= true to use a pressure from connector, false to output Medium.p_default

Modelica definition

model HeaterFan "Heater and fan in series, model configured to allow flow reversal" extends Modelica.Icons.Example; package Medium = Buildings.Media.Air "Medium model"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal=Q_flow_nominal/1000/10 "Nominal mass flow rate"; parameter Modelica.SIunits.PressureDifference dp_nominal(displayUnit="Pa")=2000 "Pressure"; parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal = 1000 "Heat flow rate at u=1, positive for heating"; parameter Boolean use_p_in = true "= true to use a pressure from connector, false to output Medium.p_default"; FMUs.Fan floMac( redeclare final package Medium = Medium, m_flow_nominal=m_flow_nominal, dp_nominal=dp_nominal, use_p_in=use_p_in) "Flow machine with pressure raise as an input"; FMUs.HeaterCooler_u hea( redeclare final package Medium = Medium, m_flow_nominal=m_flow_nominal, dp_nominal=dp_nominal, Q_flow_nominal=Q_flow_nominal, use_p_in=use_p_in) "Heater"; Modelica.Blocks.Sources.Constant dp(k=dp_nominal) "Pressure raise of fan"; Modelica.Blocks.Sources.Constant uHea(k=0.2) "Control signal for heater"; Source_T sou(redeclare package Medium = Medium, use_p_in=use_p_in) "Source for mass flow rate and pressure"; Sink_T sin(redeclare package Medium = Medium, use_p_in=use_p_in) "Sink for flow rate, and source for backflow properties"; Modelica.Blocks.Sources.Constant m_flow(k=m_flow_nominal) "Mass flow rate"; Modelica.Blocks.Sources.Constant pIn(k=100000) "Inlet pressure"; Modelica.Blocks.Sources.Constant TIn(k=293.15) "Inlet temperature"; Modelica.Blocks.Sources.Constant X_w_in(k=0.01) "Inlet mass fraction"; Modelica.Blocks.Sources.Constant TBac(k=303.15) "Temperature of backward flow"; Modelica.Blocks.Sources.Constant X_w_bac(k=0.015) "Moisture mass fraction for back flow"; Modelica.Blocks.Sources.Constant CBac[Medium.nC](each k=0.01) if Medium.nC > 0 "Trace substances for back flow"; Modelica.Blocks.Sources.Constant C[Medium.nC](each k=0.01) if Medium.nC > 0 "Trace substances for forward flow"; equation connect(uHea.y, hea.u); connect(dp.y, floMac.dp_in); connect(sou.outlet, hea.inlet); connect(hea.outlet, floMac.inlet); connect(sin.inlet, floMac.outlet); connect(sin.T_in, TBac.y); connect(CBac.y, sin.C_in); connect(m_flow.y, sou.m_flow_in); connect(sou.p_in, pIn.y); connect(TIn.y, sou.T_in); connect(C.y, sou.C_in); connect(X_w_in.y, sou.X_w_in); connect(sin.X_w_in, X_w_bac.y); end HeaterFan;

Buildings.Fluid.FMI.Examples.HeaterFanPressureDriven Buildings.Fluid.FMI.Examples.HeaterFanPressureDriven

Heater and fan in series, model configured to allow flow reversal and pressure driven flow rate

Buildings.Fluid.FMI.Examples.HeaterFanPressureDriven

Information

This example demonstrates how to configure a model with a heater and a fan that causes a pressure rise in the air stream. The fan increases the pressure of the medium, and it also computes how much power is needed for this pressure rise, which is an input to the fan model.

The component invBloCon at the bottom of the model sets up an equality constraint on the pressure between the sink and the source. It also outputs a signal for the mass flow rate. Hence, this component is used to declare how to break the algebraic loop in this signal flow diagram. For a model with prescribed mass flow rate, see Buildings.Fluid.FMI.Examples.HeaterFan.

For this example, the models are not exported as FMUs. However, the thermofluid flow models are wrapped using input/output blocks.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
MassFlowRatem_flow_nominalQ_flow_nominal/1000/10Nominal mass flow rate [kg/s]
PressureDifferencedp_nominal2000Pressure [Pa]
HeatFlowRateQ_flow_nominal1000Heat flow rate at u=1, positive for heating [W]

Modelica definition

model HeaterFanPressureDriven "Heater and fan in series, model configured to allow flow reversal and pressure driven flow rate" extends Modelica.Icons.Example; package Medium = Buildings.Media.Air "Medium model"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal=Q_flow_nominal/1000/10 "Nominal mass flow rate"; parameter Modelica.SIunits.PressureDifference dp_nominal(displayUnit="Pa")=2000 "Pressure"; parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal = 1000 "Heat flow rate at u=1, positive for heating"; constant Boolean use_p_in = true "Set to true, as this model computes the mass flow rate based on the pressure drop"; FMUs.Fan floMac( m_flow_nominal=m_flow_nominal, dp_nominal=dp_nominal, use_p_in=use_p_in) "Flow machine with pressure raise as an input"; FMUs.HeaterCooler_u hea( m_flow_nominal=m_flow_nominal, dp_nominal=dp_nominal, Q_flow_nominal=Q_flow_nominal, use_p_in=use_p_in) "Heater"; Modelica.Blocks.Sources.Constant dp(k=dp_nominal) "Pressure raise of fan"; Modelica.Blocks.Sources.Constant uHea(k=0.2) "Control signal for heater"; Source_T sou(redeclare package Medium = Medium, use_p_in=use_p_in) "Source for mass flow rate and pressure"; Sink_T sin(redeclare package Medium = Medium, use_p_in=use_p_in) "Sink for flow rate, and source for backflow properties"; Modelica.Blocks.Sources.Constant m_flow(k=m_flow_nominal) "Mass flow rate"; Modelica.Blocks.Sources.Constant pIn(k=100000) "Inlet pressure"; Modelica.Blocks.Sources.Constant TIn(k=293.15) "Inlet temperature"; Modelica.Blocks.Sources.Constant X_w_in(k=0.01) "Inlet mass fraction"; Modelica.Blocks.Sources.Constant TBac(k=303.15) "Temperature of backward flow"; Modelica.Blocks.Sources.Constant X_w_bac(k=0.015) "Moisture mass fraction for back flow"; Modelica.Blocks.Sources.Constant CBac[Medium.nC](each k=0.01) if Medium.nC > 0 "Trace substances for back flow"; Modelica.Blocks.Sources.Constant C[Medium.nC](each k=0.01) if Medium.nC > 0 "Trace substances for forward flow"; Modelica.Blocks.Math.InverseBlockConstraints invBloCon "Block to set up residual function for nonlinear system of equation for pressure drop and mass flow rate"; equation connect(uHea.y, hea.u); connect(dp.y, floMac.dp_in); connect(sou.outlet, hea.inlet); connect(hea.outlet, floMac.inlet); connect(sin.inlet, floMac.outlet); connect(sin.T_in, TBac.y); connect(CBac.y, sin.C_in); connect(sou.p_in, pIn.y); connect(TIn.y, sou.T_in); connect(C.y, sou.C_in); connect(pIn.y, invBloCon.u1); connect(sin.p, invBloCon.u2); connect(invBloCon.y1, sou.m_flow_in); connect(X_w_in.y, sou.X_w_in); connect(X_w_bac.y, sin.X_w_in); end HeaterFanPressureDriven;

Buildings.Fluid.FMI.Examples.HeaterFan_noReverseFlow Buildings.Fluid.FMI.Examples.HeaterFan_noReverseFlow

Heater and fan in series, model configured to not allow flow reversal

Buildings.Fluid.FMI.Examples.HeaterFan_noReverseFlow

Information

This example demonstrates how to configure a model with a heater and a fan that causes a pressure rise in the air stream. The model is identical with Buildings.Fluid.FMI.Examples.HeaterFan except that reverse flow is not allowed due to the parameter allowFlowReversal=false. Consequently, the connectors for the fluid properties for the reverse flow are removed, and the blocks on the right hand side of the model Buildings.Fluid.FMI.Examples.HeaterFan have been deleted.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
Booleanuse_p_infalse= true to use a pressure from connector, false to output Medium.p_default
MassFlowRatem_flow_nominalQ_flow_nominal/1000/10Nominal mass flow rate [kg/s]
PressureDifferencedp_nominal2000Pressure [Pa]
HeatFlowRateQ_flow_nominal1000Heat flow rate at u=1, positive for heating [W]

Modelica definition

model HeaterFan_noReverseFlow "Heater and fan in series, model configured to not allow flow reversal" extends Modelica.Icons.Example; package Medium = Buildings.Media.Air "Medium model"; final parameter Boolean allowFlowReversal = false "= true to allow flow reversal, false restricts to design direction (inlet -> outlet)"; parameter Boolean use_p_in = false "= true to use a pressure from connector, false to output Medium.p_default"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal=Q_flow_nominal/1000/10 "Nominal mass flow rate"; parameter Modelica.SIunits.PressureDifference dp_nominal(displayUnit="Pa")=2000 "Pressure"; parameter Modelica.SIunits.HeatFlowRate Q_flow_nominal = 1000 "Heat flow rate at u=1, positive for heating"; FMUs.Fan floMac( redeclare final package Medium = Medium, m_flow_nominal=m_flow_nominal, dp_nominal=dp_nominal, final allowFlowReversal=allowFlowReversal, use_p_in=use_p_in) "Flow machine with pressure raise as an input"; FMUs.HeaterCooler_u hea( redeclare final package Medium = Medium, m_flow_nominal=m_flow_nominal, dp_nominal=dp_nominal, Q_flow_nominal=Q_flow_nominal, final allowFlowReversal=allowFlowReversal, use_p_in=use_p_in) "Heater"; Modelica.Blocks.Sources.Constant dp(k=1000) "Pressure raise of fan"; Modelica.Blocks.Sources.Constant uHea(k=0.2) "Control signal for heater"; Source_T sou( redeclare package Medium = Medium, final allowFlowReversal=allowFlowReversal, use_p_in=use_p_in) "Source for mass flow rate and pressure"; Modelica.Blocks.Sources.Constant m_flow(k=m_flow_nominal) "Mass flow rate"; Modelica.Blocks.Sources.Constant pIn(k=100000) "Inlet pressure"; Modelica.Blocks.Sources.Constant TIn(k=293.15) "Inlet temperature"; Modelica.Blocks.Sources.Constant X_w_in(k=0.01) "Inlet mass fraction"; Modelica.Blocks.Sources.Constant C[Medium.nC](each k=0.01) if Medium.nC > 0 "Trace substances for forward flow"; equation connect(uHea.y, hea.u); connect(dp.y, floMac.dp_in); connect(sou.outlet, hea.inlet); connect(hea.outlet, floMac.inlet); connect(m_flow.y, sou.m_flow_in); connect(sou.p_in, pIn.y); connect(TIn.y, sou.T_in); connect(C.y, sou.C_in); connect(X_w_in.y, sou.X_w_in); end HeaterFan_noReverseFlow;

http://simulationresearch.lbl.gov/modelica