Buildings.Fluid.Storage.Ice.BaseClasses

Base classes for ice tank models

Information

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

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

Package Content

Name Description
Buildings.Fluid.Storage.Ice.BaseClasses.LMTDStar LMTDStar Normalized log mean temperature difference across the ice storage unit
Buildings.Fluid.Storage.Ice.BaseClasses.NormalizedHeatFlowRate NormalizedHeatFlowRate Charging or discharging rate based on the curves
Buildings.Fluid.Storage.Ice.BaseClasses.QStar QStar Calculator for q* under charging mode
Buildings.Fluid.Storage.Ice.BaseClasses.StateOfCharge StateOfCharge Mass of ice remaining in the tank
Buildings.Fluid.Storage.Ice.BaseClasses.Tank Tank Block to compute the tank heat transfer
Buildings.Fluid.Storage.Ice.BaseClasses.calculateLMTDStar calculateLMTDStar This function calculates the log mean temperature difference for the ice storage unit
Buildings.Fluid.Storage.Ice.BaseClasses.Examples Examples Examples that test models in the base classes

Buildings.Fluid.Storage.Ice.BaseClasses.LMTDStar Buildings.Fluid.Storage.Ice.BaseClasses.LMTDStar

Normalized log mean temperature difference across the ice storage unit

Buildings.Fluid.Storage.Ice.BaseClasses.LMTDStar

Information

This subroutine calculates the log mean temperature difference for the detailed ice storage unit using the function Buildings.Fluid.Storage.Ice.BaseClasses.calculateLMTDStar.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
TemperatureTFre273.15Freezing temperature of water or the latent energy storage material [K]
TemperatureDifferencedT_nominal10Nominal temperature difference [K]

Connectors

TypeNameDescription
input RealInputTInInlet temperature [K]
input RealInputTOutOutlet temperature [K]
output RealOutputlmtdStaNormalized LMTD

Modelica definition

model LMTDStar "Normalized log mean temperature difference across the ice storage unit" extends Modelica.Blocks.Icons.Block; parameter Modelica.Units.SI.Temperature TFre = 273.15 "Freezing temperature of water or the latent energy storage material"; parameter Modelica.Units.SI.TemperatureDifference dT_nominal = 10 "Nominal temperature difference"; Modelica.Blocks.Interfaces.RealInput TIn(unit="K", displayUnit="degC") "Inlet temperature"; Modelica.Blocks.Interfaces.RealInput TOut(unit="K", displayUnit="degC") "Outlet temperature"; Modelica.Blocks.Interfaces.RealOutput lmtdSta(final quantity="1") "Normalized LMTD"; equation lmtdSta = Buildings.Utilities.Math.Functions.smoothMin( x1=10, x2=Buildings.Fluid.Storage.Ice.BaseClasses.calculateLMTDStar( TIn=TIn, TOut=TOut, TFre=TFre, dT_nominal=dT_nominal), deltaX=1E-6); end LMTDStar;

Buildings.Fluid.Storage.Ice.BaseClasses.NormalizedHeatFlowRate Buildings.Fluid.Storage.Ice.BaseClasses.NormalizedHeatFlowRate

Charging or discharging rate based on the curves

Buildings.Fluid.Storage.Ice.BaseClasses.NormalizedHeatFlowRate

Information

This blocks calculate the normalized heat transfer rate for the ice tank in charging or discharging mode.

The module use the following logic:

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
RealcoeCha[6] Coefficients for charging curve
RealdtCha Time step of curve fitting data
RealcoeDisCha[6] Coefficients for discharging curve
RealdtDisCha Time step of curve fitting data

Connectors

TypeNameDescription
output RealOutputqNorNormalized heat transfer rate: charging when postive, discharge when negative
input RealInputSOCState of charge
input RealInputlmtdStaLMTD star
input BooleanInputcanFreezeSet to true if tank can be charged
input BooleanInputcanMeltSet to true if tank can be melted

Modelica definition

