L Subramanian

V Debusschere
email: vincent.debusschere@grenoble-inp.fr

N Hadjsaid

H B Gooi
email: ehbgooi@ntu.edu.sg

A Distributed Model Predictive Control Framework for Grid-friendly Distributed Energy Resources Lalitha Subramanian, Student Member, IEEE, Vincent Debusschere, Senior Member, IEEE, Hoay Beng Gooi, Senior Member, IEEE, and Nouredine Hadjsaid, Senior Member, IEEE

Abstract-This work develops a distributed fast-frequency control framework for application in self-consuming energy communities. We propose a distributed consensus optimization of inertia coefficients based on the individual resource constraints of grid-friendly distributed energy resources (DERs). The distributed inertia scheduling relies on the presence of a peer-to-peer communication infrastructure, which can be the same as the one used for the distributed primary or secondary frequency control. In the proposed control strategy, the inertia coefficients of the individual DERs are however optimally tuned by a faster control loop to improve the frequency response metrics such as the peak overshoot and the settling time of the frequency transient with the help of local model predictive controllers. The coordination among the DERs are simulated on the CIGRE benchmark microgrid and the control is validated on a power hardware-in-the-loop platform.

Index Terms-Consensus, Distributed energy resource, Frequency control, Inertia, Microgrids, Model predictive control.

I. INTRODUCTION

C OLLECTIVE self-consumption, sharing energy re- sources within a defined geographical area, for operation as a microgrid, or communicating and sharing resources with other similar energy communities, is gaining momentum in European Energy policies. Notably, its recognition is stated in national legal frameworks such as the French Energy Transition for Green Growth Act in 2015. The idea of collective self-consumption is modular and revolves around the idea of a sharing economy, where under-utilized resources under individual ownership are shared for the benefit of the community in exchange for energy or monetary benefits [START_REF] Chakraborty | Sharing Storage in a Smart Grid: A Coalitional Game Approach[END_REF]. It increases the economic viability of renewable self-consumption, thus opening up avenues for energy service and flexibility markets [START_REF]Regulatory Aspects of Self-Consumption and Energy Communities CEER Report[END_REF]. In this context, the main objective of this work is to develop a control framework that can realize virtual inertia control (VIC) by sharing flexible resources among distributed energy resources (DERs) instead of investing on dedicated energy storage systems (ESSs) or dispatchable resources for fast-frequency response, thus improving the economic viability of such installation.

A. State-of-art

Numerous research works exist on control strategies that act as synthetic inertia emulators including virtual synchronous generators [START_REF] Bevrani | Virtual synchronous generators: A survey and new perspectives[END_REF] and various modified versions of swing-based virtual inertia controllers [START_REF] Tamrakar | Virtual Inertia: Current Trends and Future Directions[END_REF]. Most of these controllers assume the presence of a sufficient DC voltage source and sink by using a constant DC voltage source [START_REF] Peng | The Application of Microgrids Based on Droop Control With Coupling Compensation and Inertia[END_REF], [START_REF] Soni | Analysis of Frequency Transients in Isolated Microgrids[END_REF], which is only true for dedicated storage systems designed to act as a fast-frequency reserve for the microgrid. Exploring synthetic inertia from multiple resources, the authors of [START_REF] Fang | Distributed Power System Virtual Inertia Implemented by Grid-Connected Power Converters[END_REF] proposed a virtual inertia control strategy by DC-link voltage variation of grid-connected power converters. However, the inertia controller on the AC side is constrained by the flexibility limitation of the resources on the DC side. Recently, distributed energy storage are being exploited for energy management [START_REF] Bera | C2C: Community-Based Cooperative Energy Consumption in Smart Grid[END_REF], [START_REF] Chakraborty | Sharing Storage in a Smart Grid: A Coalitional Game Approach[END_REF], as well as primary and secondary frequency control [START_REF] Lou | Distributed MPC-Based Secondary Voltage Control Scheme for Autonomous Droop-Controlled Microgrids[END_REF], and voltage control [START_REF] Guo | MPC-Based Coordinated Voltage Regulation for Distribution Networks with Distributed Generation and Energy Storage System[END_REF]. We target here the application of distributed flexibility resources including distributed energy storage systems (DESS) for a coordinated fast-frequency control.

Unlike the implicit inertia property of synchronous machines which is fixed and proportional to the machine capacity, synthetic inertia offered by a converter-based DER can be varied to optimize the frequency response characteristics. Methods such as bang-bang control [START_REF] Alipoor | Power system stabilization using virtual synchronous generator with alternating moment of inertia[END_REF], LQR optimization [START_REF] Markovic | LQR-Based Adaptive Virtual Synchronous Machine for Power Systems With High Inverter Penetration[END_REF], and predictive control [START_REF] Kerdphol | Enhanced Virtual Inertia Control Based on Derivative Technique to Emulate Simultaneous Inertia and Damping Properties for Microgrid Frequency Regulation[END_REF] have been proposed for inertia tuning. The authors of [START_REF] Sockeel | Virtual Inertia Emulator-based Model Predictive Control for Grid Frequency Regulation Considering High Penetration of Inverter-based Energy Storage System[END_REF] have recently shown that the energy storage requirement for synthetic inertia is reduced by model predictive control (MPC) formulation compared to PI control. However, the MPC control proposed in [START_REF] Sockeel | Virtual Inertia Emulator-based Model Predictive Control for Grid Frequency Regulation Considering High Penetration of Inverter-based Energy Storage System[END_REF] is only for ESS-sizing. It has not been used to optimally tune the inertia parameters to improve the frequency response. Hence, we propose a local model predictive inertia control in grid-friendly DERs to vary the inertia level based on the local flexibility constraints. To the best of our knowledge a coordinated MPC framework has not yet been implemented for the fast-frequency control problem.

Distributed flexibility resources can be coordinated in a cooperative or competitive manner [START_REF] Chakraborty | Sharing Storage in a Smart Grid: A Coalitional Game Approach[END_REF]. Since the problem addressed in this work is a grid-supporting function, cooperative method becomes an obvious choice for resource coordination. Once again, the resource coordination can be addressed by a centralized control architecture with a microgrid operator or with distributed control employing a peer-to-peer communication network [START_REF] Wu | Secondary coordinated control of islanded microgrids based on consensus algorithms[END_REF]. In order to mitigate the need for a centralized authority in every energy community, we aim to coordinate the flexible DERs by a peer-to-peer distributed optimization. In [START_REF] Hammad | On Effective Virtual Inertia of Storage-Based Distributed Control for Transient Stability[END_REF], the authors defined an effective inertia term that is representative of the equivalent aggregate value of inertia of synchronous generators and the distributed energy storage reserves. The authors of [START_REF] Chamorro | Distributed synthetic inertia control in power systems[END_REF] have implemented an evolutionary game to coordinate the inertia contribution of synchronous generators and strictly identical DERs. Consensus optimization as well as coalition game theory methods can be applied to reach an equilibrium in a cooperative control problem. In [START_REF] Xing | Cooperative energy management optimization based on distributed MPC in grid-connected microgrids community[END_REF], the authors presented the superiority of a distributed MPC compared to the consensus methods. In our study, we employ a consensus optimization to coordinate the upperbound of the inertia coefficients grid-friendly DERs based on the available flexibility. We complement the constraints of the distributed consensus to the local inertia MPCs for a faster response as we aim to address the fast-frequency control problem.

B. Contribution

The main contribution of this work is the proposed cooperative consensus of the inertia coefficients based on the available flexibility of the DERs. The distributed consensus optimization is complemented by local model predictive controllers that optimize the frequency response by tuning the level of injected inertia.The proposed control strategy is tested on 100 % converter-based microgrid with grid-friendly DERs using a power hardware-in-the-loop (PHIL) platform. With our proposed framework of coordinative inertia control by model prediction, we show that it is possible to replace dedicated inertia reserves and their CAPEX for self-consuming energy communities.

II. DISTRIBUTED VIRTUAL INERTIA CONTROL

The interaction of cyber and physical layers of the power system facilitates the usage of remote measurements and control exchanges between DERs participating in the gridsupport functions for the system. In this section, we present the proposed distributed average consensus control of inertia coefficients, considering DERs as plug-and-play agents, with identical linear time-invariant (LTI) dynamics, which can be involve in peer-to-peer communications. The completely distributed control architecture with peer-to-peer communication, shown in Fig. 1b, differs from the centralized formulation, which involves the microgrid controller, show in Fig. 1a. We thereby aim to exploit the cyber-physical architecture of the power system to deliver a robust inertia compensation while evading installations of dedicated storage reserves to perform the same task.

The agents in the system or the different DERs can choose to participate in grid-support functions over a scheduled period of time and are thus declare as grid-friendly DERs. Synchronous generators, or virtual synchronous generators, which are the grid-froming entities in the system, contribute to its global inertia. The grid-friendly DERs act as power reserves, the objective of which is to provide the maximum power response in the event of a disturbance. The maximum power response to be delivered by each DER in the event of a disturbance is obtained by the consensus optimization. The consensus objective is to maintain the remaining stored energy of each DER the same, to equally exploit the grid-friendly DERs.

The communication network used for the distributed control of 'n' number of DERs is represented by a connectivity matrix α = {n, n}, with elements a ij whose value is '1' if there exists a communication link from node 'i' to node 'j', and '0' otherwise. The rows and columns represent the nodes and the grid-friendly DER respectively. For the distributed control, it is required that there is a communication path between every node with every other node and that the graph is balanced, i.e. every node 'i' satisfies

n j=1 a ij = n j=1 a ji .
Consider a microgrid with grid-forming inverters providing the voltage and frequency reference to the islanded power system. The system dynamics is expressed by 2H s . ω = ∆P -D s ω. Due to the power injected from the coordinated DERs, this is modified in [START_REF] Chakraborty | Sharing Storage in a Smart Grid: A Coalitional Game Approach[END_REF] with P i reflecting the scheduled power injected by the DER, P i , and its synthetic inertia support.

