Analysis of a Multi-Timescale Framework for the Voltage Control of Active Distribution Grids

: The development of strategies for distribution network management is an essential element for increasing network performance and reducing the upgrade of physical assets. This paper analyzes a multi-timescale framework to control the voltage of distribution grids characterized by a high penetration of renewables. The multi-timescale solution is based on three levels that coordinate Distributed Generation (DG) and Energy Storage Systems (ESSs), but differs in terms of the timescales and objectives of the control levels. Realistic load and photovoltaic generation proﬁles were created for cloudy and clean sky conditions to evaluate the performance features of the multi-timescale framework. The proposed solution was also compared with different frameworks featuring two of the three levels, to highlight the contribution of the combination of the three levels in achieving the best performance.


Introduction
The growing allocation of Renewable Energy Sources (RESs) and the introduction of more and more Distributed Generation (DG) is leading to important challenges for network management. Low Voltage (LV) grids, in particular, are exposed to an increasing penetration of Photovoltaic (PV) generation, thereby becoming active distribution networks that require new solutions for maintaining the voltage within the limits defined by grid standards [1][2][3]. The RESs introduce in fact a high level of uncertainty and can generate peaks several times higher than the load, which could eventually lead to the risk of overvoltages [4,5]. A common solution adopted by Distribution System Operators (DSOs) to deal with this issue is the reinforcement of the grid by updating physical assets such as transformers or cables [6]. However, smart control techniques have proven to be an attractive alternative, being not only less invasive and more environmentally friendly, but also economically more convenient than the installation of additional lines or devices [7,8]. At the same time, Energy Storage Systems (ESSs) are being increasingly installed in the distribution grid, thus becoming a key resource for implementing the aforementioned smart control measures [9][10][11]. Moreover, ESSs are more and more available in combination with PV systems in LV distribution grids [12], thus making the combined use of PV and ESSs an interesting option to control the voltage. By optimally controlling the operation of ESSs, the net load and generation can be adjusted, which increases the capability to prevent overvoltage events [13] and diminishes the requirements for grid reinforcements by reducing the peak power flows [14]. Improving the balance between load and generation contributes to reducing the amount of power flowing throughout the lines and reducing the amount of power flowing through the transformer connecting to the medium voltage. However, the ability of reaching a good balance is based on the availability of a reliable monitoring of the distribution grid and on the possibility to control the power injections at several nodes of the grid.
In the literature, several works proposed innovative solutions and algorithms for the voltage control of distribution grids, which differ in terms of the considered timescale and of the methods used for solving the voltage optimization problem. The first category of papers demonstrates the benefits of day-ahead scheduling of Distributed Energy Resources (DERs) [15][16][17]. Many of them focus on the management of the ESSs, taking into account the possible constraints associated with their State of Charge (SoC) [18,19]. In Jamal et al. [18], for example, the ESS scheduling was forced to guarantee a minimum level of SoC for the following day, which allowed a proper day-by-day operation of the ESSs. Attention was paid also to the maximum and minimum levels of the SoC, mostly to avoid a full discharging, since this would lead to a fast deterioration of the storage. The dayahead scheduling of DGs is in general an effective way to reshape the levels of net load and generation in the grid, but it relies on the use of forecasts. Consequently, these strategies become less effective in the case of mismatches between the forecast and the actual conditions. Furthermore, scheduling results usually do not allow dealing with the quickly changing conditions typically introduced by the intermittent behavior of DGs.
A second category of voltage control solutions refers to algorithms devised to solve possible voltage violations occurring in the grid in the near-real-time range [20][21][22]. These works have proposed online feedback controllers, where system measurements are used to calculate the control output that drives the distribution grid to reach acceptable voltage levels. Available solutions differ depending on the resources used for the voltage management, the control technique, or the implementation scheme. These control solutions allow solving the voltage violations by relying on field measurements, so the calculated output is fully dependent on the actual operating conditions. Since in the online control proposed in Antoniadou-Plytaria et al. [20][21][22], no forecast data were involved, calculations can be repeated very frequently because they depend only on the acquisition rate of the measurements. On the other hand, however, this prevents considering the future horizon and generally does not allow obtaining an optimal usage of the resources over time. As demonstrated in De Din et al. [23], the ESSs could be used for implementing an online feedback-based voltage control without having a pre-defined schedule. However, the control solves short-term voltage violations without taking into account how the set-points can eventually affect the SoC throughout the day. Thus, this approach misses a proper control of the State of Charge (SoC) and therefore the possibility of reaching the optimum over a longer period of time. As an example, the physical constraints on the SoC could prevent the use of the ESSs in those moments where their support would be more beneficial.
To overcome these limitations, recently, scheduling approaches have been coupled with measurement-based control strategies to create hierarchical control architectures [16,17,24]. In Malekpour et al. [17], the scheduling optimization was coupled with a local voltage control based on a droop-control method providing scheduled reactive power set-points. The control shows a hierarchical structure; however, the reactive power set-points calculated by the scheduling are directly used by the droop-based control without any correction based on the real measurements. A different approach was presented in Gupta et al. [16], where the day-ahead scheduling was connected to a Model Predictive Control (MPC). The scheduling stage defines a day-ahead dispatch plan based on the forecast of the stochastic load and generation at the grid connection points. A short-term MPC was then used to apply corrective actions looking at the mismatches between the dispatch plan and the real measurements. In the case of low granularity in the forecast data, the MPC can be further coupled with an online feedback-based control [25].
The present paper aims at taking a further step towards the implementation of effective solutions for the voltage control of LV distribution grids by presenting a multitimescale framework composed of three-level control: day-ahead scheduling, MPC, and online feedback-based control. The scheduling stage provides the initial operation plan for the DGs, whereas the MPC refines it by exploiting real measurements to update the set-points for the distributed resources. Lastly, the online feedback control compensates for possible voltage violations that could still happen during the real-time operation of the system. The term multi-timescale represents a cascaded control framework with interdependencies between processes on different timescales, where each control is designed for one timescale and exchange information with the other layers to update cost terms and constraints [26]. A three-level multi-timescale solution was recently proposed in Fard et al. [27], which only dealt with the reactive power control of PVs and excluded the use of day-ahead scheduling. The paper however demonstrated the positive impact of using a fast voltage control layer interfaced with slower upper layers.
The multi-timescale architecture proposed in this paper was tested with realistic generation and load profiles typically present in LV distribution grids to highlight the key role played by each of the control levels. Specific tests were performed to show the contribution of each of the components of the three-level control in achieving an effective voltage control solution. Therefore, aside from describing the proposed three-level solution, the purpose of the paper was to compare the full solution with two-level frameworks where the same strategy was deprived of one of its components. This approach demonstrated how each level had a specific role in the control of the voltage. Overall, the contributions of this paper were: (i) to propose a three-level framework for voltage control together with the associated algorithms; (ii) to analyze and demonstrate the beneficial contribution of each of the levels in comparison with different two-level control strategies; (iii) to test and validate the proposed framework with realistic conditions typical of LV distribution grids.
The rest of the paper is structured as follows. Section 2 briefly introduces the linearized branch-flow model describing the dependence of the node voltages on the active and reactive power injections. Section 3 describes in detail the proposed multi-timescale framework and the algorithms used at each control level. Section 4 presents the simulation setup used for the tests, while Section 5 shows the results obtained in different simulation scenarios. Finally, Section 6 summarizes the main highlights of this work and concludes the paper.

