LBL logo

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

NameDescription
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.StratifiedLoadingUnloading StratifiedLoadingUnloading Test model for stratified tank
Buildings.Fluid.Storage.Examples.StratifiedEnhancedInternalHex StratifiedEnhancedInternalHex Example showing the use of StratifiedEnhancedInternalHex

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.ConstantPropertyLiquidWater "Medium model";

  inner Modelica.Fluid.System system(p_ambient=400000, massDynamics=Modelica.Fluid.Types.Dynamics.DynamicFreeInitial);
  Buildings.Fluid.Storage.ExpansionVessel expVes(
    redeclare package Medium = Medium, VTot=0.1) "Expansion vessel";
  Buildings.Fluid.MixingVolumes.MixingVolume vol(
    redeclare package Medium = Medium,
    V=1,
    nPorts=1,
    m_flow_nominal=0.001) "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.ConstantPropertyLiquidWater "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);
    FixedResistances.FixedResistanceDpM 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";
    FixedResistances.FixedResistanceDpM 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";
  inner Modelica.Fluid.System system;
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.StratifiedLoadingUnloading Buildings.Fluid.Storage.Examples.StratifiedLoadingUnloading

Test model for stratified tank

Buildings.Fluid.Storage.Examples.StratifiedLoadingUnloading

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).

Parameters

TypeNameDefaultDescription
MassFlowRatem_flow_nominal1*1000/3600/4[kg/s]

Modelica definition

model StratifiedLoadingUnloading "Test model for stratified tank"
  extends Modelica.Icons.Example;

 package Medium = Buildings.Media.ConstantPropertyLiquidWater "Medium model";
 constant Integer nSeg = 7 "Number of segments in tank";

 parameter Modelica.SIunits.MassFlowRate m_flow_nominal= 1*1000/3600/4;

  Buildings.Fluid.Sources.Boundary_pT sou_1(
    p=300000 + 5000,
    T=273.15 + 40,
    redeclare package Medium = Medium,
    use_T_in=false,
    nPorts=2);
  Sources.MassFlowSource_T sin_1(
    redeclare package Medium = Medium,
    T=273.15 + 20,
    m_flow=-0.028,
    use_m_flow_in=true,
    nPorts=1);
  Buildings.Fluid.Storage.StratifiedEnhanced tanEnh(
    redeclare package Medium = Medium,
    hTan=3,
    dIns=0.3,
    VTan=0.1,
    nSeg=nSeg,
    show_T=true,
    m_flow_nominal=m_flow_nominal) "Tank";

  inner Modelica.Fluid.System system;
  Sources.MassFlowSource_T sin_2(
    redeclare package Medium = Medium,
    T=273.15 + 20,
    m_flow=-0.028,
    use_m_flow_in=true,
    nPorts=1);
  Buildings.Fluid.Storage.Stratified tan(
    redeclare package Medium = Medium,
    hTan=3,
    dIns=0.3,
    VTan=0.1,
    nSeg=nSeg,
    show_T=true,
    m_flow_nominal=m_flow_nominal) "Tank";

  Modelica.Blocks.Sources.Pulse pulse(
    amplitude=2*m_flow_nominal,
    offset=-m_flow_nominal,
    period=7200);
  Buildings.Fluid.Sensors.EnthalpyFlowRate HIn_flow(redeclare package Medium =
        Medium, m_flow_nominal=m_flow_nominal) "Enthalpy flow rate";
  Buildings.Fluid.Sensors.EnthalpyFlowRate HOut_flow(redeclare package Medium
      = Medium, m_flow_nominal=m_flow_nominal) "Enthalpy flow rate";
  Buildings.Fluid.Sensors.EnthalpyFlowRate HInEnh_flow(redeclare package Medium
      = Medium, m_flow_nominal=m_flow_nominal) "Enthalpy flow rate";
  Buildings.Fluid.Sensors.EnthalpyFlowRate HOutEnh_flow(redeclare package
      Medium = Medium, m_flow_nominal=m_flow_nominal) "Enthalpy flow rate";
  Modelica.Blocks.Math.Add add(k2=-1);
  Modelica.Blocks.Continuous.Integrator dHTanEnh 
    "Difference in enthalpy (should be zero at steady-state)";
  Modelica.Blocks.Math.Add add1(
                               k2=-1);
  Modelica.Blocks.Continuous.Integrator dHTan 
    "Difference in enthalpy (should be zero at steady-state)";
