Extends from Modelica.Fluid.Icons.BaseClassLibrary (Icon for library).
Name | Description |
---|---|
![]() | Model to add buoyancy if there is a temperature inversion in the tank |
![]() | Model to reduce the numerical dissipation in a tank |
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).
Type | Name | Default | Description |
---|---|---|---|
Volume | V | Volume [m3] | |
Integer | nSeg | 2 | Number of volume segments |
Time | tau | Time constant for mixing [s] |
Type | Name | Description |
---|---|---|
HeatPort_a | heatPort[nSeg] | Heat input into the volumes |
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"; equation for i in 1:nSeg-1 loop Q_flow[i] = k*max(heatPort[i+1].T-heatPort[i].T, 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;
This model reduces the numerical dissipation that is introduced by the standard upwind discretization scheme. The model is described by Wischhusen (2006). Since we use this model in conjunction with Modelica.Fluid, we compute a heat flux that need to be added to each volume in order to give the results published in the above paper. The model is used by Buildings.Fluid.Storage.StratifiedEnhanced.
Wischhusen Stefan, An Enhanced Discretization Method for Storage Tank Models within Energy Systems, Modelica Conference, Vienna, Austria, September 2006.
Extends from Buildings.BaseClasses.BaseIcon (Base icon).
Type | Name | Default | Description |
---|---|---|---|
Integer | nSeg | 2 | Number of volume segments |
Real | a | 1E-4 | Tuning factor. a=0 is equivalent to not using this model |
TemperatureDifference | delta | 1 | Temperature difference for which which exp(-|x|) will be approximated [K] |
Type | Name | Description |
---|---|---|
HeatPort_a | heatPort[nSeg] | Heat input into the volumes |
input RealInput | m_flow | Mass flow rate from port a to port b |
input RealInput | H_flow[nSeg + 1] | Enthalpy flow between the volumes |
FluidPort_a | fluidPort[nSeg + 2] | Fluid port, needed to get pressure, temperature and species concentration |
model Stratifier "Model to reduce the numerical dissipation in a tank" extends Buildings.BaseClasses.BaseIcon; replaceable package Medium = Modelica.Media.Interfaces.PartialMedium "Medium model"; 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.SIunits.Enthalpy[nSeg+2] hOut "Extended vector with new outlet enthalpies to reduce numerical dissipation"; Modelica.SIunits.Enthalpy[nSeg+2] h "Extended vector with port enthalpies, needed to simplify loop"; parameter Real a(min=0)= 1E-4 "Tuning factor. a=0 is equivalent to not using this model"; parameter Modelica.SIunits.TemperatureDifference delta = 1 "Temperature difference for which which exp(-|x|) will be approximated"; Modelica.Fluid.Interfaces.FluidPort_a[nSeg+2] fluidPort( redeclare each package Medium = Medium) "Fluid port, needed to get pressure, temperature and species concentration"; protected Integer s(min=-1, max=1) "Index shift to pick up or down volume"; 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"; Real[nSeg] intArg "Argument for interpolation function"; parameter Real intDel=a*cp0*delta "Scaling argument delta for interpolation function"; Real[nSeg] ex "Output of smooth exponential function"; 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; // in loop, i+1-s is the "down" volume, i+1+s is the "up" volume s = if m_flow > 0 then 1 else -1; hOut[1] = h[1]; hOut[nSeg+2] = h[nSeg+2]; for i in 1:nSeg loop /* // original implementation that causes chattering intArg[i-1] = -a * abs(h[i-s]-h[i]); hOut[i] = (h[i]-h[i+s]) * exp(intArg[i-1]) + h[i+s]; */ // approximation that is once continuously differentiable // and does not cause chattering intArg[i] = a * (h[i-s+1]-h[i+1]); ex[i] = Buildings.Utilities.Math.Functions.smoothExponential( intArg[i], intDel); hOut[i+1] = (h[i+1]-h[i+s+1]) * ex[i] + h[i+s+1]; if s > 0 then heatPort[i].Q_flow = -m_flow * (hOut[i]-hOut[i+1]) +H_flow[i] -H_flow[i+1]; else heatPort[i].Q_flow = +m_flow * (hOut[i+2]-hOut[i+1]) -H_flow[i] +H_flow[i+1]; end if; end for; end Stratifier;