Impact of DG Installation on the Voltage Profile
The increasing installation of DGs in the distribution grid is well known to bring undesired effects on the voltage profile, because most of the existing distribution grid infrastructure was developed when DGs were not present or planned [28]. In the LV grid, the peaks of load and generation from PV (which is main the generation source at the LV level) are usually not aligned during the day, and this can cause significant fluctuations of the voltage over time. In this context, the ESSs will play a more and more significant role in the voltage regulation of distribution grids, given that their installation is growing due to both technical and economical benefits [29]. From a technical perspective, ESSs can inject real or reactive power to contribute to voltage control [29], to help solve under-or over-voltage events locally, reducing the support from the Medium Voltage (MV) grid [4]. From an economical perspective, the impact of the installed ESSs on the voltage profile helps keep the grid conditions far from the operational boundaries with a consequent reduction of the cost for new equipment and a decrease of the line losses.
This section introduces the equations that are used throughout the paper to model the distribution grid and the impact of the power injections on the voltage profiles of the nodes. The final equation of the model is shown in Equation (1), which describes the impact of distributed power injections on the voltage profile of the grid in time, which was extensively analyzed in De Din et al. and Farivar et al. [23,30], and it can be linearly approximated around the slack bus voltage under the assumptions of negligible shunt impedances and voltage magnitudes near nominal. The resulting equation is described as: where V is the N BUS × 1 vector of voltage magnitudes for the N BUS grid nodes; 1 is an N BUS × 1 vector of ones; V 0 is the voltage magnitude at the slack bus; p c and q c are the N BUS × 1 vectors of active and reactive power consumption at the nodes (defined as positive), respectively; p g and q g are the N BUS × 1 vectors of active and reactive power generation at the nodes (defined as positive), respectively; and R and X are the real and imaginary parts of the N BUS × N BUS impedance matrix of the grid [23]. Equation (1) shows that the voltage magnitude at each node of the grid differs from the voltage V 0 at the slack bus due to the existing power consumptions and generations, which are weighted according to the resistance and reactance terms in the grid impedance matrix that are responsible for the resulting voltage drops. Equation (1) allows evaluating operating conditions with the predominance of generation, which would lead the voltage of the grid nodes to rise along the grid, whereas larger power consumptions would lead the voltage to drop below the slack bus value. Therefore, PV systems that generate power during the day could lead to an overvoltage event in the case of low power consumption levels or, vice versa, a high peak of consumption in the evening (exacerbated for example by the charging of Electrical Vehicles (EVs)) with no local generation could lead to possible undervoltage issues [31].
The aim of the present paper was to use the distributed controllable resources installed in the distribution grid to flatten the voltage profiles. This approach reduces the losses [32], since it reduces the amount of power flowing in the lines. Reducing it is particularly relevant in the case of reverse power flow, which leads to a voltage increase in the Medium Voltage (MV) grid [33].
The controllable DERs considered in this work were: • PV: with Q DG the controlled reactive power power injection and P curt DG the controlled active power curtailment. • ESS: with P ESS the controlled active power injection, whereas no reactive power control was considered.
The choice of using PVs was justified by the fact that PVs are usually the main component of the DG at the LV level, and consequently, a high PV penetration plays a key role in producing voltage violations and reverse power flows in the LV grid [5].
The resulting variation of voltage linked to the controlled power of the DGs and ESSs is defined as [23]: ∆V = 1V 0 + R(P curt DG + P ESS ) + XQ DG (2) where the variables P curt DG , P ESS , and Q DG are vectors with dimensions equal to the total nodes of the grid, having null values on the positions corresponding to nodes where PVs or ESSs are not installed. In addition, the use of the term injection in the paper refers generically to positive (injection) and negative (absorption) values of power if not clearly specified.