2H s . ω = ∆P -D s ω + n i=1 P i with P i = P i -K vi ω (1)
We use a generalized first-order virtual battery model to represent holistically the heterogeneous DERs. The first-order virtual battery model (VBM) parameters are the state-of-charge (SOC) bounds, C min and C max , which reflect the energy capacity, the time-varying power limits, P -(t) and P + (t), the self-dissipation rate s and the initial SOC C 0 . The parameters of each homogeneous or heterogeneous DER, such as electric vehicle parking lots, flexible heating and cooling systems, fast curtailable demand and so on, can be obtained using a performance tracking optimization technique [START_REF] Nandanoori | Identification and validation of virtual battery model for heterogeneous devices[END_REF] which is out of the scope of this work. The VBM representation of the DER 'i' is given in [START_REF]Regulatory Aspects of Self-Consumption and Energy Communities CEER Report[END_REF], where C i (t) and P i (t) are the SOC at time t and the power response of the grid-friendly DER at time t respectively.

     Ċi (t) = -sC i (t) -P i (t) C imin ≤ C i (t) ≤ C imax P - i (t) ≤ P i (t) ≤ P + i (t) (2)
The DER 'i' is modeled by a linearized state-space representation using the VBM and the small-signal representation of the inertia controllers [START_REF] Soni | Analysis of Frequency Transients in Isolated Microgrids[END_REF] as expressed in (3). The control input is proportional to the difference between the state of the given DER and the neighboring DERs, based on a local voting protocol expressed in (4) [START_REF] Morstyn | Distributed cooperative control of microgrid storage[END_REF].

ẋi = Ax i + Bu i ( 3
)
u i = K i n j=1 a ij (x j -x i ) (4)
K i is the state feedback matrix of the DER 'i', obtained by solving the linear quadratic optimization problem given by ( 5), subject to the state update equation from the DER model and the control bounds.

min t2,i t1,i (x i Qx i + u i Ru i ) dt (5)
The solution to the linear quadratic problem is given by ( 6), where M i is the solution to the Ricatti equation [START_REF] Markovic | LQR-Based Adaptive Virtual Synchronous Machine for Power Systems With High Inverter Penetration[END_REF] given in [START_REF] Fang | Distributed Power System Virtual Inertia Implemented by Grid-Connected Power Converters[END_REF], Q and R are tunable cost penalties.

K i = R -1 i B i M i (6) 0 = A M i + M i A -M i B i R -1 i B i M i + Q (7)
The consensus reached via local voting protocol by agents with identical dynamics and a balanced connectivity matrix is the distributed average of the initial control states [START_REF] Morstyn | Distributed cooperative control of microgrid storage[END_REF].

III. LOCAL MPC CONTROL

In this section, we describe the control strategy in the physical control layer of each grid-friendly DER. The heterogeneous flexibility of the DERs on the DC-side has to be controlled to perform a synthetic inertia function. In this work, we employ a model predictive strategy, replacing all the conventional PI controllers in the DER, as shown in Fig. 2. The predictive control gives access to the trajectory information, which allows the MPC to conduct an optimization over the prediction horizon, avoiding pre-determined constraints based on safety-margins. The MPC is a receding horizon control that highly relies on the model accuracy for the prediction and has proven its superior performance over a PI control on several applications, including microgrids control [START_REF] Sockeel | Virtual Inertia Emulator-based Model Predictive Control for Grid Frequency Regulation Considering High Penetration of Inverter-based Energy Storage System[END_REF].

The control comprises the DC-DC controller, the inverter current controller, and the inertia controller, whose functions are to regulate the DC-link voltage, control the inverter current for a given power setting, and tune the injected transient power for fast-frequency response respectively. These controllers are discussed here.

A. Model Predictive DC-DC Control

The objective of the DC-DC controller is to utilize proportionately the available storage reserves to maintain the power balance between the DC and AC side of the converter, i.e. to regulate the DC-link voltage.

The MPC controller shown in Fig. 3 comprises a reference calculator, which determines the updated set-point for the control. The predictor predicts the control objective over the prediction horizon based on the disturbance predictor. The prediction horizon consists of N discrete time intervals throughout this paper. The optimizer then determines the control variables for N time intervals and minimize the error between the predicted value and the reference setting over the prediction horizon. However, only a few time steps of control action are performed before the next cycle of prediction, which is termed as the control horizon, with N c discrete time intervals. In this work, we consider the control horizon as one sample time.

1) Disturbance Prediction: The varying PV current, I pv , and the AC output current drawn by the inverter, I ac , are the disturbances in the DC-link voltage control problem. Since the DC-DC control loop is a very fast inner control loop, we consider the prediction for the next time step to remain the same as the current measured disturbances, as expressed in [START_REF] Bera | C2C: Community-Based Cooperative Energy Consumption in Smart Grid[END_REF]. The disturbance measurements are updated each time-step.

I pv (k + 1) = I pv (k) I ac (k + 1) = I ac (k) (8)
The DC-link capacitor current is predicted using (9) [START_REF] Shan | A model predictive control for renewable energy based AC microgrids without any PID regulators[END_REF], where γ is the coefficient to limit the capacitor current, I s is the control step time, and V * dc and V dc (k) are the reference and the measured DC voltages respectively.

I c (k + 1) = C γ.T s (V * dc -V dc (k)) (9)
2) Control Reference calculation: With the predicted DC current, I dc (k + 1) = I pv (k + 1) -I c (k + 1) -I ac (k + 1), the reference power to be injected by the ESS is calculated with [START_REF] Guo | MPC-Based Coordinated Voltage Regulation for Distribution Networks with Distributed Generation and Energy Storage System[END_REF]. In this work, we use a hybrid ESS comprising of a battery energy storage system (BESS) and a supercapacitor bank (SCESS) to depict ranges of power ratings. As the SCESS is of higher power capacity, the high frequency component

I(k + 1) = I(k) + (Ts/L) V (k) 0 0 I(k + 1) = I(k) + (Ts/L) (V (k) -V dc (k)) BUCK MODE 0 0 I(k + 1) = I(k) -(Ts/L) V (k) 0 1 I(k + 1) = I(k) -(Ts/L) (V (k) -V dc (k))
Fig. 4: MPC Inverter Control Schematic.

of P * ess is assigned to the SCESS, while the low frequency component or the slower disturbances are assigned to the BESS, with the use of filters.

P * ess (k + 1) = V * dc İdc (k + 1) With    P * bess (k + 1) = ωc s+ωc P * ess (k + 1) P * scess (k + 1) = s s+ωc P * ess (k + 1) (10)
3) Model Prediction: Based on the model, the predictions of the battery and supercapacitors power are given by [START_REF] Alipoor | Power system stabilization using virtual synchronous generator with alternating moment of inertia[END_REF].

P bt (k + 1) = I bt (k + 1) × V bt (k + 1) P sc (k + 1) = I sc (k + 1) × V sc (k + 1) With V bt (k + 1) = V bt (k) V sc (k + 1) = V sc (k) (11)
The current prediction I(k + 1) is given by Table I for the different converter switching states. Once again, the highfrequency and low-frequency components are assigned to I sc (k + 1) and I bt (k + 1) respectively. 4) Finite control set Optimization: In order to track the reference settings, the control adjustment may be obtained by solving the optimization problem of ( 12), subject to the state update equations.

B. Model Predictive Inverter Current Control

Similar to the DC-DC controller, the objective of the AC-side inverter current controller is to track the DER power set-point by tracking the equivalent current reference. The illustrated control shown in Fig. 4 is a grid-following control, where V ac is obtained from the node of connection.

The main grid or the grid-former provides the AC voltage reference in case of grid-connected and islanded modes respectively. The inverter state-space representation is written based on the LC filter equations [START_REF] Kerdphol | Enhanced Virtual Inertia Control Based on Derivative Technique to Emulate Simultaneous Inertia and Damping Properties for Microgrid Frequency Regulation[END_REF].

L f dIi dt = V i -V c -I i R C f dVc dt = I i -I inv ⇒ ẋ(k) = Ax(k) + By(k) With x(k) = I i (k) V c (k) ; y(k) = V i (k) I o (k) ; A = - R f L f -1 L f 1 C f 0 ; B = 1 L f 0 0 -1 C f (13)
Solving the differential equation leaves us with the expression of the inverter predictor current of ( 14). For synthetic inertia emulation and droop, the additional injected reference power is expressed in [START_REF] Wu | Secondary coordinated control of islanded microgrids based on consensus algorithms[END_REF], where M and D are the inertia and the droop damping constants of the individual DER, whose base value is determined by the distributed control layer for a given time slot, say 15 minutes, in which the inertia reserve is scheduled. From the power reference, the new current reference is given in [START_REF] Hammad | On Effective Virtual Inertia of Storage-Based Distributed Control for Transient Stability[END_REF].

∆P * inv (k + 1) = M (k) ω(k) + D(k)ω(k) With ω(k) = 2π (f (k) -f * ) (15)
I * i (k + 1) = I i (k) + ∆P * inv (k + 1)/V ac (k) (16)
The reference tracking is implemented with the MPC controller by optimizing the objective function given in [START_REF] Chamorro | Distributed synthetic inertia control in power systems[END_REF].

min N -1 k=1 1 I * i (I * i (k + 1) -I i (k + 1)) (17)

C. Model Predictive Inertia Tuning

With the presented controls, it is possible to realize a distributed virtual inertia control (D-VIC) with individual DER controls. In this work, we complement the D-VIC with a simple MPC-tuner, the objective of which is to fast-tune the inertia offered by the individual DER locally while respecting the base values obtained by the slower distributed control. The fast tuning essentially means that the power injected by the grid-friendly DER is varied locally in each DER to optimize the frequency response characteristics over the prediction horizon.

The real-time controllability of the inertia reserve is a unique aspect of the synthetic inertia, which is absent in synchronous machines. The controllability of the inertia can be exploited to improve the frequency transient metrics. It has been shown by recent research works [START_REF] Alipoor | Power system stabilization using virtual synchronous generator with alternating moment of inertia[END_REF], [START_REF] Markovic | LQR-Based Adaptive Virtual Synchronous Machine for Power Systems With High Inverter Penetration[END_REF] that a high inertia can improve the initial ROCOF, ωmax = ∆P d /(2H s ), while fast-acting primary frequency reserves, along with inertia reserves, can improve the frequency nadir, f nadir . Both the inertia and the fast-acting primary frequency reserves inject additional power in response to the disturbance. In this work, we distinguish the fast-acting primary and the inertia reserves based on their control function. The inertia reserves inject an additional power proportionally to the frequency derivative, while the primary reserves inject an additional power proportionally to the frequency deviation. By fast-acting primary reserves, we refer then to the power injected proportionally to the frequency deviation but with a very short control delay. However high the fast-acting primary reserves is in the system, only the inertia reserves affect the initial ROCOF. Hence, the system inertia is highly significant before the occurrence of the disturbance. The base value of the individual inertia constant of DERs is henceforth the upper limit of the inertia provided by the DERs through the frequency transient.

