ANN-based grid voltage and frequency forecaster

: This paper presents a method for the forecasting of the voltage and the frequency at the point of connection between a battery energy storage system installed at The University of Manchester and the local low-voltage distribution grid. The techniques are to be used in a real-time controller for optimal management of the storage system. The forecasters developed in this study use an artificial neural network (ANN)-based technique and can predict the grid quantities with two different time windows: one second and one minute ahead. The developed ANNs have been implemented in a dSPACE-based real-time controller and all forecasters show very good performance, with correlations coefficients >0.85, and mean absolute percentage errors of <0.2%.


Introduction
The increasing penetration of distributed generators (DGs) in the form of renewables sources, such as wind and solar, is anticipated to continue, and in 2035, 49% of the UK's electricity generation capability is anticipated to be from renewables [1]. The uncontrolled nature of most renewable sources means that there can often be a mismatch between their output and the network demand, and this can lead to challenges in managing the local network voltage [2] and frequency. The situation is further exacerbated by the growing popularity of electric vehicles and heat pumps [3], which can often present high loads on a single-phase of a three-phase low-voltage distribution network. Many methods have been proposed to enable voltage support for low-voltage networks by providing/absorbing reactive power [2]. According to the National Grid codes [4,5], these methods all have local control to regulate the active and reactive power output of the device, which for example could be a DG or an electrical storage system, according to the local frequency and voltage, respectively.
As an example, Figs. 1 and 2 show typical voltage-reactive power and frequency-active power profiles, respectively. These can be applied to any device that can absorb or inject reactive and/or active power. The profile in Fig. 1 is centred on a nominal voltage (V nom ) of 400 V and once the measured voltage is outside of the deadband, the device will respond according to the profile. If the measured voltage is normally close to the nominal voltage, then the profile in Fig. 1 works well and commands the asset to either absorb or inject reactive power. If, however, large load variations occur on the network, then the local voltage will exhibit sustained or rapid changes away from the nominal value and the device may effectively saturate at 100% reactive power and so will be unable to support the local voltage. Similar considerations can be made for Fig. 2 where 50 Hz is the nominal frequency of the grid voltage in the UK. This paper presents both local voltage and frequency forecast techniques, which have been devised for use in low-voltage distribution grids, and evaluates their forecasting performance. The forecasters devised in this study use an artificial neural network (ANN)-based technique. ANNs can be considered as simplified mathematical models of brain-like systems. They function as parallel-distributed computing networks and can learn new associations, new functional dependencies, and new patterns [6]. In [7], an off-line ANN one minute ahead grid-voltage forecaster was trained using data from a RTDS simulated power network, and the maximum error of their forecaster was 3%.
Forecasting the voltage and the frequency of the grid is a key activity for a number of reasons. For example, the possibility to enable both the nominal voltage (and/or nominal frequency) and the gradient of the absorb/inject response of the profile is shown in Fig. 1 (and in Fig. 2) to be updated in real time based on the specific need of the distribution system operator (DSO) can enable the optimisation of the DGs management. Another application is the state of charge (SoC) optimisation of a BESS or of a group of BESS operating as a virtual power plant (VPP). The forecasted grid frequency acts as an input of an energy management system (EMS) that creates the profiles to be used as part of a wider active network management strategy, which is responsible for ensuring the security of supply for the DSOs low-voltage network. These applications are typical of the management of active distribution systems [8] where the variables are forecasted with 'long'-term horizons. Another important application, where the forecasted horizon is much shorter, is the control of distributed power systems where time delays can influence the stability of the systems and might degrade its performance [9]. In this case, statistical modelling techniques may be used to overcome time delays due, for example, to communication latencies [10].
The paper is organised as follows: Section 2 describes the design of the ANN-based forecasters, Section 3 reviews the results obtained in the study, and Section 4 presents the conclusions and gives an overview of potential areas for future work.