Multi-Timescale Framework
A common approach in the application of control strategies for electrical grids is the use of several control stages in a hierarchical control structure, where each stage serves a different purpose. In the distribution grid, this approach can be mapped to different timescales that can be related to the granularity of the data and the acquisition rate of the measurements. The proposed hierarchical approach consists of three parts: day-ahead scheduling, MPC, and online feedback control for fast dynamics.
The day-ahead scheduler receives the load and generation forecasts for the following day divided into time frames of a given length (e.g. 15, 30, or 60 min; see for example [17]). The scheduling is mainly responsible for providing a base operation plan of the ESSs with the goal of keeping the voltage close to its nominal value while reaching the target for the SoC at the end of the day. The scheduling is determined without using real-time measurements, and therefore, its effectiveness is subject to the effect of possible mismatches between the load and generation forecast data and the actual operating conditions of the grid [16].
The second stage of the multi-timescale framework is the MPC, which is employed as an intermediate control layer to mitigate the above issues by means of real-time measurements, thus increasing the robustness towards forecast errors. The purpose of the MPC is to track the operation plan of the ESSs, while using reactive power injections of the PVs and the active power injections of the ESSs as the primary generation units to drive the bus voltages towards the nominal value. In this work the MPC was designed to give less priority to the active power curtailment of the PVs, so that the other two controllable variables can be used first. The active power of the ESSs calculated by the scheduling is converted into an SoC reference by the MPC, thus changing the objective of the MPC in tracking the SoC in combination with flattening the voltage. In this work, the MPC time-step was shorter than the scheduling, but not as fine as that of the online control, which uses the MPC outputs as reference inputs, as described in Section 3.2. By using this approach, the set-points calculated by the MPC are transmitted to the DGs and can be modified only by the online control, when it detects a voltage violation, as explained in Section 3.3.
The last control level of the framework is the online feedback control, which aims at preventing sudden voltage violations due to rapid and unexpected changes in generation or load that would increase the unbalance between these two terms. The online feedback control receives reference set-points from the MPC and, as long as no voltage levels violating the limits are detected, it does not apply any change to these set-points. The results of the online control are transferred to the DGs and ESSs only when a voltage violation leads the set-points deviating from what was determined with the MPC. This reduces the amount of information exchange in comparison with a condition where the online feedback control is used as standalone, and it transmits the set-points at each iteration.
The complete structure of the framework described in this section is represented in Figure 1

