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 |
ExpansionVessel
|
Test model for expansion vessel |
Stratified
|
Test model for stratified tank |
StratifiedEnhancedInternalHex
|
Example showing the use of StratifiedEnhancedInternalHex |
StratifiedUnloadAtMinimumTemperature
|
Example that demonstrates how to draw from a hot water tank at the minimum temperature |
Test model for expansion vessel
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
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Water ;
Buildings.Fluid.Storage.ExpansionVessel expVes(
redeclare package Medium = Medium, V_start=1) ;
Buildings.Fluid.MixingVolumes.MixingVolume vol(
redeclare package Medium = Medium,
V=1,
nPorts=1,
m_flow_nominal=0.001,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial)
;
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;
Test model for stratified tank
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
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Water ;
Buildings.Fluid.Storage.Stratified tanSim(
redeclare package Medium = Medium,
hTan=3,
dIns=0.3,
nSeg=10,
m_flow_nominal=0.1,
VTan=3) ;
Modelica.Blocks.Sources.TimeTable TWat(table=[0,273.15 + 40; 3600,273.15 +
40; 3600,273.15 + 20; 7200,273.15 + 20]) ;
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) ;
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) ;
Buildings.Fluid.Sensors.EnthalpyFlowRate HOut_flow1(
redeclare package Medium =
Medium, m_flow_nominal=0.1) ;
Modelica.Blocks.Continuous.Integrator dH
;
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])
;
Modelica.Blocks.Sources.Sine sine(
f=1/86400,
amplitude=10,
offset=273.15 + 20);
Buildings.HeatTransfer.Sources.PrescribedTemperature TBCSid2
;
Buildings.HeatTransfer.Sources.PrescribedTemperature TBCSid1
;
Buildings.HeatTransfer.Sources.PrescribedTemperature TBCTop1
;
Buildings.HeatTransfer.Sources.PrescribedTemperature TBCTop2
;
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;
Example showing the use of 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
Type | Name | Default | Description |
PressureDifference | dpHex_nominal | 2500 | Pressure drop across the heat exchanger at nominal conditions [Pa] |
MassFlowRate | mHex_flow_nominal | 0.278 | Mass flow rate of heat exchanger [kg/s] |
Modelica definition
model StratifiedEnhancedInternalHex
extends Modelica.Icons.Example;
package MediumTan =
Buildings.Media.Water ;
package MediumHex =
Buildings.Media.Water ;
parameter Modelica.Units.SI.PressureDifference dpHex_nominal=2500
;
parameter Modelica.Units.SI.MassFlowRate mHex_flow_nominal=0.278
;
Buildings.Fluid.Sources.Boundary_pT bouWat(
redeclare package Medium =
MediumTan, nPorts=3)
;
Buildings.Fluid.Sources.Boundary_pT solColSup(
redeclare package Medium = MediumHex,
nPorts=3,
use_p_in=true,
T=353.15) ;
Buildings.Fluid.Sources.Boundary_pT toSolCol(
redeclare package Medium = MediumHex,
nPorts=3,
p(displayUnit="Pa") = 3E5,
T=283.15) ;
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)
;
Buildings.Fluid.Sensors.TemperatureTwoPort senTemSte(
redeclare package Medium = MediumHex,
allowFlowReversal=false,
m_flow_nominal=mHex_flow_nominal,
tau=0) ;
Modelica.Blocks.Sources.Step step(
height=dpHex_nominal,
offset=3E5,
startTime=300) ;
Buildings.Fluid.Sensors.TemperatureTwoPort senTemDyn(
redeclare package Medium = MediumHex,
allowFlowReversal=false,
m_flow_nominal=mHex_flow_nominal,
tau=0) ;
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) ;
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)
;
Buildings.Fluid.Sensors.TemperatureTwoPort senTemDynSol(
redeclare package Medium = MediumHex,
allowFlowReversal=false,
m_flow_nominal=mHex_flow_nominal,
tau=0)
;
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;
Example that demonstrates how to draw from a hot water tank at the minimum temperature
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
Type | Name | Default | Description |
Volume | VTan | 3 | Tank volume [m3] |
MassFlowRate | m_flow_nominal | 3*1000/3600 | Nominal mass flow rate [kg/s] |
Modelica definition
model StratifiedUnloadAtMinimumTemperature
extends Modelica.Icons.Example;
package Medium =
Buildings.Media.Water ;
parameter Modelica.Units.SI.Volume VTan=3 ;
parameter Modelica.Units.SI.MassFlowRate m_flow_nominal=3*1000/3600
;
constant Integer nSeg=5 ;
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) ;
Buildings.Fluid.Sources.Boundary_pT loa(
redeclare package Medium = Medium,
nPorts=1)
;
Buildings.Fluid.Sources.MassFlowSource_T masSou(
nPorts=1,
redeclare package Medium = Medium,
m_flow=m_flow_nominal) ;
Buildings.Fluid.Actuators.Valves.TwoWayLinear valTop(
redeclare package Medium = Medium,
m_flow_nominal=m_flow_nominal,
dpValve_nominal=3000,
use_inputFilter=false) ;
Buildings.Fluid.Actuators.Valves.TwoWayLinear valMid(
redeclare package Medium = Medium,
m_flow_nominal=m_flow_nominal,
dpValve_nominal=3000,
use_inputFilter=false) ;
Buildings.Fluid.Actuators.Valves.TwoWayLinear valBot(
redeclare package Medium = Medium,
m_flow_nominal=m_flow_nominal,
dpValve_nominal=3000,
use_inputFilter=false) ;
Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor TMid
;
Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor TBot
;
Modelica.Blocks.Logical.Hysteresis onOffBot(uLow=273.15 + 40 - 0.05, uHigh=
273.15 + 40 + 0.05)
;
Buildings.Fluid.Sensors.TemperatureTwoPort senTem(
redeclare package Medium = Medium,
m_flow_nominal=m_flow_nominal,
tau=0) ;
Modelica.Blocks.Logical.Hysteresis onOffMid(uLow=273.15 + 40 - 0.05, uHigh=
273.15 + 40 + 0.05)
;
Modelica.Blocks.Logical.And and2
;
Modelica.Blocks.Math.BooleanToReal yMid
;
Modelica.Blocks.Math.BooleanToReal yTop
;
Modelica.Blocks.Logical.Nor nor
;
Modelica.Blocks.Logical.Not not1
;
Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow hea
;
Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor TTop
;
Modelica.Blocks.Logical.Hysteresis onOffHea(uLow=273.15 + 50 - 0.05, uHigh=
273.15 + 50 + 0.05)
;
Modelica.Blocks.Math.BooleanToReal yHea(realFalse=150000)
;
Modelica.Blocks.Math.BooleanToReal yBot
;
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(valMid.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(valMid.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,valMid. 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;