Implementation of the forecasters
The approach used in this research consists of recording data at a low-voltage grid connection, using the data to develop the voltage and frequency forecasters, and demonstrating the voltage and frequency forecaster on a practical system. The data sets used to develop the voltage and frequency forecast methods are recorded from the low-voltage (400 V) connection of the battery energy storage system (BESS) installed at The University of Manchester [11]. The dSPACE real-time controller, which provides an interface to the BESS, can record the voltage and the frequency of the grid at a fixed sample time up to 1 ms. This paper presents the development of two different types of ANN: one type is trained online during the real-time operation of the system and is based on an ANN called recurrent neural network (RNN), and this method is used to forecast the frequency of the grid one second ahead; the second one is trained using offline historical datasets and is a feed-forward neural network (FFNN), which can forecast both the frequency and the voltage one minute ahead. The RNN and FFNN have both been chosen because they can efficiently approximate any non-linear function and are widely used in the fields of control systems and forecasting.

Training datasets
The dataset used to train the ANN-based forecasters are of the following type: Z = (z 1 , z 2 , …, z n ), where Z is the time series of the variable being forecasted (so either voltage or frequency here), and n is the number of samples.
In the online ANN case, only frequency is being forecast, and the data used to train the frequency forecaster are logged every second in real time by the dSPACE system, and so the input and the output of the ANN are generated at the same instant in time and are continuously updated.
The offline ANN voltage and frequency forecasters are trained using two historical datasets, one for the frequency and one for the voltage, and so the input and the output of the ANN are generated at different instants in time. Fig. 3 shows the data used for the offline ANN voltage and frequency forecaster training which was logged every 500 ms in the dSPACE system between 2:46 p.m. on the 24th to 12 noon on the 30th May 2017. Before using it for the training of the ANNs, the data have been down-sampled obtaining n = 8,474 1-min samples.

ANN used in the study
The RNN used for the online forecasting of the grid frequency is an Elman Neural Network [12] and its general structure is shown in Fig. 4. The network consists of four layers: one neuron in the Input Layer (IL) corresponds to the frequency f(k) at time k, there are five neurons in the Context Layer (CL), five neurons in the Hidden Layer (HL), and one neuron in the Output Layer (OL) which corresponds to the forecasted grid frequency (at time k + 1). The weights of the neural network have been adapted online during the learning process using the adaptive interaction (AI) rule as described in [12,13].
The grid frequency f(k) at time instant k is scaled by the nominal value of grid frequency, f grid_nom , to form the input node to the IL. The IL transfers the input signal into the hidden layer so that the output of the node is [12]: The outputs of the hidden nodes are: where r and j vary in the range [1][2][3][4][5].
S j (2) is the sigmoid activation function so that the output of the jth hidden node is: where n j (2) is the activation degree of the jth node. The online adaptation is performed in the AI block in Fig. 4, and the network weights are calculated as [12]: )z (1) where w 1 j c is the weight between the input neuron and the j-th hidden node, Δw j (k − 1) = w j (k − 1) − w j (k − 2), e f is the frequency error, and μ is the learning rate.
The CL applies a unit delay to all five inputs, so: where z r (3) is the output of the rth node in the CL. The output of the OL is a linear transfer function (TF) described by the following relationship: where w j is the weight that connects the jth node of the HL to the output node, and w 0 is a bias term. Fig. 5 shows the general structure of the feed-forward neural network (FFNN) used for the offline forecasting of the voltage and the frequency. The input Z to the Input Layers (IL) of the two models correspond to the voltage V(t) and the frequency f(t) at the instant t, respectively, and the OL give as a results the voltage V(t + 1) and the frequency f(t + 1) that are the forecasted quantities one-minute ahead; both models have a single neuron in the IL and OL.
In this implementation, Z(t) is passed straight through the IL to the HL, which is formed by 12 neurons. The 'weights_1' block performs the dot product of 12 weight gain values with the input Z(t) to form 12 outputs, and these outputs are each summed with a separate bias value, contained in the one-dimensional array bias_1.
The 'tansig' block performs a hyperbolic tangent sigmoid TF. The outputs of the HL nodes are used as the inputs to the OL 'weights_2' block. The 'weights_2' block performs the dot product of the outputs of the HL outputs with a one-dimensional array containing 12 gain values, and the single output is summed with a single bias value, bias_2. The output of the sum block is passed to the TF block, which in this case is the 'tansig' or the 'purelin' function, to form the forecasted value Z(t + 1).
The two FFNN-based forecasters are trained offline using a scaled conjugate gradient algorithm (named 'trainscg') [14] run in a Matlab/Simulink environment.
The main features of the voltage and frequency FFNN are listed in Table 1.
The ANNs presented in this study have been developed using the Matlab Neural Network Toolbox™. The settings in Table 1 were determined with the goal of achieving a mean square error (MSE) of 10 × 10 −9 .