Scheduling of Energy Storage Systems
The objective function of the scheduling is here defined as the sum of quadratic functions optimized over N steps of time length T S according to the time resolution available for the forecast power profiles: where: • V K is the full vector of voltage magnitudes calculated at iteration K • V nom = 1V 0 is the vector of nominal voltage values.
• P ESS,K is the vector of active power set-points assigned to ESSs calculated at iteration K.
• W V , W ESS are the N BUS -dimensional symmetric matrices of weights associated with each variable.
In the proposed solution, the operation of the ESSs has the constraint of reaching at the end of the day the same level of SoC present at the start of day. This choice is arbitrary, and it was made for the sole purpose of demonstrating the accomplishment of the scheduling objective. The same approach was used also in Babaei et al. [19] to ensure that the ESSs have enough SoC available for the following day. With such a constraint for the SoC, the scheduler guarantees that even for subsequent days, the ESSs start always with the same amount of the SoC. Without this constraint, the value of the SoC tends to deviate increasingly and to stray from the SoC values of the other ESSs, resulting in a large discrepancy in the utilization levels of the installed ESSs. It is worth noting, however, that a different target value for the SoC at the end of the day can be easily set using the same control formulation. However, different and less technical approaches can be used, for example to reach economic profits based on the market, for example by grouping the ESSs based on their offers [34]. The second objective of the optimization function is to flatten the voltage profile closer to the nominal values to reduce the overall losses. The objective function does not present the PVs' controllable variables in the equation, given that the purpose of the scheduler is to provide a plan only for the ESSs and to leave the control of the PVs at the lower levels of the framework.
The minimization problem formulation results in: The optimization is subject to some equality and inequality constraints. Constraints (a) and (b) are respectively the box constraints for the voltage and the approximation of Equation (1) that estimates the voltage variation based on the calculated set-points, where: • P max DG,K represents the maximum available DGs' forecasted active power at the instant K. • P Load,K represents the active power load forecast at the node where the DGs are installed for the instant K.
Constraint (c) is the box constraint for the active power of the ESSs and the last constraints, (d), (e), and (f), are linked to the SoC of the ESSs, to guarantee that the SoC profiles follow the characteristic equations (d), the constraints (e), and that the objective SoC at the last time-step of the day is achieved (f). The vector C ESS defines the ESSs' capacity, and the coefficient η ESS represents the efficiency of the ESSs. Therefore, the only values passed to the MPC are the set-points calculated for the N steps of the active power of the ESSs P ESS,ref .

Model Predictive Control
The model predictive control is used to perform the first stage of closed-loop control that makes use of measurements from the field and the results of the day-ahead scheduling to define the operating conditions for the future time-steps within a prediction horizon H p . When the MPC is connected to an upper level control and it is supposed to follow the result of the scheduler, the objective function can be chosen adequately to minimize the deviation from the operating plan, so that the original scheduling is followed as long as possible, unless undesired voltage conditions are predicted [35].
The objective function of the MPC is minimized for the whole prediction horizon, which results in N p = H p /T M steps, where T M is the length of the time-step. The choice of the time-step length could be in general different from the time-step used for the scheduling. Although the MPC calculates the control set-points for the N p steps of the prediction horizon, only the first step of the control sequence is transmitted to the DGs (PVs and ESSs). The MPC also uses voltage and power measurements from the field to calculate the set-points based on the updated condition of the grid. With this approach, the voltage violations can be predicted by means of the forecasts and counteracted in advance, and on the other side, it is robust against forecast errors by using real measurements. The MPC controls the active power injection of the ESSs and the active power curtailment and reactive power control of PVs, but assigning a large weight to the active power curtailment to avoid its use as much as possible.
The implemented MPC solves an optimization problem at each control step k in a centralized manner; however, in the literature can be found examples where the MPC was implemented in a distributed fashion, e.g., in Notarnicola et al. [36]. The centralized MPC solves an optimization problem at each control step k. The objective function is different from the schedule, given that the other DGs are controlled and that the ESSs are supposed to be operated according to the schedule. Unlike the scheduling, the MPC includes the active power curtailment P curt DG and the reactive power Q DG as optimization variables, the optimal values of which are calculated independently from the result of the scheduling. The set-points are calculated at iteration k for the prediction horizon H p , and they are defined as ∆P curt DG,k , ∆Q DG,k , and ∆P ESS,k , which are the variations from the last measured values P curt DG,meas , Q DG,meas , and P ESS,meas , where: • ∆P curt DG,k is the vector of active power set-points assigned to the PVs calculated at iteration k.
• ∆P ESS,k is the vector of active power set-points assigned to the ESSs calculated at iteration k. • ∆Q DG,k is the vector of reactive power set-points assigned to the PVs calculated at iteration k. where: • SoC k is the SoC calculated at time-step k.
• W P , W Q , W SoC are the N-dimensional symmetric weighting matrices linked to the variables P curt DG , Q DG , and SoC, respectively. The optimization function clearly shows that the MPC control aims at maintaining the voltage closer to a nominal value V nom , while the SoC tracks the reference values In case T M < T S , the reference value P ESS,ref obtained from the scheduling with an interval T S is interpolated to obtain the required granularity T M .
The resulting optimization problem is eventually defined as: The constraint (a) is the same box constraint defined in Equation (4). Constraint (b) differs from the one defined in Equation (4)