model NormalizedHeatFlowRate "Charging or discharging rate based on the curves" extends Modelica.Blocks.Icons.Block; parameter Real coeCha[6] "Coefficients for charging curve"; parameter Real dtCha "Time step of curve fitting data"; parameter Real coeDisCha[6] "Coefficients for discharging curve"; parameter Real dtDisCha "Time step of curve fitting data"; Modelica.Blocks.Interfaces.RealOutput qNor(final quantity="1/s") "Normalized heat transfer rate: charging when postive, discharge when negative"; Modelica.Blocks.Interfaces.RealInput SOC "State of charge"; Modelica.Blocks.Interfaces.RealInput lmtdSta "LMTD star"; Modelica.Blocks.Interfaces.BooleanInput canFreeze "Set to true if tank can be charged"; Modelica.Blocks.Interfaces.BooleanInput canMelt "Set to true if tank can be melted"; protected Modelica.Blocks.Math.Add SOCCom(final k2=-1) "1 - SOC"; Modelica.Blocks.Sources.Constant const(k=1) "Constant output of 1"; Buildings.Fluid.Storage.Ice.BaseClasses.QStar qStaCha( final coeff=coeCha, final dt=dtCha) "q* for charing mode"; Buildings.Fluid.Storage.Ice.BaseClasses.QStar qStaDisCha( final coeff=coeDisCha, final dt=dtDisCha) "q* for discharging mode"; Buildings.Controls.OBC.CDL.Continuous.Subtract qSta "Effective normalized heat flow rate"; equation connect(qStaCha.lmtdSta, lmtdSta); connect(lmtdSta, qStaDisCha.lmtdSta); connect(SOC, qStaCha.x); connect(qStaCha.active, canFreeze); connect(qStaDisCha.active, canMelt); connect(qNor, qSta.y); connect(SOCCom.u2, SOC); connect(const.y, SOCCom.u1); connect(qStaDisCha.x, SOCCom.y); connect(qStaCha.qNor, qSta.u1); connect(qStaDisCha.qNor, qSta.u2); end NormalizedHeatFlowRate;

Buildings.Fluid.Storage.Ice.BaseClasses.QStar Buildings.Fluid.Storage.Ice.BaseClasses.QStar

Calculator for q* under charging mode

Buildings.Fluid.Storage.Ice.BaseClasses.QStar

Information

This block calculates the normalized heat transfer rate q* between the chilled water and the ice in the thermal storage tank using

q* Δt = C1 + C2x + C3 x2 + [C4 + C5x + C6 x2]ΔTlmtd*

where Δt is the time step of the data samples used for the curve fitting, C1-6 are the curve fit coefficients, x is the fraction of charging, also known as the state-of-charge, and Tlmtd* is the normalized LMTD calculated using Buildings.Fluid.Storage.Ice.BaseClasses.calculateLMTDStar.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
Realcoeff[6] Coefficients for qstar curve
Realdt Time step of curve fitting data

Connectors

TypeNameDescription
input BooleanInputactiveSet to true if this tank mode can be active
input RealInputxSOC for charging, or 1-SOC for discharging [1]
input RealInputlmtdStaNormalized LMTD [1]
output RealOutputqNorNormalized heat transfer rate

Modelica definition

model QStar "Calculator for q* under charging mode" extends Modelica.Blocks.Icons.Block; parameter Real coeff[6] "Coefficients for qstar curve"; parameter Real dt "Time step of curve fitting data"; Modelica.Blocks.Interfaces.BooleanInput active "Set to true if this tank mode can be active"; Modelica.Blocks.Interfaces.RealInput x(unit="1") "SOC for charging, or 1-SOC for discharging"; Modelica.Blocks.Interfaces.RealInput lmtdSta(unit="1") "Normalized LMTD"; Modelica.Blocks.Interfaces.RealOutput qNor(final quantity="1") "Normalized heat transfer rate"; equation if active then qNor =Buildings.Utilities.Math.Functions.smoothMax( x1=0, x2=Buildings.Utilities.Math.Functions.polynomial(x, coeff[1:3]) + Buildings.Utilities.Math.Functions.polynomial(x, coeff[4:6])*lmtdSta, deltaX=1E-7)/dt; else qNor = 0; end if; end QStar;

Buildings.Fluid.Storage.Ice.BaseClasses.StateOfCharge Buildings.Fluid.Storage.Ice.BaseClasses.StateOfCharge

Mass of ice remaining in the tank

Buildings.Fluid.Storage.Ice.BaseClasses.StateOfCharge

Information

This block calculates the state of charge using

d SOC/dt = Q̇eff/(Hf   mice,max)

where SOC is the state of charge, is the heat transfer rate of the ice tank, positive for charging and negative for discharging, Hf is the fusion of heat of ice and mice,max is the nominal mass of ice in the storage tank.

The model sets eff = Q̇, unless the state of charge is 0 or 1, in which case eff is set to zero if it were to lead to over- or under-charging.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
RealSOC_start Start value for state of charge [1]
EnergyE_nominal Storage capacity [J]

Connectors

TypeNameDescription
input RealInputQ_flowHeat transfer rate: positive for charging, negative for discharging [W]
output RealOutputQEff_flowActual heat flow rate, taking into account 0 ≤ SOC ≤ 1 [W]
output RealOutputSOCState of charge [1]

Modelica definition

