Buildings.Fluid.Storage.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.Storage.

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

Package Content

Name Description
Buildings.Fluid.Storage.Examples.ExpansionVessel ExpansionVessel Test model for expansion vessel
Buildings.Fluid.Storage.Examples.Stratified Stratified Test model for stratified tank
Buildings.Fluid.Storage.Examples.StratifiedEnhancedInternalHex StratifiedEnhancedInternalHex Example showing the use of StratifiedEnhancedInternalHex
Buildings.Fluid.Storage.Examples.StratifiedUnloadAtMinimumTemperature StratifiedUnloadAtMinimumTemperature Example that demonstrates how to draw from a hot water tank at the minimum temperature

Buildings.Fluid.Storage.Examples.ExpansionVessel Buildings.Fluid.Storage.Examples.ExpansionVessel

Test model for expansion vessel

Buildings.Fluid.Storage.Examples.ExpansionVessel

Information

This model tests a pressure expansion vessel. The medium model that is used in this example changes its density as a function of temperature. To see the effect of the expansion vessel, delete the connecting line between the volume and the expansion vessel and check how much more the pressure increases as the fluid is heated.

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

Modelica definition

model ExpansionVessel "Test model for expansion vessel" extends Modelica.Icons.Example; // package Medium = Modelica.Media.Water.WaterIF97OnePhase_ph "Medium model"; package Medium = Buildings.Media.Water "Medium model"; Buildings.Fluid.Storage.ExpansionVessel expVes( redeclare package Medium = Medium, V_start=1) "Expansion vessel"; Buildings.Fluid.MixingVolumes.MixingVolume vol( redeclare package Medium = Medium, V=1, nPorts=1, m_flow_nominal=0.001, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial) "Volume of water"; Modelica.Blocks.Sources.Pulse pulse( amplitude=20, period=3600, offset=293.15); Buildings.HeatTransfer.Sources.PrescribedTemperature preTem; Modelica.Thermal.HeatTransfer.Components.ThermalConductor theCon(G=10000); equation connect(pulse.y, preTem.T); connect(preTem.port, theCon.port_a); connect(theCon.port_b, vol.heatPort); connect(vol.ports[1], expVes.port_a); end ExpansionVessel;

Buildings.Fluid.Storage.Examples.Stratified Buildings.Fluid.Storage.Examples.Stratified

Test model for stratified tank

Buildings.Fluid.Storage.Examples.Stratified

Information

This test model compares two tank models. The only difference between the two tank models is that one uses the third order upwind discretization scheme that reduces numerical diffusion that is induced when connecting volumes in series.

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

Modelica definition

model Stratified "Test model for stratified tank" extends Modelica.Icons.Example; package Medium = Buildings.Media.Water "Medium model"; Buildings.Fluid.Storage.Stratified tanSim( redeclare package Medium = Medium, hTan=3, dIns=0.3, nSeg=10, m_flow_nominal=0.1, VTan=3) "Tank"; Modelica.Blocks.Sources.TimeTable TWat(table=[0,273.15 + 40; 3600,273.15 + 40; 3600,273.15 + 20; 7200,273.15 + 20]) "Water temperature"; Buildings.Fluid.Sources.Boundary_pT sou_1( p=300000 + 5000, T=273.15 + 50, redeclare package Medium = Medium, use_T_in=true, nPorts=2); Buildings.Fluid.Sources.Boundary_pT sin_1( redeclare package Medium = Medium, T=273.15 + 20, use_p_in=true, p=300000, nPorts=2); Buildings.Fluid.FixedResistances.PressureDrop res_1( from_dp=true, redeclare package Medium = Medium, dp_nominal=5000, m_flow_nominal=0.1); Buildings.Fluid.Storage.StratifiedEnhanced tanEnh( redeclare package Medium = Medium, hTan=3, dIns=0.3, nSeg=10, m_flow_nominal=0.1, VTan=3) "Tank"; Buildings.Fluid.FixedResistances.PressureDrop res_2( from_dp=true, redeclare package Medium = Medium, dp_nominal=5000, m_flow_nominal=0.1); Buildings.Fluid.Sensors.EnthalpyFlowRate HOut_flow(redeclare package Medium = Medium, m_flow_nominal=0.1) "Enthalpy flow rate"; Buildings.Fluid.Sensors.EnthalpyFlowRate HOut_flow1(redeclare package Medium = Medium, m_flow_nominal=0.1) "Enthalpy flow rate"; Modelica.Blocks.Continuous.Integrator dH "Differenz in enthalpy (should be zero at steady-state)"; Modelica.Blocks.Math.Add add(k2=-1); Modelica.Blocks.Sources.TimeTable P(table=[0,300000; 4200,300000; 4200, 305000; 7200,305000; 7200,310000; 10800,310000; 10800,305000]) "Pressure boundary condition"; Modelica.Blocks.Sources.Sine sine( freqHz=1/86400, amplitude=10, offset=273.15 + 20); Buildings.HeatTransfer.Sources.PrescribedTemperature TBCSid2 "Boundary condition for tank"; Buildings.HeatTransfer.Sources.PrescribedTemperature TBCSid1 "Boundary condition for tank"; Buildings.HeatTransfer.Sources.PrescribedTemperature TBCTop1 "Boundary condition for tank"; Buildings.HeatTransfer.Sources.PrescribedTemperature TBCTop2 "Boundary condition for tank"; equation connect(TWat.y, sou_1.T_in); connect(tanSim.port_b, HOut_flow.port_a); connect(HOut_flow.port_b, res_1.port_a); connect(tanEnh.port_b, HOut_flow1.port_a); connect(HOut_flow1.port_b, res_2.port_a); connect(add.y, dH.u); connect(HOut_flow.H_flow, add.u1); connect(HOut_flow1.H_flow, add.u2); connect(P.y, sin_1.p_in); connect(sine.y, TBCSid1.T); connect(sine.y, TBCTop1.T); connect(sine.y, TBCSid2.T); connect(sine.y, TBCTop2.T); connect(TBCSid2.port, tanEnh.heaPorSid); connect(TBCTop2.port, tanEnh.heaPorTop); connect(sin_1.ports[1], res_1.port_b); connect(sin_1.ports[2], res_2.port_b); connect(sou_1.ports[1], tanSim.port_a); connect(sou_1.ports[2], tanEnh.port_a); connect(TBCSid1.port, tanSim.heaPorSid); connect(TBCTop1.port, tanSim.heaPorTop); end Stratified;

