Voltage Optimization in MV Network with Distributed Generation Using Power Consumption Control in Electrolysis Installations

: Connecting a large number of distributed sources to the medium and low voltage grid poses many problems. The most important of these are the voltage changes inside the network, what can be observed when the power ﬂow from these sources towards the HV/MV (High Voltage/Medium Voltage) transformer station. In particular, if the power consumption in nodes of the MV network is small and the distance between the place of installation of the source and the substation is large, increases and changes in voltage may be dangerous for the insulation of the network and burdensome for the consumers connected to it. The solution most frequently used to control voltage increases is the appropriate setting of the controller that affects the on-load tap changer of the MV/HV or even MV/LV (Medium Voltage/Low Voltage) transformer. It is also possible to regulate the reactive power of the sources and, of course, to limit their generated active power (curtailment of generation). The development of energy storage technology has made it possible to introduce consumers into the network, whose power can be controlled in a wide range. The article proposes the concept of an innovative voltage control system in the MV network, whose output values are three groups of parameters: HV/MV transformer ratio, reactive power of sources and active power of consumers connected in generation nodes. In the technological sense, it has been assumed that the loads are installations of electrolyzers used to produce “green hydrogen”, according to the P2G (Power to Gas) formula. The tests consisting in the execution of several hundred calculation cycles for the IEEE 37 test network, using the Monte Carlo simulation, have shown that the subordination of the hydrogen production process to the objectives of voltage control in the MV network clearly contributes to stabilizing its value, while meeting the technological requirements. The control variables of the proposed control system are the result of the optimization algorithm described in the article, the function of which is the quality of network voltage.


