To fill the presented gap, Amplify (abstract multipurposelimited flexibility) was developed. We take peak shaving (PS) as an exemplary PA, for which the usage of a BESS is described e.g., in Tull de Salis et al. (2014); Lu et al. (2014); Tiemann et al. (2020). MPOs represent SAs like trading on energy markets or balance group management and are received by the local agent from an aggregator. Thereby, the PA is always prioritized in the present scenario – in contrast to other approaches e.g. with dynamic prioritization [cf. Namor et al. (2018); Marchgraber and Gawlik (2021)].
The result of Amplify is composed of four vectors, each of which consists of one value per time interval: the minimum and maximum power flexibility and the minimum and maximum energy flexibility. It refers to the idea of operational flexibility from Ulbig and Andersson (2015), which consists of a power gradient, a power and an energy dimension and allows a unified representation.
If all obligations can be met (for the other case see section Problem handling), the remaining flexibility is calculated by a fourstep procedure as shown in Fig. 1:

1
Available power range: The battery power is curtailed in order to meet power requirements from peak shaving and additional applications.

2
Allowed state of charge range: Calculate the state of charge (SoC) which can and which has to be reached to meet all requirements, while respecting the available power range as well as charge and discharge efficiencies.

a.
Forward integration: Calculate which SoC can be reached starting from the current SoC level.

b.
Backward integration: Calculate which SoC is required before peak shaving or MPOs.

3
Power flexibility: Apply SoC restrictions to the available power range.

