Buildings.Fluid.Examples

Example models integrating multiple components

Information

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

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

Package Content

Name Description
Buildings.Fluid.Examples.ResistanceVolumeFlowReversal ResistanceVolumeFlowReversal System demonstrating impact of allowFlowReversal on number/size of non-linear systems
Buildings.Fluid.Examples.SimpleHouse SimpleHouse Illustrative example of a simple heating, ventilation and room model
Buildings.Fluid.Examples.FlowSystem FlowSystem  
Buildings.Fluid.Examples.Performance Performance Package of examples that demonstrate computation speed performance

Buildings.Fluid.Examples.ResistanceVolumeFlowReversal Buildings.Fluid.Examples.ResistanceVolumeFlowReversal

System demonstrating impact of allowFlowReversal on number/size of non-linear systems

Buildings.Fluid.Examples.ResistanceVolumeFlowReversal

Information

This model demonstrates the impact of the allowFlowReversal parameter on the size of nonlinear systems of equations. The user can change the parameter value in the allowFlowReversal block and rerun the simulation. The results are also demonstrated below for nRes.k = 10, which is the number of parallel branches containing one pressure drop element and one mixing volume each.

This model was created to demonstrate the influence of a new implementation of Buildings.Fluid.Interfaces.ConservationEquation. The old implementation used the actualStream() function whereas the new implementation uses the semiLinear() function. This change allows Dymola to exploit knowledge about the min and max attributes of m_flow. When Dymola knows in which way the medium will flow, nonlinear systems can be simplified or completely removed. This is illustrated by the results below. See issue 216 for a discussion.

Note that Dymola 2015FD01 can only reliable solve the last case. For the other two cases the Newton solver of the nonlinear system does not converge.

These results were generated using Dymola 2015FD01 64 bit on Ubuntu 14.04 and with Evaluate=false.

ResistanceVolumeFlowReversal = true

Sizes of nonlinear systems of equations: {6, 11, 56}
Sizes after manipulation of the nonlinear systems: {1, 9, 12}

ResistanceVolumeFlowReversal = false

Old implementation

Sizes of nonlinear systems of equations: {6, 11, 44}
Sizes after manipulation of the nonlinear systems: {1, 9, 11}

New implementation

Sizes of nonlinear systems of equations: {6, 11, 4}
Sizes after manipulation of the nonlinear systems: {1, 9, 1}

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

Parameters

TypeNameDefaultDescription
Realm_flow_nominal0.1Gain value multiplied with input signal

Modelica definition

model ResistanceVolumeFlowReversal "System demonstrating impact of allowFlowReversal on number/size of non-linear systems" extends Modelica.Icons.Example; package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; parameter Real m_flow_nominal=0.1 "Gain value multiplied with input signal"; Buildings.Fluid.Sources.Boundary_pT bou(redeclare package Medium = Medium, nPorts=1) "Boundary for pressure boundary condition"; Movers.FlowControlled_m_flow pump( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, use_inputFilter=false, allowFlowReversal=allowFlowReversal.k, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, nominalValuesDefineDefaultPressureCurve=true) "Pump model with unidirectional flow"; Buildings.Fluid.HeatExchangers.Heater_T hea( redeclare package Medium = Medium, dp_nominal=1000, QMax_flow=1000, m_flow_nominal=m_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, allowFlowReversal=allowFlowReversal.k) "Heater"; Modelica.Blocks.Sources.Pulse pulse(period=1000) "Pulse input"; Modelica.Blocks.Math.Gain gain(k=m_flow_nominal) "Gain for m_flow_nominal"; Buildings.Fluid.Actuators.Valves.ThreeWayLinear val( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dpValve_nominal=1000, l={0.002,0.002}, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState) "Three way valve with constant input"; Modelica.Blocks.Sources.Constant const(k=0.5) "Constant valve set point"; Modelica.Blocks.Sources.BooleanConstant allowFlowReversal(k=false) "Block for setting allowFlowReversal in components"; Buildings.Fluid.FixedResistances.PressureDrop[nRes.k] res( redeclare package Medium = Medium, each allowFlowReversal=allowFlowReversal.k, each m_flow_nominal=m_flow_nominal, each dp_nominal=1000) "Fluid resistance for splitting flow"; Modelica.Blocks.Sources.IntegerConstant nRes(k=10) "Number of parallel branches"; Delays.DelayFirstOrder[nRes.k] vol( redeclare each package Medium = Medium, each m_flow_nominal=m_flow_nominal, each nPorts=2, each energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, each massDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, each allowFlowReversal=true) "Mixing volumes for enthalpy circuit"; equation connect(bou.ports[1], hea.port_a); connect(pulse.y, hea.TSet); connect(pump.m_flow_in, gain.y); connect(gain.u, pulse.y); connect(hea.port_b, val.port_1); connect(val.port_2, pump.port_a); connect(const.y, val.y); connect(val.port_3, hea.port_a); for i in 1:nRes.k loop connect(pump.port_b, res[i].port_a); connect(res[i].port_b, vol[i].ports[1]); connect(vol[i].ports[2], val.port_3); end for; end ResistanceVolumeFlowReversal;