Online Feedback Control for Fast Dynamics
The last control algorithm composing the hierarchical structure is the online control for fast dynamics. As described at the beginning of Section 3, the purpose of this control is to correct any voltage violations that could still occur due to fast and unexpected changes in the profiles of load and generation. It is based on the algorithm presented by the authors in De Din et al. [23] for the (near-) real-time control of multiple DGs, based on the technique originally presented in Bolognani et al. [38]. This control level substitutes the local controllers based on droop curves, since it has been demonstrated to achieve better results in terms of the coordination of the DGs and the response to voltage violations [21].
The control logic is based on a distributed algorithm, meaning that the set-points for each controllable resource can be calculated independently by local controllers through the exchange of a limited amount of information among topologically adjacent actors participating in the control [23]. The distributed solution was not analyzed in detail in the present paper (for more information, see [23]), but the main concepts behind the adopted algorithm are recalled in the following. In this work, we adopted the centralized version of [23], meaning that the vectors and the matrices considered in the paper have full rank (N BUS × 1 and N BUS × N BUS , respectively), with zero values on the position corresponding to the nodes where no DGs or ESSs are installed.
The calculation of the active and reactive power set-points is based on a dual-ascent procedure presented in Bolognani et al. [21], which is summarized in the following. The optimization problem can be decoupled for the different controllable quantities (i.e., the active power of the ESSs and the active and reactive powers of the PVs), so that three independent sub-problems are obtained. For each optimization sub-problem, the associated Lagrangian is written as: where λ x min , λ x max , µ min , µ max are vectors of Lagrangian multipliers associated with the voltage and power constraints, respectively. The variable V h is the voltage of the node h ∈ N BUS , whereas x can be ∆p curt DG , ∆q DG , or ∆p ESS , depending on the considered optimization subproblem and the associated controllable quantity. The matrix W is a weighting matrix, which is equal to R or X depending on the involved control quantities. The variables differ from the solution proposed in De Din et al. [23] only by the fact that they represent the deviation from the set-points calculated by the MPC. Similar to the MPC, the online control does not use measurements from the load to calculate the control output.
The output set-points are the result of Equation (9) calculated every time-step T C : where the calculation of the Lagrangian multipliers follows the theory described in [21,23]. The calculation of the maximum and minimum values for the calculated outputs depends on: Different from the day-ahead scheduling and the MPC, the result of this control algorithm is to keep the voltage between the limits V max , V min , since the objective is to modify the MPC set-points only if voltage violations are detected. To this aim, the control tries to minimize the amount of variation of the set-points from the values defined by the MPC, necessary to keep the voltage within the limits. By doing so, the control outputs determine only the required variation necessary to be within the voltage limits.
As explained in De Din et al. [21,23], the set-points calculated by the online control are different from zero only when the voltage limits are exceeded. In all other cases, there are no changes of the MPC set-point, which then reduces the rate and amount of data transmission, given that the output is updated every T M , rather than every T C .
The final outputs of the hierarchical control are then: • P curt DG,TOT = P curt DG,MPC + ∆p curt DG • Q DG,TOT = Q DG,MPC + ∆q DG • P ESS,TOT = P ESS,MPC + ∆p ESS

Simulation Description
As described in Section 1, the purpose of the present paper is to demonstrate the beneficial impact of using a multi-timescale approach and to demonstrate the effect of each of the control levels. The first test is performed using the complete framework, to show the results produced by the full structure on controlling the voltage and the SoC of the ESSs. However, the results are not sufficient to clearly show the contribution of the different control levels, since it is difficult to distinguish the contribution of all the framework components. For this reason, additional tests were performed where one of the three levels was removed from the framework. The resulting three tests were: • Test 1, framework without the scheduler: In this test, the full framework was compared with a case where the scheduler was removed from the framework, to demonstrate that a framework consisting only of the MPC and online control can lead the voltage close to the nominal value, but does not optimally control the SoC of the ESSs. • Test 2, framework without the MPC: In this test, the full framework was compared with a case where the MPC was removed, to show the importance of the MPC in creating set-points for PVs and ESSs that are able to compensate for the forecast errors in the scheduling. In this case, the scheduler calculates the reference values for the PVs and ESSs, which are used directly in the online feedback control. • Test 3, framework without the online control: In this test, the online feedback control was removed. The purpose of this test was to demonstrate the capability of the online control to solve voltage violations due to rapid variations of the load and generation profiles. Thus, the full framework was compared with a structure without the online control. For this test, the MPC transmits the power set-points every time-step T M without being modified by the low-level control.
To perform the tests on the grid described in Section 4.2, the load and generation synthetic data described in Sections 4.3 and 4.4 were used to test the complete framework and to perform Test 1 and Test 2. A different set of generation data in Section 4.5 was created to perform Test 3. The indicators used in Section 5 for the analysis of the results were the following:

1.
Loading (W): This indicator was applied in Test 1 and Test 2 and calculated the total loading index as the sum of the power flowing though the branches (P BR ) calculated for the full day: where N tot is the number of data points obtained from the simulation of the whole day and N BR the number of branches of the grid.

2.
Voltage variation (%): This indicator was used in Test 1 and Test 2 and calculated the sum of the percentage voltage variation on all nodes N BUS for the whole day, compared to the nominal value.
3. ∆SoC K=N : This indicator verified the achievement of the condition on the SoC, and it was applied in Test 1 and Test 2. The indicator is defined as:

