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 |
---|---|
Battery | Test model for battery |
Buildings.Electrical.DC.Storage.Examples.Battery
Test model for 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.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold(threshold
=0.99);
Modelica.Blocks.Sources.SampleTrigger startDischarge(period=24*3600,
startTime=14*3600);
Modelica.Blocks.Logical.LessEqualThreshold lessEqualThreshold(threshold=0.01);
Modelica.Blocks.Logical.Switch chaSwi "Switch to charge battery";
Modelica.Blocks.Logical.Switch disSwi "Switch to discharge battery";
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";
Modelica.StateGraph.InitialStep off "Off state";
Modelica.StateGraph.TransitionWithSignal toOn "Transition to on";
Modelica.StateGraph.StepWithSignal charge "State to charge battery";
Modelica.StateGraph.TransitionWithSignal toHold "Transition to hold";
Modelica.StateGraph.Step hold "Battery charge is hold";
Modelica.StateGraph.TransitionWithSignal toDischarge
"Transition to discharge";
Modelica.StateGraph.StepWithSignal discharge "State to discharge battery";
Modelica.StateGraph.TransitionWithSignal toOff "Transition to off";
inner Modelica.StateGraph.StateGraphRoot stateGraphRoot;
equation
connect(POff.y, disSwi.u3);
connect(POff.y, chaSwi.u3);
connect(PDis.y, disSwi.u1);
connect(PCha.y, chaSwi.u1);
connect(add.y, bat.P);
connect(bat.SOC, greaterEqualThreshold.u);
connect(bat.SOC, lessEqualThreshold.u);
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);
connect(startCharge.y, toOn.condition);
connect(charge.active, chaSwi.u2);
connect(greaterEqualThreshold.y, toHold.condition);
connect(startDischarge.y, toDischarge.condition);
connect(disSwi.u2, discharge.active);
connect(discharge.outPort[1], toOff.inPort);
connect(lessEqualThreshold.y, toOff.condition);
connect(off.outPort[1], toOn.inPort);
connect(toOn.outPort, charge.inPort[1]);
connect(charge.outPort[1], toHold.inPort);
connect(toHold.outPort, hold.inPort[1]);
connect(hold.outPort[1], toDischarge.inPort);
connect(toDischarge.outPort, discharge.inPort[1]);
connect(toOff.outPort, off.inPort[1]);
connect(disSwi.y, add.u1);
connect(chaSwi.y, add.u2);
end Battery;