Introduction
The large number of installations of renewable energy sources, connected to the MV and LV grids, are associated with various problems, which are particularly acute in periods of low power demand. If the power generated by distributed sources corresponded to the power consumed at the points of their connection, then the state of the grid would correspond to the normal state of load. However, the specificity of dispersed generation and the technologies used, is that the correlation between the power they produce and the general power demands is negligible. The power flow in the direction of HV/MV stations results in an effect known as "voltage rise". (or sometimes incorrectly as an "overvoltage"), which is the antonym of the voltage drop. Therefore, the voltage at the connection points of disperse sources, as well as at the connection points of receiving installations in their vicinity, may increase above the limit values. A number of works have been published which consider problems resulting from radical change in the characteristics of distribution in their vicinity, may increase above the limit values. A number of works have been published which consider problems resulting from radical change in the characteristics of distribution networks, so far regarded as typical (radial system of operation, unidirectional power flow) [1][2][3][4][5]. The variability of network operating conditions-related to load changes, changes of power generated in distributed sources, changes occurring in the HV network, may result in daily voltage fluctuations in a wide range. Of course, one cannot pass the blame for this voltage discomfort entirely on to dispersed sources, but it is certainly worthwhile to analyse what is their actual role in distorting the voltage profile of MV networks. If, under certain conditions, this role proves to be important, it is necessary to propose technical measures which can compensate for this negative impact. These measures are described in the literature [6,7]. In the research of the authors of the present article, attention has so far been focused on the possibility of using the capacity of dispersed sources to consume (or less frequently generate) reactive power [3]. At the same time, a great progress in energy storage technologies has been observed for several years, with P2G (power to gas) technologies playing the greatest role [8], and alkaline water electrolyzers (AEL) are considered to be the cheapest and easiest to access [9,10]. Thus, from the voltage control point of view, another executive element may be the active power loads, for which an increase or decrease in power consumption does not affect the continuity of the technological process of the consumption supplied by them. Such a process is the production of hydrogen in electrolyzers, especially if their construction in a modular form is considered. After making such an assumption, it was possible to propose an innovative system of voltage control in the MV network, in which, apart from the traditional tap control, there are dispersed sources consuming or generating reactive power and flexible loads subordinated also to the process of voltage control- Figure 1.  Illustration of the concept of the optimal voltage control system in a MV network with dispersed generation and electrolysis installations (P l1 , P l2 , . . . P lj -normal loads, P g1 , P g2 , P g3 , P g4 -active power generation, Q g1 , Q g2 , Q g3 , Q g4 -reactive power generation/consumption by RES, P 1 , P 2 , P 3 , P 4 -controllable loads, electrolyzers, U HV high voltage, U MV medium voltage, ϑ Tr -HV/MV transformer ratio).
The present article consists of six chapters. The first chapter contains an introduction to the subject of research and a justification of the advisability of introducing a new method of voltage control using electrolyzers. The second chapter presents a literature review on the integration of P2G systems with the power system. The third chapter contains the formulation of the optimization task and a description of the algorithm of its solution. The fourth chapter presents the IEEE 37 test network. The results of calculations showing the effectiveness of the proposed regulation system are included in the fifth chapter. Discussion of the results and conclusions are contained in the sixth chapter.
Part of the work devoted to this topic concerns the optimal size and deployment of P2G installations. In article [28], the authors present analyses concerning the optimal selection of electrolyzers size by minimizing hydrogen production costs. Maximization of profit from energy purchase and sale with simultaneous minimization of operating costs through the use of P2G technology is considered in article [29]. For the research, a 30 node IEEE 30 test network and actual historical data were used. Optimal size and distribution of electrolyzers is analyzed in paper [30]. The objective function included both the number of units and the place of their connection. An interesting analysis can be found in study [31], where the selection of the electrolyzers was considered as an alternative to network expansion. The actual distribution network was modelled and the possible size of the electrolyzers was examined in order to achieve the same effect as in the case of network modernization (e.g., cable replacement) to eliminate overloads. The results showed that the cable is now a more cost-effective option compared to installing an electrolyzers. According to the article, a cable investment is about 30% of the electrolyzer's costs. However, the profitability of an electrolyzer installation depends to a large extent on the excess power in the network. The steady decrease of unit costs of electrolyzers should also be kept in mind [32]. Article [22] focuses on reducing the constraints on wind power generation by using storage capacity. Greater capacity means more capacity to be produced from these sources. Energy storage may, thus, be used to increase the capacity installed in wind farms where this is economically justified, i.e., at a lower cost than the generation curtailment.
Some articles only discuss aspects of storing surplus energy from renewable sources and feeding it into the grid under conditions of higher demand [22,[33][34][35]. This is also possible using P2G technology, as evidenced by article [36]. Its approach is both to store surplus electricity from renewable sources and to use it later (feed-in) to flatten the load curve (peaks in demand). The problem was treated as a task of non-linear optimization with limitations. The aim of the analyses was to maximize the profit from the operation of such a system, as well as the possibility of optimal provision of voltage control services in the grid, both in high generation states and in high power demand.
The use of "flexible loads" technology for voltage control in the MV network is presented in article [37]. Particular attention is paid to the coordination of different ways of keeping the voltage within acceptable limits. Paper [38] reviews typical solutions for elimination of negative voltage effects in networks saturated with installations of renewable energy sources. The way of their assessment is presented and what should be followed, when choosing an appropriate method.
The subject of power losses appears in article [35], where it is proposed to create an optimal charging/discharging schedule for minimizing power losses. The authors claim that the proposed method can be used to analyze other problems such as voltage control, flattening of the load curve and improving reliability.
Similar considerations are also being carried out for low-voltage networks, where an increasing number of micro-installations are being connected. An example is work [39], which presents the possibility of implementing P2G systems to absorb surplus electricity from photovoltaic installations. The example of the southern region of Germany, which has a large capacity to generate power from such sources, has been analyzed by forecasting load and generation profiles for the period 2015-2025. In the context of the above review, the present article is characterized by a comprehensive approach to the regulation process, since as many as three types of decision-making variables are used, and at the same time, the technological process of hydrogen production is considered. The participation of electrolyzers in the process of regulating voltage and maintaining its quality may be treated as a commercial ancillary service for the benefit of the power system.
The authors are aware that the performance of OPF (Optimal Power Flow) calculations in practice requires a network computing model in real mode (in each calculation cycle). This is achieved using a state estimation process that is enabled by the voltage and power measurements. The subject of estimation and the impact of measurement accuracy on the results of power flows has been the subject of research, among others, in the works [40][41][42]. It seems that the implementation of the proposed voltage control system is possible due to the small size of the computational task, and thus-the short time of obtaining the calculation results, enabling the process of optimal voltage regulation in real time. Due to the fact that the state estimation was not the main subject of this article, the authors decided to discuss this problem further in subsequent publications.

Formulation of the Objective Function and Its Constrains
The purpose of voltage control presented in this article is not only to maintain the voltages in network nodes within the scope required by the regulations [43,44], i.e., between 0.9·U nMV and 1.1·U nMV , but also to equalize the voltage profile of the entire network. Supplying the receivers with a voltage of a different value than the nominal one affects the deterioration of their efficiency, durability and reliability. Therefore, one of the most important objectives of the control carried out in the distribution network is to keep the voltage as close as possible to the nominal value in all its nodes. It is not possible to precisely achieve this goal in every node of the network, due to changing loads and generation of active power and changes of voltage values on the HV side. The optimization process allows for its "best" practical implementation.
Therefore, the traditional standard of MV network operation consists in maintaining day and night value (set) of voltage on MV buses in a HV/MV station by changing the transformer taps under load. Such a state (in Polish conditions, two voltage settings are applied-day and night-within the range from 15.5 kV to 16.3 kV) does not, of course, guarantee optimal conditions of network operation or reaching the values of voltages close to the nominal one in all network nodes. The HV/MV power supply station generally consists of two transformers with 10-25 MVA each. Several to a dozen of MV lines are connected to the MV switchgear (usually 15 kV in Poland). Each line supplies at least a dozen or so MV/LV transformer stations- Figure 1. The total number of transformer stations supplied from one HV/MV power supply station is usually several dozen, often more than a hundred. Since, in most cases, the transformers in the station work on separate sections of the MV switchgear, the evaluation of the voltage quality is formulated in relation to the area supplied from one transformer. In such a network area, there appear objects of dispersed generation, whose influence on voltage conditions is significant. Sometimes these objects are planned to be connected in nodes of one MV line. Such an example is analyzed in the present article.
The parameter that characterizes the quality of the voltage supply to costumers in static conditions is the voltage deviation. As has already been stated, the most desirable value, from the point of view of operation and lifetime of the costumers, is the voltage close to the nominal one. Maintaining the voltage value within the acceptable range (±10% U n ) does not guarantee optimal operating conditions for the costumers. Due to the changing load of the network and voltage drops occurring, day or night setting on MV buses in HV/MV station (U MVs = const) also does not guarantee the operation of costumers in optimal voltage conditions. Therefore, various voltage quality indicators are introduced, allowing for global assessment of network voltage conditions and their optimization [2,4,6,[45][46][47].
The analyses carried out assume that the expected voltage value for all nodes of the MV network is 15.75 kV (1.05·U nMV ) and a quality indicator of the regulation process has been proposed, where: U o -expected voltage value in all network nodes equal to 1.05·U nMV . It was assumed that each state of the network depends on the value of the elements of three vectors-x, y, z. Their physical sense is presented below: Considering the objective function described above, together with the vectors x, y, z, the optimization task under consideration can be formulated as follows: • the vector of decision variables x providing the minimum function described by the relation (1) is sought: • the vector of inequality limits h, ensuring that the value of the vector elements of dependent variables and the vector of decision variables is maintained within the limits set by technical requirements: h(x, y, z) ≥ 0.
Inequality constrains were defined as follows: • minimum and maximum values for transformer ratio (ϑ). The transformer adopted for the calculation has 19 operating positions of the on-load tap changer, within ±9 (including the tap in the neutral position). • minimum and maximum reactive power values of each renewable source (Q GK ). It is assumed that each RES source has the ability to generate/absorb maximum reactive power equal to 0, 4, P nG , • minimum and maximum voltage values for all network nodes (U i ). The voltage was maintained in the range from 0.9 U nMV to 1.1 U nMV , which translates into voltage values from 13.5 kV to 16.5 kV, • the permissible current-carrying capacity values for sections of power lines (I lmax ). The value assumed in the calculations was I lmax = 290 A, • the permissible load of the transformer (S nT ). The calculations assume the transformer power S nT = 10 MVA.
The determination of the state vector z, for the known values of vectors x and y, is one of the basic computational problems included in the computer analysis of power systems. This problem, known as load flow analysis (LF), is described in textbooks, such as [48,49]. Many algorithms and computer programs have been developed to solve this problem. Generally speaking, the components of the unknown vector z (state variables) are determined from a system of nonlinear equations of the form: Each equation is formulated for a node of the analyzed network, so that the power balance for this node is equal to zero.
The nature of the issue under consideration is such that the determination of the elements of the state vector takes place through an iterative process. The decision variable vector consists of a discrete variable (transformer tap changer setting) and continuous variables (reactive power of sources, active power of electrolyzers). The use of the classical optimization method to solve the problem under consideration would be difficult to implement, so one of the heuristic methods was chosen, which is described in point 3.2.

Description of the Optimisation Algorithm
The task under consideration is known as OPF (Optimal Power Flow). In view of the difficulties with quick solution of OPF type tasks using methods similar to the classical ones [50][51][52][53], which have been found in the research and confirmed in many publications, attention was focused on the possibility of using an alternative method of solving problems of non-linear optimization, which is based on heuristics. Heuristic methods allow to solve various types of tasks that cannot be solved by classical methods or the application of these methods is too time-consuming and complicated in the software sense. Compared to classical methods, heuristic methods are characterized by the fact that they do not require knowledge of the derivative form of the objective function, they are resistant to discontinuities of this function and to "getting stuck" of the calculation process in the local minimum. In case of a divergent iterative process, the heuristics work in such a way that the flow data can be reloaded at any time during the calculation process. The best solution recently found is not lost, as this vector is remembered at every stage of the calculation. The classic method would then have to be interrupted and the calculation restarted. Moreover, heuristic methods can start from an unacceptable point (a penalty for exceeding the limits is then added).
Heuristic methods are currently used more and more often (not only in the power industry), as modern gradient-less methods to solve non-linear optimization tasks with limitations. They are constantly being developed, as evidenced by new publications [54][55][56][57][58]. Sources of inspiration in the development of new methods may be different. Solving optimization tasks, belonging to different fields of science and technology, does not require fundamental changes in algorithms. In particular, every objective function can be optimized without the need to check its continuity or differentiation. Due to the random nature of heuristic methods, there is a high probability of finding a global optimum.
The optimization method used in the research is called the Algorithm of the Innovative Gunner (AIG) [59]. It differs from other methods of generating new values of decision variables. Generally speaking, in most heuristic methods, the iterative process of determining new values of the vector components x is similar, because most often in the next iterative step an action [53,[60][61][62][63], is performed, which can be described as an additive modification, and the correction of the l-th component of the vector, in the i-th iterative step, is determined as a function value, ∆x whereby the f l function and the ξ vector are characteristic of the heuristic method used. In the case of the AIG algorithm, relation (5) is replaced by an expression: Therefore, the difference is that in the next steps the components of vector x change by multiplying (no by adding). The g l1 (ξ 1 ), g l2 (ξ 2 ) functions, providing that ξ 1 = α, ξ 2 = β, are assumed accordingly: where α and β are the "correction angles", drawn from the (−α max , α max ) and (−β max , β max ) range using a normal (or uniform) probability distribution. The block diagram of the AIG algorithm is shown in Figure 2 [59].
whereby the fl function and the ξ vector are characteristic of the heuristic method used.
In the case of the AIG algorithm, relation (5) is replaced by an expression: Therefore, the difference is that in the next steps the components of vector x change by multiplying (no by adding). The gl1 (ξ1), gl2 (ξ2) functions, providing that ξ1 = α, ξ2 = β, are assumed accordingly: where α and β are the "correction angles", drawn from the (−αmax, αmax) and (−βmax, βmax) range using a normal (or uniform) probability distribution. The block diagram of the AIG algorithm is shown in Figure 2 [59]. Given that in the AIG algorithm we are dealing with a population of new solutions, it is characterized by a large exploration of the search space. The subsequent solutions differ (sometimes quite significantly) from the previous ones, which allows to avoid local optimum. Its innovativeness results from a specific and original way of determining subsequent solutions in the iterative process, which distinguishes it from other heuristic methods. The presentation of the AIG algorithm and its properties was made by the authors in [59], and its effectiveness was widely studied in [53]. Given that in the AIG algorithm we are dealing with a population of new solutions, it is characterized by a large exploration of the search space. The subsequent solutions differ (sometimes quite significantly) from the previous ones, which allows to avoid local optimum. Its innovativeness results from a specific and original way of determining subsequent solutions in the iterative process, which distinguishes it from other heuristic methods. The presentation of the AIG algorithm and its properties was made by the authors in [59], and its effectiveness was widely studied in [53].
In order to solve problems in the field of power engineering an appropriate calculation workshop is necessary. The PowerWorld Simulator program, version 20, was used for calculations. This program is mainly used to calculate power flows in the power system. The software includes the SimAuto add-on, which enables connecting to external applica- tions (e.g., Matlab, Excel, Delphi). Notably, SimAuto acts as an interchangeable calculation engine that can be used in various applications. This article uses the Matlab environment, where a script is written that connects to SimAuto and calls the AIG algorithm. The course of the calculation is shown in Figure 3. The application is universal and can be used to solve various optimization issues. After running the main script in Matlab environment, there is a remote connection with the load flow program (PowerWorld Simulator) via SimAuto add-on. The change of parameters of the grid elements or the downloading of calculation results is carried out by means of appropriate commands, suitable for the respective development environment. When the AIG algorithm is started, optimization calculations follow, after which the results are saved in a file. In order to solve problems in the field of power engineering an appropriate calculation workshop is necessary. The PowerWorld Simulator program, version 20, was used for calculations. This program is mainly used to calculate power flows in the power system. The software includes the SimAuto add-on, which enables connecting to external applications (e.g., Matlab, Excel, Delphi). Notably, SimAuto acts as an interchangeable calculation engine that can be used in various applications. This article uses the Matlab environment, where a script is written that connects to SimAuto and calls the AIG algorithm. The course of the calculation is shown in Figure 3. The application is universal and can be used to solve various optimization issues. After running the main script in Matlab environment, there is a remote connection with the load flow program (PowerWorld Simulator) via SimAuto add-on. The change of parameters of the grid elements or the downloading of calculation results is carried out by means of appropriate commands, suitable for the respective development environment. When the AIG algorithm is started, optimization calculations follow, after which the results are saved in a file.

Description of the Test Network
For the analyses, the IEEE 37 [64], network was used, whose parameters were adjusted to the MV network, typical of Polish conditions. It was assumed that the total length of individual sections of the 15 kV overhead line with branches is 40 km. The line is made with ACSR 70 mm 2 conductors- Figure 4. There is a transformer with a power of 10 MVA and a ratio ϑ = 115/16.5 kV/kV ± 10% (taps every 1.11%). There are five sources connected to the lines with power ratings of PnG1 = 0.5 MW, PnG2 = 0.5 MW, PnG3 = 2.0 MW, PnG4 = 1.0 MW, and PnG5 = 2.0 MW, respectively. Each source has the capacity to generate reactive power in the range (-0.4, 0.4)PnG and this power is remotely controlled in the system shown in Figure 1.
The network load includes MV/LV transformer stations connected in almost all nodes (the total number of nodes is m = 37), with the exception of nodes 0, 10, 16, 25, 29 and 34 ( Figure 4). In the mentioned nodes (except node 0), electrolyzer installations are connected (marked in green). For electrolyzer installations, the rated power was not determined so that their power demand would result from control needs. The use of ALEtype electrolyzer properties and modular construction of the installation allow for power

Description of the Test Network
For the analyses, the IEEE 37 [64], network was used, whose parameters were adjusted to the MV network, typical of Polish conditions. It was assumed that the total length of individual sections of the 15 kV overhead line with branches is 40 km. The line is made with ACSR 70 mm 2 conductors- Figure 4. There is a transformer with a power of 10 MVA and a ratio ϑ = 115/16.5 kV/kV ± 10% (taps every 1.11%). There are five sources connected to the lines with power ratings of P nG1 = 0.5 MW, P nG2 = 0.5 MW, P nG3 = 2.0 MW, P nG4 = 1.0 MW, and P nG5 = 2.0 MW, respectively. Each source has the capacity to generate reactive power in the range (−0.4, 0.4)P nG and this power is remotely controlled in the system shown in Figure 1.
The network load includes MV/LV transformer stations connected in almost all nodes (the total number of nodes is m = 37), with the exception of nodes 0, 10, 16, 25, 29 and 34 ( Figure 4). In the mentioned nodes (except node 0), electrolyzer installations are connected (marked in green). For electrolyzer installations, the rated power was not determined so that their power demand would result from control needs. The use of ALE-type electrolyzer properties and modular construction of the installation allow for power changes in the range from zero to the nominal value (unspecified in these tests), in the remote control system shown in Figure 1. The maximum load of individual nodes is shown in Figure 5d. changes in the range from zero to the nominal value (unspecified in these tests), in the remote control system shown in Figure 1. The maximum load of individual nodes is shown in Figure 5d. As mentioned above, the original IEEE 37 [64] network was adjusted to the parameters of the MV network, which is a standard solution in the Polish power system.
A single solution of the voltage control optimisation task would not allow for a reliable analysis of the problem under consideration due to the variability of operating conditions of the test network examined (changes of HV voltage, load power and power generated in distributed sources). Therefore, it was decided to repeat the calculations many times (five hundred calculation cycles) for different operating conditions of the MV network. Being aware of the fact that individual variables may be subject to different probability distributions, it was decided that their values should be randomised using a random number generator with rectangular distribution. In this way, the authors wanted to take into account all possible cases of mutual numerical relations between the quantities influencing the network. This will happen when every value of independent variables is equally probable, with no correlation between their values. Voltage values on the 110 kV (UHV) side were drawn from 0.9·UnHV to 1.1·UnHV, which corresponds to a voltage between 99 kV and 121 kV. The load in MV network nodes was drawn in the range from 30% to 100% of maximum load, shown in Figure 5d. The power generated in RES was drawn in the range from 0 to PnGK. Figure 5a presents the values of UHV voltage for a cycle of five hundred draws, Figure  5b presents the drawn values of the power generated in RES, and Figure 5c presents the total value of the power received in the receiving nodes resulting from the draws. The maximum values of the power absorbed at individual MV/LV stations range from 30 kW to 330 kW. The total load on the grid (without electrolyzers) ranges from 2.32 MW to 3.41 MW. It is clear that the maximum value of the power consumed in the grid is lower than the maximum power that can be generated from renewable sources. Therefore, periods can be expected when power flows towards the HV/MV transformer station. Such a state of operation is associated with the effect of voltage increase and the possibility of reaching a value higher than allowed, in MV nodes. Then electrolyzer installations should fulfil their task. Excess power from renewable sources should be absorbed by them and in this way the voltage problem will be eliminated. The cooperation of electrolyzers with RES' will allow not only to maintain the values of voltage within the acceptable range, but also a value higher than allowed, in MV nodes. Then electrolyzer installations should fulfil their task. Excess power from renewable sources should be absorbed by them and in this way the voltage problem will be eliminated. The cooperation of electrolyzers with RES' will allow not only to maintain the values of voltage within the acceptable range, but also to achieve their optimal value from the point of view of the quality indicator, defined by formula (1). As indicated by simulation analyses made in order to optimize (concentrate) the values of voltages in all network nodes near the value of 1.05 UnMV, the variation of reactive power of the sources and active electrolyzers, resulting from optimal voltage regulation, is a much more complex process than the qualitative description presented above.

Results of Voltage Optimization in MV Networks
Optimization calculations were performed using a single-criteria target function, described by Equation (1), defining the voltage quality indicator. The optimization process is aimed not only at keeping the voltage values in MV network nodes within acceptable limits, but also at equalising the voltage profile, i.e., concentrating the voltage values in all nodes around 1.05·UnMV. The calculations were performed for five hundred network operating states by random change of voltage on the HV side of the transformer, drawing the value of active power generated in each of the five RESs and load in all MV/LV transformer stations. The calculations considered the state with traditional control carried out by OLTC (voltage on MV buses maintained at the level of 1.05 UnMV), taking into account simultaneous control of RES reactive power and active power of electrolyzer installations (full optimization) and without the participation of these installations (OLTC only and reactive power-partial optimization). Figure 6a-c show the values of voltages corresponding to the above-mentioned control methods (before and after optimization-full, and partial optimization, respectively), for all, five hundred random network operation states. Due to the generation in RESs, As mentioned above, the original IEEE 37 [64] network was adjusted to the parameters of the MV network, which is a standard solution in the Polish power system.
A single solution of the voltage control optimisation task would not allow for a reliable analysis of the problem under consideration due to the variability of operating conditions of the test network examined (changes of HV voltage, load power and power generated in distributed sources). Therefore, it was decided to repeat the calculations many times (five hundred calculation cycles) for different operating conditions of the MV network. Being aware of the fact that individual variables may be subject to different probability distributions, it was decided that their values should be randomised using a random number generator with rectangular distribution. In this way, the authors wanted to take into account all possible cases of mutual numerical relations between the quantities influencing the network. This will happen when every value of independent variables is equally probable, with no correlation between their values. Voltage values on the 110 kV (U HV ) side were drawn from 0.9·U nHV to 1.1·U nHV , which corresponds to a voltage between 99 kV and 121 kV. The load in MV network nodes was drawn in the range from 30% to 100% of maximum load, shown in Figure 5d. The power generated in RES was drawn in the range from 0 to P nGK . Figure 5a presents the values of U HV voltage for a cycle of five hundred draws, Figure 5b presents the drawn values of the power generated in RES, and Figure 5c presents the total value of the power received in the receiving nodes resulting from the draws. The maximum values of the power absorbed at individual MV/LV stations range from 30 kW to 330 kW. The total load on the grid (without electrolyzers) ranges from 2.32 MW to 3.41 MW. It is clear that the maximum value of the power consumed in the grid is lower than the maximum power that can be generated from renewable sources. Therefore, periods can be expected when power flows towards the HV/MV transformer station. Such a state of operation is associated with the effect of voltage increase and the possibility of reaching a value higher than allowed, in MV nodes. Then electrolyzer installations should fulfil their task. Excess power from renewable sources should be absorbed by them and in this way the voltage problem will be eliminated. The cooperation of electrolyzers with RES' will allow not only to maintain the values of voltage within the acceptable range, but also to achieve their optimal value from the point of view of the quality indicator, defined by Formula (1). As indicated by simulation analyses made in order to optimize (concentrate) the values of voltages in all network nodes near the value of 1.05 U nMV , the variation of reactive power of the sources and active electrolyzers, resulting from optimal voltage regulation, is a much more complex process than the qualitative description presented above.

Results of Voltage Optimization in MV Networks
Optimization calculations were performed using a single-criteria target function, described by Equation (1), defining the voltage quality indicator. The optimization process is aimed not only at keeping the voltage values in MV network nodes within acceptable limits, but also at equalising the voltage profile, i.e., concentrating the voltage values in all nodes around 1.05·U nMV . The calculations were performed for five hundred network operating states by random change of voltage on the HV side of the transformer, drawing the value of active power generated in each of the five RESs and load in all MV/LV transformer stations. The calculations considered the state with traditional control carried out by OLTC (voltage on MV buses maintained at the level of 1.05 U nMV ), taking into account simultaneous control of RES reactive power and active power of electrolyzer installations (full optimization) and without the participation of these installations (OLTC only and reactive power-partial optimization). Figure 6a-c show the values of voltages corresponding to the above-mentioned control methods (before and after optimization-full, and partial optimization, respectively), for all, five hundred random network operation states. Due to the generation in RESs, which in some cases exceeds the total load of the grid, the values of the voltages in the state before optimization (Figure 6a), in some states exceed the permissible range. Even a qualitative assessment of the "ribbon" that forms the lines corresponding to the individual calculation cycles clearly indicates a reduction in its area and a change in its shape, the greatest for full optimization, a little less for partial optimization. The maximum value of the voltage quality indicator before optimization was 0.055691, and its average value was 0.009135, while after optimization (in a system with electrolyzers- Figure 6b), in each state of the network, the control system "tries" to keep the voltage close to the expected value, i.e., 1.05 U nMV . The voltage quality indicator in each case improves several times in relation to the state before optimization- Figure 7a. The maximum value of the voltage quality indicator after full optimization was 0.001708 and its average value was 0.000417. Thus, after optimization, the average value of the voltage quality indicator decreased more than twenty-one times (for the vertical axis calibrated as in Figure 7a, the values of the voltage quality indicator are very small and not very visible-brown colour). For comparison, similar calculations were made for partial optimization status (OLTC only and reactive power of RES). The maximum value of the voltage quality indicator was 0.004984 and its average value was 0.00065. Thus, after the optimisation, the average value of the voltage quality indicator decreased fourteen times. Figure 7c compares the effects of full and partial optimisation. It can be clearly seen that the lack of installation of electrolyzers affects the deterioration of the voltage profile of MV network, thus, it should be considered that the active power of the installation ALE contributes significantly to the quality of the voltage control process. The average value of power losses in the analysed network also decreased-from 42.1 kW to 29.25 kW (in an optimised system with electrolyzers). This is important because the value of power losses was not part of the minimised objective function. Although globally the power losses decreased, states could be observed where they were slightly higher than before optimization- Figure 7b. For comparison, analogous calculations were also made for conditions without electrolyzers. The average power losses increased to 76 kW. In some cases, they were larger than the pre-optimization condition- Figure 7d. Thus, power control of loads has a significant impact on the reduction of power losses in the grid.
state of the network, the control system "tries" to keep the voltage close to the expected value, i.e., 1.05 UnMV. The voltage quality indicator in each case improves several times in relation to the state before optimization- Figure 7a. The maximum value of the voltage quality indicator after full optimization was 0.001708 and its average value was 0.000417. Thus, after optimization, the average value of the voltage quality indicator decreased more than twenty-one times (for the vertical axis calibrated as in Figure 7a, the values of the voltage quality indicator are very small and not very visible-brown colour). For comparison, similar calculations were made for partial optimization status (OLTC only and reactive power of RES). The maximum value of the voltage quality indicator was 0.004984 and its average value was 0.00065. Thus, after the optimisation, the average value of the voltage quality indicator decreased fourteen times. Figure 7c compares the effects of full and partial optimisation. It can be clearly seen that the lack of installation of electrolyzers affects the deterioration of the voltage profile of MV network, thus, it should be considered that the active power of the installation ALE contributes significantly to the quality of the voltage control process. The average value of power losses in the analysed network also decreased-from 42.1 kW to 29.25 kW (in an optimised system with electrolyzers). This is important because the value of power losses was not part of the minimised objective function. Although globally the power losses decreased, states could be observed where they were slightly higher than before optimization- Figure 7b. For comparison, analogous calculations were also made for conditions without electrolyzers. The average power losses increased to 76 kW. In some cases, they were larger than the pre-optimization condition- Figure 7d. Thus, power control of loads has a significant impact on the reduction of power losses in the grid.    Figure 8d-partial optimization). For a significant number of cases the optimal position of the on-load tap-changer is equal to −9. The generators with the highest power (G3 and G5) either generate reactive power more often (G3) or, as in the case of (G5), consume reactive power more often, which can be justified by their position in the network (G5 lies far from the HV/MV station). Both of these observations indicate an aspiration to maintain the voltage in the network at 1.05 Un, despite significant power consumption (active and reactive). In the state without the installation of electrolyzers (partial optimization), maximum reactive power is more often consumed, which proves the need to reduce the voltage values. This case is also a proof that the power generated in RE sources (exceeding the power consumed) flows in the direction of HV/MV stations, which causes an increase in the voltage value in the network nodes. In a system with full optimization the changes in reactive power are smaller, which (as noted above) reduces power losses.   Figure 8d-partial optimization). For a significant number of cases the optimal position of the on-load tap-changer is equal to −9. The generators with the highest power (G3 and G5) either generate reactive power more often (G3) or, as in the case of (G5), consume reactive power more often, which can be justified by their position in the network (G5 lies far from the HV/MV station). Both of these observations indicate an aspiration to maintain the voltage in the network at 1.05 Un, despite significant power consumption (active and reactive). In the state without the installation of electrolyzers (partial optimization), maximum reactive power is more often consumed, which proves the need to reduce the voltage values. This case is also a proof that the power generated in RE sources (exceeding the power consumed) flows in the direction of HV/MV stations, which causes an increase in the voltage value in the network nodes. In a system with full optimization the changes in reactive power are smaller, which (as noted above) reduces power losses.   Figure 8d-partial optimization). For a significant number of cases the optimal position of the on-load tap-changer is equal to −9. The generators with the highest power (G3 and G5) either generate reactive power more often (G3) or, as in the case of (G5), consume reactive power more often, which can be justified by their position in the network (G5 lies far from the HV/MV station). Both of these observations indicate an aspiration to maintain the voltage in the network at 1.05 U n , despite significant power consumption (active and reactive). In the state without the installation of electrolyzers (partial optimization), maximum reactive power is more often consumed, which proves the need to reduce the voltage values. This case is also a proof that the power generated in RE sources (exceeding the power consumed) flows in the direction of HV/MV stations, which causes an increase in the voltage value in the network nodes. In a system with full optimization the changes in reactive power are smaller, which (as noted above) reduces power losses. fectively. The test network used for the calculation, which includes both variable voltage values on the HV side, load with changing values and random generation in renewable sources, justifies the advisability of using heuristic optimization methods. In the future, connecting an increasing number of RES with variable generation to the medium and low voltage grid, will require the use of more and more advanced optimization algorithms authorising the use of the term smart grid for these networks.   It is also characteristic that the closer the source is connected to the HV/MV station, the lower the power consumed by electrolyzers. It is caused by the fact that the closer to the station, the smaller the voltage impact of the sources in the grid. Therefore, the power consumed by electrolyzer installations is also relatively lower, provided that this power consumption is fully subordinated to control objectives. In this way, it is possible to control voltage problems in the radial network, in which the sources connected in the depths have the greatest influence on the effect of voltage increase. In the classic approach, the active power of the sources should be limited, which would result in financial losses as a result of lost benefits from unsold electricity. Figure 10 shows the total power generated in dispersed sources and the total power consumed by electrolyzer installations. As can be seen, the relationship between these capacities is difficult to explain intuitively and qualitatively. They result from the optimization process, which even for a relatively small size of the task generates values which can only be verified by checking the value of the target function, i.e., indicator (1).
This chapter presents the results of calculations performed mainly with the AIG algorithm. Additionally, for comparison and verification, Figure 11 shows the course of the optimization process, also according to another heuristic algorithms-cuckoo search (CS- [65]) and moth-flame optimization (MFO- [63]). Tables 1-3 show the optimization results for one random state, also for the AIG, CS and MFO algorithms.
The graphs show that practically fifty iterations are sufficient to find the optimal solution (also for the use of CS and MFO algorithms), so the optimization process runs effectively. The test network used for the calculation, which includes both variable voltage values on the HV side, load with changing values and random generation in renewable sources, justifies the advisability of using heuristic optimization methods. In the future, connecting an increasing number of RES with variable generation to the medium and low voltage grid, will require the use of more and more advanced optimization algorithms authorising the use of the term smart grid for these networks.   Tables 1-3 show the calculation results for three optimization algorithms (AIG, CS and MFO), for one calculation cycle, randomly selected from among five hundred tested cases. The voltage value drawn on the HV side was 1.0358 p.u. It should be noted that although the obtained objective function values for all three algorithms are very similar (Table 3), the values of individual decision variables differ. This is due to the heuristic optimization property, in which probabilistic plays an important role and the final evaluation of the algorithm used results from multiple repetition of calculation cycles.    Tables 1-3 show the calculation results for three optimization algorithms (AIG, CS and MFO), for one calculation cycle, randomly selected from among five hundred tested cases. The voltage value drawn on the HV side was 1.0358 p.u. It should be noted that although the obtained objective function values for all three algorithms are very similar (Table 3), the values of individual decision variables differ. This is due to the heuristic optimization property, in which probabilistic plays an important role and the final evaluation of the algorithm used results from multiple repetition of calculation cycles.   Tables 1-3 show the calculation results for three optimization algorithms (AIG, CS and MFO), for one calculation cycle, randomly selected from among five hundred tested cases. The voltage value drawn on the HV side was 1.0358 p.u. It should be noted that although the obtained objective function values for all three algorithms are very similar (Table 3), the values of individual decision variables differ. This is due to the heuristic optimization property, in which probabilistic plays an important role and the final evaluation of the algorithm used results from multiple repetition of calculation cycles.
The computational tests described above were performed with the assumption that the values of the real independent variables are accurately mapped in the computational process. This is of course not the case, as transmission errors may affect the values of these variables used in the calculations. Although the issues of the state estimation and accuracy of measurement data were beyond the main scope of the presented article, an initial test of the algorithm's resistance to measurement errors of independent variables was performed. For this purpose, from among five hundred calculation cases, case number 168 was selected at random.  Treating it as a reference case, fifty additional draws of all independent variables were made (voltage values in the HV node, power received in nodes and active powers of renewable sources). For each independent variable from case 168 taken as the mean value µ of the normal distribution with standard deviation equal to σ = 1%, its measurement representation was drawn. Therefore, the independent variables taken for the optimization calculations came in the range from 0.97 to 1.03 in relation to the reference value, which can be considered a pessimistic estimation of the transmission accuracy. Figure 12 shows the values of the voltage quality index (determined by the relation (1) The computational tests described above were performed with the assumption that the values of the real independent variables are accurately mapped in the computational process. This is of course not the case, as transmission errors may affect the values of these variables used in the calculations. Although the issues of the state estimation and accuracy of measurement data were beyond the main scope of the presented article, an initial test of the algorithm's resistance to measurement errors of independent variables was performed. For this purpose, from among five hundred calculation cases, case number 168 was selected at random.
Treating it as a reference case, fifty additional draws of all independent variables were made (voltage values in the HV node, power received in nodes and active powers of renewable sources). For each independent variable from case 168 taken as the mean value μ of the normal distribution with standard deviation equal to σ = 1%, its measurement representation was drawn. Therefore, the independent variables taken for the optimization calculations came in the range from 0.97 to 1.03 in relation to the reference value, which can be considered a pessimistic estimation of the transmission accuracy. Figure 12 shows the values of the voltage quality index (determined by the relation (1)) for three calculation variants: • without optimization, for a reference case (straight line, blue color); • after optimization, for the reference case, assuming an exact mapping of independent variables in the calculations (straight line, green color); • after optimization, for fifty subcases of inaccurate transmission of the values of the independent variables, with respect to the reference case. On the basis of the obtained results, it can be concluded that although the mapping errors of the independent variables noticeably deteriorate the value of the voltage quality index, its improvement is still very clear compared to the case without optimization.