Buildings.Fluid.Storage.Examples.StratifiedEnhancedInternalHex Buildings.Fluid.Storage.Examples.StratifiedEnhancedInternalHex

Example showing the use of StratifiedEnhancedInternalHex

Buildings.Fluid.Storage.Examples.StratifiedEnhancedInternalHex

Information

This model provides an example for the Buildings.Fluid.Storage.StratifiedEnhancedInternalHex model. There are three tanks. In the tank on top, the fluid in the heat exchanger and the metal of the heat exchanger use a steady-state energy balance. In the middle tank, both use a dynamic balance. In the bottom tank, the fluid uses a steady-state heat balance but the metal of the heat exchanger uses a dynamic balance.

Each tank starts at the same water temperature, and there is no water flow through the tank. The glycol that flows through the heat exchanger starts with zero mass flow rate, and is set to its design flow rate at t=300 seconds.

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

Parameters

TypeNameDefaultDescription
PressureDifferencedpHex_nominal2500Pressure drop across the heat exchanger at nominal conditions [Pa]
MassFlowRatemHex_flow_nominal0.278Mass flow rate of heat exchanger [kg/s]

Modelica definition

model StratifiedEnhancedInternalHex "Example showing the use of StratifiedEnhancedInternalHex" extends Modelica.Icons.Example; package MediumTan = Buildings.Media.Water "Medium in the tank"; package MediumHex = Buildings.Media.Water "Medium in the heat exchanger"; parameter Modelica.SIunits.PressureDifference dpHex_nominal=2500 "Pressure drop across the heat exchanger at nominal conditions"; parameter Modelica.SIunits.MassFlowRate mHex_flow_nominal = 0.278 "Mass flow rate of heat exchanger"; Buildings.Fluid.Sources.Boundary_pT bouWat(redeclare package Medium = MediumTan, nPorts=3) "Boundary condition for water (used to set pressure)"; Buildings.Fluid.Sources.Boundary_pT solColSup( redeclare package Medium = MediumHex, nPorts=3, use_p_in=true, T=353.15) "Water from solar collector"; Buildings.Fluid.Sources.Boundary_pT toSolCol( redeclare package Medium = MediumHex, nPorts=3, p(displayUnit="Pa") = 3E5, T=283.15) "Water to solar collector"; Buildings.Fluid.Storage.StratifiedEnhancedInternalHex tanSte( redeclare package Medium = MediumTan, m_flow_nominal=0.001, VTan=0.151416, dIns=0.0762, redeclare package MediumHex = MediumHex, CHex=40, Q_flow_nominal=0.278*4200*20, hTan=1.746, hHex_a=0.995, hHex_b=0.1, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, energyDynamicsHex=Modelica.Fluid.Types.Dynamics.SteadyState, allowFlowReversal=false, allowFlowReversalHex=false, mHex_flow_nominal=mHex_flow_nominal, TTan_nominal=293.15, THex_nominal=323.15, dpHex_nominal=dpHex_nominal) "Tank with heat exchanger configured as steady state"; Buildings.Fluid.Sensors.TemperatureTwoPort senTemSte( redeclare package Medium = MediumHex, allowFlowReversal=false, m_flow_nominal=mHex_flow_nominal, tau=0) "Temperature sensor for outlet of steady-state heat exchanger"; Modelica.Blocks.Sources.Step step( height=dpHex_nominal, offset=3E5, startTime=300) "Step input for mass flow rate"; Buildings.Fluid.Sensors.TemperatureTwoPort senTemDyn( redeclare package Medium = MediumHex, allowFlowReversal=false, m_flow_nominal=mHex_flow_nominal, tau=0) "Temperature sensor for outlet of dynamic heat exchanger"; Buildings.Fluid.Storage.StratifiedEnhancedInternalHex tanDyn( redeclare package Medium = MediumTan, m_flow_nominal=0.001, VTan=0.151416, dIns=0.0762, redeclare package MediumHex = MediumHex, CHex=40, Q_flow_nominal=0.278*4200*20, hTan=1.746, hHex_a=0.995, hHex_b=0.1, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, allowFlowReversal=false, allowFlowReversalHex=false, mHex_flow_nominal=mHex_flow_nominal, energyDynamicsHex=Modelica.Fluid.Types.Dynamics.FixedInitial, TTan_nominal=293.15, THex_nominal=323.15) "Tank with heat exchanger configured as dynamic"; Buildings.Fluid.Storage.StratifiedEnhancedInternalHex tanDynSol( redeclare package Medium = MediumTan, m_flow_nominal=0.001, VTan=0.151416, dIns=0.0762, redeclare package MediumHex = MediumHex, CHex=40, Q_flow_nominal=0.278*4200*20, hTan=1.746, hHex_a=0.995, hHex_b=0.1, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, allowFlowReversal=false, allowFlowReversalHex=false, mHex_flow_nominal=mHex_flow_nominal, energyDynamicsHex=Modelica.Fluid.Types.Dynamics.SteadyState, energyDynamicsHexSolid=Modelica.Fluid.Types.Dynamics.SteadyStateInitial, TTan_nominal=293.15, THex_nominal=323.15) "Tank with heat exchanger configured as steady-state except for metal which is dynamic"; Buildings.Fluid.Sensors.TemperatureTwoPort senTemDynSol( redeclare package Medium = MediumHex, allowFlowReversal=false, m_flow_nominal=mHex_flow_nominal, tau=0) "Temperature sensor for outlet of steady state heat exchanger with solid configured dynamic"; equation connect(solColSup.ports[1], tanSte.portHex_a); connect(senTemSte.port_b, toSolCol.ports[1]); connect(senTemSte.port_a, tanSte.portHex_b); connect(senTemDyn.port_a, tanDyn.portHex_b); connect(senTemDyn.port_b, toSolCol.ports[2]); connect(tanDynSol.portHex_b, senTemDynSol.port_a); connect(senTemDynSol.port_b, toSolCol.ports[3]); connect(solColSup.ports[2], tanDyn.portHex_a); connect(solColSup.ports[3], tanDynSol.portHex_a); connect(bouWat.ports[1], tanSte.port_b); connect(bouWat.ports[2], tanDyn.port_b); connect(bouWat.ports[3], tanDynSol.port_b); connect(step.y, solColSup.p_in); end StratifiedEnhancedInternalHex;

