Buildings.Fluid.Storage.BaseClasses

Package with base classes for Buildings.Fluid.Storage

Information

This package contains base classes that are used to construct the models in Buildings.Fluid.Storage.

Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).

Package Content

NameDescription
Buildings.Fluid.Storage.BaseClasses.Buoyancy Buoyancy Model to add buoyancy if there is a temperature inversion in the tank
Buildings.Fluid.Storage.BaseClasses.ThirdOrderStratifier ThirdOrderStratifier Model to reduce the numerical dissipation in a tank


Buildings.Fluid.Storage.BaseClasses.Buoyancy Buildings.Fluid.Storage.BaseClasses.Buoyancy

Model to add buoyancy if there is a temperature inversion in the tank

Buildings.Fluid.Storage.BaseClasses.Buoyancy

Information

This model outputs a heat flow rate that can be added to fluid volumes in order to emulate buoyancy during a temperature inversion. For simplicity, this model does not compute a buoyancy induced mass flow rate, but rather a heat flow that has the same magnitude as the enthalpy flow associated with the buoyancy induced mass flow rate.

Extends from Buildings.BaseClasses.BaseIcon (Base icon).

Parameters

TypeNameDefaultDescription
VolumeV Volume [m3]
IntegernSeg2Number of volume segments
Timetau Time constant for mixing [s]

Connectors

TypeNameDescription
HeatPort_aheatPort[nSeg]Heat input into the volumes

Modelica definition

model Buoyancy 
  "Model to add buoyancy if there is a temperature inversion in the tank"
  extends Buildings.BaseClasses.BaseIcon;
  replaceable package Medium =
    Modelica.Media.Interfaces.PartialMedium "Medium model";
  parameter Modelica.SIunits.Volume V "Volume";
  parameter Integer nSeg(min=2) = 2 "Number of volume segments";
  parameter Modelica.SIunits.Time tau(min=0) "Time constant for mixing";

  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a[nSeg] heatPort 
    "Heat input into the volumes";

  Modelica.SIunits.HeatFlowRate[nSeg-1] Q_flow 
    "Heat flow rate from segment i+1 to i";
protected 
   parameter Medium.ThermodynamicState sta0 = Medium.setState_pTX(T=Medium.T_default,
         p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]);
   parameter Modelica.SIunits.Density rho_nominal=Medium.density(sta0) 
    "Density, used to compute fluid mass";
   parameter Modelica.SIunits.SpecificHeatCapacity cp0=Medium.specificHeatCapacityCp(sta0) 
    "Specific heat capacity";
   parameter Real k(unit="W/K") = V*rho_nominal*cp0/tau/nSeg 
    "Proportionality constant, since we use dT instead of dH";
   Modelica.SIunits.TemperatureDifference dT[nSeg-1] 
    "Temperature difference between adjoining volumes";
equation 
  for i in 1:nSeg-1 loop
    dT[i] = heatPort[i+1].T-heatPort[i].T;
    Q_flow[i] = k*noEvent(smooth(1, if dT[i]>0 then dT[i]^2 else 0));
  end for;

  heatPort[1].Q_flow = -Q_flow[1];
  for i in 2:nSeg-1 loop
       heatPort[i].Q_flow = -Q_flow[i]+Q_flow[i-1];
  end for;
  heatPort[nSeg].Q_flow = Q_flow[nSeg-1];
end Buoyancy;

Buildings.Fluid.Storage.BaseClasses.ThirdOrderStratifier Buildings.Fluid.Storage.BaseClasses.ThirdOrderStratifier

Model to reduce the numerical dissipation in a tank

Buildings.Fluid.Storage.BaseClasses.ThirdOrderStratifier

Information

This model reduces the numerical dissipation that is introduced by the standard first-order upwind discretization scheme which is created when connecting fluid volumes in series.

Since the model is used in conjunction with Modelica.Fluid, it computes a heat flux that needs to be added to each volume in order to give the results that a third-order upwind discretization scheme would give. If a standard third-order upwind discretization scheme were to be used, then the temperatures of the elements that face the tank inlet and outlet ports would overshoot by a few tenths of a Kelvin. To reduce this overshoot, the model uses a first order scheme at the boundary elements, and it adds a term that ensures that the energy balance is satisfied. Without this term, small numerical errors in the energy balance, introduced by the third order discretization scheme, would occur.

The model is used by Buildings.Fluid.Storage.StratifiedEnhanced.

Extends from Buildings.BaseClasses.BaseIcon (Base icon).

Parameters

TypeNameDefaultDescription
MassFlowRatem_flow_small Small mass flow rate for regularization of zero flow [kg/s]
IntegernSeg2Number of volume segments