If the inertia constant is maintained at its upper limit, through the frequency response, after the primary control reserves came into action, it causes a high peak overshoot. Once the f nadir , expressed as ∆ω max in [START_REF] Nandanoori | Identification and validation of virtual battery model for heterogeneous devices[END_REF], is crossed, the need for an inertia response to limit the ROCOF is reduced, while the droop damping constant plays a major role in the settling time of the frequency response [START_REF] Markovic | LQR-Based Adaptive Virtual Synchronous Machine for Power Systems With High Inverter Penetration[END_REF]. In the local model predictive inertia tuning, the initial inertia parameter is set as the base value or the upper limit of the inertia obtained from the distributed control layer. However, the controller is enabled only beyond a ROCOF deadband, defined as ±0.01Hz/s. Once the control is disabled, the base value of the parameters are restored in case of another disturbance.

1) Frequency predictor:

As per the per unit AC system frequency response model, expressed in [START_REF] Xing | Cooperative energy management optimization based on distributed MPC in grid-connected microgrids community[END_REF], the system frequency can be predicted over the prediction horizon of the MPC control N h , which lasts for a typical frequency transient settling period of 2 s, while the control operates with a time step of 0.1 s. Hence, the prediction is based on a simplified model.

∆ω(s) = ∆P d (s)   n d j=1 1 R j (1 + T j s) + n h i=1 2H i s   -1 With H s = n h i=1 H i S i n h i=1 S i ; D s = n d j=1 D j S j n d j=1 S j ; T 1 = T 2 = .. = T j = T, ∀j n d ( 18
)
The control assumes that every grid-friendly DER is equipped with the same MPC tuning. So, the obtained per unit optimal inertia constant is used to tune H among all controllable synthetic inertia units, thus enforcing a decentralized control.

In case the other DERs are not equipped an MPC H-tuner,the equivalent inertia of the system tuner must be modified with the H parameters of the synchronous generators or other DERs, while only the H i of the i th DER is tuned. The transfer function of the system in the standard second order form with a natural frequency ω n and a damping coefficient ζ is presented in [START_REF] Nandanoori | Identification and validation of virtual battery model for heterogeneous devices[END_REF], the time of the frequency nadir and its expression is computed by setting the frequency derivative to zero.

∆ω(s) ∆P d (s) = 1 2H s T (1 + sT ) (s 2 + 2ζω n s + ω 2 n ) With ω n = D s 2H s T ; ζ = 2H s + T D s 2 √ 2H s D s T ; ω d = ω n 1 -ζ 2 ; t nadir = 1 ω d tan -1 ω d ζω n -T -1 ; ∆ω max = f nadir = -∆P d D s 1 + T e -ζωnt nadir 2H s (19)
2) Disturbance prediction: Disturbance estimation algorithms can be used to predict the disturbance over the prediction horizon, however we are aiming for a fast-frequency control in which case the prediction is a very short-term forecast. Therefore, for a simpler model, we employ the disturbance prediction P d (k + 1) = P d (k), which is used to predict the frequency using [START_REF] Xing | Cooperative energy management optimization based on distributed MPC in grid-connected microgrids community[END_REF].

3) Optimization: The MPC tuner tracks the reference frequency by optimizing the injected inertia power in real-time by minimizing the peak overshoot frequency deviation, as expressed in [START_REF] Morstyn | Distributed cooperative control of microgrid storage[END_REF], where u i is the control effort with the upper bound constraint of the parameter H i . q and r are tunable cost penalties of the optimization problem. Thus, the optimization alters the inertia power-ROCOF slope to improve the frequency response characteristics.

min N -1 k=1 q∆ω i (k) 2 + r∆u i (k) 2 (20)

IV. RESULTS AND DISCUSSION

In this section, we illustrate the proposed framework and control on the CIGRE benchmark microgrid [START_REF] Stavros Papathanassiou | A benchmark low voltage microgrid network[END_REF]. Information on the system and initial settings are presented.

A. System Description

We consider the CIGRE benchmark system [START_REF] Stavros Papathanassiou | A benchmark low voltage microgrid network[END_REF] as it is a radial distribution microgrid with DERs of different capacities and is representative of self-consuming energy communities towards which this work is targeted. The microgrid comprises six DERs that are classified as shown in Fig. 5, based on their functionalities. In the islanded mode, the grid-forming DER 2 acts as the reference voltage source of the microgrid and performs voltage and frequency regulations. Among the other DERs, DER 4 and DER 5 are not equipped with flexible resources. However, they can provide unidirectional flexibility via PV curtailment. It is not desirable to curtail the PV production unless there is an unavoidable case. The other DERs (1, 3 and 6) are equipped with time-varying flexibility with hybrid energy storage systems and PV production.

Table II presents the virtual battery model parameters of the DER-ESS used in the study. The charging/discharging rate r max gives the ratio of energy to power capacity of the ESS. The round trip efficiency is η and s, the self-discharge rate, is presented per day (p.d.) or per month (p.m.). The used data is representative of typical commercial ESSs.

We consider that the hybrid ESS (HESS) in DER 1 and DER 3 comprises battery ESS (BESS) and flywheel ESS (FESS), and The FESS provides 30 kW of short-term peak discharge rate and the SCESS provides a peak power of 10 kW, while the corresponding BESS are designed to provide sufficient energy capacity for going off-grid or to support a given load level. DER 6 suppoerted with only the BESS, shown in Fig. 5, has a lower power rating compared to its fast-acting counterparts. B. Validation 1) Simulations: Time domain simulations are carried out by modeling the microgrid and the inverter controls on MATLAB/Simulink R . Initially, we compare the microgrid frequency response when the system inertia varies, as shown in Fig. 6a, in the occurrence of a disturbance. It is seen in Fig. 6b that the ROCOF and f nadir depend on the inertia coefficient. However, it also determines the peak overshoot and the settling time of the frequency response in 100 % inverter-based lowinertia systems (e.g. H s = 4 s and 5 s). Keeping D constant at 1% p.u, a higher inertia coefficient (e.g. H s = 8 s and 9 s) mitigates the initial ROCOF and f nadir , but increases the peak overshoot and the settling time of the frequency response.

With the implemented synthetic inertia control, we examine the effect of the inertia parameters on the frequency response using modal analysis in Fig. 6b. Based on the control equations, the small-signal model of the inverter control is derived, ignoring the DC side of the model as the MPC controller maintains the DC-link voltage [START_REF] Soni | Analysis of Frequency Transients in Isolated Microgrids[END_REF]. The modes of the inverter droop control are referred to as inverter power modes and the modes of the swing equation-based control that emulate inertia are referred to as the electro-mechanical modes since the control is based on a virtual rotor and prime-mover input power. Increase in H i shifts the inverter power modes towards the left half of the s-plane, thereby stabilizing the system. However, the electro-mechanical modes of the swing-based controller are shifted to the right, decreasing the stability margin of the system. Therefore, the inertia and damping parameters have to be traded off for optimal response.

In Fig. 7, we present the simulation results with the synthetic inertia control using different DERs. f nadir with a high K vi , the frequency response may have a higher peak overshoot and a longer settling time, which decreases the stability margin. A higher K vi also indicates a high power injection from storage reserves, and a higher operating expenditure (OPEX).

Following this, we present the result of the improved distributed predictive controller in Fig. 8. The ROCOF and the frequency nadir are optimized by a high control coefficient, after what the inertia coefficient is significantly reduced, resulting in a shorter settling time with mitigated oscillation. The power injected by the grid-friendly DERs P i is limited by P - k , P + k for the k th 15-min interval. The optimized K vi base values are shown in Fig. 8. The K vi values are designed for the standard ROCOF limit of the system, 0.5 Hz/s. If the system ROCOF dips beyond the standard limit, the K vi base values are naturally decreased with the saturation of P i .

Fig. 9 shows the battery and supercapacitor response to maintain the AC-DC power balance by regulating the DC-link voltage with PV variation and AC-microgrid disturbances. The supercapacitor responds to the high-frequency disturbance, while the battery responds to slower disturbances. For the fastfrequency response, we see that the supercapacitor delivers a proper response, while the battery delivers a slower-butsustained primary frequency response thanks to its high-energy capacity, but low charge/discharge speed. The hybridization of the storage technology clearly makes sense in the studied configuration.

2) Experimentation: For the real-time validation, we have used a power hardware-in-the-loop (PHIL) platform, shown in Fig. 10a. The platform comprises a 5 kW inverter, controlled at a 10 kHz switching frequency by a dSpace R controller, supplied by a controllable DC voltage source operating at 700 Vdc. The inverter is controlled in the grid-following or The waveform recorded in Fig. 10b showcases a gridfriendly DER response to a series of disturbances (0.2 p.u. step-load increase, 0.2 p.u. momentary loss of PV generation with gaussian noise, and a step load decrease of 0.1 p.u.) to maintain the frequency balance of the microgrid. The DER inverter I 1 operates as a grid-feeder, which follows a constant power set point over the 15 min sample time, while the gridfriendly DER responds well to the momentary disturbances in the system, maintaining the frequency constant. The first block of waveform shows the response on the grid-friendly DER to the disturbance, while the grid-feeding I 1 does not respond to the disturbance in the constant power mode and decrease with the change in the power set point. The send block shows the response of I 2 to the step load decrease. In this work, we have proposed a distributed model predictive synthetic inertia control for coordinating grid-friendly DERs using the communication network. For the DER coordination, we employed a generalized first-order virtual battery model to represent homogeneous and heterogeneous DER flexibilities. The inertia service provided by the DERs are scheduled for every 15-minute interval by distributed consensus with the objective of equal exploitation accounting for the device flexibility limits. Further, the local DERs are equipped with a faster MPC which adapts the synthetic inertia minimizing the contradicting ROCOF and peak overshoot to improve the overall frequency response characteristics. The proposed control strategy has been put to test on the CIGRE benchmark microgrid with heterogeneous DERs. The control is validated in real-time using a power hardware-in-the-loop setup. The results indicate that the proposed strategy successfully manages distributed resources optimally, while improving the overall frequency response.