4.
Voltage outside the limits (%): This was the only indicator used in Test 3 and calculated the percentage of time that the voltage remained outside the two limits compared to the full day, calculated as: where N viol,h is the number of simulated data points where the voltage violates the limits.
The multi-timescale voltage control presented in Section 3 was implemented in Python, and it was tested in loop with a power flow simulation of the grid [39]. The scheduling was calculated at the beginning of the simulation, since it represented the day-ahead optimization, where the granularity of the resulting schedule was T S = 30 min. The MPC used the simulated measurements every time-step T M = 15 min to perform the optimization. It also used the same time-step for the prediction horizon, with a maximum prediction length of N p = 12 steps. The value of the time-step for the online control T C2 was 1 min. The complete time division of the multi-timescale framework is described in Figure 2.

Grid Data
Simulations were performed on the 33-bus radial LV grid shown in Figure 3, which was taken from the real distribution grid scenario presented in Hashemi et al. [23,40].  Table 1 shows the data used for the lines, in terms of per unit values of resistance and reactance, where the nominal voltage was set as V nom = 380 V and P nom = 10 kW. In the simulated grid, each customer was supposed to be equipped with both a PV plant and an ESS with a nominal value of 4 kW. The number of customers connected to each node is described in Table 2. This particular scenario was selected in order to stress the conditions for the distribution grid under test, given that placing generation on each customer increased the dynamics in the grid. Moreover, having ESSs coupled with PVs was in line with the recent PV installations, as described in Section 1. However, the algorithms implemented in the framework worked independently of where and how many customers had PVs or ESSs installed. Therefore, the equivalent power injected/consumed at the nodes was aggregated with the power resulting from each customer, which depended on the specific load profile, PV generation, and charging/discharging behavior of the ESSs. Additional details on the the load and PV generation data are provided in Sections 4.3 and 4.4.

Load Data
The LV load data used in this demonstration were divided into two sets: the synthetic data that reproduced the forecasts and the synthetic data that represented the actual load consumption used to perform the power flow. Both data sets were generated using the tool developed in the Flexmeter project [41]. The tool realistically emulated the behavior of individual residential customers by aggregating consumption profiles of the appliances of individual household. It was possible then to replicate typical intermittent and fluctuating load profiles characterizing the distribution grid in LV, which added the possibility of testing the proposed framework with realistic scenarios. The realistic profiles of the residential customers were obtained by a combination of measurements and open-source databases available online.
The forecasted load profiles are shown in Figure 4 and were obtained by scaling according to the number of customers connected to each node the statistical load profile for a customer with a nominal power of 3.5 kW and a yearly energy consumption of 3500 kW h/year. The randomly generated profile for each node was obtained following the same nominal values, resulting in the profiles described in Figure 5. In the figures, the profiles of bus 27 and bus 32 are highlighted in green and blue, respectively, whereas the profiles of the remaining nodes of the grid are all in grey color. This color scheme is used throughout the paper.

Generation Data
The PV production was emulated using the PV profile generator presented in Pau et al. [42]. This tool reproduced daily profiles of PV generation calculated on different locations, days of the year, and PV installation characteristics. As an additional input for the calculation of the profiles, it was possible to consider different weather conditions (which possibly change during the day), emulating the impact of different cloud coverage on the generated active power, which in the tests was used to generate profiles with clear and cloudy sky conditions. In the simulations, all the customers were assumed to be equipped with a PV plant with a nominal power of 4 kW.
The tool was used to create the clear sky generation profiles in Figure 6a, to be used as forecasted data. For the real PV injections, fluctuating profiles linked to possible cloudy weather conditions were generated. The difference between clear and cloudy sky conditions was used to test the positive impact of using measurements of the intermittent generation to compensate for the error in the forecast. The resulting profiles in Figure 6b representing the real PV injections were used as the input data for the power flow simulation. The generation profiles calculated for each node were cumulative, since they were the aggregation of the PV generation for all the residential customers connected to the node, based on Table 2. For the sake of simplicity, the generation curves were identical for all the customers, given that in the proposed LV grid, it was reasonable to consider identical irradiation for all the nodes. The described scenario represented the "worst-case scenario", the mismatch between the forecasted data and the real measurements being considerable. Thus, the result of the scheduler based on the forecast data could produce power set-points that, if not corrected by other control levels based on the measurements, could affect the quality of the voltage control. Moreover, using clear sky conditions represented the "worstcase scenario" because the calculated voltage profiles V K in the scheduler depended on the values P max DG,K from Figure 6a, which were higher than the real profiles and did not present intermittent variations.

Data for Test 3
To obtain an adverse condition for the online control, a different set of generation profiles was generated, as described in Figure 7a. These profiles were combined in Test 3 with the load profiles in Figure 7b. The profiles were generated for the full day, but the figures show only a portion of the whole day between 13.2 h and 13.8 h. This portion of the day was chosen because during this time, the resulting voltage profiles crossed the undervoltage limit.

