2.3.1. Location, Negative, and Positive Flexibility

Since in the setting considered here all flexible devices are stationary, the location of a flexible device is considered to be constant and is described by a unique identifier. In Germany, the Bundesnetzagentur introduced a 11-digit identifier (MaLo-ID: market location identifier) to simplify the market communication. Therefore, each HEMS that offers flexibility must attach the MaLo-ID to their bids.

Generally, all flexible devices are able to offer positive and negative flexibility, some even at the same time. For example, an EV charging station can offer positive flexibility by stopping an ongoing charging process or by reducing the charging power. Negative flexibility can be offered by charging a vehicle even though it has not been scheduled or by increasing the charging power while charging.

#### 2.3.2. Power, Duration, and Energy

The DERs have different operating types. For both operating types, flexibility can be determined using Equations (11) and (12).

$$p\_{\rm pos}^{\delta} = \begin{cases} \ P\_{\rm max}^{\delta} - p^{\delta} & \forall \delta \in G \\ p^{\delta} & \forall \delta \in C \end{cases} \tag{11}$$

$$p\_{n\text{cg}}^{\delta} = \begin{cases} -p^{\delta} & \forall \delta \in G \\ p^{\delta} - P\_{\text{max}}^{\delta} & \forall \delta \in \mathbb{C} \end{cases} \tag{12}$$

As mentioned in Section 2.2, *p*<sup>δ</sup> denotes the power of the electricity consumer (C) and generator (G). *P*<sup>δ</sup> *max* is the maximal power of each flexible device. *p*<sup>δ</sup> *pos* and *p*<sup>δ</sup> *neg* represent the resulting positive and negative flexibility power for each device. Note that the positive and negative flexibility power is always positive and negative, respectively, or zero. As described above, one device can offer positive and negative flexibility at the same time.

Equations (13)–(15) describe the duration that flexibility is available. *d*<sup>δ</sup> *flex* is the maximal duration that flexibility can be offered by a flexible device.

$$\max\_{t\_{flex}^{\epsilon} \in \left[t\_{flex}^{\nu} \mid T\right]} d\_{flex}^{\delta} = \left(t\_{flex}^{\epsilon} - t\_{flex}^{\epsilon}\right) \Delta t \tag{13}$$

s.t.

$$f\_t\left(\not{p}^{\delta'},\;p\_{flex}^{\delta}\right) = 0 \qquad \qquad \forall t \in \begin{matrix} \forall \delta' \in A\_f - \delta \\ t\_{flex'}^{\varepsilon} t\_{flex}^{\varepsilon} \end{matrix} \tag{14}$$

$$\operatorname{gr}\Big(\hat{p}^{\delta'}, \left. p^{\delta}\_{flx} \right) \le 0 \qquad \qquad \qquad \qquad \forall \delta' \in A\_f - \delta \Big) \tag{15}$$

$$\forall t \in \left[ t^{\operatorname{st}}\_{flx}, t^{\operatorname{tr}}\_{flx} \right] \tag{15}$$

This optimization problem is solved for each time step. The start time *t s flex* of each flexibility is exactly the time step chosen by each iteration. *t e flex* is variable in this problem and should be maximized without violating constraints *ft* and *gt*, which are abstracted from the equality and inequality constraints discussed in Section 2.2, respectively. Subscript *t* for *f* and *g* indicates that the constraints shall be satisfied in the whole domain of *t*. *p*<sup>δ</sup> *flex* is the positive or negative power of one specific flexible appliance, whereas *p*ˆδ refers to all other flexible appliances that still follow the cost-optimal schedules.

Once the flexibility duration has been acquired, the flexible energy is calculated by Equation (16).

$$\epsilon\_{flx,t}^{\delta} = \sum\_{s=t}^{t+d\_{flx}^{\delta}-1} p\_{flx,t}^{\delta} \cdot \Delta t \tag{16}$$

Hence, the duration for which flexibility can be offered depends on the device's current state. In the case of an EV, the flexibility that can be offered depends on the battery's SoC, maximal charging power and availability.

In a final step, the flexibility would need a price tag in order to be offerable on a flexibility platform. However, this paper focuses on the quantification of flexibility of EVs and therefore the pricing is excluded from this analysis. Nevertheless, one possible pricing mechanism for flexibility of EV is described in [9].

Finally, the HEMS transfers the calculated flexibility parameters to a flexibility platform and waits for flexibility calls. Once a provider is called for flexibility, user preferences change, or new forecasts are available, the HEMS reinitiates the entire procedure from optimization to flexibility calculation and updates the offers on the flexibility platform.

The model is open-source and accessible via the link in the Supplementary Material.

#### **3. Case Study**

Figure 2 visualizes the general design of the case study. In a first step, we computed vehicle availabilities based on field trial data, collected by the California Department of Transportation and the Karlsruhe Institute of Technology. After gathering and pre-processing the vehicle availabilities and electricity tariffs, the cost-optimal charging schedules and the flexibility for each vehicle availability is calculated using the model described in Section 2. In order to analyze the aggregated flexibility potential of more than 4000 Californian and more than 11,000 German vehicle availabilities, the final results are aggregated. The following paragraphs describe the case study setup in detail. The link in the Supplementary Material contains an open-source script for the case study.

**Figure 2.** Case study design, US CHTS, and GER MP refers to the Californian and German field trial data used to calculate the vehicle availabilities [18–20]. Con refers to the constant electricity rate in California [21], ToU refers to the 'ToU-D-Prime' electricity tariff of Southern California Edison [22], and RTP refers to the Hourly Real-Time prices of ComEd in Illinois [23], US. ntariff refers to the number of electricity tariffs, navail refers to the number of vehicle availabilities, and ncontr refers to the number of controller strategies investigated in this case study.