Fig. 1 :

 1 Fig. 1: Control Structures for DERs as Multi-agent Systems.

Fig. 2 :

 2 Fig. 2: Proposed Control Scheme of a Grid-friendly DER.

Fig. 3 :

 3 Fig. 3: The MPC DC-DC Control Schematic.

  scess (k + 1) -P scess (k + 1))

I

  i (k + 1) = e Ats x(k) + A -1 (e Ats -I)By(k) With e Ats =

Fig. 5 :

 5 Fig. 5: Modified CIGRE Benchmark Microgrid System.

  (a) Effect of Hs on the Frequency Response. (b) Bifurcation Plot Showing the Effect of an Increasing Inertia.

Fig. 6 :

 6 Fig. 6: Effect of the Synthetic Inertia on the System Dynamics.

  Fig. 7a presents the frequency responses based on the power rating of the DERs with different synthetic inertia control coefficients K vi . The corresponding aggregated power injected by the DERs is shown in Fig. 7b. If K vi is optimized only for the initial ROCOF and (a) Frequency Response with Different Synthetic Inertia Control Coefficients. (b) Power Injected by VICs for Fast-frequency Support.

Fig. 7 :

 7 Fig. 7: Synthetic Inertia. Illustration of the Need for MPC.

  (a) Improved Frequency Response Compared to Fig. 7a. (b) Power Injected by MPC D-VICs.

Fig. 8 :

 8 Fig. 8: Distributed Predictive Synthetic Inertia Control.

Fig. 9 :

 9 Fig. 9: Response Characteristics of the Hybrid Energy Storage.

  (a) Power Hardware-in-the-loop Platform (b) Experimental Validation of Grid-friendly DER Response.

Fig. 10

 10 Fig. 10: PHIL Validation

TABLE I :

 I Buck-Boost Converter Outputs.

	S 1	S 2	Predictor Equation
			BOOST MODE
	1	0

TABLE II :

 II Virtual Battery Model Parameters.

	Parameters	DER-1	DER-3	DER-6
		FESS	BESS	SCESS	BESS	BESS
	s, %	5 p.d.	5 p.m.	90 p.m.	5 p.m.	5 p.m.
	C 0 , %	100	50	100	70	80
	C min , %	∼0	20	5	50	20
	Cmax, %	∼100	80	95	80	80
	rmax	10 min	3 h	10 s	3 h	3 h
	η, %	85	70	92	70	70
	BESS and supercapacitor bank (SCESS) respectively. Hybrid
	energy storage systems allow highly efficient operation and
	reduce the cost over the system's lifetime. The BESS in
	this case only takes over when the FESS is at full-speed or
	stand still, or when the SCESS is fully charged or discharged,
	especially for lasting frequency deviations. It thereby improves
	the battery lifetime since the fast-acting ESS have a long cycle
	life and far lesser deterioration compared to BESS. Li-ion
	BESS is considered in this work. A typical FESS can provide
	up to 80 % of its rated power capacity after 10-15 years
	of usage. FESS are of a higher energy capacity than SCESS.


Thi Thanh

Quynh Nguyen

Christophe Bobineau

Senior Member, IEEE, Quang Vincent Debusschere

Huy Giap

Senior Member, IEEE Nouredine Hadjsaid

Dr Nguyen

Dr Giap

CPDE: A methodology for the transparent distribution of centralized smart grid programs

Keywords: Distributed programming, CPDE methodology, distributed database, declarative language, Smartlog, smart grid

Control and management in smart grids are facing many challenges such as scalability, heterogeneity and technology innovation. This requires a transformation from the traditional centralised paradigm into a distributed one. In this paper, a new distributed programming methodology, called Centralised Programming and Distributed Execution (CPDE), is proposed. CPDE relies on (i) the abstraction of the whole system as a distributed database, (ii) the use of the Smartlog declarative and reactive rule based language for expressing data manipulation, and (iii) the automatic Smartlog rule distribution according to data distribution. It thus provides a simple and straightforward mean for distributed programming. A centralised algorithm of fair over-voltage regulation of PV systems is used as a typical smart grids study case to validate the methodology and to compare it with centralized implementations. The experiments are implemented in a real-time simulation platform with a network of Raspberry Pis. In addition to showing its correctnes and ease of use, the performance of the CPDE implementation is studied, as well as its sensitivity to the increasing number of computing units and the data distribution. Results are promising and show the clear benefits of this methodology compared to more classical implementations.

INTRODUCTION

T HE integration of renewable energy and storage devices into the traditional power systems requires immediate response to manage intermittent resources, through bidirectional energy flow controls and decentralized management of the renewable energy generation. The power grid needs a technology transformation to meet these challenges [START_REF] Hirsch | Microgrids: A review of technologies, key drivers, and outstanding issues[END_REF].

The cooperation of the electricity grid and the information network promises to bring to life an innovative grid [START_REF] Schwefel | Emerging technologies initiative smart grid communications: Information technology for smart utility grids[END_REF]. Along with the development of smart devices such as smart meters, micro-computers and the use of available communication infrastructures (e.g., Wi-Fi [START_REF] Zhang | Hybrid communication architectures for distributed smart grid applications[END_REF], 3G, 4G, 5G, power-line communication [START_REF] Passerini | Smart grid monitoring using power line modems: Anomaly detection and localization[END_REF], etc.), the electrical system could be better controlled and managed, up to real-time [START_REF] Sayed | Chapter 18 -scada and smart energy grid control automation[END_REF].

Nevertheless, the information network integrated into the electrical grid poses many problems, especially regarding the scalability of the infrastructure. The larger the system is, the more powerful the computing servers must be. That leads to a problem of costs, both from the investment and operation point of view. Moreover, the huge amount of data driven to servers in short time can cause a problem of velocity in data processing, particularly in heterogeneous and complex systems like smart grids. Thus, local processing should be encouraged to limit overload and bottleneck phenomenons in central servers [START_REF] Ma | Consensus ADMM and Proximal ADMM for economic dispatch and AC OPF with SOCP relaxation[END_REF], [START_REF] Liu | General distributed secondary control for multi-microgrids with both pqcontrolled and droop-controlled distributed generators[END_REF].

Implementing algorithms for smart grids

Numerous centralized algorithms have been developed to ensure parameter control and management in power grids (e.g. voltage or frequency control). However, with the development and scale-up of smart grids, these algorithms may no longer be sufficient. They show indeed many shortcomings, such as very high computation and communication costs, single points of failure, etc. [START_REF] Hirsch | Microgrids: A review of technologies, key drivers, and outstanding issues[END_REF].

Besides, along with the current development of the infrastructures, computing devices can be found largely scattered over the power grid. This huge available computing resources can fully participate in the management of the power system itself. Distributed algorithms in this context seem to be more efficient than the centralized ones, because they deal with the imminent problems of control and management while ensuring the replacement of the conventional centralized controller [START_REF] Lin | A distributed control architecture for global system economic operation in autonomous hybrid ac/dc microgrids[END_REF]. However, there are still some drawbacks in distributed programming that restrains their deployment in reality.

For instance, using generic distributed algorithms to achieve agreement on a common parameter value in power grid control, such as consensus algorithms is possible (e.g Metropolis [START_REF] Hanqing | Multiagent-based coordination consensus algorithm for state-ofcharge balance of energy storage unit[END_REF], Finite-time Average Consensus algorithms [START_REF] Guo | Distributed cooperative secondary control for voltage unbalance compensation in an islanded microgrid[END_REF] and Maximum Degree Weight [START_REF] Xu | Distributed optimal resource management based on the consensus algorithm in a microgrid[END_REF]). But this kind of solution presents a convergence rate that depends on the grid's configuration and that is mostly not compatible with near real-time needs of smart grid control. Specific distributed algorithms for power grid management, such as Dual Decomposition [START_REF] Soares | Distributed optimization algorithm for residential flexibility activationresults from a field test[END_REF], Optimality Condition Decomposition (OCD) [START_REF] Kargarian | Toward distributed/decentralized dc optimal power flow implementation in future electric power systems[END_REF], Analytical Target Cascading (ATC) [START_REF] Malekpour | Hierarchical architecture for integration of rooftop pv in smart distribution systems[END_REF], Auxilliary Problem Principle (APP) [START_REF] Korte | Spanning trees and arborescences[END_REF], Alternating Direction of Multipliers Method (ADMM) algorithm with Proximal Message Passing (PMM) [START_REF] Molzahn | A survey of distributed optimization and control algorithms for electric power systems[END_REF] have been pro-posed for the optimal power flow problem (OPF). But they need up to several thousand iterations to converge for nodal OPF in a small grid [START_REF] Mhanna | Adaptive admm for distributed ac optimal power flow[END_REF]. Furthermore, the convergence rate is shown to be linear with the number of power grid nodes [START_REF] Boyd | Distributed optimization and statistical learning via the alternating direction method of multipliers[END_REF]. The ALADIN algorithm [START_REF] Engelmann | Distributed ac optimal power flow using aladin[END_REF] was proposed to reduce the number of iterations in comparison of the ADMM algorithm, but this improvement is not proven in the case where the number of nodes increases significantly. In addition to a slow convergence rate, neglecting the communication delay leads to non-reactive control and management of power systems, incompatible with a their evolution towards smart grids. Stability limits of the systems could be violated and the quality of the energy would be difficult to ensure.

To summarize, programming with such distributed algorithm is still challenging. A distributed program is a set of cooperating local programs, and all data exchange and process synchronization have to be taken into account. These challenges increase with the number of participating computing devices. A solution for reducing these challenges is to use higher abstraction levels, for instance, abstracting the whole system as a distributed database and using declarative data manipulation languages. Control and management of power grids consist in reacting to changes in the environment (i.e. change in the sensor data) to adjusts parameters (i.e. acting on actuators). Declarative and reactive languages are thus needed. Distributed datalog-based languages such as Netlog [START_REF] Grumbach | Netlog, a Rule-Based Language for Distributed Programming[END_REF], Nlog [START_REF] Li | Privacy-preserving verification and root-cause tracing towards uav social networks[END_REF] or Smartlog [START_REF] Nguyen | Using declarative programming for network data management in smart grids[END_REF], the later one being dedicated to smart grid use, can be advantageously exploited. But, even with the use of such languages, data exchange among participating devices is still to be managed.