Buildings.Fluid.Examples.SimpleHouse Buildings.Fluid.Examples.SimpleHouse

Illustrative example of a simple heating, ventilation and room model

Buildings.Fluid.Examples.SimpleHouse

Information

This model contains a simple model of a house with a heating system, ventilation and weather boundary conditions. It servers as a demonstration case of how the Buildings library can be used.

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

Parameters

TypeNameDefaultDescription
AreaA_wall100Wall area [m2]
AreaA_win5Window area [m2]
Realg_win0.3Solar heat gain coefficient of window [1]
VolumeV_zoneA_wall*3Wall area [m3]
HeatFlowRateQHea_nominal700Nominal capacity of heating system [W]
MassFlowRatemWat_flow_nominalQHea_nominal/10/4200Nominal mass flow rate for water loop [kg/s]
MassFlowRatemAir_flow_nominalV_zone*2*1.2/3600Nominal mass flow rate for air loop [kg/s]
PressureDifferencedpAir_nominal200Pressure drop at nominal mass flow rate for air loop [Pa]
BooleanallowFlowReversalfalse= false because flow will not reverse in these circuits

Connectors

TypeNameDescription
BusweaBusWeather data bus

Modelica definition

model SimpleHouse "Illustrative example of a simple heating, ventilation and room model" extends Modelica.Icons.Example; package MediumAir = Buildings.Media.Air; package MediumWater = Buildings.Media.Water; parameter Modelica.SIunits.Area A_wall=100 "Wall area"; parameter Modelica.SIunits.Area A_win=5 "Window area"; parameter Real g_win( min=0, max=1, unit="1") = 0.3 "Solar heat gain coefficient of window"; parameter Modelica.SIunits.Volume V_zone=A_wall*3 "Wall area"; parameter Modelica.SIunits.HeatFlowRate QHea_nominal=700 "Nominal capacity of heating system"; parameter Modelica.SIunits.MassFlowRate mWat_flow_nominal=QHea_nominal/10/4200 "Nominal mass flow rate for water loop"; parameter Modelica.SIunits.MassFlowRate mAir_flow_nominal=V_zone*2*1.2/3600 "Nominal mass flow rate for air loop"; parameter Modelica.SIunits.PressureDifference dpAir_nominal=200 "Pressure drop at nominal mass flow rate for air loop"; parameter Boolean allowFlowReversal=false "= false because flow will not reverse in these circuits"; Modelica.Thermal.HeatTransfer.Components.HeatCapacitor walCap(T(fixed=true), C=10*A_wall*0.05*1000*1000) "Thermal mass of walls"; MixingVolumes.MixingVolume zone( redeclare package Medium = MediumAir, V=V_zone, nPorts=2, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, m_flow_nominal=mAir_flow_nominal, massDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial) "Very based zone air model"; Modelica.Thermal.HeatTransfer.Components.ThermalResistor convRes(R=1/2/A_wall) "Thermal resistance for convective heat transfer with h=2"; HeatExchangers.Radiators.RadiatorEN442_2 rad( redeclare package Medium = MediumWater, T_a_nominal=273.15 + 50, T_b_nominal=273.15 + 40, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, allowFlowReversal=allowFlowReversal, Q_flow_nominal=QHea_nominal) "Radiator"; Sources.Boundary_pT bouAir( redeclare package Medium = MediumAir, nPorts=2, use_T_in=true) "Air boundary with constant temperature"; Sources.Boundary_pT bouWat(redeclare package Medium = MediumWater, nPorts=1) "Pressure bound for water circuit"; BoundaryConditions.WeatherData.ReaderTMY3 weaDat(filNam="modelica://Buildings/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos") "Weather data reader"; BoundaryConditions.WeatherData.Bus weaBus "Weather data bus"; Modelica.Thermal.HeatTransfer.Components.ThermalResistor wallRes(R=0.25/ A_wall/0.04) "Thermal resistor for wall: 25 cm of rockwool"; Buildings.HeatTransfer.Sources.PrescribedTemperature Tout "Exterior temperature boundary condition"; HeatExchangers.HeaterCooler_u heaWat( redeclare package Medium = MediumWater, m_flow_nominal=mWat_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=allowFlowReversal, dp_nominal=5000, Q_flow_nominal=QHea_nominal) "Heater for water circuit"; Movers.FlowControlled_m_flow pump( redeclare package Medium = MediumWater, use_inputFilter=false, m_flow_nominal=mWat_flow_nominal, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=allowFlowReversal, nominalValuesDefineDefaultPressureCurve=true, inputType=Buildings.Fluid.Types.InputType.Stages, massFlowRates=mWat_flow_nominal*{1}) "Pump"; Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor senTemZonAir "Zone air temperature sensor"; Actuators.Dampers.VAVBoxExponential vavDam( redeclare package Medium = MediumAir, dp_nominal=dpAir_nominal, from_dp=true, m_flow_nominal=mAir_flow_nominal) "Damper"; Movers.FlowControlled_dp fan( redeclare package Medium = MediumAir, dp_nominal=dpAir_nominal, use_inputFilter=false, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, nominalValuesDefineDefaultPressureCurve=true, m_flow_nominal=mAir_flow_nominal, show_T=true) "Constant head fan"; Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow window "Very simple window model"; HeatExchangers.ConstantEffectiveness hexRec( redeclare package Medium1 = MediumAir, redeclare package Medium2 = MediumAir, dp1_nominal=0, dp2_nominal=0, m1_flow_nominal=mAir_flow_nominal, m2_flow_nominal=mAir_flow_nominal, eps=0.85) "Heat exchanger for heat recuperation"; Modelica.Blocks.Logical.Hysteresis hysRad(uLow=273.15 + 20, uHigh=273.15 + 22) "Hysteresis controller for radiator"; Modelica.Blocks.Math.BooleanToReal booleanToReal1 "Boolean to real"; Modelica.Blocks.Logical.Not not1 "negation for enabling heating when temperatur is low"; Modelica.Blocks.Sources.Constant const_dp(k=dpAir_nominal) "Pressure head"; Modelica.Blocks.Math.Gain gaiWin(k=A_win*g_win) "Gain for window solar transmittance and area as HGloHor is in W/m2"; Modelica.Blocks.Math.BooleanToInteger booleanToInt "Boolean to integer"; Controls.Continuous.LimPID conDam(controllerType=Modelica.Blocks.Types.SimpleController.P, yMin=0.1) "Controller for damper"; Modelica.Blocks.Sources.Constant TSetRoo(k=273.15 + 24) "Room temperature set point for air system"; HeatExchangers.SensibleCooler_T cooAir( energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=allowFlowReversal, m_flow_nominal=mAir_flow_nominal, dp_nominal=0, redeclare package Medium = MediumAir) "Cooling for supply air"; Modelica.Blocks.Sources.Constant TSupAirCoo(k=273.15 + 20) "Cooling setpoint for supply air"; equation connect(convRes.port_b, walCap.port); connect(convRes.port_a, zone.heatPort); connect(weaDat.weaBus, weaBus); connect(wallRes.port_b, walCap.port); connect(Tout.T, weaBus.TDryBul); connect(Tout.port, wallRes.port_a); connect(heaWat.port_b, rad.port_a); connect(bouWat.ports[1], heaWat.port_a); connect(rad.port_b, pump.port_a); connect(senTemZonAir.port, zone.heatPort); connect(window.port, walCap.port); connect(bouAir.ports[1], hexRec.port_b1); connect(hexRec.port_a1, zone.ports[1]); connect(rad.heatPortCon, zone.heatPort); connect(rad.heatPortRad, walCap.port); connect(not1.y, booleanToReal1.u); connect(not1.u, hysRad.y); connect(booleanToReal1.y, heaWat.u); connect(heaWat.port_a, pump.port_b); connect(const_dp.y, fan.dp_in); connect(gaiWin.y, window.Q_flow); connect(gaiWin.u, weaBus.HGloHor); connect(booleanToInt.u, not1.y); connect(booleanToInt.y, pump.stage); connect(bouAir.ports[2], hexRec.port_a2); connect(hexRec.port_b2, fan.port_a); connect(vavDam.port_b, zone.ports[2]); connect(senTemZonAir.T, hysRad.u); connect(senTemZonAir.T, conDam.u_s); connect(conDam.y, vavDam.y); connect(TSetRoo.y, conDam.u_m); connect(fan.port_b, cooAir.port_a); connect(cooAir.port_b, vavDam.port_a); connect(TSupAirCoo.y, cooAir.TSet); connect(bouAir.T_in, weaBus.TDryBul); end SimpleHouse;