model StateOfCharge "Mass of ice remaining in the tank" extends Modelica.Blocks.Icons.Block; parameter Real SOC_start(min=0, max=1, final unit="1") "Start value for state of charge"; parameter Modelica.Units.SI.Energy E_nominal "Storage capacity"; Modelica.Blocks.Interfaces.RealInput Q_flow(final unit="W") "Heat transfer rate: positive for charging, negative for discharging"; Modelica.Blocks.Interfaces.RealOutput QEff_flow(final unit="W") "Actual heat flow rate, taking into account 0 &le; SOC &le; 1"; Modelica.Blocks.Interfaces.RealOutput SOC( final min=0, final max=1, final unit="1") "State of charge"; Boolean charged "True if tank is fully charged"; Boolean discharged "True if tank is fully discharged"; Boolean suspend "True if either fully charged or fully discharged"; initial equation SOC = SOC_start; charged = SOC_start >= 1; discharged = SOC_start <= 0; equation der(SOC) = if suspend then 0 else Q_flow/E_nominal; suspend = charged or discharged; QEff_flow = if suspend then 0 else Q_flow; when SOC < 0 then discharged = true; charged = pre(charged); elsewhen SOC > 1 then charged = true; discharged = pre(discharged); elsewhen (pre(discharged) and Q_flow > 1) then charged = pre(charged); discharged = false; elsewhen (pre(charged) and Q_flow < -1) then charged = false; discharged = pre(discharged); end when; end StateOfCharge;

Buildings.Fluid.Storage.Ice.BaseClasses.Tank Buildings.Fluid.Storage.Ice.BaseClasses.Tank

Block to compute the tank heat transfer

Buildings.Fluid.Storage.Ice.BaseClasses.Tank

Information

Model that implements the heat transfer rate between the working fluid and the ice, and that computes the state of charge of the tank.

See Buildings.Fluid.Storage.Ice.Tank for the implemented equations.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
Genericperredeclare parameter Building...Performance data
SpecificHeatCapacitycp Specific heat capacity of working fluid [J/(kg.K)]
Initialization
RealSOC_start Start value for state of charge [1]

Connectors

TypeNameDescription
input RealInputTInInlet temperature [K]
input RealInputTOutOutlet temperature [K]
output RealOutputQ_flowActual heat flow rate, taking into account 0 &le; SOC &le; 1 [W]
output RealOutputSOCstate of charge [1]
output RealOutputmIceMass of remaining ice [kg]
input RealInputQLim_flowLimit on heat flow rate due to temperatures and mass flow rate [W]

Modelica definition

model Tank "Block to compute the tank heat transfer" extends Modelica.Blocks.Icons.Block; constant Modelica.Units.SI.TemperatureDifference dTSmall(min=1E-3) = 0.01 "Small temperature difference"; parameter Real SOC_start(min=0, max=1, final unit="1") "Start value for state of charge"; replaceable parameter Buildings.Fluid.Storage.Ice.Data.Tank.Generic per "Performance data"; final parameter Modelica.Units.SI.Energy E_nominal=per.Hf*per.mIce_max "Storage capacity"; parameter Modelica.Units.SI.SpecificHeatCapacity cp "Specific heat capacity of working fluid"; Modelica.Blocks.Interfaces.RealInput TIn(final unit="K", displayUnit="degC") "Inlet temperature"; Modelica.Blocks.Interfaces.RealInput TOut(final unit="K", displayUnit="degC") "Outlet temperature"; Modelica.Blocks.Interfaces.RealOutput Q_flow(final unit="W") "Actual heat flow rate, taking into account 0 &le; SOC &le; 1"; Modelica.Blocks.Interfaces.RealOutput SOC( final unit = "1") "state of charge"; Modelica.Blocks.Interfaces.RealOutput mIce( quantity="Mass", unit="kg") "Mass of remaining ice"; Modelica.Blocks.Interfaces.RealInput QLim_flow(final unit="W") "Limit on heat flow rate due to temperatures and mass flow rate"; Buildings.Fluid.Storage.Ice.BaseClasses.StateOfCharge SOCCalc( final SOC_start=SOC_start, final E_nominal=E_nominal) "State of charge calculation"; Controls.OBC.CDL.Continuous.LessThreshold canFreeze( final t=per.TFre - dTSmall, final h=dTSmall/2) "Outputs true if temperatures allow ice to be produced"; Controls.OBC.CDL.Continuous.GreaterThreshold canMelt( final t=per.TFre + dTSmall, final h=dTSmall/2) "Outputs true if temperature allows tank to be melted"; protected Modelica.Blocks.Math.Max QMax_flow "Maximum heat flow rate"; Modelica.Blocks.Math.Min QMin_flow "Miminum heat flow rate"; Modelica.Blocks.Logical.Switch QThe_flow "Heat flow rate extracted from fluid, not taking into account state of charge"; Modelica.Blocks.Math.Gain masIce( final k=per.mIce_max, y(final unit="kg")) "Mass of ice"; Buildings.Fluid.Storage.Ice.BaseClasses.NormalizedHeatFlowRate norQSta( final coeCha=per.coeCha, final coeDisCha=per.coeDisCha, final dtCha=per.dtCha, final dtDisCha=per.dtDisCha); Modelica.Blocks.Math.Gain QCoe_flow(k=E_nominal, y(final unit="W")) "Heat flow rate based on performance curves, without any limitation"; Buildings.Fluid.Storage.Ice.BaseClasses.LMTDStar lmtdSta( final TFre=per.TFre, final dT_nominal=per.dT_nominal); equation connect(norQSta.qNor, QCoe_flow.u); connect(QThe_flow.y, SOCCalc.Q_flow); connect(QMin_flow.y, QThe_flow.u1); connect(QCoe_flow.y, QMin_flow.u2); connect(QCoe_flow.y, QMax_flow.u1); connect(SOCCalc.SOC, SOC); connect(QMax_flow.y, QThe_flow.u3); connect(lmtdSta.lmtdSta, norQSta.lmtdSta); connect(SOCCalc.SOC, norQSta.SOC); connect(norQSta.canMelt, canMelt.y); connect(canFreeze.y, norQSta.canFreeze); connect(canFreeze.y, QThe_flow.u2); connect(SOCCalc.QEff_flow, Q_flow); connect(lmtdSta.TIn, TIn); connect(canFreeze.u, TIn); connect(lmtdSta.TOut, TOut); connect(TIn, canMelt.u); connect(QLim_flow, QMin_flow.u1); connect(QLim_flow, QMax_flow.u2); connect(SOCCalc.SOC, masIce.u); connect(masIce.y, mIce); end Tank;

