Accelerated Real-Time Simulations for Testing a Reactive Power Flow Controller in Long-Term Case Studies

-is paper presents the development of an accelerated real-time cosimulation and testing platform, especially for long-term simulations of power systems. -e platform is planned to be utilized in the development and testing of active network management functions for microgrids and smart grids. Long-term simulations are needed in order to study, for example, the potential weekly, monthly, or yearly usage of distribution-network-connected distributed energy resources for different technical flexibility services. In order to test new algorithms in long-term study cases, real-time simulations or hardware-in-the-loop tests should be accelerated. -is paper analyzes the possibilities and challenges of accelerated long-term simulations in studying the potential use of a large-scale wind turbine for reactive power flow control between distribution system operator (DSO) and transmission system operator (TSO) networks. To this end, the reactive power flow control is studied for different voltage levels (HV and MV) in the Sundom Smart Grid in Vaasa, Finland. -e control of reactive power flow between HV and MV networks is realized with a reactive power window control algorithm for a 3.6MWMV-network-connected wind turbine with a full-scale power converter. -e behaviour of the reactive power controller during long-term simulations is studied by offline and real-time simulations. Moreover, the real-time simulations are performed with both software-in-the-loop and controller-hardware-in-the-loop.


Introduction
Utilization of the distribution-network-connected distributed energy resources (DER), that is, flexibilities, is becoming increasingly important for improving local and system-wide grid resiliency and for providing the technical flexibility services needed by DSOs and TSOs. Flexibilities consist of active (P) and reactive (Q) power control of flexible resources, such as controllable distributed generation (DG) units, energy storages (ESs), controllable loads, and electric vehicles (EVs), which are connected in DSO grids. e flexibility services from DER for DSOs and TSOs can, for example, be realized as part of active network management (ANM) functions for grid-connected microgrids.
Currently, the standards for microgrids, especially IEEE and IEC, for control and management are under development, and only a few standards for microgrids have been published so far [1][2][3][4][5][6][7][8][9][10]. However, for the development of microgrid control and management functions, different simulation studies and tests have been performed [11,12]. Different kinds of vendor-defined microgrid controllers have already been developed and tested [13], but there is a lack of standardized tests for microgrid control [14]. One of the challenges with vendor-defined solutions is that they might not meet interoperability and grid-code requirements. Figure 1 presents the traditional impact of standardization on product development, illustrating the product's lifetime cycle and standardization phases [15]. Because of the phase of the standardization, it can be concluded that microgrid controllers are in the stage of "need for product standards to resolve issues." Despite this standardization situation, the different solutions for microgrid management are becoming increasingly global.
However, the software upgradability of new products becomes more important as requirements (e.g., grid codes and standards) change. Standardization takes more time as products and solutions become more complex, while at the same time, technology development goes faster, and the need for new solutions becomes faster. Start-ups in particular will probably not wait for the final standards. erefore, many standards could be obsolete when they are released and require an immediate upgrade process. e standardization of microgrid control systems is intended to define the requirements for microgrids "regardless of topology, configuration or jurisdiction and to present the control approaches required from the distribution system operator and the microgrid operator" [1]. e IEEE Standard 2030.7 defines the functions that a microgrid control system must perform, and the IEEE Standard 2030.8 presents the testing procedures for adopting the functional specification of microgrid control systems. According to [1], a microgrid control system is defined as "a system that includes the control functions that define the microgrid as a system that can manage itself, operate autonomously, and connect to and disconnect from the main distribution grid for the exchange of power and the supply of ancillary services; it includes the functions of the Microgrid Energy Management System (MEMS); it is the microgrid controller if implemented in the form of a centralized system" [1,2].
One requirement for microgrid controller functions is to provide flexibility services like ancillary services (AS) [1], which can be realized with a technical or market-based approach. Technical AS are related to, for example, the control of reactive power (Q) flow between the DSO's and the TSO's networks. e testing approach of microgrid controllers should include definitions for the test scenarios, the performance metrics, and the testing environment, which can range from a fully simulated environment to real equipment installed in the field [2,16]. Figure 2 presents the coverage and fidelity of the different testing methods [17,18]. Pure simulation is utilized in the research stage and in a very early stage of product development. In controllerhardware-in-the-loop (CHIL) simulations, the controller is a real device, but everything else is simulated. In powerhardware-in-the-loop (PHIL) simulations, there are real power devices (e.g., photovoltaic units, loads, and storage) in addition to the controller.
Consequently, it is essential to build comprehensive test platforms for microgrid controllers that can perform the CHIL and PHIL simulations and the tests for different types of required functionalities [1,2] to verify the proper operation of the functions of the developed microgrid controller. Besides, the test platform should be flexible so that it can serve different kinds of microgrids [4] with the purpose of (i) Improving electricity supply reliability and network resilience by intentional islanding (ii) Providing power to remote areas with lower cost (iii) Reducing the energy cost for microgrid users in grid-connected mode (iv) Providing preparedness for disasters In HIL simulations, the Hardware under Test (HuT) is connected to the simulated system running in the real-time simulator or target. e real connection has delays and affects the stability of the system that has to be respected. In CHIL simulations, the delay consists of the target input/ output processing and communication time delay/latency as well as processing time of the controller [19]. e effect of the delay should be taken into account when tuning controller control parameters. Further, in PHIL simulations, the error is caused by delays and distortion introduced by the power interface. Moreover, the power amplifier between the power hardware and the target (the real-time simulator) may cause the system to be unstable. erefore, it is essential to develop an interfacing algorithm between the target (simulated system) and the HuT. In addition to the previous ones, the utilized sample time of the real-time simulation has a major impact on the stability behaviour. [18,20].
Based on the literature review on selected CHIL testbeds [21][22][23][24] and PHIL testbeds [25] suitable for microgrids, transition and dispatch function in power balance management and ancillary services are of great interest. e focus of [21][22][23][24] is on implementing control algorithms on hardware and stability issues. Long-term case studies in simulations are lacking. e authors in [22] present the results of a software controller for dynamic power-sharing with three PV units in islanded microgrid operation in which the PV generation profiles are represented in one-day historical data. e time scale was compressed into 14 min in real-time simulations, but analysis of the method and the  effect of delays are not presented. New kinds of algorithms, computational techniques, or models could be developed for accelerating long-term simulations. e focus in this paper is on developing an accelerated real-time cosimulation and a testing platform and setup, especially for long-term simulations. Furthermore, the aim is to test controller behaviour in the accelerated real-time simulations, in which the feasibility of the platform is evaluated. is kind of platform is novel; we did not come across any similar solution in the literature. e platform is planned to be utilized for the development and testing of microgrid controller ANM functions for microgrids in the grid-connected mode, particularly for long-term case studies. e long-term simulations are needed in order to study, for example, the potential weekly, monthly, or yearly usage and operation of distribution-network-connected DER for different technical flexibility services. e simulation setup developed consists of the real measurement data from the Sundom Smart Grid (SSG), a simulated power grid, communications, control functions, and a controller.
In the next section, Sundom Smart Grid (SSG), the SSG, and the different requirements for the reactive power flow are presented. After that, the section " e Real-Time Cosimulation Platform" presents the developed real-time cosimulation platform. e different simulations, executed tests, and experiments with the developed platform are presented in the section "Executed Tests and Experiments." e final section is "Conclusions and Discussion." Figure 3 presents the SSG, which is a pilot of a local MVnetwork-based smart grid created in cooperation with ABB, Vaasan Sähköverkko (DSO), Elisa (communications), and the University of Vaasa [27]. e SSG enables the development of AS solutions for future grids beyond the traditional boundaries from the HV level to the LV level. In the SSG, there are four MV feeders, and one feeder (J08) is only for the wind turbine (WT). Real-time IEC 61850 generic object-oriented substation event (GOOSE) measurements and sampled value (SV) measurements are gathered online from all the four feeders at the HV/MV substation, as well as from three MV/LV substations with 20 measurement points. For future research purposes, the measurement data are collected in servers. e different requirements for the reactive power flow between the MV and HV networks in the SSG studied, with several requirements and targets, are presented in [28]. In Europe, the European Network of Transmission System Operators for Electricity (ENTSO-E) sets grid-code requirements, for example, for connection of demand facilities and generators [29,30]. Moreover, the national TSO has set requirements for the DSO's reactive power flow by a "reactive power window" [31] at the point of interconnection (POI), that is, between the TSO and DSO networks. e reactive power window (RPW) specifies the amount of reactive power that can be exported to the HV network and imported from the HV network without separate compensation. is RPW requirement and related compensation tariff aim to optimize the reactive power flow from the transmission network's point of view. In addition, reliable and future-proof islanding detection, as well as the possibility of making a stable transition to islanded operation, can be considered simultaneously with the reactive power flow control between HV and MV networks [26,[32][33][34].

Sundom Smart Grid (SSG)
Based on the results presented in [35], there would be an 80 k€ yearly cost for the DSO, caused by the capacitive reactive power flow generated by the cables in the SSG. In [36], the use cases and future scenarios for reactive power management are developed further to study and develop the RPW controller. e scenarios studied are Scenario 2018, Scenario 2028, and Scenario 2035.

The Real-Time Cosimulation Platform
e utilized real-time simulation platform is based on an OPAL-RT system consisting of power system simulations with ePHASORSIM (transient stability, phasor mode), as well as control and communications with eMEGASIM (electromagnetic transients, discrete type). Communication between the controller and the interfaces of the simulated power system is implemented with IEC 61850 GOOSE messages on Ethernet. Figure 4 presents an outline of the platform.
In previous researches [19,36] for software-in-the-loop (SIL) simulations, a GOOSE publisher block is implemented in the real-time simulation model to publish (send) the measured active power (P meas ) and the measured reactive power (Q meas ) from the target (OP5600 simulator). Furthermore, a GOOSE subscriber block is implemented to subscribe (receive) the P meas and Q meas values from the Ethernet network. For the CHIL tests, a GOOSE subscriber and publisher are implemented in the hardware under testing, in addition to the RPW control algorithm. e implementation process is presented in [19], in which the simulation time step (T s ) is 0.01 s for the real-time SIL and CHIL simulations. e results gathered by the real-time target are the hourly average active and reactive powers (P HVavg and Q HVavg ), the instantaneous active and reactive powers (P HV and Q HV ), the active and reactive powers from WT (P WT and Q WT ), and the bus voltages. e CHIL tests are performed for the BeagleBone Black (BBB) as well as for the field-programmable gate array (FPGA) controllers. e IEC 61850 GOOSE message packets traveling over the network are captured by Wireshark software (.pcap files) from the traffic between the controller and the target. e results in [19] show that FPGA controllers are more efficient for future microgrid controller studies.

Executed Tests and Experiments
In this research, the parameters for reliably performing the accelerated real-time simulations are defined and analyzed by testing the improved RPW control algorithm [36]. e offline SIL, real-time SIL, and CHIL tests are performed with the parameters defined in the platform developed in [19] in order to determine how the real-time simulations could be accelerated, what kind of phenomena can occur, and when Journal of Electrical and Computer Engineering the results are reliable. e results from the real-time SIL and CHIL tests should correspond to the offline SIL results when there are no communication and hardware processor delays.
In this study, the simulations are performed with the controller limits set according to Figure 5. e limits for the controlled values are set ± 50 kVAr tighter, except QD1 � Qi + 200 kVAr for the controller of the WT converter. In other words, the controller operation (a trigger for calculating a setpoint value for the WT converter) limits are the TSO limits (the red limits), but the setup limits for the WT converter are set tighter (the blue limits).
e offline SIL simulations, as well as the real-time SIL and CHIL tests, are presented below. In order to run longterm power flow simulations, for a one-year period, in this case, the simulations are accelerated by implementing the input-data-reading step from the  OpFromFile block.
is block reads from a Matlab file (.mat) and outputs the samples from the file. Further, the time factor, coefficient T d , for reading a data row from the input data (in this case, the hourly average values over one year from the SSG) or the look-up table is set so as to correspond to the reading step of the one-hour input data. e aim of this study is to test different values for T d to find a value that does not distort the results, that is, answering the question of how much the real-time simulations can be accelerated. For the one-year simulation, the hourly average values of the one-year measurements as input data generate 8760 rows of data, and the coefficient T d is set accordingly to find the initial range for which the results are reliable. Figure 4: e real-time cosimulation platform [36].

Journal of Electrical and Computer Engineering
Generally, the use of accelerated simulation would mean the modification of the models so that their behaviour in the accelerated time scale is equivalent to the behaviour in realtime scale. is means that the modified model is dimensionally similar. In this study, this kind of approach would have meant overly complicated modifications to the models, so another approach was used. Instead, the original time-scalebased models were used with a suitable selection of the simulation time steps so that the desired outcome was reached. e cosimulation platform and the concept are presented in more detail in Figure 6. Different simulation time steps are also shown in Figure 6, where T s � 0.01 s represents the simulation time step both for the simulated power system in ePHASORSIM and for the measurements, PI/I control, and so forth in eMEGASIM. Further, T d represents the time step for the reading cycle of the input data (PQ load and PQ generation ). T c represents the time step for reactive power setpoint (Q set ) value calculation in the RPW controller. e involved time steps and the limiting factors of the system are the following: and CHIL (T d,p ) setups. e input data reading cycle has to be defined so that it enables maximum acceleration of the simulated system, while the results are not disrupted. e results can be proved with the equivalent results from offline SIL and real-time SIL as well as from the CHIL tests. In addition, the input data reading cycle based on the (measurement) data type has to be selected for real-time tests, so that reasonable computation times are achieved. Both of these hardware controllers were fast enough, not limiting the accelerated CHIL tests in this case. Within one simulation time step, T s , they were able to receive P_HV and Q_HV values, process the new setpoint value Q set , and send it back to real-time simulator.
(4) I or PI controller operating time step: the I or PI controller operation depends on the defined sampling time for it. In this study, the sampling time is the same as the simulation time step T s . (5) Acceleration.
In this case, an input data (D e ) row represents the one-hour average value of active power, and the output values thus represent hourly averages. e data type could also be, for example, 10 min average (D 10min ) or 5 min average (D 10min ) keeping in mind that acceleration: e electricity network model is running in real time with T s � 0.01 s, which is selected so that the transient phenomena have time to decay, and the system has reached steady state before new input data is read with time steps T d of 0.1 s or more. Table 1 presents the coefficients and the effects of their values. For example, in Option 1, selecting T d � 0.1 means that a one-year accelerated real-time simulation will take 876 s (around 15 min) with one-hour average input data. Further, the simulation time step T s � 0.01 s is equivalent to 360 s in real-world time, which means that the power flow of the system is known in intervals of 360 s. Option 29 (T d � 20) presents the setup in which the power flow would be calculated every 1.8 s (representation of the real-world time). In this case, the accelerated real-time simulation would take 49 hours. e time step for the RPW controller action, T c , could be selected in SIL, which is also presented. e selection of T c mimics how often the RPW controller can calculate a new setpoint if desired, and T s determines when the potential new setpoint value comes into effect for the WT converter. In the following sections, the evaluation of the suitable initial coefficients for accelerated real-time simulations is presented with the results from the offline simulations.

Offline SIL Tests.
Several offline SIL tests are performed to define the initial coefficient T d for the accelerated realtime simulations. e comparisons of the results between Option 1 and Option 6 (T d � 0.1 and T d � 1), as well as between Option 6 and Option 24 (T d � 1 and T d � 10), are presented in Figure 7. It can be seen that there is a difference between both comparisons due to the different T d values, which means that the smaller values (0.1 and 1) are not suitable. For the next trial, the comparisons of the results between Option 14 and Option 24 (T d � 5 and T d � 10), as well as between Option 9 and Option 14 (T d � 4 and T d � 5), are made, and it can be observed that no difference exists between the results. e latter result indicates that a suitable initial T d coefficient is ≥ 4.
By examining the results more closely, one can see that a difference in results emerges around 4000 h and later. Figure 8 shows that time point in more detail with different T d values. When T d is 0.1 or 1 and even when T d is 5 or 10, Q WT was "oscillating" in the time period between 4031 h and 4032 h. e oscillation form, that is, the amplitude of the oscillation, is increasing, which illustrates that the system is in an unstable region during that hour. Further, when T d is smaller, the value of Q WT after this oscillating hour is different. When T d � 0.1, Q WT � −0.2213 MVAr, and when T d � 1, Q WT � -0.2305 MVAr. ese observations explain the difference in downstream results (after 4032 h). When T d is 5 or 10, the oscillation also occurs, but now the resulting Q WT is the same (−0.3103 MVAr).
is oscillation phenomenon is presented more closely in Figure 9. At t � 403100, the point (Q HV , P HV ) is inside the window (0.7982 MVAr, 4.9824 MW), consuming active and reactive power, while the reactive power of the WT converter is capacitive, Q WTset � Q WTmeas � −0.1869 MVAr. In the next time step, t � 403101, the "measured" point (Q HV , P HV ) is outside the window (Q HV � 0.9620 MVAr ind. , P HV � 5.399 MW) (the limit is Q D � 0.83 MVAr) when Q WTmeas � −0.1869 MVAr. en, a new setpoint of the WT converter is calculated, Q WTset (t � 403101) � −0.1820 MVAr, which is realized by the control at the next time step, t � 403102. However, at that moment, Q WTset is not high enough, and (Q HV , P HV ) is outside the window (0.9994 MVAr, 5.4718 MW) again, while Q WTmeas (t � 403102) � Q WTset (t � 403101) � −0.1820 MVAr. is phenomenon occurs over a period of time, depending on the selected T d .
After all, a new setpoint aims to influence the reactive power Q HV by correcting the output of the WT converter so that the next (Q HV , P HV ) point will be inside the window. However, according to Figure 10, the RPW control is lagging a simulation step; that is, the new setpoint is calculated based on the last measurement of (Q HV (t i−1 ), P HV (t i−1 )). At this specific time, there is a possibility of having oscillations in the controlled system due to the delay of the control. is delay is dependent on two aspects: the selection of T d as well as the delay of the I or PI controller. e I or PI controller was used to prevent algebraic loops in the modelled system.
Above we stated that the total oscillation time is dependent on T d . e effect of T d selection on the oscillation time is studied further in order to find a relationship. Figure 11 presents the results of the oscillation time in simulations with different values of T d . Increasing the value of T d seems to decrease the total oscillation time τ T d,i . In addition, two other results are presented, one with an I controller and one with a PI controller. In both cases, T I � 99.5 and T c � 0.01 are used for the I controller. For comparison, a PI controller with K P � 1.2 and T I � 99.5, as well as T c � 0.02, is investigated. e results are presented in Table 2. Based on both these results, with a suitable initial value (in this case, T d ≥ 4), it can be derived that the total oscillation time decreases linearly in the ratio

Journal of Electrical and Computer Engineering
Based on equation (2), the oscillation time in real-world time would be 1.3 s in the I-controller case and 3 ms in the PI-controller case. e above oscillation phenomenon occurs in accelerated simulations. However, it was found that the duration of the oscillation decreases when T d increases or becomes closer to real time. e evaluation of how the P and I parameters depend on the accelerated real-time simulation could be a future research topic.

Real-Time SIL Tests.
e first real-time SIL tests are performed with T d � 0.1 and T d � 1. e results are presented in Figure 12 by comparing them to the corresponding results of the offline SIL simulations. It can be observed that there are again small differences between both cases. is is due to the delay in communications.
Next, it is studied whether increasing T d decreases the difference between offline SIL and real-time SIL results, that is, whether it can eliminate the effect of the communication delay. Based on the offline results, T d > 4 could be a suitable value. e reactive power flows at the WT converter are presented in Figure 13 when T d � 5, T d � 7, and T d � 10. It can be seen that the results of the offline SIL and real-time SIL simulations are different when T d � 0.1, 1, 4, and 5, whereas the results look similar when T d � 7 or 10. Based on the above, a suitable factor for real-time simulations could be T d ≥ 7. Figure 14 presents a comparison of the real-time simulation results when T d � 7 and T d � 10. It can be observed that now the results converge.
Further, the oscillating hour 4031 was investigated from a communication's point of view. Figure 15 presents the situation in which T d � 1, T d � 5, T d � 7, and T d � 10. Oscillations occur when T d � 1 and T d � 5 but not when T d was 7 or 10.

CHIL Tests.
e long-term CHIL tests were conducted with T d � 7. Now, the coefficient T c is dependent on the processor capacity of the hardware used. e hardware used for the CHIL tests is an FPGA that has a Dual-Core ARM Cortex ™ -A9 (925 MHz) processor, as well as 10/100/ 1000 Mbps Ethernet with a high-speed bus, to exchange data between the hard processor system (HPS) and the FPGA.
is scenario aims to compare the CHIL test results with the real-time SIL test results. e RPW controller is set up to the TSO limits of ±50 kVAr, except QD 1 � Q i + 200 kVAr. Figure 16 presents the results from the tests with the FPGA against the real-time SIL test results when T d � 7. It can be observed that the results are equal now.

Conclusions and Discussion
e accelerated real-time cosimulation platform proves to be useful and efficient in one-year power flow simulations. is research demonstrates how to accelerate the long-term simulations by different setups of the input data. Moreover, this paper clarifies how the input data processed in the longterm simulations or tests affect the results. e offline SIL and real-time SIL simulations show that it is possible to find a data-reading cycle, coefficient T d , to accelerate the long-term real-time simulations. When T d is equal or greater than a particular value, the simulation results do not differ even when T d is increased. Consequently, this value would be a suitable initial value for investigating the coefficient of the accelerated real-time simulations. In addition, it is found that, by increasing the value of T d , the possible oscillation period becomes shorter. Further, based on this result, a suitable I or PI controller can be derived for accelerated real-time tests that enable adaptive closed-loop control, preventing oscillations in the closed-loop controlled system. Finally, even in CHIL tests with an FPGA and the selected coefficient T d , the results of the real-time SIL and CHIL tests do not differ.
e performance of the FPGA shows that it is suitable hardware for testing the algorithm in long-term simulations.
Our suggestion for long-term simulation runs is to carry out offline SIL simulations by using real-time simulation models with different time factors and verify that the results are equal. e time factor for the real-time SIL simulations can then be selected, and the results would be expected to be close to the offline results, with only an effect of the communication time delay. is method could be utilized to define the test procedure, for example, for CHIL applications in the development of microgrid controllers, especially for ancillary services. e more detailed stability analysis of the proposed control method and detailed technical analysis of the proposed approach will be done in future studies. is paper's aim is to present the potential and the related issues of the developed method for accelerated real-time simulations.
Data Availability e data that support the findings of this study are available from the corresponding author upon reasonable request and with permission of Vaasan Sähköverkko.

Conflicts of Interest
e authors declare that there are no conflicts of interest regarding the publication of this paper.