Buildings.Electrical.DC.Storage.BaseClasses

Base models for battery package

Information

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

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

Package Content

Name Description
Buildings.Electrical.DC.Storage.BaseClasses.Charge Charge Model to compute the battery charge

Buildings.Electrical.DC.Storage.BaseClasses.Charge Buildings.Electrical.DC.Storage.BaseClasses.Charge

Model to compute the battery charge

Buildings.Electrical.DC.Storage.BaseClasses.Charge

Information

This model represents the charge/discharge mechanism of a battery.

This model two parameters ηCHA and ηDIS that represent the efficiency during the charge and discharge of the battery.

The model given the power P that should be provide or taken from the battery and compute the actual power flowing through the battery as

EquationCondition
Pactual = P ηCHA P ≥ 0
Pactual = P (2 - ηDIS) P < 0

The actual power is then used to compute the variation of the state of charge SOC. The state of charge is the state variable of this model and is a real value between 0 and 1.

d SOC / dt = Pactual

Note:The input power P has to be controlled in order to avoid the state of charge SOC exceeding the range between 0 and 1.

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

Parameters

TypeNameDefaultDescription
EfficiencyetaCha0.9Efficiency during charging [1]
EfficiencyetaDis0.9Efficiency during discharging [1]
RealSOC_start0.1Initial state of charge [1]
EnergyEMaxEMax(min=0, displayUnit="kWh")Maximum available charge [J]

Connectors

TypeNameDescription
input RealInputP[W]
output RealOutputSOCState of charge

Modelica definition

model Charge "Model to compute the battery charge" extends Modelica.Blocks.Icons.Block; parameter Modelica.SIunits.Efficiency etaCha(max=1) = 0.9 "Efficiency during charging"; parameter Modelica.SIunits.Efficiency etaDis(max=1) = 0.9 "Efficiency during discharging"; parameter Real SOC_start(min=0, max=1, unit="1")=0.1 "Initial state of charge"; parameter Modelica.SIunits.Energy EMax(min=0, displayUnit="kWh") "Maximum available charge"; Modelica.SIunits.Power PAct "Actual power"; Modelica.Blocks.Interfaces.RealInput P(final quantity="Power", final unit="W"); Modelica.Blocks.Interfaces.RealOutput SOC(min=0, max=1) "State of charge"; protected Boolean underCharged "Flag, true if battery is undercharged"; Boolean overCharged "Flag, true if battery is overcharged"; initial equation pre(underCharged) = SOC_start < 0; pre(overCharged) = SOC_start > 1; SOC = SOC_start; equation // Charge balance of battery PAct = if P > 0 then etaCha*P else (2-etaDis)*P; der(SOC)=PAct/EMax; // Equations to warn if state of charge exceeds 0 and 1 underCharged = SOC < 0; overCharged = SOC > 1; when change(underCharged) or change(overCharged) then assert(SOC >= 0, "Warning: Battery is below minimum charge.", level=AssertionLevel.warning); assert(SOC <= 1, "Warning: Battery is above maximum charge.", level=AssertionLevel.warning); end when; end Charge;