Complete Multi-Timescale Framework
The first results represented the solution where all the components of the hierarchical scheme in Figure 1 were used. At first, the scheduling calculated the SoC ref for the MPC based on the clean sky forecasted profile shown in Figure 6a and on the forecasted load profile in Figure 4. As described in Section 3, the scheduling calculated the optimized output based on a time-frame of 30 min and solved the minimization function simultaneously for the time-steps. The results of the scheduling are described in Figure 8a, showing the scheduled active power for the ESSs, and Figure 8b, describing the resulting reference profile for the SoC. From Figures 6a and 8a, it is clear that the ESSs charged (behaving as the load, therefore negative power) when there was PV generation and discharged (behaving as the generator, positive power) when PV generation reduced. Thus, the ESSs discharged during the first and the last hours of the day, when the PVs' generation was null or very low, to reduce the SoC and charge when the PVs were injecting active power to compensate for it. The next set of results showed the controlled system variables after the application of the set-points calculated by the MPC and the online control. In this case, the real generation and load profiles ( Figures 5 and 6b respectively) were applied in the simulation and used every 15 min by the MPC and every 1 min by the online control. The resulting voltage profile is represented in Figure 9b, which shows the ability of the hierarchical structure to maintain the voltage closer to the reference value V nom in comparison with the uncontrolled voltage scenario (Figure 9a). Figure 9b also shows that from 0 h to 5 h and from 20 h to 24 h, the voltage was for most of the nodes higher than the nominal values even though there was no generation. This was clearly due to the discharging profile of the ESSs that injected power into the grid to track the SoC schedule. The voltage was kept far from the voltage limits; therefore, the online control was never activated, meaning that the active and reactive set-points were constant for the whole MPC time-step duration.  Figure 10a,b shows the result of the active power curtailment and reactive power set-points, respectively. In the figures, it is highlighted how the set-points changed during each 15 min time-step. In the performed test, the active power curtailment was the less prioritized action, resulting in a zero output, given that the control of the ESSs and of the reactive power was sufficient to achieve the solution for the minimization problem. Figure 11a shows that the MPC was not always tracking the scheduled set-points for the ESSs, given that the active power set-points for the ESSs were at some points quite different to the ones calculated by the scheduling (Figure 8a). However, overall, the SoC was well tracked by the MPC, as highlighted in Figure 11b.

Test 1: Framework without the Scheduler
This section presents the results of the first test described in Section 4.1. The scheduler was removed from the framework, and the MPC ran without receiving a reference value for the SoC to track. The resulting objective function for the MPC was modified as follows: + (P curt DG,meas + ∆P curt DG,k ) T W P (P curt DG,meas + ∆P curt DG,k ) + (Q DG,meas + ∆Q DG,k ) T W Q (Q DG,meas + ∆Q DG,k ) + (P ESS,meas + ∆P ESS,k ) T W ESS (P ESS,meas + ∆P ESS,k ) (15) where: • W ESS is the N BUS -dimensional symmetric weighting matrix linked to the variable P ESS . • The results of the MPC optimization are the set-points values P curt DG,MPC , Q DG,MPC , and P ESS,MPC , which are defined as the sum of the last measured value and the result of the first iteration of the MPC.
From Equation (15), it is clear that the only reference value for the MPC objective function was the nominal value for the voltage, whereas the quadratic term for the SoC was substituted with the quadratic term related to the active power injections of the ESSs. The control scheme of Test 1 is described in Figure 12, where, in comparison with the structure in Figure 1, the scheduler was removed. The obtained results show that, although the voltage profiles shown in Figure 13a were maintained closer to the nominal value, the SoC profiles clearly diverged from the scheduled values ( Figure 13b). This demonstrated that the SoC of the installed ESSs was not controlled, resulting in a condition at the end of the day that was quite different from the start of the day. Since the SoC was not forced to return to the initial condition, the ESSs did not need to discharge at the end of the day, and therefore, they could contribute to the sole objective of tracking the nominal voltage. A scenario like this, repeated over multiple days, can easily lead to the non-optimal management of the batteries where the SoC reaches its maximum value, not allowing the batteries to be used when needed.