Connectors

TypeNameDescription
HeatPort_aheatPort[nSeg]Heat input into the volumes
input RealInputm_flowMass flow rate from port a to port b
input RealInputH_flow[nSeg + 1]Enthalpy flow between the volumes
FluidPort_afluidPort[nSeg + 2]Fluid port, needed to get pressure, temperature and species concentration

Modelica definition

model ThirdOrderStratifier 
  "Model to reduce the numerical dissipation in a tank"
  extends Buildings.BaseClasses.BaseIcon;
  replaceable package Medium =
    Modelica.Media.Interfaces.PartialMedium "Medium model";

  parameter Medium.MassFlowRate m_flow_small(min=0) 
    "Small mass flow rate for regularization of zero flow";
  parameter Integer nSeg(min=2) = 2 "Number of volume segments";
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a[nSeg] heatPort 
    "Heat input into the volumes";

  Modelica.Blocks.Interfaces.RealInput m_flow 
    "Mass flow rate from port a to port b";

  Modelica.Blocks.Interfaces.RealInput[nSeg+1] H_flow 
    "Enthalpy flow between the volumes";

  Modelica.Fluid.Interfaces.FluidPort_a[nSeg+2] fluidPort(
      redeclare each package Medium = Medium) 
    "Fluid port, needed to get pressure, temperature and species concentration";

protected 
  Modelica.SIunits.SpecificEnthalpy[nSeg+2] hOut 
    "Extended vector with new outlet enthalpies to reduce numerical dissipation";
  Modelica.SIunits.SpecificEnthalpy[nSeg+2] h 
    "Extended vector with port enthalpies, needed to simplify loop";
  Modelica.SIunits.HeatFlowRate Q_flow[nSeg] 
    "Heat exchange computed using upwind third order discretization scheme";
  Modelica.SIunits.HeatFlowRate Q_flow_upWind 
    "Heat exchange computed using upwind third order discretization scheme";
  Real sig 
    "Sign used to implement the third order upwind scheme without triggering a state event";
  Real comSig 
    "Sign used to implement the third order upwind scheme without triggering a state event";

  parameter Medium.ThermodynamicState sta0 = Medium.setState_pTX(T=Medium.T_default,
         p=Medium.p_default, X=Medium.X_default[1:Medium.nXi]);
  parameter Modelica.SIunits.SpecificHeatCapacity cp0=Medium.specificHeatCapacityCp(sta0) 
    "Density, used to compute fluid volume";
equation 
  // assign zero flow conditions at port
  fluidPort[:].m_flow = zeros(nSeg+2);
  fluidPort[:].h_outflow = zeros(nSeg+2);
  fluidPort[:].Xi_outflow = zeros(nSeg+2, Medium.nXi);
  fluidPort[:].C_outflow  = zeros(nSeg+2, Medium.nC);

  // assign extended enthalpy vectors
  for i in 1:nSeg+2 loop
    h[i] = inStream(fluidPort[i].h_outflow);
  end for;

  // Value that transitions between 0 and 1 as the flow reverses.
  sig = Modelica.Fluid.Utilities.regStep(m_flow,1,0,m_flow_small);
  comSig = 1-sig;

  hOut[1] = h[1];
  hOut[nSeg+2] = h[nSeg+2];

  hOut[2] = sig*h[2]
          + comSig * (0.5*(h[1]+h[2])-0.125*(h[3]+h[1]-2*h[2]));

  for i in 2:(nSeg-1) loop
    hOut[i+1] = sig*0.5*(h[i+2]+h[i+1])+comSig*0.5*(h[i]+h[i+1])
              - 0.125*(h[i+2]+h[i]-2*h[i+1]);
  end for;

  hOut[nSeg+1] = comSig*h[nSeg-1]
               + sig * (0.5*(h[nSeg+2]+h[nSeg+1])-0.125*(h[nSeg+2]+h[nSeg]-2*h[nSeg+1]));

  for i in 1:nSeg loop
     Q_flow[i] = sig*(m_flow*(hOut[i+1]-hOut[i])+ H_flow[i] - H_flow[i+1])
                + comSig*(m_flow*(hOut[i+2]-hOut[i+1])- H_flow[i] + H_flow[i+1]);
  end for;

  Q_flow_upWind = sum(Q_flow[i] for i in 1:nSeg);

  for i in 1:nSeg loop
    heatPort[i].Q_flow = Q_flow[i] - Q_flow_upWind/nSeg;
  end for;
end ThirdOrderStratifier;

Automatically generated Fri Nov 4 08:28:19 2011.