*4.1. Model Structure Details*

Figure 10 displays the whole real-time simulation model. The model is partitioned in two parts, one running on the FPGA, the other on the CPU. The FPGA partition contains the model of all the hardware parts, as shown in Figure 8, namely, the grid network specified in Figure 7 and the output filters of the EPCs hardware specified in Table 1. The CPU partition comprises the following blocks.


The devised partition allows to perform simulation with small discretization steps on FPGA for those models presenting fast dynamics and allow the execution of even complex control algorithm on CPU. The accuracy of the developed real-time simulation setup has been verified by comparison with equivalent desktop computer simulation models executed with variable time step simulations.

**Figure 10.** System model in the real-time simulator. The green bottom-left block, executed on FPGA, models the distribution network and the EPCs hardware, the other blocks, executed on CPU, model the EPC controls shown in Figures 4 and 5.


**Table 1.** Electronic power processor (EPC) parameters.

### *4.2. Results*

The control system has been tested in different operating conditions. Six scenarios of operation with different kinds of constraints while minimizing the cost function (11) are described next.


The obtained results in steady-state conditions are reported in Table 2, while transient behaviors in relevant conditions are displayed in Figure 11. As a general remark, it is possible to note that voltage deviations and distribution loss significantly reduce in all the considered test cases when distributed EPCs are active and controlled by the microgrid controller. Each operating condition is considered in more details in the following.


Figure 11a refers to the transition from Case 0 to Case 1 and then to Case 2. It displays, from top to bottom, the total active and reactive power exchanged at the PCC and the measured total distribution losses. Case 1 allows a significant improvement in terms of power quality, indeed the maximum voltage deviation of the network nodes halves and the power factor at the PCC increases from 0.850 to 0.996. In addition, distribution loss is mitigated by 18%. Significant improvements are obtained by activating active power control too: in this case distribution loss decreases by an additional 60% in the last time interval of Figure 11a.

Figure 11b refers to Case 3, reporting the currents through the three phases at the PCC and the correspondingly measured active and reactive powers. Noticeably, power balance is achieved accurately, being the active and reactive powers among the phases at the PCC are of equal amount.

The dynamics related to power flow control are important when considering demand–response at the point of connection with the main grid, which is demonstrated in Figure 11c,d. The former relates to a constraint of zero active and reactive power exchange, the latter to a constraint of pure, balanced active power exchanged with the main grid. Additionally in this case, the optimal coordination of distributed EPCs allows to accurately track the given references.

**Figure 11.** Results in the considered operating conditions. (**a**) Distribution losses in Case 0, Case 1, and Case 2; (**b**) active and reactive power balancing at the PCC (point of common coupling) in Case 3; (**c**) zero active and reactive power reference at the PCC in Case 4; (**d**) demand–response at the PCC with requested active power equal to 10 kW and zero reactive power in Case 5; (**e**) disturbance rejection at the PCC after a load change within the grid with ideal communication; (**f**) as in the previous case but with non-ideal communication.

The impact on the dynamic performances of including communication impairments in the system is considered too in the validation. Figure 11e–f show the effect seen at the PCC after a sudden increase of power absorption by 27.5 kW due to the connection of the load at node R18. During the condition in which the control system is set to impose zero power flow at PCC, Figure 11e refers to the case of ideal communication whilst Figure 11f refers to non-ideal and impaired communication with 20% packet loss and random latency in the interval [300 ms, 1 s]. Considering the random nature of the considered aspect, a batch of sixty consecutive acquisitions are simultaneously reported in the figures. Figure 11e shows that the control brings back to zero the controlled quantity in a time compatible with the chosen control frequency of 2 Hz if the communication is ideal. Instead, in the case of Figure 11e, dynamics are significantly delayed even though steady-state performance is preserved. Such kind of considerations are important in the design of master–slave microgrid architectures (see, e.g., [31,32]) where a single EPC is expected to buffer possible energy unbalances. In such a case, Figure 11e indicates that a master EPC should be able to buffer about 82.5 kJ, while in case of communication fault as in Figure 11e the buffered energy increases to 137.5 kJ, which corresponds to 40% and 68%, respectively, of the capacity of a super-capacitor energy storage as in [33]. In addition, it is possible to note an oscillation due to the active and reactive coupling of the droop control loop.