Discussion and Conclusions
This article draws attention to the negative voltage impact of a large number of distributed sources connected to the medium voltage grid. Their location at different points on MV lines and the possibility of maximum generation during off-peak hours may lead to voltage variations over a wide range. Sometimes the voltages reach values beyond the acceptable range, which is unfavourable for costumers. Elimination of negative voltage phenomena coming from RES' is possible thanks to dedicated and autonomous management and control systems. An example of such a solution has been shown in the article- On the basis of the obtained results, it can be concluded that although the mapping errors of the independent variables noticeably deteriorate the value of the voltage quality index, its improvement is still very clear compared to the case without optimization.

Discussion and Conclusions
This article draws attention to the negative voltage impact of a large number of distributed sources connected to the medium voltage grid. Their location at different points on MV lines and the possibility of maximum generation during off-peak hours may lead to voltage variations over a wide range. Sometimes the voltages reach values beyond the acceptable range, which is unfavourable for costumers. Elimination of negative voltage phenomena coming from RES' is possible thanks to dedicated and autonomous management and control systems. An example of such a solution has been shown in the article-mastering too large voltage changes is possible not only by means of classic HV/MV transformer ratio control, but also by means of power consumption control of flexible loads and simultaneous use of the RES possibilities in the scope of reactive power generation or consumption. It has been shown that the application of the installation of electrolyzers in the MV network has a positive impact not only on the optimum voltage values, from the point of view of the applied quality indicator, but also on the reduction of power losses. This is understandable, because the excess power generated in renewable sources is consumed locally, as a result of connecting electrolyzers.
Thus, the opinion about the beneficial impact of the consumption subordinate to remote control (and such may include modular electrolyzers) has been confirmed for the network model under consideration, corresponding to the actual networks.
The new concept of control will not only allow to maintain the voltage value in MV network nodes to the extent required by the regulations, but will also ensure the minimum (i.e., optimal) value of a dedicated indicator of its quality. This has been proven in the calculations performed and described. A significant improvement of the voltage quality index (defined by relation (1)) was found, as well as a visible alignment of the voltage profile, which justifies the advisability of seeking new solutions in the field of voltage control in MV networks, taking into account distributed generation.
The originality of the proposed solution lies in the use of as many as three types of control variables (OLTC tap changer, reactive powers of distributed sources and active powers of selected loads). The effects of the control clearly show the synergy of their joint action in accordance with the original heuristic algorithm for minimization of the objective function. Despite the relatively small number of control variables, the effect of their operation giving a very large improvement in voltage quality would not be possible to obtain intuitively. The authors consider this effect to be the greatest achievement of the article, although they argue that the practical implementation of the proposed system still requires solving a number of engineering problems.
The process of optimal voltage control can take place on condition that the actual network is correctly mapped in the optimization process. The creation of a calculation model involves the estimation of the state of MV networks, which is possible due to the current and voltage measurements performed. The radial structure of the network, a small number of nodes, reduces the calculation complexity of this problem, compared to multi-node closed HV networks. It seems that the implementation of the proposed voltage control system is possible in practice, due to the small size of the calculation task and, consequently, the short time of obtaining results, enabling the process of optimal control in real time.