In this paper, the architecture of distributed systems such as multi-agent systems [START_REF] Wang | A distributed control scheme of microgrids in energy internet and its multi-site implementation[END_REF] as well as the protocols used for data exchange are not presented as they do not fit with the focus of the method presented in this paper. Instead, we focus on solving issues related to data exchanges management and processes synchronization.

Objectives of the work

We aim at simplifying distributed programming in smart grids by totally hiding data exchanges among computing devices. We propose to use the Smartlog rule-based data manipulation language to program centralized control and management algorithms and then to automatically transform these centralized programs into sets of cooperating programs (i.e. to distribute the rules of the programs) in order to transparently achieve a distributed execution. This distributed programming methodology is named CPDE, for Centralized Programming and Distributed Execution. The CPDE method has been first mentioned in [START_REF] Nguyen | A new approach for the distributed deployment of centralized algorithms in smart grids[END_REF], focusing on the basic principle of the method.

In this paper, we first recall the general structure and behavior of Smartlog programs, and the corresponding system architecture (section 2). We then detail our automatic rule distribution algorithm according to the distribution of data (Section 3). Section 4 and Section 5 present an experimental performance evaluation of distributed programs obtained using CPDE compared to both Smartlog and Java centralized implementations. This evaluation will show the advantages of CPDE (simplicity, correctness and efficiency). The experiments are realized with a real-life voltage control algorithm (AAPC [START_REF] Alyami | Adaptive real power capping method for fair overvoltage regulation of distribution networks with high penetration of pv systems[END_REF]) over real-time power grid simulation and actual computing devices, in a power hardware in the loop experimental validation. Section 7 concludes the paper on the main advantages of the CPDE methodology.

SMARTLOG LANGUAGE AND SYSTEM

The major details of the architecture of the nodes in the considered smart grid as well as the Smartlog language can be found in [START_REF] Nguyen | Smartlog-a declarative language for distributed programming in smart grids[END_REF]. The primary knowledge is reintroduced in this section before addressing the CPDE methodology.

Note that the work was developed based on a context in which internet of things components are more and more participating in the power system's infrastructure. Reusing electrical legacy system was considered to decrease investment, as cited in [START_REF] Nguyen | Smartlog-a declarative language for distributed programming in smart grids[END_REF]. Besides, Smartlog is a high level abstract language aiming to simplify the distributed programming. Our first prototype is implemented based on an executable machine language (PostgreSQL and Java in our test-case) and as the rule distribution is performed statically (off-line), rule triggering and execution can be implemented in any language using code generation, on very basic hardware platforms. In this case, a small and cheap extension to any legacy component is possible, even if most probably not considered, due to the actual number of such components in traditional distribution grids

Architecture of a node in the network

Each computing node is an elementary cell in the network that has the ability to store data, communicate and perform computations. The architecture of each node is presented in Fig. 1. The architecture of each node contains three parts:

•

The local database stores the node's information: Sensing data, parameters, intermediate results and so on.

•

The rule engine decides which rules have to be triggered in the Smartlog program and executes them.

•

The sensor interface is in charge of the interaction with the sensors and actuators.

•

The communication interface manages data exchanges with others nodes in the network.

Structure of the Smartlog program

The structure of a Smartlog program is proposed in Listing 1.

•

The Data_types (lines 2 to 5) defines the scheme of data stored in the local database.

•

The Initial_data (lines 6 to 8) declares the data initialization. These insertion will not activate any rule in the Module blocks.

Smartlog programs contain sets of rules in the form Head:-Body (line 10). When a rule is triggered, the validation of the body B leads to the generation of the head H. Data generated by the head part of rules can be locally stored (e.g. intermediate results or parameter activating an actuator) or sent to another node to pursue distributed computing. The body part of a rule is composed of one or more terms that can be atoms a j (i.e. test of existence of data items in the local database), conditions c j or assignment of variables s j . All terms have to be satisfied in order to produce the head. Rules are triggered by a modification or insertion of data items corresponding to the first term of the body. To optimize the execution, rules that must be triggered by the same data_type are grouped in modules. Rules in the same module can be exclusive or executed in sequence.

Network communication and cooperation

Each node in the network has its own IP address, which helps identify the location of the node. Nodes communicate using the TCP/IP protocol in which data packets are sent and received as in sequential order. In Smartlog, the change in a specific data_type activates the corresponding calculations. Transferring data from one node to another can trigger calculations elsewhere as well. That is notably why Smartlog can fully support distributed programming.

As an illustration, let us consider two modules, A and B, in two different sites, i and j. After executing the rule of the module A in the site i, B is sent to the site j. Herein, it triggers the next rule validation in the module B in the site j.

SARD

Centralized smartlog program

Description of data distribution

SEMI-AUTOMATIC RULE DISTRIBUTION (SARD)

We propose a new programming methodology, called Centralized Programming and Distributed Execution (CPDE), to simplify the distributed programming in SmartLog by hiding synchronization and data exchange aspects.

The CPDE methodology approaches the distributed Smartlog programming based on the principle presented in Fig. 2. A centralized program (that can be executed on a single device) is transparently rewritten into multiples cooperating Smartlog programs according to a given data distribution schema. These programs will be instantiated on the distributed devices and will perform equivalent computations. The rewriting process exploits a Semi-Automatic Rule Distribution processor (SARD) developed to that purpose.

Principle

Based on the description of the data distribution, the SARD processor analyzes the set of rules of a centralized Smartlog program. It decomposes them (if necessary) into subrules, corresponding to each location, while ensuring that the distributed programs present the same behavior as the centralized one. Some critical hypotheses should first be satisfied in the input program.

•

The centralized Smartlog program runs without error;

• The communication network is reliable.

In addition, the volume of communications and transferred data must be minimized, limiting the bandwidth usage. In the following sections, we focus on two main parts: the description of the data distribution and the rule transformation process.

Description of the data distribution

A big part of the smart grid data is naturally scattered over the network. For example, sensor data are stored where they are produced and parameter data are stored where they are exploited (actuators). The rest of the (intermediate) data can be stored anywhere. The design of the distributed database allows each dataset scheme to be fragmented horizontally (groups of data items), vertically (groups of data attributes from all data items), or in a hybrid manner. Each part of the dataset is called a fragment.

For the horizontal fragmentation, each fragment holds all the attributes of the original data_type, but it only contains a part of the original data items, specified by a predicate [START_REF] Özsu | Principles of distributed database systems[END_REF]. The original dataset can be recomposed by the union of all horizontal fragments.

DT = ∪ i DT i (1)
For the vertical fragmentation, each fragment holds several attributes, mandatory including the key attributes, extracted from all data items of the dataset. The original dataset can be recomposed by joining all vertical fragments.

DT = i DT i (2)
The hybrid fragmentation of a dataset is a horizontal fragmentation followed by a vertical fragmentation of all horizontal fragments. The original dataset can be recomposed with [START_REF] Zhang | Hybrid communication architectures for distributed smart grid applications[END_REF].

DT = ∪ i ( j DT ij ) (3)
In the power grid, measurement and control data are normally fragmented horizontally according to the identifier of the corresponding sensor/actuator and located near them. Meanwhile, the intermediate data allocation depends on the optimal data placement process. The design of the optimal data placement is not the focus of this paper, assuming that it has been correctly specified beforehand. Each data fragment is allocated to one device in the network.

To describe the data distribution in the network, we propose to combine fragmentation aspects (horizontal and vertical) and allocation aspects. The proposed syntax is conceived as an extension of the syntax of the Smartlog data_type block (D). Each data_type definition contains the original data_type (D i |D i ⊂ D) with its attributes (A i ) and its data fragments(

F i |D i = {A i , F i }).
In each fragment definition (F ij |F ij ⊂ F i ), we define three parts: (i) the filtering condition in the key attributes C ij (for the horizontal fragmentation); (ii) the set of attributes A ij (for the vertical fragmentation) and (iii) the location in which the data items are stored

L ij , F ij = {C ij , A ij , L ij }.
The location part is mandatory, while the condition and attributes parts are optional. As an illustration, the data_type A, horizontally fragmented is presented in Listing 4, lines 2 to 13. Since all devices of the network should be known by name, locations are thus expressed as names. The correspondence between device names and IP addresses are defined in the IPmap block of the data distribution description, as shown in listing 4, lines 15 to 18.

the SARD processor follows three main steps: (i) rule rewriting, to take datasets fragmentation into account; (ii) rule distribution, to manage data exchanges and processes synchronization and (iii) the distributed program generation.

Rules transformations

Rule transformations are the first two steps (rewriting and distribution) of the SARD processor, presented below.

Rule rewriting

The original rule is developed based on the description of the data distribution. The idea is to first replace atoms in the body part of rules by their reconstruction from fragments, and then duplicate rules for each head fragment as described by Algorithm 1.

Algorithm 1 Rule rewriting. procedure RULEREWRITING(rule R) for B i in B do if B i instantOf Atom then get D i from B i D ik ← D i , a ik ← {D ik , B i } if D i is not horizontal fragmentation then Group of juncture D ik of D i Replace B i by set of juncture a ik (SA|a ik ⊂ SA) else Replace B i by a ik (a ik ∈ SA) if i == 0 then for a ik in SA do Create a new Rule R r , add a ik to R r add R r to list of Rule (LR|R r ⊂ LR) else for a ik in SA do for R r in LR do if C a ik ∩ C Rr = ∅ then add a ik into R r else for R r in LR do if C Bi ∩ C Rr = ∅ then add B i into R r for F i in H do D i ← F i , a i ← {D i , H} if ∃c i ∈ F i then add c i into R r Add a i to R r
The body rewriting depends on the type of fragmentation (horizontal or vertical). Atoms vertically fragmented are simply replaced by the conjunction of fragments (join). For example, the rule R, presented in [START_REF] Passerini | Smart grid monitoring using power line modems: Anomaly detection and localization[END_REF], where the data_type B is fragmented as B(x, y, z) = B 1 (x, y) B 2 (x, z), is rewritten as rule R 1 in [START_REF] Sayed | Chapter 18 -scada and smart energy grid control automation[END_REF].

