Functions optimize_demand
,
add_battery_optimization
or smart_charging
make use of Quadratic programming in order to obtain the optimal power
load given certain conditions. The Quadratic programming problem can be
formulated according to multiple objectives. Currently,
flextools
package allows to optimize a time-series power
load considering multiple objectives:
- Minimize the power exchanged with the grid (net power)
- Minimize the energy cost
In this article, we’ll cover the optimization problem for the first objective, net power minimization, for both the flexible demand (e.g. heatpumps, electric vehicles, etc.) and the battery.
Demand optimization
To minimize the energy exchanged with the distribution grid while maximizing the use of local generation, using the flexibility from a power demand profile, the objective function of the optimization problem has been raised in the following way:
Where:
- : Number of time intervals within the optimization window
- : Local power generation time-series vector
- : Non-flexible load time-series vector
- : Flexible load time-series vector (if not optimized)
- : Optimal flexible load time-series vector
- : penalty on change for the flexible load
Moreover, the squared term penalizes high values of net power, so the optimization always results in the most flat as possible net power profile (peak shaving).
This optimization problem has the following constraints:
- The energy consumed by the flexible load must remain the same than the expected behavior:
- Optimal flexible load must be lower than a certain maximum power :
- The energy balance between generation and loads must be lower than the grid import capacity :
At the same time, we can optimize the flexible energy demand with two opposite approaches:
- Postpone the consumption to later time-slots (shift the energy forward)
- Consume now (store) the energy that will be consumed later (shift the energy backward)
We consider both approaches for different objectives or applications. The energy shift is always done within a maximum time horizon () to consider realistic scenarios. For example, the time horizon for the energy demand of a water boiler could have a time horizon of 6 hours, because it wouldn’t make sense to heat the water more than 6 hours before the final consumption. Each one of these approaches brings extra constraints to the optimization problem:
If the energy can only be shifted forward:
- The cumulative sum of the optimal load must be higher than the cumulative sum of the original flexible load except the last time slots, and lower than the total cumulative sum of the original flexible load (energy can only be shifted forwards):
- The maximum values for the optimal demand will depend on the time horizon :
If the energy can only be shifted backward:
- The cumulative sum of the optimal demand must be higher than the total cumulative sum of the original demand (energy can only be shifted backwards), and lower than the cumulative sum of the original demand except the following time slots:
- The maximum values for the optimal demand will depend on the time horizon :
Battery optimization
To minimize the energy exchanged with the distribution grid while maximizing the use of local generation, using the flexibility from a battery, the objective function of the optimization problem has been raised in the following way:
Where:
- : Number of time intervals within the optimization window
- : Local power generation time-series vector
- : Power load time-series vector
- : Optimal battery power time-series vector. Positive charging, negative discharging.
- : penalty on change for the flexible load
Additionally, this optimization problem also counts with the following parameters used in the constraints below:
- : Battery capacity
- : Maximum charging power
- : Maximum discharging power
- : Minimum state of charge of the battery
- : Maximum state of charge of the battery
- : state of charge at the beginning/end of the optimization window
Optimization constraints:
- Battery power (positive = charging, , negative = discharging, ) limits:
- State of charge limits:
- The balance of charged/discharge energy must be 0 at the end of the optimization window to have the same initial state of charge at the beginning of every optimization window:
- The energy balance of generation and loads must be between the import capacity and export capacity :