Figure 12 shows a long-term simulation over ten hours, in which the distribution loss in case of communication impairments is specifically considered. The simulation comprises variability in load power absorption at node R18, which is periodically switched on and off, and in PV power generation, sampled with a time step of one second, which considers a measured profile during a cloudy day. The simulation is run with ideal as well as non-ideal communication, showing negligible impact of communication impairments on power flow optimization: distribution loss increases from an average of 349 W to an average of 354W, which confirms the effectiveness of the approach.

**Figure 12.** Long-term simulation (i.e., 10 h) without/with communication impairments.

Finally, Figure 13 shows a long-term simulation over twenty hours in which the load at node R15 is switched on/off randomly, the load at node R18 absorbs the actual power profile measured in a subsection of a university campus, and the source at node R16 generates the actual power profile measured at a PV installation. The figure shows, specifically, the instantaneous distribution loss when the distributed converters are disabled (i.e., case without optimal control) and the case in which the converters are controlled according to the presented optimal power flow (i.e., case with optimal control). Notably, the average distribution loss amounts to 1.122 kW in the first case, while, enabling distributed converters to respond to the optimal control signals, the distribution loss decreases to 392 W, which corresponds to a distribution loss reduction of 65%.

**Figure 13.** Long-term simulation (i.e., 20 h) without/with optimal control.

In summary, the described control approach is based on a general algorithm with an explicit solution of the control problem. In this way, it is not affected by convergence issues even in case of communication failures and it is adaptable to generic networks and operating conditions. The approach is validated by means of a real-time simulation setup that is described in detail herein. This setup can be considered for the validation of generic systems involving fast electronic power converters, control algorithms for management of distributed resources, and a communication infrastructure allowing data exchange for distributed resources coordination. The considered scenario and validation testbed are useful in the forthcoming power-electronics-dominated grids, where control and communication play an important and substantial role [34,35].

### **5. Conclusions**

In this paper, an optimal power flow control method for microgrids and its real-time validation considering a benchmark low-voltage distribution network with distributed energy resources has been presented. Distributed resources are considered interfaced to the network by means of electronic power converters implementing a specific power-based droop controller. Such a controller allows power-flow control when operating connected to the main grid, while preserving the capability of operating islanded in case of accidental disconnection. The power-flow control method is implemented centrally at microgrid level and set to dispatch power references to the distributed electronic converters. The reported results show that the local control of distributed converters driven by the control signals computed by the described power flow control method achieves minimum distribution losses, improved power quality indices, and fulfillment of constraints at the point of connection with the main grid. The real-time experimental setup allowed to investigate steady-state operation as well as short-term and long-term dynamics in realistic generation and communication network conditions. The reported results show the effectiveness of the described power flow control in several conditions of practical interest. Notably, the approach is suitable to provide optimal coordination of distributed energy resources to respond, for example, to demand–response requests issued by entities at higher layers in the power-system control hierarchy. The described real-time simulation testbench may be taken as reference for other studies concerning power electronics nominated grids exploiting communication for distributed resources coordination. Future studies may regard the overall operation of a grid subsection that integrate the shown dynamic power optimization and long-term energy optimizations. Actually, the control approach was devised to provide the flexibility needed to comply, in the future, with the European vision where clusters of prosumers aggregated in microgrids will actively participate to the electrical market by trading their energy resources.

**Author Contributions:** Conceptualization, P.M. and T.C.; methodology, P.T.; software, P.T., H.A.; validation, H.A., P.T.; formal analysis, P.T.; data curation H.A.; investigation, H.A., T.C.; writing—original draft preparation, T.C.; writing—review and editing, P.T.; visualization, H.A., T.C.; supervision, P.M., P.T., T.C.; resources T.C.; project administration, T.C.; funding acquisition, P.T., P.M., T.C. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was mainly funded by Interdepartmental Centre Giorgio Levi Cases, project NEBULE. Part of the funding is also coming form the PRIN project HEROGRIDS.

**Conflicts of Interest:** The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.

### **References**


**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