R : H(m, k, t) :-A(m, n, t), B(m, , k). (4) R 1 : H(m, k, t) :-A(m, n, t), B 1 (m, ), B 2 (m, k); (5)
The horizontal fragmentation implies to duplicate the rule for each fragment. For example, if B is horizontally fragmented into B 3 holding B items where x > 10 and B 4 holding B items where x ≤ 10, B can be recomposed with B(x, y, z) = B 3 (x, y, z) ∪ B 4 (x, y, z). The rule R from (4) will be then rewritten as rules R 21 and R 22 in [START_REF] Ma | Consensus ADMM and Proximal ADMM for economic dispatch and AC OPF with SOCP relaxation[END_REF].

R 21 : H(m, k, t):-A(m, n, t), B 3 (m, , k); R 22 : H(m, k, t):-A(m, n, t), B 4 (m, , k); (6)
After rewriting the body part, the fragmentation of the head has to be considered. The resulting rules of the previous step will be duplicated for each fragment of the head. Horizontal fragments imply adding the fragment condition to the body part. If H in rule R is vertically fragmented into H 1 (x, y) and H 2 (x, z) then the rule R 1 is finally rewritten into rules R 11 and R 12 as presented in [START_REF] Liu | General distributed secondary control for multi-microgrids with both pqcontrolled and droop-controlled distributed generators[END_REF].

R 11 : H(m, k) :-A(m, n, t), B 1 (m, ), B 2 (m, k); R 12 : H(m, t) :-A(m, n, t), B 1 (m, ), B 2 (m, k); (7)
If H is horizontally fragmented into H 3 and H 4 with conditions x > 12 and x ≤ 12 respectively, then the same rule R 1 is rewritten into rules R 13 and R 14 , [START_REF] Lin | A distributed control architecture for global system economic operation in autonomous hybrid ac/dc microgrids[END_REF].

         R 13 : H(m, k, t) :-A(m, n, t), B 1 (m, ), B 2 (m, k), m > 12; R 14 : H(m, k, t) :-A(m, n, t), B 1 (m, ), B 2 (m, k), m <= 12; (8)
Aggregate functions (COUNT, MIN, MAX, SUM and AVG) are supposed to be computed over the whole original dataset. There is no problem in case of a vertical fragmentation as the aggregation concerns only one attribute, but the case of a horizontal fragmentation is more tricky. The solution consists in computing (sub-)aggregates for each horizontal fragment and store the results in intermediate datasets which then contribute to compute the final aggregated values.

For example, the rule R, defined in [START_REF] Hanqing | Multiagent-based coordination consensus algorithm for state-ofcharge balance of energy storage unit[END_REF], where B is horizontally fragmented into B 1 and B 2 , is first rewritten into rules R 1 and R 2 , as in [START_REF] Guo | Distributed cooperative secondary control for voltage unbalance compensation in an islanded microgrid[END_REF], according to the dataset fragmentation.

R : H(m, k, t) :-A(m, n, t), B(m, , l), k := sum(l); (9)
         R 11 : H(m, k, t):-A(m, n, t), B 1 (m, , l), k := sum(l); R 12 : H(m, k, t):-A(m, n, t), B 2 (m, , l), k := sum(l); (10)
Then, each resulting rules are rewritten to compute the aggregates (SUM) over the fragments. The final rules are shown in [START_REF] Xu | Distributed optimal resource management based on the consensus algorithm in a microgrid[END_REF] where R 21 and R 22 partially compute the sum

                             R 21 : T mp 1 (m, k 1 , t):-A(m, n, t), B 1 (m, , l), k 1 := sum(l); R 22 : T mp 2 (m, k 2 , t):-A(m, n, t), B 2 (m, , l), k 2 := sum(l);          R 231 : H(m, k, t):-!T mp 1 (m, k 1 , t), !T mp 2 (m, k 2 , t), k := k 1 + k 2 ; R 232 : H(m, k, t):-!T mp 2 (m, k 2 , t), !T mp 1 (m, k 1 , t), k := k 1 + k 2 ; (11)

Rules distribution

After determining which rules can be incurred from the original rule R, the next step is to analyze the rewritten rules R r according to the data allocation and to decide the data transferred among locations. Each rule is considered one after the other in the set of R r . 3.3.2.1 Rule in the form of a cyclic graph We use a directed (cyclic) graph G(V, E), where (V, E) is a set of vertices, corresponding to terms of the rule, and labeled edges, representing links among terms, respectively. For example, in Fig. 3, the edge between A and B 1 represents the passing of the variable m from A to B 1 , meaning that the term B 1 is evaluated after A.

The first term of the body part of a rule (A in Fig. 3) is the only one that possesses values assigned to all variables. Thus all paths in the graph start with this term and end with the head part of the rule. We analyze all variables of the terms in the rule in the reverse order (from H to a 0 ) to constitute the edges. Each term that can create new variables (except the condition one) can be a vertex of the graph G(V, E).

As the body of a Smartlog rule is a conjunction of terms, all these terms are commutative, the commutativity of terms possibly leads to produce cycles in the graph. The whole graph G represents all possible execution orders of the terms of a rule. As an illustration, the initial directed cyclic graph constituted for Rule R 1 , expressed in [START_REF] Sayed | Chapter 18 -scada and smart energy grid control automation[END_REF], is shown in Fig. 3.

Covering minimum acyclic directed graph

To select the best evaluation order of the rule, we have first to enumerate all covering minimum acyclic graphs representing actual possible evaluation orders (each vertice is attained only one time). This enumeration is performed in two steps: (i) eliminating edges participating in cycles to avoid infinite loops, and (ii) eliminating redundant edges to avoid unnecessary communications and computations. For example, by deleting one of the edges in cycles (B 1 → B 2 or B 2 → B 1 in the cyclic graph presented in Fig. 3, we generate two acyclic graphs (Fig. 4a and Fig. 4b respectively).

If there are two different paths between two vertices (A and B 2 in Fig. 4a), one direct and one passing through other vertice(s) (B 1 in the same figure), the direct one is then redundant and should be eliminated. The resulting covering minimum acyclic graphs are shown in Fig. 5.

3.3.2.3 Variable rerouting By eliminating redundant edges, the transportation of some variables may be forgotten and has to be compensated. For example, in Fig. 5a the transfer of variable t from vertex A to vertex H has been lost. This variable has to be rerouted using the retained path between A and H as shown in Fig. 6.

Data location and transfer

The location of each vertex (fragment data_type) of the minimum acyclic graph has to be considered. Location of atom vertices is known from the description of the data distribution. These locations allow constituting sub-graphs where all data_types are co-localized and thus identifying needed communications between locations. Non-atom

H B1 B2 A ( 1 ) (2) ( 3 ) (4) (5) (6)
(a) First covering acyclic graph.

H B1 B2 A ( 1 ) (2) ( 3 ) (4) (5) (6)
(b) Second covering acyclic graph. on locations where all needed variables have known values. For instance, in Rule R 1 , from (5), we assume that A and B 1 are co-localized in site S 1 , B 2 is in site S 2 and H in site S 3 , as illustrated by red dashed rectangles in Fig. 7a and Fig. 7b (communcations are represented as red edges).

Messages between two locations are generated by local rules and include all data to be transferred. For example in Fig. 8, where two sets of data have to be transferred from S 1 to S 2 ((m, t) from B 1 to H, and (m, k) from B 2 to H respectively), only one message is transmitted, including the variables (m, t, k).

3.3.2.5 Process synchronization It is always possible to build a minimal acyclic directed graph for a global rule comprising only one input (the first term of the body) and only one output (the head of the rule), and to partition according to the data locations. Each location evaluate the local rules that are supposed to be independent. These cooperating locations have thus to be synchronized to achieve equivalent evaluations as the original global rule. The synchronize locations ensure that messages contain sufficient information to match data included in messages coming from different locations. For example, in Fig. 9, S 5 receives two messages from S 2 and S 4 (m 2 and m 5 respectively). These two messages must be synchronized, so we need to find the location at the origin of m 2 and m 5 (here S 1 ). More precisely, we need to identify the term in S 1 at the origin of these two messages. m 2 is a consequence of m 1 , generated from terms A, B, C and D. m 5 is a consequence of m 4 and m 3 , the latest one is generated from terms A and B. The term causing the need of synchronization is thus B. So the key of B has to be propagated in all outgoing messages from location S 1 until location S 5 .

The communication cost of each candidate minimum acyclic graph must now be computed in order to select the most efficient one.

3.3.2.6 Selection of the optimal graph This step is critical to properly optimize the distributed computation. Each graph is examined and only the one minimizing the communication cost is retained. With the hardware architecture hypotheses of [START_REF] Nguyen | Using declarative programming for network data management in smart grids[END_REF], the communication decision is subject to optimization with the objective functions defined as follows:

1) Minimize the number of communications; 2) Minimize the number of transferred data-items.

In fact, to determine precisely the influence of each variable on the objective function (F ), all the characteristics of the considered network such as bandwidth, error rate, communication costs, etc. must be taken into account. In this paper, we do not focus on the cost model and we use a simple one, for illustration, as shown in [START_REF] Soares | Distributed optimization algorithm for residential flexibility activationresults from a field test[END_REF].

min F = x * y (12)
Where x represents the number of communications and y the total number of transferred data-items.

The optimal evaluation graph is the one offering the minimum cost. The optimal minimum acyclic graph allows determining the optimal rule execution order in which the behavior of a rule is still transformed in the same way as in the distributed system. The transferred data items must be started from the root of the graph (the vertex holds the first term of the body part) and end at the destination which holds the head part of the rule.

The rule distribution complies with the optimal graph. The direction of communication between two vertices respects the direction of the edge, and the transferred data items are the label of the edge.

As an illustration, let us consider the objective function of the two labeled graphs presented in Fig. 7a and Fig. 7b, F 1 and F 2 , respectively. For Rule R 1 , expressed in (5), the optimal graph is shown in Fig. 7a with F 1 . Indeed, in Fig. 7b, there are three communications and eight transferred data items, but in Fig. 7a only two communications and five transferred data items, thus F 1 = 2 * 5 < F 2 = 3 * 8.

Generating the programs

The last step of the SARD processor is to construct the distributed Smartlog programs for each location. Firstly, the data communication is taken into account to create new communication rules and temporary data_type triggering the next evaluation in a different location.

Performing communication

Data are packed in the form of a temporary data_type and sent to another location by message passing. The name of the temporary data_type, which is generated automatically, allows triggering the next actions in another location. The new temporary data_types are added to the data_types block in both locations (the sender and the receiver). The Data_type IPMap is declared and added at the end of the body part to indicate the mapping IP of the target address. For example, data sent with the optimal graph of Fig. 7a is expressed by the rules declared in Listing 5 and Listing 6.

