Electric Storage
The electric storage system, typically a household battery, plays a key role in residential energy management by offering the flexibility to store and release energy during peak events. By optimizing battery charging and discharging, the Model Predictive Control (MPC) strategy enables efficient energy allocation while respecting user state-of-charge objectives and grid constraints. This section presents the MPC formulation for the electric storage device, which balances energy cost, user comfort, and battery operational limits. The formulation is based on predictive modeling to anticipate battery behavior over a time horizon, allowing proactive power peak management during service restoration.
The electric storage formulation is designed to minimize deviations from a desired SoC, while considering dynamic electricity rates, battery efficiency, and self-discharge characteristics. The use of a convex optimization framework ensures the feasibility of calculations, allowing the MPC to run efficiently on embedded devices with limited resources. This approach was chosen to provide a robust and scalable solution capable of adapting to varying grid conditions and user preferences, making it suitable for integration into HEMS.
Optimization Formulation
The MPC formulation for the electric storage device optimizes charging and discharging power over a prediction horizon , with time steps of duration (derived from the optimization interval, e.g., 10 minutes). The objective is to minimize the comfort penalty, defined as the quadratic deviation between the battery's residual energy and a desired SoC, weighted by a user-defined priority. The power allocation cost is integrated into the overall MPC objective, but for electric storage, only the comfort term is device-specific here.
The comfort penalty for electric storage is formulated as follows:
where:
- is the priority weight for electric storage.
- is the desired state of charge (constant over the horizon).
- is the residual energy (SoC) at time .
- is the normalization factor, generally defined as the battery's energy capacity.
The dynamics of electric storage are governed by the evolution of the battery's state of charge, which accounts for charging and discharging efficiencies as well as self-discharge:
where:
- is the degradation factor representing self-discharge.
- is the charging efficiency.
- is the discharging efficiency.
- is the charging power at time .
- is the discharging power at time .
- is the duration of the time step (in hours).
The constraints ensure that the battery operates within its physical and operational limits:
- Residual Energy Limits:
where and are the minimum and maximum residual energy, respectively.
- Power Limits:
where is the maximum battery power.
- Initial Condition:
where is the initial state of charge.
- Final SoC Requirement:
where is the required state of charge at the end of the horizon.
The net power provided by electric storage, which contributes to the overall power constraint, is:
Justification of the Formulation
The formulation prioritizes user comfort by minimizing the deviation from a desired SoC, which is essential to ensure the battery can power critical loads during peak events. The inclusion of charging and discharging efficiencies (, ) as well as the degradation factor () allows for accurate modeling of real battery behavior, which improves the accuracy of MPC predictions. The convex formulation avoids the use of binary variables for charge/discharge exclusivity to reduce computational complexity, which is crucial for real-time applications in embedded devices. The assumption of a constant desired SoC simplifies optimization, while corresponding to typical residential use cases where users generally prefer a stable target SoC.
Variable Definitions
The variables and parameters specific to the electric storage formulation are summarized in the following table:
Variable/Parameter | Description | Units |
---|---|---|
Charging power at time | W | |
Discharging power at time | W | |
Net power at time | W | |
Residual energy (SoC) at time | Wh | |
Desired state of charge (constant) | Wh | |
Priority weight for electric storage | - | |
Normalization factor (generally energy capacity) | Wh | |
Degradation factor (self-discharge) | - | |
Charging efficiency | - | |
Discharging efficiency | - | |
Maximum power capacity | W | |
Minimum residual energy | Wh | |
Maximum residual energy | Wh | |
Initial state of charge | Wh | |
Required final state of charge | Wh | |
Time step duration | h |
Classes
ElectricStorageMPC
This module defines the ElectricStorageMPC
class, which models an electric battery storage system for MPC.
It extends the abstract DeviceMPC
class, providing a concrete implementation for formulating the optimization problem specific to battery charging and discharging. This includes defining objectives related to maintaining a desired state of charge and incorporating constraints such as power limits and energy balance equations.
This class models the behavior of a stationary battery energy storage system (BESS). It formulates the optimization problem for charging and discharging the battery to meet certain objectives (e.g., maintaining a desired state of charge) while respecting the physical limitations of the device.
Methods
__init__(devices: List[Dict[str, Any]])
Initializes the ElectricStorageMPC
.
Args:
devices
: A list of dictionaries, where each dictionary contains the configuration and parameters of an electric storage device.
create_mpc_formulation(start: datetime, stop: datetime, steps_horizon_k: int, interval: int = 10, norm_factor: int = 10)
Creates the optimization formulation for the electric storage device.
This method builds a CVXPY optimization problem that models the battery's behavior over the prediction horizon. The objective is to minimize the deviation from a desired state of charge, while adhering to constraints such as:
- State of charge (SoC) limits (min and max).
- Charging and discharging power limits.
- The energy balance equation that governs how SoC changes over time.
Args:
start
: The start time of the optimization horizon.stop
: The end time of the optimization horizon.steps_horizon_k
: The number of time steps in the horizon.interval
: The duration of each time step in minutes.norm_factor
: A normalization factor for the objective function.
Returns:
- A tuple containing the objective terms, constraints, and the dispatch variable for the CVXPY optimization problem.