equation 

  connect(sou_1.ports[1], HIn_flow.port_a);
  connect(HIn_flow.port_b, tan.port_a);
  connect(tan.port_b, HOut_flow.port_a);
  connect(HOut_flow.port_b, sin_2.ports[1]);
  connect(sou_1.ports[2], HInEnh_flow.port_a);
  connect(HInEnh_flow.port_b, tanEnh.port_a);
  connect(tanEnh.port_b, HOutEnh_flow.port_a);
  connect(HOutEnh_flow.port_b, sin_1.ports[1]);
  connect(HInEnh_flow.H_flow, add.u1);
  connect(HOutEnh_flow.H_flow, add.u2);
  connect(add.y, dHTanEnh.u);
  connect(HIn_flow.H_flow, add1.u1);
  connect(HOut_flow.H_flow, add1.u2);
  connect(add1.y, dHTan.u);
  connect(pulse.y, sin_1.m_flow_in);
  connect(pulse.y, sin_2.m_flow_in);
end StratifiedLoadingUnloading;

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 of how the Buildings.Fluid.Storage.StratifiedEnhancedInternalHex model can be used. In it a constant water draw is taken from the tank while a constant flow of hot water is passed through the heat exchanger to heat the water in the tank.

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

Modelica definition

model StratifiedEnhancedInternalHex 
  "Example showing the use of StratifiedEnhancedInternalHex"
  extends Modelica.Icons.Example;

  package Medium = Buildings.Media.ConstantPropertyLiquidWater 
    "Buildings library model for water";

  Buildings.Fluid.Sources.Boundary_pT boundary(      nPorts=1, redeclare 
      package Medium = Medium);
  Buildings.Fluid.Sources.MassFlowSource_T boundary2(
    redeclare package Medium = Medium,
    nPorts=1,
    m_flow=0.278,
    T=353.15);
  Buildings.Fluid.Sources.Boundary_pT boundary3(          redeclare package
      Medium = Medium, nPorts=1);
  Buildings.Fluid.Sensors.TemperatureTwoPort senTem( m_flow_nominal=0.1,
      redeclare package Medium = Medium);
  Modelica.Blocks.Sources.RealExpression realExpression(y=senTem.T);
  Buildings.Fluid.Sources.MassFlowSource_T boundary1(
    use_T_in=true,
    redeclare package Medium = Medium,
    nPorts=1,
    m_flow=0);
  Buildings.Fluid.Storage.StratifiedEnhancedInternalHex tan(
    redeclare package Medium = Medium,
    m_flow_nominal=0.001,
    VTan=0.151416,
    dIns=0.0762,
    redeclare package MediumHex = Medium,
    CHex=40,
    energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
    Q_flow_nominal=0.278*4200*20,
    mHex_flow_nominal=0.278,
    energyDynamicsHex=Modelica.Fluid.Types.Dynamics.SteadyState,
    hexTopHeight=0.995,
    hexBotHeight=0.1,
    hexSegMult=1,
    hTan=1.746,
    TTan_nominal=293.15,
    THex_nominal=323.15);
  inner Modelica.Fluid.System system;
equation 
  connect(senTem.port_b, boundary.ports[1]);
  connect(realExpression.y, boundary1.T_in);
  connect(boundary1.ports[1], tan.port_a);
  connect(tan.port_b, senTem.port_a);
  connect(boundary2.ports[1], tan.port_a1);
  connect(tan.port_b1, boundary3.ports[1]);
end StratifiedEnhancedInternalHex;

Automatically generated Fri Dec 13 11:35:55 2013.