Module(A1){ ˆTmp1(x,t) :-A1(x,y,t), B1(x,_), IPMap('S2',@ip); } Listing 5: Sub-rules generated in the site S1.

Module(Tmp1){ ˆB1(x,k,t) :-Tmp1(x,t), B2(x,k), IPMap('S3',@ip); } Listing 6: Sub-rules generated in the site S2.

After transforming the original rule into sub-rules in which all the term of the body part have the same location, each rule is assigned corresponding to its location.

Generating distributed Smartlog programs

A distributed Smartlog program is constructed in each location with the set of data_types, initial_data, and the assigned rules. In each program, rules are grouped by module, a set of data_types and initial_data are rewritten for the data_type block and initial_data block, respectively.

A Smartlog program comprises possibly many modules, and each one may contain many rules. The process of rule transformation into sub-rules can cause rule duplication in each location. In that case, the simplification of the program is performed.

EXPERIMENTAL EVALUATION

In this section, we apply the SARD processor over a reference Smartlog program implementing an over-voltage protection for a photovoltaic power generation. We then compare the behavior of both implementations in order to highlight the correctness and performance of the resulting distributed programs. We then study the influence of the number of nodes and the data distribution design on the performance. Note that the presented method has been successfully applied to other reference smart grids regulation processes like the frequency containment reserve for instance [START_REF] Nguyen | Using declarative programming for network data management in smart grids[END_REF], [START_REF] Nguyen | Smartlog-a declarative language for distributed programming in smart grids[END_REF]. Those results are not presented in this paper because the comparison of the implemented regulations is not relevant for the comprehension of the method and also not to extend the length of the paper.

AAPC: over-voltage control for smart grid

The rise of renewable energy, especially Photovoltaic (PV) sources, in traditional distribution grids causes risks of power unbalance as well as a decrease of the quality of the energy. One of the most notable issues, when this energy is injected to the grid, is over-voltage. There are many solutions approaching this problem, and one of the most effective methods with a centralized control is the Adaptive Active Power Capping (AAPC) [START_REF] Alyami | Adaptive real power capping method for fair overvoltage regulation of distribution networks with high penetration of pv systems[END_REF]. The principle of the method is presented in Fig. 10.

The purpose of the AAPC method is to determine the limit of the produced active power of each PV source so that the nodes' voltage in the whole grid do not exceed the bound of over-voltage and ensure the fair sharing of active power for all participating sources. The AAPC method assumes that a small change in voltage is approximated with the power variation in a small period of time span (t 1 -t 2 ), with V C1 and V C2 the two concerned bounds of the voltage. V c2 is the bound of over-voltage, in which the source is disconnected from the grid, [V C1 -V C2 ] = [1.042 -1.058] (pu). The over-voltage occurs in one or several nodes of the grid, called critical nodes (Cri). In the AAPC method, V c2 corresponds to the voltage of other nodes j (not critical ones), and is estimated based on the ratio P ROV .

P ROV = V c2 -V k (t 1 ) V k (t 1 ) -V c1 = V c2 -V j (t 1 ) V j (t 1 ) -V j (t 0 ) (13)
In principle, AAPC uses the linear regressive method for each photovoltaic source to predict the upper power limitation (Plim) expressed in [START_REF] Malekpour | Hierarchical architecture for integration of rooftop pv in smart distribution systems[END_REF].

P j l (t 1 ) = P j (t 0 ) + (V c2 -V j (t o ))/ξ j (14)
With ξ the linear coefficient (Slope) calculated by the ratio of voltage variation (Vvar) and power variation (Pvar).

ξ j = V j (t 1 ) -V j (t 0 ) P j (t 1 ) -P j (t 0 ) (15)
The photovoltaic power production within its threshold prevents over-voltages in the grid. P j ref , the generated power of the j th PV node in the next step, is its limit power Fig. 11: PREDIS Test network configuration [START_REF] Alvarez-Herault | An original smart-grids test bed to teach feeder automation functions in a distribution grid[END_REF].

(Plim) or maximal produced power (Pmax) predicted by a maximum power point tracking calculation, expressed in [START_REF] Molzahn | A survey of distributed optimization and control algorithms for electric power systems[END_REF].

P j ref (t 1 ) = min(P j l (t 1 ), P j m (t 2 )) (16)
Each photovoltaic node has the same responsibility to participate in the stable operation of the grid. Thus, the curtailment of each PV panel must be identical. The power production of each node at next time t 2 , called P j a (t 2 ), is expressed in [START_REF] Mhanna | Adaptive admm for distributed ac optimal power flow[END_REF].

P j a (t 2 ) = η * P j m (t 2 ) (17)
With η the power curtailment (Pcur), defined as:

η = j=n j=1 P j ref (t 1 )/ j=n j=1 P j m (t 2 ) ( 18
)

Experimental setup

The distribution grid PREDIS [START_REF] Alvarez-Herault | An original smart-grids test bed to teach feeder automation functions in a distribution grid[END_REF] is used as a test object. This grid has 14 nodes, with five distributed sources, three asynchronous machines and multiple static loads. The grid configuration is shown in Fig. 11. This grid is simulated in MATLAB/SIMULINK and executed in OPAL/RT for real-time simulation. Raspberry Pis play the role of local computing units installed at the nodes with distributed sources (PV), and are named following the node order. The centralized Smartlog program has data_types declared as follows (identifiers are underlined):

• Measure(ID, Timestamp, VOLT, POW, Pmax): Instantaneous measure at node ID of the voltage, active power and maximal produced power;

• Warning(ID, Timestamp): Keeps the timestamp at which the node ID attains the warning status;

• WarningMeasure(WarningID, ID, VOLT, POW): Measure the data of all nodes when the grid enters warning status;

• Alert(ID, Timestamp, PROV): Stores the timestamp at which the critical node attains the alert status, and the corresponding value of the P ROV ratio;

• Slope(Cri-ID, ID, Slope, Vvar): Slope coefficient and V var for the linear regression; The dataset is generated automatically during the realtime simulation. The measured data at each distributed PV source is sent to each corresponding Raspberry Pi .

Regarding the scenario of voltage control, we consider the change of injected power at each node. To verify the methodology, the injected power has to change with time and sometimes cause over-voltage in the grid. We carry out the simulation for 10 minutes. During this time we keep the load constant and change the PV irradiation. In reality, the change of solar power depends mainly on climate and cloud conditions. The curve presented in Fig. 12 is used to evaluate the method as well as to assess the response time for this case study.

EXERIMENTATION AND ANALYSIS

According to the objectives of the experimentation, we focus on evaluating the behavior of the algorithm implementations rather than the algorithm itself.

Correctness of the distributed execution

Description

To demonstrate the correctness of our method, we implement the centralized algorithm from [START_REF] Alyami | Adaptive real power capping method for fair overvoltage regulation of distribution networks with high penetration of pv systems[END_REF] in Java (which represents the reference implementation in our work) and in Smartlog. The results of these two implementations are compared with the results of the distributed implementation using the CPDE methodology and the SARD processor.

Regarding the data distribution, there are eight data_types in the centralized Smartlog program. They are assumed to be fragmented horizontally and distributed over five Raspberry Pis, except three intermediate data_type (Warning, Alert, and Curtail), only located in two raspberry Pis at node N o 7 and N o 9, respectively.

In the Predis grid, the 7 th node, corresponding to Raspberry Pi N o 7, is designed as the critical node during the simulation (this node has the highest voltage in the grid). Therefore, we will discuss the result mainly for this node in the following sections.

Results and discussion

Fig. 13 shows the voltage response at the 7 th node for both implementations (centralized and distributed). The voltage in all implementations is controlled and does not exceed the upper bound (1.058 pu). The results are identical, which confirms the correctness of the SARD algorithm.

At the second minute of the simulation, the active power of the PV increases linearly and causes an over-voltage in the grid. The AAPC algorithm is activated to restrain the percentage of power production. In continuous time, the curtailment is almost inversely proportional to the increase in active power. This means that the curtailment decreases linearly when the power production increases and exceeds the upper bound of power. In practice, the response time is defined as the interval between two consecutive updates of the power curtailment when the grid operates in overvoltage. We thus estimate the response time of each deployment in the experiment based on this definition.

We call t i the local processing time of each rule, t c the average delay time for each communication and N the number of computing units in the network. The response time of a node is estimated with [START_REF] Engelmann | Distributed ac optimal power flow using aladin[END_REF].

T res = T comp + T comm (19)
With R j the number of fired rules at the j th node. The analysis of the response time is shown in Table 1.

The average response time of the three implementation (centralized Smartlog program, centralized java program and distributed Smartlog program) are shown in Fig. 14.

The response time of the distributed program is smaller than the response time of the centralized program: max( i∈R N o 7 t i , j∈R N o 9 t j ) + N t c < j∈N i∈Rj t i . Indeed, in the real-time platform, the time delay t c is not significant in comparison to the processing time. Besides, the data sharing over the network speeds up the query time. Moreover, computing units operate in parallel and the sharing of computing load will apparently reduce the total computing time. Note that, the way the distributed programming is designed, in a reactive manner, will ensure the correctness of the method even when the network presents a bad communication delays.

Impact of the number of computing units

Description

In order to evaluate the influence of the number of computing units, we scale up the number of PV generator nodes as well as the number of computing units in the network. Since the experimental infrastructure is limited, the number of Raspberry Pis used is 3, 5 and 10 (the maximum number of Raspberry Pi on our real-time platform).

Results and discussion

The results of the experiment are proposed in Fig. 15. The average response time is considered in this case.

In all situations (3, 5 and 10 computing nodes), the response time of the distributed Smartlog execution is smaller than the two centralized ones. The gain in response time increases with the number of computing nodes. Also, as the number of nodes increases, the difference between the response times of the three implementations increases as well. The performance of the distributed Smartlog execution can be justified using the following arguments.

