2.3.1. Workdays

The determination of suitable values for the BL and SoCini is a dynamic process performed by using the established energy predictions for each day. On the other hand, battery operation is constrained to work between a 0.8 SoC and 0.2 SoC margin, which means a capacity of ~28.8 kWh out of the total 48 kWh is available for operation throughout the day. The other operational constraints, e.g., the limited number of charging cycles, which affect the degradation of the battery are not taken into account.

The algorithm starts at 00:00 by receiving the predicted energy demand profile for the upcoming day. Based on the maximum predicted power demand of the prediction profile, a series of test baselines (BLtest) are generated as shown in Figure 8a. Next, for different SoCini values ranging from 20% to 80% (20%, 30%, ... , 80%), the charging and discharging patterns of battery storage are evaluated for each BLtest profile as illustrated in Figure 8b. For the evaluation, the charging efficiency is taken as 85.5%, and the discharging efficiency is taken as 95%.

For each case, the cumulative energy which could not be delivered by the BESS to shave the peaks throughout the day, denoted by Xdischarge (read: 'inability to discharge'), and the cumulative energy which could not be stored by the battery to fill the valleys throughout the day, denoted by Xcharge (read: 'inability to charge'), are calculated. Performing the simulations for each case results in a complete overview with all different combinations of BL and SoCini, and corresponding values for Xdischarge and Xcharge. This information forms the basis in order to decide which case is expected to perform the best. Then, the chosen BL and SoCini are used for the operation of the specific workday.

**Figure 8.** (**a**) Principle of defining test baselines based on the maximum predicted power demand. (**b**) Peak shaving and valley filling depending on the test baseline and building energy demand forecast.

#### 2.3.2. Weekend Days and Holidays

The operational strategy of the weekend/holiday is to maximize PV self-consumption and prevent net power injection into the grid, meaning BL = 0 kW is chosen for weekends. At 00:00, an energy demand profile of the building is generated based on the predictions for the upcoming 24 h. By using these energy predictions and the assumed charging efficiency of the battery, the expected required storage capacity of the battery to prevent net injection between 07:00 and 17:00 is estimated. From this, the required SoCini is calculated. Figure 9 shows a visual representation of an example weekend day.

**Figure 9.** Foreseen excess photovoltaic (PV) production depending on building energy demand forecast on weekend days and holidays.

An illustration of the operational strategy to maintain the flattened demand profile on weekdays and weekends/holidays is shown in Figure 10. Before implementing it in the real building, the prediction models that are established in Section 2.2, the operational strategy and algorithm to determine the BL and SoCini, as well as a BESS model are implemented in MATLAB.

**Figure 10.** BESS operational schedule.

Even though the demand predictions are carried out with hourly resolution data, after the determination of the required baseline (BL) and SoCini, operational strategies are simulated with the highest-resolution data available, i.e., 1 min resolution data. This is becausecontrol of the real system occurs on the time scale of seconds rather than hours. Furthermore, battery behavior can only be accurately modeled when simulating with very high-resolution data. After simulation of the power flows in the BESS, the 1 min operation data are averaged to 15 min resolution data. The 15 min resolution is of interest because national electricity grid balancing in the Netherlands is carried out in time blocks of 15 min (clock quarters), also known as the program time unit (PTU) [53]. It is, therefore, reasonable to assess the performance of flexibility e fforts at the same resolution.

## 2.3.3. Assessment of Operational Strategy

Because this research focuses on assessing the building's electrical energy flexibility, key performance indicators (KPIs) are chosen wherein the actual impact of energy flexibility is quantified. Important KPIs that evaluate overall building energy performance and which are used in this research are:


Furthermore, a qualitative assessment is included using the load duration curves only for working hours and for both working and non-working hours. In addition, similar to the load duration curve, a Baseline Deviation Duration Curve (BDDC) is defined, since the aim of the model is to maintain the power demand as set by the baseline for the building through the operation of the BESS. This curve visualizes how well the system can maintain the baseline during the operational hours. The BDDC can be constructed by calculating the o ffset between the baseline and electricity consumption from the grid (*Pbuilding,net*) for all working hours, as shown in Equation (10).

$$P\_{\text{baseline}, \text{deviation}, t=i} = P\_{\text{building}, \text{net}, t=i} - P\_{\text{baseline}, t=i} \begin{bmatrix} k\mathcal{W} \end{bmatrix} \tag{10}$$

Then, the values of Pbaseline,deviation are sorted in descending order. This leads to a curve that is analogous to the load duration curve. The obtained Baseline Deviation Duration Curve visualizes how well the BESS strategy can maintain the baseline.

#### *2.4. Step 3: Real Building Management System (BMS) Implementation*

The final step concerns the practical implementation of the prediction models, algorithms, and BESS control strategies in the InsiteView® Building Management System (BMS). The BMS platform coordinates sensor-based measurements, actuators, and monitoring data at all operational levels in the building and provides an environment where advanced control algorithms can be implemented. After beta testing for ~4 weeks, an experimental phase was conducted for 13 days, from 7 August 2019 to 19 August 2019.

An overview of the general methodological steps that are used to structure Section 2 and the results (Section 3) is provided in Figure 11.


**Figure 11.** Summary of the methodological framework.