Buildings.Fluid.Storage.Examples.StratifiedUnloadAtMinimumTemperature Buildings.Fluid.Storage.Examples.StratifiedUnloadAtMinimumTemperature

Example that demonstrates how to draw from a hot water tank at the minimum temperature

Buildings.Fluid.Storage.Examples.StratifiedUnloadAtMinimumTemperature

Information

Example for tank model that has three outlets, each with a valve. The valve at the bottom opens when the temperature in that tank segment is sufficiently warm to serve the load. The tank in the middle also opens when its tank temperature is sufficiently high, but only if the valve below is closed. Finally, the valve at the top only opens if no other valve is open. Hence, there is always exactly one valve open. On the right-hand side of the model is a heater that adds heat to the bottom of the tank if the top tank segment is below the set point temperature.

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

Parameters

TypeNameDefaultDescription
VolumeVTan3Tank volume [m3]
MassFlowRatem_flow_nominal3*1000/3600Nominal mass flow rate [kg/s]

Modelica definition

model StratifiedUnloadAtMinimumTemperature "Example that demonstrates how to draw from a hot water tank at the minimum temperature" extends Modelica.Icons.Example; package Medium = Buildings.Media.Water "Medium model"; parameter Modelica.SIunits.Volume VTan=3 "Tank volume"; parameter Modelica.SIunits.MassFlowRate m_flow_nominal = 3*1000/3600 "Nominal mass flow rate"; constant Integer nSeg=5 "Number of volume segments"; Buildings.Fluid.Storage.Stratified tan( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, VTan=VTan, hTan=2, dIns=0.2, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, nSeg=nSeg, T_start=353.15) "Hot water storage tank"; Buildings.Fluid.Sources.Boundary_pT loa(redeclare package Medium = Medium, nPorts=1) "Load (imposed by a constant pressure boundary condition and the flow of masSou)"; Buildings.Fluid.Sources.MassFlowSource_T masSou( nPorts=1, redeclare package Medium = Medium, m_flow=m_flow_nominal) "Mass flow rate into the tank"; Buildings.Fluid.Actuators.Valves.TwoWayLinear valTop( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dpValve_nominal=3000, use_inputFilter=false) "Control valve at top"; Buildings.Fluid.Actuators.Valves.TwoWayLinear valMed( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dpValve_nominal=3000, use_inputFilter=false) "Control valve at top"; Buildings.Fluid.Actuators.Valves.TwoWayLinear valBot( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, dpValve_nominal=3000, use_inputFilter=false) "Control valve at top"; Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor TMid "Temperature tank middle"; Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor TBot "Temperature tank bottom"; Modelica.Blocks.Logical.Hysteresis onOffBot(uLow=273.15 + 40 - 0.05, uHigh= 273.15 + 40 + 0.05) "Controller for valve at bottom"; Buildings.Fluid.Sensors.TemperatureTwoPort senTem( redeclare package Medium = Medium, m_flow_nominal=m_flow_nominal, tau=0) "Outflowing temperature"; Modelica.Blocks.Logical.Hysteresis onOffMid(uLow=273.15 + 40 - 0.05, uHigh= 273.15 + 40 + 0.05) "Controller for valve at middle of tank"; Modelica.Blocks.Logical.And and2 "And block to compute control action for middle valve"; Modelica.Blocks.Math.BooleanToReal yMid "Boolean to real conversion for valve at middle"; Modelica.Blocks.Math.BooleanToReal yTop "Boolean to real conversion for valve at top"; Modelica.Blocks.Logical.Nor nor "Nor block for top-most control valve"; Modelica.Blocks.Logical.Not not1 "Not block to negate control action of upper level control"; Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow hea "Heat input at the bottom of the tank"; Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor TTop "Temperature tank top"; Modelica.Blocks.Logical.Hysteresis onOffHea(uLow=273.15 + 50 - 0.05, uHigh= 273.15 + 50 + 0.05) "Controller for heater at bottom"; Modelica.Blocks.Math.BooleanToReal yHea(realFalse=150000) "Boolean to real for valve at bottom"; Modelica.Blocks.Math.BooleanToReal yBot "Boolean to real conversion for valve at bottom"; equation connect(masSou.ports[1], tan.port_b); connect(TMid.port, tan.heaPorVol[3]); connect(TBot.port, tan.heaPorVol[5]); connect(valTop.port_b, senTem.port_a); connect(valMed.port_b, senTem.port_a); connect(valBot.port_b, senTem.port_a); connect(senTem.port_b,loa. ports[1]); connect(valTop.port_a, tan.fluPorVol[1]); connect(valMed.port_a, tan.fluPorVol[3]); connect(valBot.port_a, tan.fluPorVol[5]); connect(onOffMid.y, and2.u1); connect(yMid.u, and2.y); connect(yTop.u, nor.y); connect(and2.y, nor.u1); connect(onOffBot.y, nor.u2); connect(yTop.y, valTop.y); connect(yMid.y, valMed.y); connect(not1.u, onOffBot.y); connect(not1.y, and2.u2); connect(hea.port, tan.heaPorVol[5]); connect(TTop.port, tan.heaPorVol[1]); connect(onOffHea.u, TTop.T); connect(onOffHea.y, yHea.u); connect(hea.Q_flow, yHea.y); connect(onOffBot.y, yBot.u); connect(yBot.y, valBot.y); connect(TBot.T, onOffBot.u); connect(onOffMid.u, TMid.T); end StratifiedUnloadAtMinimumTemperature;