Calling ti the average time needed to execute a rule, and Rj the average number of rules processed by a node. When N is big enough, so that N t c (max( i∈R N o 7 t i , j∈R N o 9 t j ), the limit of the response time of the distributed programming is:

lim N   max   i∈R N o 7 t i ; j∈R N o 9 t j   + N t c   = N t c (20)
Meanwhile, the limit of the response time of the centralized program is:

lim N   j∈N i∈Rj t i   = N Rj ti (21)
With the same experiment architecture, t c < Rj ti , when the number of nodes in the network increases (N → ∞), the response time of the centralized program increases much faster than the one of the distributed program.

Impact of the distributed data configuration

Description

The sensing data are naturally scattered, usually close to the sensors in smart grids. To show the impact of the distributed data configuration on the performance, we focus mainly on the impact of the fragmentation and allocation of the intermediate data_types that are used to perform the aggregate computation over the network. If all the intermediate data_types are stored on the same node, this one is in charge of the computation of aggregate functions. Other The first activation of the voltage regulation is considered to analyze the impact of data configurations on the performances. We use again [START_REF] Engelmann | Distributed ac optimal power flow using aladin[END_REF] to assess the response time of each data distribution configuration. Note that Cases 1, 2 and 4 present five computing units, while Case 3 six.

Results and discussion

The four presented configurations are tested on the same application. The two main purposes of this test-case are to show the impact of using multiple data distribution configurations on the performances of the implementation as well as the adaptation of the methodology to multiple data distribution designs.

The response of the four cases are presented in Fig. 16. For all cases, the objective of voltage regulation is reached: the voltage is controlled around the upper limit (1.058 pu) when the PV production is over the limit, causing an overvoltage in the grid. The implementation can manage various designs of data distribution, even with data_types that are fragmented horizontally or vertically: The centralized algorithm is exactly transformed in the distributed one. Table 2 presents the comparison of the four cases and the related response times expressions.

The communication times of Cases 2 and 4 are equal, but the number of fired rules in a node is not the same in each case. Case 4 presents a longer computing time than case 2 because it must deal with data integrity by regrouping vertical fragments. For Case 3, the aggregate function is dispersed on another node bus, which needs more communications than in Case 1. In fact, the comparison of their performance depends on the deviation of the average time delay of communications and the required time to execute a rule.

This analysis reinforces the results shown in Fig. 17. The response time in the experiment is collected based on the interval of consecutive changes of the power curtailment values, once the power production increases linearly and causes over-voltage. We proceed with a statistic study of the four cases for the first moments of the simulation, when the voltage regulation is activated during the experimentation. The results are placed next to the value of the centralized implementations for comparison.

As seen, Case 2 is the best one. That can be explained as follow. In Case 1, similar to the centralized implementation, all the intermediate data are stored on the same node, common computations are performed in only one node, which is why the response time is larger than in the other cases. In Cases 2, 3, and 4, the intermediate data are allocated in multiple nodes. For Case 3, another Raspberry Pi (N o 6) is in charge of the aggregated computation, but it takes more time than in Case 2 because it requires more communication to request data from/to the various locations. The vertical data fragmentation in Case 4 is also good for the average response time, which is smaller than Cases 1, 3 and equal to Case 2 in the distributed implementation. However, the vertical fragmentation in Case 4 seems to not fit with this application as it present a deviation compared to Case 2.

The configuration of the data distribution has a strong influence on the performances of the execution. Thus, the problem of the optimal data distribution must be addressed in the future to reach the best performances with the upcoming Smartlog implementations.

DISCUSSION

Applying the proposed method in distributed management for smart grids shows promising results. However, the approach of distributed programming by using the Smartlog language is still in early stages. A few drawbacks can be highlighted in this paper, in a form of prospective researches:

• The distributed execution can not be automatically configured once a node is disconnect from the network as the rules are currently statically distributed;

• The SARD processor is based on a semi-automatic rule distribution principle. The data fragments should be predefined;

• The data location is supposed to be unique in the network, but in fact, the data are usually replicated, so that the decision of communication can be optimized if the data replication is taken into account;

• The communication cost model is simplified in this paper. A more accurate model should be used for each studied network.

CONCLUSION

In this paper, a new distributed programming methodology is proposed, called Centralized Programming and Distributed Execution (CPDE). This methodology is developed to facilitate distributed programming by first implementing centralized algorithms with Smartlog (Smartlog being a declarative and reactive rule-based data manipulation language dedicated to smart grid management needs). This centralized program is then translated into a distributed one using a Semi-Automatic Rule Distribution (SARD) processor according to a given data distribution description. This methodology totally hides the difficulties of distributed programming (i.e. data transfer and process synchronization are now transparent).

An experimentation has been conducted to validate our approach and highlight its performances and scalability compared to traditional centralized implementations (in Smartlog and Java). We also studied the influence of the number of participating nodes and data distributions alternatives on the performances. All these experiments have been realized in real-time simulation environment with hardware in the loop (computing devices) using a realworld application of over-voltage control with Photovoltaic power sources.

Future work will include: (i) the optimization of the data distribution, regarding its strong influence on performance; (ii) a more precice communication cost model; and (iii) the improvement of the prototype, for example using dedicated software instead of PostgreSQL as data storage and rule execution engine.

Thi-Thanh-Quynh Nguyen is currently a PhD student of Grenoble Institute of Technology. Her thesis is rolling in the collaboration of two laboratories: Grenoble Electrical Engineering Laboratory (G2Elab) and Grenoble Informatics Laboratory (LIG). Her research interests include Big data, distributed data management for smart grids and distributed control and management in microgrid. Nouredine Hadjsaid is a Professor at Grenoble Institute of Technology, Director of the Laboratory of Electrical Engineering of Grenoble (G2ELAB). He is also a visiting professor at Virginia Tech (USA) and NTU (Singapore). His research interests are in smart grids, which include distributed generation and power grids, information and communication technologies in power grids, and power grid safety, among others.

Christophe

Fig. 1 :

 1 Fig. 1: Structure of each node in the grid.

01

  Program(NameOfProgram){ 02 Data_types{//define the data types 03 A(Value1: int key, Value2: int, Value3: float). 04 H(Value1: int key, Value2: int, Value3: float). 05 } 06 Initial_data{//set up initial data 07 H(1, 0, 0). 08 } 09 Module(A){//rules 10 H(m, k, t) :-A(m, n, t),n >5, k:= t+n; 11 } 12 ... 13 } Listing 1: The structure of a Smartlog program.

Fig. 2 :

 2 Fig. 2: Principle of Smartlog rule distribution with CPDE.

Fig. 3 :

 3 Fig. 3: Intial cyclic graph of Rule R 1 , expressed in (5).

Fig. 4 :

 4 Fig. 4: Possible acyclic graphs of Rule R 1 .

Fig. 5 :

 5 Fig. 5: Covering minimum acyclic graphs of Rule R 1 .

  Rerouting data items of Fig 4b.

Fig. 6 :

 6 Fig. 6: Rerouting variables of acyclic graphs of Rule R 1 .

Fig. 7 :Fig. 8 :

 78 Fig. 7: Data location in acyclic graphs of Rule R 1 .

2 Fig. 9 :

 29 Fig. 9: An illustrated graph for synchronization process.

Fig. 10 :

 10 Fig.10: Adaptive Active Power Capping method[START_REF] Alyami | Adaptive real power capping method for fair overvoltage regulation of distribution networks with high penetration of pv systems[END_REF].

Fig. 12 :

 12 Fig. 12: The PV generation curve for 10 minutes.

Fig. 13 :

 13 Fig. 13: 7 th node's voltages for all implementations.

Fig. 14 :Fig. 15 :

 1415 Fig. 14: Average response time for all implementations.

Fig. 16 :

 16 Fig. 16: 7 th node's voltages for all data distributions.

Fig. 17 :

 17 Fig. 17: Responses times of all considered study cases.

  Bobineau has obtain his PhD in computer science from the University of Versailles Saint-Quentin in 2002. He is working since then at the Grenoble Informatics Laboratory (Grenoble Institute of Technology). His topics cover transaction management, distributed query optimization and data storage from embedded systems to Big Data. Vincent Debusschere has obtained his Ph.D. in ecodesign of electrical machines from the Ecole Normale Superieure de Cachan in 2009. He joined the Electrical Engineering Laboratory of the Grenoble Institute of Technology, in 2010 as an Associated Professor. His research interests include renewable energy integration, modeling of flexibility levers for smart grids, multi-criteria assessment, artificial intelligence and optimal design of complex systems. Quang Huy Giap is a Lecturer-researcher at the University of Science and Technology, The University of Danang. He received his PhD in Automation-Production in 2011 from Grenoble INP, France. His research is situated in the field of Automation, with a special focus on fault detection and diagnostics technologies, renewable energies and energy management.

  Listing 4: A sample data type block.

		14 }
		15 IPmap{
		16 S1: 192.168.1.100;
		17 S2: 192.168.1.101;
		18 }
	01 Data_types{
	02 A(Value1: int key, Value2: int, Value3: int){
	03	Fragment(A1){
	04	Condition: a>2;
	05	--Attributes:
	06	Location: 'S1';
	07	}
	08	Fragment(A2){
	09	Condition: a<=2;
	10	--Attributes:
	11	Location: 'S2';
	12	}
	13 }

TABLE 1 :

 1 Response times for the major implementations.

		Tcomp		Tcomm
	Centralized	j∈N	i∈R j t i		0
	Distributed	max( i∈R N o 7	t i , j∈R N o 9	t j )	N tc

  wise, if we distribute these intermediate data_types, the aggregate computation is carried out in parallel by multiple nodes of the network. The data distribution schemes of the intermediate data_types are expressed below: Case 1: The intermediate data_types are stored in only one of the five Raspberry Pis (7 th node in our case). Case 2: Two intermediate data_types (Warning and Alert) are stored in the Raspberry Pi N o 7 and Curtail in the N o 9. Case 3: We add a new Raspberry Pi at the 6 th node of the grid to store the intermediate data_types. Case 4: Similar to Case 2, but Alert is fragmented vertically and stored in the Raspberry Pis N o 7 and N o 9.

TABLE 2 :

 2 Response times for all data distributions.

	Case Tcomp				Tcomm
	1 2 3	t i max( i∈R N o 7 i∈R N o 7 max( i∈R j (j<>N o 6) t i , i∈R N o 6 t j ) t i , j∈R N o 9	t i )	(2N -2)tc N tc 2N tc
	4	max( i∈R N o 7	t i , j∈R N o 9	t j )		N tc

ACKNOWLEDGMENTS

The authors would like to thank the French Embassy in Vietnam and the Foundation Grenoble INP for funding the PhD leading to the presented results.