Buildings.Fluid.Storage.Ice.BaseClasses.calculateLMTDStar Buildings.Fluid.Storage.Ice.BaseClasses.calculateLMTDStar

This function calculates the log mean temperature difference for the ice storage unit

Information

This subroutine calculates the log mean temperature difference for the detailed ice storage unit. The temperature difference is non-dimensionalized using a nominal temperature difference of 10 Kelvin. This value must be used when obtaining the curve fit coefficients.

The log mean temperature difference is calculated using

Tlmtd* = Tlmtd/Tnom

Tlmtd = (Tin - Tout)/ln((Tin - Tfre)/(Tout - Tfre))

where Tin is the inlet temperature, Tout is the outlet temperature, Tfre is the freezing temperature and Tnom is a nominal temperature difference of 10 Kelvin.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

TypeNameDefaultDescription
TemperatureTIn Inlet temperature [K]
TemperatureTOut Outlet temperature [K]
TemperatureTFre273.15Freezing temperature of water or the latent energy storage material [K]
TemperatureDifferencedT_nominal10Nominal temperature difference [K]

Outputs

TypeNameDescription
ReallmtdNormalized LMTD

Modelica definition

function calculateLMTDStar "This function calculates the log mean temperature difference for the ice storage unit" extends Modelica.Icons.Function; input Modelica.Units.SI.Temperature TIn "Inlet temperature"; input Modelica.Units.SI.Temperature TOut "Outlet temperature"; input Modelica.Units.SI.Temperature TFre = 273.15 "Freezing temperature of water or the latent energy storage material"; input Modelica.Units.SI.TemperatureDifference dT_nominal = 10 "Nominal temperature difference"; output Real lmtd "Normalized LMTD"; protected constant Modelica.Units.SI.TemperatureDifference dTif_min=0.02 "Small temperature difference, used for regularization"; constant Modelica.Units.SI.TemperatureDifference dTof_min=0.01 "Small temperature difference, used for regularization"; //Modelica.Units.SI.Temperature TOutEps // "Outlet temperature, bounded away from TIn"; Real dTio "Inlet to outlet temperature difference"; Real dTif "Inlet to freezing temperature difference"; Real dTof "Outlet to frezzing temperature difference"; Real lndT "log of the temperature difference"; Real eps = 1E-09 "Small tolerance"; algorithm dTio := abs(TIn-TOut); dTif := Buildings.Utilities.Math.Functions.smoothMax( x1 = abs(TIn-TFre), x2 = dTif_min, deltaX = eps); dTof := Buildings.Utilities.Math.Functions.smoothMax( x1 = abs(TOut-TFre), x2 = dTof_min, deltaX = eps); // lmtd := Buildings.Utilities.Math.Functions.smoothMax( // x1 = 0, // x2 = (dTio/log(dTif/dTof))/dT_nominal, // deltaX = 1E-09); lmtd := (dTio/max(eps, log(dTif/dTof)))/dT_nominal; end calculateLMTDStar;