Test 2: Framework without the MPC
In this second test, the MPC was removed from the control structure, and the reference values for the online control, which normally were provided by the MPC, were given directly by the scheduling.
In this situation, the schedule calculated the set-points for all the variables, by solving: minimize P curt DG ,Q DG ,P ESS C(V K , P curt DG,K , Q DG,K , P ESS,K ) | K=T S subject to a) V min ≤ V K ≤ V max , b) V K = 1V 0 + R DG (P max DG,K + P curt DG,K − P Load,K ) + X DG Q DG,K + R ESS P ESS,K c) − P max DG,K ≤ P curt DG,K ≤ 0, d) − P max DG,K · sin(φ max ) ≤ Q DG,K ≤ P max DG,K · sin(φ max ), e) P ESS,min ≤ P ESS,K ≤ P ESS,max , where: This means that the online control received the output of the schedule P curt DG,ref , Q DG,ref , and P ESS,ref as references, which were calculated based on profiles that differed from the real measurements ( Figures 5 and 6b).
The structure of Test 2 is described in Figure 14, and it highlights that the online control received reference values calculated only based on forecasted data. This solution was then prone to errors linked to the difference between the synthetic data used for the forecast and the data used for the simulation of the grid. The clear sky profiles used for the scheduler resulted in reference values for the online control that overcompensated the injection of the active power from the PVs, since the real profiles had lower values. These lower values were produced by the scheduler, which predicted a higher overvoltage and required absorptions of active and reactive power to compensate for it, thus producing the opposite effect.  As a result, the voltage profiles in Figure 15a are very far from the nominal value and closer to the lower limit, and they were kept within the limits by the online control. As explained in Section 3.3, the online control only reacted when voltage violations were detected.  Figure 15b shows the active power set-points applied to the ESSs, which were the result of the scheduling (Figure 8a) and of the online control. The online control requested the positive injection of active power to compensate for the undervoltage events, which resulted in positive peaks in Figure 15b. The results of this test highlighted the importance of the MPC in compensating the mismatches between the forecasted profiles and the real measurements, providing reference values P curt DG,MPC , Q DG,MPC , and P ESS,MPC that reflected the actual behavior of the grid. The mismatches' compensation resulted in voltage profiles that were much closer to the nominal values ( Figure 9b). Moreover, the test demonstrated the role of the online control, which kept the voltage in the limits, but did not push the voltage towards the nominal value.
The calculation of the indicators loading (W), voltage variation (%), and ∆SoC K=N was applied to the results of the uncontrolled simulation, the full architecture, and Tests 1 and 2 in Table 3. The indicators showed numerically what is also highlighted in the figures. The results showed that in terms of loss reduction and the voltage profile, Test 1 was the best solution; however, the request for the SoC was clearly not fulfilled. Thus, the full framework was the preferable solution for the three indicators.

Test 3: Framework without the Online Control
As described in Section 4.1, in Test 3, the online control level was removed from the full framework, as described in Figure 16. The test was performed to demonstrate the impact that the online control had on compensating sudden variations of voltage happening between two iterations of the MPC. These voltage variations were related to the dynamics of the load and generation profiles described in Figure 7a,b, which showed a portion of the daily profiles where changes within the value of T M were present. These profiles created a mismatch that produced an undervoltage event (Figure 17a) Figure 17b shows that the undervoltage between 13.4 h and 13.5 h and between 13.6 h and 13.8 h was reduced by means of the online control, which modified the MPC control outputs in Figure 18a by changing the constant set-point values calculated by the MPC, with a time-step of one minute ( Figure 18b). As explained in Section 3.3, the actions of the online control brought the voltage profiles above the lower limit. Therefore, the constant set-points of the MPC of Figure 18a were modified with the peaks in Figure 18b between 13.4 h and 13.5 h and between 13.6 h and 13.8 h, which rapidly reduced the amount of active power charging of the ESSs to compensate for the undervoltage.   The calculation of the indicator of the voltage outside the limits (%) was applied to Test 3 and performed for the whole simulation of the 24 h to numerically compare the two cases in Table 4. The values showed that the online control reduced the percentage of time that the voltage remained outside the limits, demonstrating at the same time that the amount of time that under-or over-voltage events were not resolved by the MPC was in any case very limited.

Indicators With Online Control Without Online Control
Voltage outside the limits (%) 0.45 1.5

Conclusions
This paper presented a three-level hierarchical control architecture containing a scheduling algorithm, an MPC, and an online feedback control for fast dynamics. The proposed control structure aimed at controlling the voltage of an LV distribution grid while tracking a scheduled reference for the SoC. The MPC and the online control exploited the resources integrated in the grid making use of the reactive power control and active power curtailment of the PVs and the active power control of the ESSs. The scheduling was implemented with the technical objective of minimizing the quadratic expression of the control actions, controlling the voltage to the nominal value while managing the SoC of the ESSs, ensuring the availability for the next day of the batteries and preventing overcharging or empty storage systems. The MPC objective function followed the SoC schedule for the ESSs and compensated for mismatches between the forecasted and real data. The sudden voltage variation happening during the time-step of the MPC was compensated by the higher time resolution of the online control, thus trying to maintain the voltage between the technical limits. The test of the numerical simulations demonstrated the ability of the proposed architecture to control the voltage to the nominal value and to track the desired SoC reference calculated by the scheduler, in the presence of realistic load and generation profiles. The differences introduced between forecasts and actual operating conditions demonstrated the ability of the framework to compensate for both forecast uncertainties and for the typical fluctuating generation profiles of LV distribution grids. Additional tests were carried out to demonstrate the benefits of such a three-level framework, highlighting how removing one of the levels degraded the results in terms of the indicators defined in the paper. The proposed framework represents an interesting option to manage a large penetration of DGs in low voltage grids, controlling the voltage with integrated scheduling requirements.