LBL logo

Buildings.Electrical.DC.Storage.Examples

Package with example models

Information

This package contains examples for the use of models that can be found in Buildings.Electrical.DC.Storage.

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

Package Content

Name Description
Buildings.Electrical.DC.Storage.Examples.Battery Battery Test model for battery

Buildings.Electrical.DC.Storage.Examples.Battery Buildings.Electrical.DC.Storage.Examples.Battery

Test model for battery

Buildings.Electrical.DC.Storage.Examples.Battery

Information

This model illustrates use of a battery connected to an DC voltage source and a constant load. The battery is charged every night at 23:00 until it is full. At 14:00, it is discharged until it is empty. This control is implemented using a finite state machine. The charging and discharing power is assumed to be controlled to a constant value of 10,000 Watts.

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

Modelica definition

model Battery "Test model for battery" extends Modelica.Icons.Example; Buildings.Electrical.DC.Storage.Battery bat(EMax=40e3*3600, V_nominal=12) "Battery"; Buildings.Electrical.DC.Sources.ConstantVoltage sou(V=12) "Voltage source"; Modelica.Electrical.Analog.Basic.Ground ground; Buildings.Electrical.DC.Loads.Conductor loa( P_nominal=0, mode=Buildings.Electrical.Types.Load.VariableZ_P_input, V_nominal=12) "Electrical load"; Modelica.Blocks.Sources.Constant const1(k=-10e3) "Power consumption of the load"; Modelica.Blocks.Sources.SampleTrigger startCharge(period=24*3600, startTime=23*3600); Modelica_StateGraph2.Step off(final initialStep=true, nOut=1, nIn=1, use_activePort=true) "Battery is disconnected"; Modelica_StateGraph2.Transition THold(use_conditionPort=true, delayedTransition=false); Modelica_StateGraph2.Step charge( nIn=1, use_activePort=true, final initialStep=false, nOut=1) "Battery is charged"; Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold(threshold= 0.99); Modelica_StateGraph2.Transition TOn( use_conditionPort=true, delayedTransition=false, loopCheck=false); Modelica_StateGraph2.Step discharge( nOut=1, use_activePort=true, final initialStep=false, nIn=1) "Battery is discharged"; Modelica_StateGraph2.Step hold( nOut=1, final initialStep=false, use_activePort=false, nIn=1) "Battery charge is hold"; Modelica.Blocks.Sources.SampleTrigger startDischarge(period=24*3600, startTime=14*3600); Modelica_StateGraph2.Transition TDischarge(use_conditionPort=true, delayedTransition=false); Modelica.Blocks.Logical.LessEqualThreshold lessEqualThreshold(threshold= 0.01); Modelica_StateGraph2.Transition TOff(use_conditionPort=true, delayedTransition=false) "Battery is empty and switched off"; Modelica.Blocks.Logical.Switch switch1; Modelica.Blocks.Logical.Switch switch2; Modelica.Blocks.Sources.Constant PCha(k=1e4) "Charging power"; Modelica.Blocks.Sources.Constant POff(k=0) "Off power"; Modelica.Blocks.Sources.Constant PDis(k=-1e4) "Discharging power"; Modelica.Blocks.Math.Add add; Buildings.Electrical.DC.Sensors.GeneralizedSensor powSen "Power sensor"; equation connect(startCharge.y, TOn.conditionPort); connect(TOn.outPort, charge.inPort[1]); connect(hold.outPort[1], TDischarge.inPort); connect(TDischarge.outPort, discharge.inPort[1]); connect(TOff.conditionPort, lessEqualThreshold.y); connect(off.outPort[1], TOn.inPort); connect(discharge.outPort[1], TOff.inPort); connect(TOff.outPort, off.inPort[1]); connect(charge.activePort, switch1.u2); connect(discharge.activePort, switch2.u2); connect(POff.y, switch2.u3); connect(POff.y, switch1.u3); connect(PDis.y, switch2.u1); connect(PCha.y, switch1.u1); connect(switch1.y, add.u1); connect(switch2.y, add.u2); connect(add.y, bat.P); connect(bat.SOC, greaterEqualThreshold.u); connect(bat.SOC, lessEqualThreshold.u); connect(greaterEqualThreshold.y, THold.conditionPort); connect(charge.outPort[1], THold.inPort); connect(THold.outPort, hold.inPort[1]); connect(startDischarge.y, TDischarge.conditionPort); connect(const1.y, loa.Pow); connect(loa.terminal, sou.terminal); connect(bat.terminal, powSen.terminal_p); connect(powSen.terminal_n, sou.terminal); connect(sou.n, ground.p); end Battery;

Automatically generated Mon May 4 10:19:58 2015.