Analysis of the results
This section presents the comparison of the real quantities (voltages and frequencies) and those forecasted with the use of the developed ANNs described in Section 2. Fig. 6 shows the measured and forecasted frequencies for the one-second ahead, online ANN forecaster; the ANN was implemented in the dSPACE system and so trained in real time. Totally, 800 data samples are shown in the top plot in Fig. 6, which corresponds to 800 s, and the bottom plot shows a magnified view of the traces between 100 and 200 s. This test was performed between 08:51 a.m. and 09:04 a.m. on the 20th December 2017. The parameters of the online forecaster used in real time have been initialised by running the same structure of the RNN in an offline simulation.
Figs. 7 and 8 show the measured and forecasted frequencies and voltages, respectively, for the one-minute ahead, offline ANN trained forecasters. The ANNs are implemented in the dSPACE system and have been previously trained with the data presented in Section 2. The three plots show a good correlation between the forecasted and the measured quantities, both for the online and for the offlinetrained forecasters.
The performance of the three forecasters can also be described quantitatively, in terms of statistical errors. Table 1 lists the correlation coefficient r, the coefficient of determination R 2 , the root mean square error (RMSE), and the mean absolute percentage  The correlation coefficients, r, for all forecasters are higher than 0.85, which indicates their performance is very good, and enable the frequency and voltage to both be estimated with a reasonable accuracy. This is confirmed by the MAPE that is always significantly <0.2%.
The MAPE of both one-minute ahead offline trained forecasters in Table 2 is smaller than 0.15%, while the one-second ahead online trained forecaster performs even better showing a MAPE equal to 0.02%. The maximum absolute percentage errors for the offline forecasters are 0.5% and 1.5% for the frequency and the voltage, respectively.
The online forecasting is preferable to the offline due to its ability to modify its forecast overtime, this means if changes are made to the local distribution grid, or new load or generation systems are added, then the online forecaster will overtime adapt. The online technique is also preferable to the offline when there is insufficient data for the offline training (e.g. because of a lack of time for the collection).
With reference to the different time horizons (one second and one minute), the performance of the presented forecasters are comparable. For this reason, all of them can be used both for energy management applications and to overcome communication time delays in the control of power systems.

Conclusions and future works
In this work, three ANN-based techniques for the forecasting of the voltage and frequency of the low-voltage distribution grid have been presented. The forecasters have been tested in a dSPACE realtime system located within the battery energy storage facility installed at The University of Manchester.   The analytical expressions developed for the three forecasters have been evaluated experimentally, and good performance of the ANN-based models to forecast the voltage and the frequency of the grid, both one-second and one-minute ahead, has been demonstrated. The MAPE of the one-minute ahead forecasters is smaller than 0.15%, while the one-second ahead forecaster performs even better showing a MAPE equal to 0.02%.
The forecasters presented here can easily be implemented whether a data set of the variables to forecast is available (offline forecasting) or it is not (online forecasting) and avoids the need for any knowledge, or modelling of the distribution network.
Future work includes the forecasted grid frequencies and voltages being used within an EMS under development at The University of Manchester. In order to optimise the operations of the BESS that is part of this development, a future contribution concerns the realisation and the testing of a number of forecasters with different characteristics according to the specific application. In particular, the development of the forecasters will include: different type of training (online and offline), different time horizons (from hundreds of milliseconds to hours), and different lengths of the forecasted data sets.
Another future contribution concerns the development of some ANN-based techniques to overcome the problems due to the communication time delays occurring in distributed power systems. In this case, the forecasted grid frequencies and voltages will be used to compensate for the delay due to the communications between different control systems in order to guarantee the stability of the control loop of the BESS under study.

Acknowledgments
This work was supported by the UK Engineering and Physical Sciences Research Council (EPSRC) Multi-scale ANalysis for Facilities for Energy STorage (Manifest) project [EP/N032888/1]. A. Mellit would like to thank the International Centre for Theoretical Physics (ICTP), Trieste (Italy) for providing the materials and the computer facilities used to develop some parts of the work presented in the paper.