4
Energy flexibility: Convert SoC range to energy range and respect efficiency losses.
Basic considerations
Battery model
In this work, we apply the battery storage model from Tiemann et al. (2020), of which we neglect the self discharge rate. There, a battery is modeled by a capacity \(C_\mathrm{E}\), maximum charge/discharge power \(P^{\text {max}}_{\text {s,ch}}\) / \(P^{\text {max}}_{\text {s,dis}}\), and charge/discharge efficiencies \(\eta _{\text {s,ch}}\)/\(\eta _{\text {s,dis}}\). Controlled by a desired set point \(P_{\text {des}}(t)\), a battery will provide as much power as possible depending on its power limits and the current SoC \(F(t) \in [0,1]\). Charge power is considered as positive and discharge power as negative.
Time
The model is calculated for uniform time intervals (e.g., 15 min: \(\Delta t^{\text {intv}}= 15\, \text {min}\)), which are expressed by an indexed time consideration. The current point in time \(t_0\) always lies within the current interval of index \(i_{\text {t}}=0\).
$$\begin{aligned} i_{\text {t}}\in \mathbb {N} ~~ 0 \le i_{\text {t}}\le i^{\text {max}}_{\text {t}}\end{aligned}$$
(1)
\(T^{\text {max}}= i^{\text {max}}_{\text {t}}\cdot \Delta t^{\text {intv}}\) is the planning horizon with \(i^{\text {max}}_{\text {t}}\) the number of respected time intervals. \(T_0 \le t_0\) is the beginning of the current time interval.
Primary application: peak shaving
Given the primary use case peak shaving, a residual load curve \(P^{\text {res}}(i_{\text {t}})\) below a predefined peak shaving limit \(P^{\text {max,set}}_{\text {peak}}(i_{\text {t}})\) is calculated. The storage has to balance negative values of \(P^{\text {res}}(i_{\text {t}})\) with discharge power and cannot exceed positive values in order to perform peak shaving:
$$\begin{aligned} P^{\text {res}}(i_{\text {t}})= P^{\text {max,set}}_{\text {peak}}(i_{\text {t}})P^{\text {fcast}} (i_{\text {t}})\end{aligned}$$
(2)
As the future residual load is usually not known in advance, a forecast \(P^{\text {fcast}} (i_{\text {t}})\) is used in order to consider the customer load profile. Other PA can be performed if their requirements are representable as residual load curve as well.
Secondary purposes
Obligations from energy market trading are respected as power values per time interval, of which the battery’s power has to reach or exceed the respective value. Here, we use \(P^{\text {mpo}}_{\text {ch}}(i_{\text {t}}) \ge 0\) for charge and \(P^{\text {mpo}}_{\text {dis}}(i_{\text {t}}) \le 0\) for discharge MPOs. The generation of economically meaningful MPOs would e.g. be performed by some kind of market intelligence, but does not lie within the scope of this work.
Flexibility model calculation
Available power range
At the start of the flexibility calculation, we assume unrestricted battery power, where each element of the maximum/minimum power vector equals the maximum battery charge/discharge power \(P^{\text {max}}_{\text {s,ch}}\)/\(P^{\text {max}}_{\text {s,dis}}\). This power range is then reduced independently for each time interval in order to meet all obligations from PA and MPOs (without consideration of the SoC):
$$\begin{aligned} P^{\text {max}}_{\text {avail}}(i_{\text {t}})&= \text {min} \left( P^{\text {max}}_{\text {ch}}(i_{\text {t}}), P^{\text {res}}(i_{\text {t}}), P^{\text {mpo}}_{\text {dis}}(i_{\text {t}}) \right) \end{aligned}$$
(3)
$$\begin{aligned} P^{\text {min}}_{\text {avail}}(i_{\text {t}})&= \text {max} \left( P^{\text {max}}_{\text {dis}}(i_{\text {t}}), P^{\text {mpo}}_{\text {ch}}(i_{\text {t}}) \right) \end{aligned}$$
(4)
In case of the current interval (\(i_{\text {t}}=0\)), the already passed time and performed power of the battery have to be respected as well. Here, \(P_{\text {s},0}(t_0)\) is the average power at the outer battery terminals from the beginning of the current time interval \(T_0\) until the current point in time \(t_0\):
$$\begin{aligned} P^{\text {max}}_{\text {ch}}(i_{\text {t}})&= {\left\{ \begin{array}{ll} \frac{P_{\text {s},0}(t_0) \cdot (t_0 T_0) + P^{\text {max}}_{\text {s,ch}}\cdot (\Delta t  (t_0T_0))}{\Delta t} &{} \text {, if } i_{\text {t}}= 0 \\ P^{\text {max}}_{\text {s,ch}}&{} \text {, if } i_{\text {t}}> 0 \end{array}\right. } \end{aligned}$$
(5)
$$\begin{aligned} P^{\text {max}}_{\text {dis}}(i_{\text {t}})&= {\left\{ \begin{array}{ll} \frac{P_{\text {s},0}(t_0) \cdot (t_0 T_0) + P^{\text {max}}_{\text {s,dis}}\cdot (\Delta t  (t_0T_0))}{\Delta t} &{} \text {, if } i_{\text {t}}= 0 \\ P^{\text {max}}_{\text {s,dis}}&{} \text {, if } i_{\text {t}}> 0 \end{array}\right. } \end{aligned}$$
(6)
Allowed state of charge range
In a second step, we calculate how much energy can be and has to be charged in order to meet all requirements while respecting the SoC within the battery as well as the charge and discharge efficiency. This is performed in two parallel substeps (sections Forward integration  reachable state of charge and Backward integration  required state of charge) which are combined after calculation. To keep the notation tight, efficiencies are considered as follows:
$$\begin{aligned} P^{\text {max,eff}}_{\text {avail}}(i_{\text {t}})&= P^{\text {max}}_{\text {avail}}(i_{\text {t}}) \cdot {\left\{ \begin{array}{ll} \eta _{\text {s,ch}}&{} \text {, if } P^{\text {max}}_{\text {avail}}(i_{\text {t}}) > 0 \\ 1/\eta _{\text {s,dis}} &{} \text {, if } P^{\text {max}}_{\text {avail}}(i_{\text {t}}) < 0 \end{array}\right. } \end{aligned}$$
(7)
$$\begin{aligned} P^{\text {min,eff}}_{\text {avail}}(i_{\text {t}})&= P^{\text {min}}_{\text {avail}}(i_{\text {t}}) \cdot {\left\{ \begin{array}{ll} \eta _{\text {s,ch}}&{} \text {, if } P^{\text {min}}_{\text {avail}}(i_{\text {t}}) > 0 \\ 1/\eta _{\text {s,dis}} &{} \text {, if } P^{\text {min}}_{\text {avail}}(i_{\text {t}}) < 0 \end{array}\right. } \end{aligned}$$
(8)
Forward integration—reachable state of charge In this step, the maximum and minimum reachable SoC are calculated by applying the available power range.
$$\begin{aligned} F^{\text {max}}_{\text {s,reach}}(i_{\text {t}}+1)&= \text {min} \left( 1, F^{\text {max}}_{\text {s,reach}}(i_{\text {t}}) + \frac{\Delta t^{\text {intv}}}{C_\mathrm{E}} \cdot P^{\text {max,eff}}_{\text {avail}}(i_{\text {t}})\right) \end{aligned}$$
(9)
$$\begin{aligned} F^{\text {min}}_{\text {s,reach}}(i_{\text {t}}+1)&= \text {max} \left( 0, F^{\text {min}}_{\text {s,reach}}(i_{\text {t}}) + \frac{\Delta t^{\text {intv}}}{C_\mathrm{E}} \cdot P^{\text {min,eff}}_{\text {avail}}(i_{\text {t}})\right) \end{aligned}$$
(10)
Thereby, the start SoC \(F_{\text {s}}(0)\) is virtual, as it is not guaranteed that it actually occurred at the start of the current interval. However, it would have been the case, if the storage had steadily delivered the average power \(P_{\text {s,0}}(t_0)\):
$$\begin{aligned} F_{\text {s}}(0) =F_{\text {s}}(t_0)  P_{\text {s},0}(t_0) \cdot (t_0 T_0) \cdot {\left\{ \begin{array}{ll} \eta _{\text {s,ch}}&{} \text {, if } P_{\text {s},0}(t_0) > 0 \\ 1/\eta _{\text {s,dis}} &{} \text {, if } P_{\text {s},0}(t_0) < 0 \end{array}\right. } \end{aligned}$$
(11)
$$\begin{aligned} F^{\text {max}}_{\text {s,reach}}(0) = F^{\text {min}}_{\text {s,reach}}(0) = F_{\text {s}}(0) \end{aligned}$$
(12)
Backward integration—required state of charge In this step, the maximum and minimum required SoC is calculated in order to be able to fulfill peak shaving and the MPOs. It is calculated as follows:
$$\begin{aligned} F^{\text {max}}_{\text {s,requ}}(i_{\text {t}})&= \text {min} \left( 1, F^{\text {max}}_{\text {s,requ}}(i_{\text {t}}+1)  \frac{\Delta t^{\text {intv}}}{C_\mathrm{E}} \cdot P^{\text {min,eff}}_{\text {avail}}(i_{\text {t}})\right) \end{aligned}$$
(13)
$$\begin{aligned} F^{\text {min}}_{\text {s,requ}}(i_{\text {t}})&= \text {max} \left( 0, F^{\text {min}}_{\text {s,requ}}(i_{\text {t}}+1)  \frac{\Delta t^{\text {intv}}}{C_\mathrm{E}} \cdot P^{\text {max,eff}}_{\text {avail}}(i_{\text {t}})\right) \end{aligned}$$
(14)
The maximum and minimum SoC, which the battery could reach after the end of the forecast horizon \(F^{\text {max}}_{\text {s,requ}}(i^{\text {max}}_{\text {t}}+ 1)\) and \(F^{\text {min}}_{\text {s,requ}}(i^{\text {max}}_{\text {t}}+ 1)\) can be adjusted as required. In this work, \(F^{\text {max}}_{\text {s,requ}}(i^{\text {max}}_{\text {t}}+ 1)\) is set to 1 and \(F^{\text {min}}_{\text {s,requ}}(i^{\text {max}}_{\text {t}}+ 1)\) is set to 0. As they do not lie within the forecast horizon, no limitation is assumed meaningful.
Combination of forward and backward integration The most restrictive combination of reachable and required SoC results in the allowed SoC range:
$$\begin{aligned} F^{\text {max}}_{\text {s}}(i_{\text {t}}) = \text {min} \left( F^{\text {max}}_{\text {s,reach}}(i_{\text {t}}), F^{\text {max}}_{\text {s,requ}}(i_{\text {t}}) \right) \end{aligned}$$
(15)
$$\begin{aligned} F^{\text {min}}_{\text {s}}(i_{\text {t}}) = \text {max} \left( F^{\text {min}}_{\text {s,reach}}(i_{\text {t}}), F^{\text {min}}_{\text {s,requ}}(i_{\text {t}}) \right) \end{aligned}$$
(16)
Based on the current forecast, the battery can fulfill all scheduled obligations if its SoC is kept within this range.
Power flexibility
In order to derive what power set points a battery can perform if the SoC is considered, we combine the information from the allowed SoC range and the available power range. For each time interval, the maximum and minimum power is calculated individually. It displays the power, with which the battery can be charged or discharged, without exceeding the allowed SoC range. The power flexibility constitutes the more restrictive constraint respectively:
$$\begin{aligned} P^{\text {max}}_{\text {allow}}(i_{\text {t}})&= \frac{\left( F^{\text {max}}_{\text {s}}(i_{\text {t}}+1)F^{\text {min}}_{\text {s}}(i_{\text {t}})\right) \cdot C_\mathrm{E}}{\Delta t^{\text {intv}}} \cdot {\left\{ \begin{array}{ll} 1/\eta _{\text {s,ch}},&{} \text {if } P^{\text {max}}_{\text {allow}}(i_{\text {t}})> 0 \\ \eta _{\text {s,dis}},&{} \text {if } P^{\text {max}}_{\text {allow}}(i_{\text {t}})< 0 \\ \end{array}\right. } \end{aligned}$$
(17)
$$\begin{aligned} P^{\text {min}}_{\text {allow}}(i_{\text {t}})&= \frac{\left( F^{\text {min}}_{\text {s}}(i_{\text {t}}+1)F^{\text {max}}_{\text {s}}(i_{\text {t}})\right) \cdot C_\mathrm{E}}{\Delta t^{\text {intv}}} \cdot {\left\{ \begin{array}{ll} 1/\eta _{\text {s,ch}},&{} \text {if } P^{\text {min}}_{\text {allow}}(i_{\text {t}})> 0 \\ \eta _{\text {s,dis}},&{} \text {if } P^{\text {min}}_{\text {allow}}(i_{\text {t}})< 0 \\ \end{array}\right. } \end{aligned}$$
(18)
$$\begin{aligned} P^{\text {max}}_{\text {flex}}(i_{\text {t}})&= \text {min} \left( P^{\text {max}}_{\text {avail}}, P^{\text {max}}_{\text {allow}}(i_{\text {t}})\right) \end{aligned}$$
(19)
$$\begin{aligned} P^{\text {min}}_{\text {flex}}(i_{\text {t}})&= \text {max} \left( P^{\text {min}}_{\text {avail}}, P^{\text {min}}_{\text {allow}}(i_{\text {t}})\right) \end{aligned}$$
(20)
It can be interpreted as the maximum individual power values which can be offered by the battery without compromising the obligations from either purpose.
Energy flexibility
The energy flexibility allows to schedule obligations of a battery which last longer than one time interval. It expresses the amount of energy (not SoC) with which the battery can be charged or discharged. To this end, the allowed SoC range is scaled with the energy capacity of the battery.
$$\begin{aligned} E^{\text {max}}_{\text {flex}}(i_{\text {t}})&= (F^{\text {max}}_{\text {s}}(i_{\text {t}})  F_{\text {s}}(0) ) \cdot C_\mathrm{E}\end{aligned}$$
(21)
$$\begin{aligned} E^{\text {min}}_{\text {flex}}(i_{\text {t}})&= (F^{\text {min}}_{\text {s,incr}}(i_{\text {t}})  F_{\text {s}}(0) ) \cdot C_\mathrm{E}\end{aligned}$$
(22)
To respect that discharge MPOs actually consume additional energy due to efficiency losses, the minimum SoC \(F^{\text {min}}_{\text {s,incr}}\) is increased: For each time interval, the maximum dischargeable energy (maximum delta of the SoC) is calculated. For this, the earliest point in time \(j_{\text {t}}\) is determined at which continuous discharging without intermediate charge obligation can be started. Three conditions have to hold for \(j_{\text {t}}(i_{\text {t}})\) and the interval \(I = [j_{\text {t}}(i_{\text {t}}), i_{\text {t}}]\). First, the time of \(j_{\text {t}}(i_{\text {t}})\) cannot be in the past. Second, it has to be earlier in time than \(i_{\text {t}}\). Third, the storage must not have to charge in I.
Upon that, \(l_{\text {t}}(i_{\text {t}}) \in [j_{\text {t}}(i_{\text {t}}), i_{\text {t}}]\) is set such that it maximizes the dischargeable energy, which is limited by either the maximum SoC \(F^{\text {max}}_{\text {s}}(l_{\text {t}})\) or the maximum discharge power until \(i_{\text {t}}\), which is integrated over time up to \(E^{\text {max}}_{\text {s,dis}}\):
$$\begin{aligned} \Delta F^{\text {max}}_{\text {s,dis}}(i_{\text {t}})&= \max _{l_{\text {t}}(i_{\text {t}})} \left( F^{\text {max}}_{\text {s,dis}}(l_{\text {t}}(i_{\text {t}})) \right) \end{aligned}$$
(23)
$$\begin{aligned} F^{\text {max}}_{\text {s,dis}}(l_{\text {t}}(i_{\text {t}}))&= \min \left( F^{\text {max}}_{\text {s}}(l_{\text {t}})  F^{\text {min}}_{\text {s}}(i_{\text {t}}), E^{\text {max}}_{\text {s,dis}}(l_{\text {t}}(i_{\text {t}}))/C_\mathrm{E} \right) \end{aligned}$$
(24)
$$\begin{aligned} E^{\text {max}}_{\text {s,dis}}(l_{\text {t}}(i_{\text {t}}))&= \sum _{m_{\text {t}}=l_{\text {t}}(i_{\text {t}})}^{i_{\text {t}}1} \frac{P^{\text {min}}_{\text {flex}}(m_{\text {t}})}{\eta _{\text {s,dis}}} \cdot \Delta t^{\text {intv}}\end{aligned}$$
(25)
Finally, the minimum SoC is increased by the efficiency losses, which would occur if the battery is discharged by the maximum dischargeable energy:
$$\begin{aligned} F^{\text {min}}_{\text {s,incr}}(i_{\text {t}}) = F^{\text {min}}_{\text {s}}(i_{\text {t}}) + \Delta F^{\text {max}}_{\text {s,dis}}(i_{\text {t}}) \cdot \left( \frac{1}{\eta _{\text {s,dis}}}1 \right) \end{aligned}$$
(26)
In case the minimum energy flexibility exceeds the maximum energy flexibility due to the increase because of efficiency losses, we set the maximum energy flexibility to the same value. This way, we prevent offering more energy flexibility than is available due to efficiency losses. The presented procedure results in four vectors, the minimum and maximum power flexibility and the minimum and maximum energy flexibility. They represent the remaining flexibility of a battery if the requirements for peak shaving as the PA and additional MPOs are met. Amplify is designed such that the offered flexibility can be used, but it is not guaranteed that the battery is fully utilized by calling the entire flexibility. The abstract representation as power and energy allows the aggregator to neglect battery specific parameters. If a new MPO lasts for only one time interval (15 min), only the power flexibility has to be considered. If it lasts for multiple time intervals, all power values of it have to lie within the power flexibility. The energy trajectory, which results from an integration of these power values, has to fit into the energy flexibility range, so that a BESS can fulfill the new MPO. Subsequent power values within one MPO are allowed to differ, but it is important that they do not change sign, such that pure charge or discharge MPOs are generated (interim zero values are allowed). Due to the dense representation, the flexibility can be transmitted from distributed batteries or their agents without causing extensive network traffic. Amplify can be used to size new MPOs which can be given to the battery. After a new MPO was accepted, flexibility has to be recalculated in order to display the remaining potential correctly. The handling and effect of already accepted MPOs is not discussed here for reasons of brevity.