Novel Improved Adaptive Neuro-Fuzzy Control of Inverter and Supervisory Energy Management System of a Microgrid

: In this paper, energy management and control of a microgrid is developed through supervisor and adaptive neuro-fuzzy wavelet-based control controllers considering real weather patterns and load variations. The supervisory control is applied to the entire microgrid using lower–top level arrangements. The top-level generates the control signals considering the weather data patterns and load conditions, while the lower level controls the energy sources and power converters. The adaptive neuro-fuzzy wavelet-based controller is applied to the inverter. The new proposed wavelet-based controller improves the operation of the proposed microgrid as a result of the excellent localized characteristics of the wavelets. Simulations and comparison with other existing intelligent controllers, such as neuro-fuzzy controllers and fuzzy logic controllers, and classical PID controllers are used to present the improvements of the microgrid in terms of the power transfer, inverter output e ﬃ ciency, load voltage frequency, and dynamic response.


Introduction
Distributed generation (DG) systems based on renewable energy sources (RES), such as solar, wind, biomass, and hydropower, which are increasing steadily across the globe, are important in the generation of clean energy. In DG, energy conversion systems are placed near to the end consumers and large units are replaced with smaller ones. DG enables lower active power losses and operational costs, increased operational performance, and increased energy efficiency of the power system. Power system regulators are turning towards RES-based DG systems, along with the conventional centralized generation systems [1].
In DG and microgrid systems, one of the most critical parts is the inverter, because of its extensive range of functions [2]. Their operation is standardized by many international industrial standards and The rest of this research work is arranged as follows. The structure and control of the microgrid is given in Section 2. In Section 3, the supervisory algorithm is discussed. Section 4 provides the results and a comparison with the other existing intelligent and classical controllers. Finally, Section 5 draws the conclusions of this research. Figure 1 illustrates the general structure of the proposed microgrid under analysis. It consists of a PV array, UC, and battery storage system. The PV array is capable of generating 261 kW under variable weather patterns and the UC/battery storage system are integrated for backup during excess power demand and as an energy storage system for surplus power. A DC-DC boost converter connects the PV array to the inverter. Similarly, two non-isolated buck boost converters connect the UC/battery to the DC bus, followed by the inverter. The inverter is controlled using a new wavelet-based adaptive controller. The adaptive-based controlled inverter is then coupled to the AC link at the grid and load. Energy management, power sharing, and transferring among PV, UC, and the battery with the rest of the microgrid are performed via energy management and supervisory control system (EMSCS).

Control of PV
The power of PV varies according to the weather patterns; therefore, its output is controlled by using an incremental conductance (IC) maximum power point tracking (MPPT) method, and is then regulated via a DC-DC boost converter, as illustrated in Figure 2. In PV, the optimal terminal voltage is determined by minimizing the MPPT error, which is shown as "e" in Figure 2, which is determined on a P/V curve through the IC method. The boost converter is controlled using PID controllers through the control of the duty cycle.

Control of Ultra-Capacitor/Battery
Both the UC and battery are controlled through PIDs embedded in DC-DC buck-boost converters. The boost mode permits power flow from the UC and/or battery to the DC during power demand bus, and the buck mode is utilized to charge the UC and/or battery from the DC bus during surplus power. Another advantage of the UC/battery is to regulate the DC bus voltage during abrupt weather variations and load changes. The control diagrams of the UC and battery are illustrated in  The power of PV varies according to the weather patterns; therefore, its output is controlled by using an incremental conductance (IC) maximum power point tracking (MPPT) method, and is then regulated via a DC-DC boost converter, as illustrated in Figure 2. In PV, the optimal terminal voltage is determined by minimizing the MPPT error, which is shown as "e" in Figure 2, which is determined on a P/V curve through the IC method. The boost converter is controlled using PID controllers through the control of the duty cycle.

Control of Ultra-capacitor/Battery
Both the UC and battery are controlled through PIDs embedded in DC-DC buck-boost converters. The boost mode permits power flow from the UC and/or battery to the DC during power demand bus, and the buck mode is utilized to charge the UC and/or battery from the DC bus during surplus power. Another advantage of the UC/battery is to regulate the DC bus voltage during abrupt weather variations and load changes. The control diagrams of the UC and battery are illustrated in Figures 3 and 4, respectively.

Control of Ultra-capacitor/Battery
Both the UC and battery are controlled through PIDs embedded in DC-DC buck-boost converters. The boost mode permits power flow from the UC and/or battery to the DC during power demand bus, and the buck mode is utilized to charge the UC and/or battery from the DC bus during surplus power. Another advantage of the UC/battery is to regulate the DC bus voltage during abrupt weather variations and load changes. The control diagrams of the UC and battery are illustrated in Figures 3 and 4, respectively.

Control of Inverter
Inverters are critical for injecting power from the DG or microgrid into the grid or grid-coupled load.
The control law for the proposed problem is written as follows: where P and Q stand for the active and reactive powers, respectively. According to the control law, the amount of P and Q injected into the load and grid from the inverter must be done according to

Control of Inverter
Inverters are critical for injecting power from the DG or microgrid into the grid or grid-coupled load. The control law for the proposed problem is written as follows: subjected to : (1) where P and Q stand for the active and reactive powers, respectively. According to the control law, the amount of P and Q injected into the load and grid from the inverter must be done according to the desired powers defined to the controller, provided that the maximum efficiency (η) is obtained while keeping the power quality constraints, i.e., THD and frequency (f), according to the IEEE standards [3][4][5]. The value of the power quality constraints must be kept smaller in order to reduce the power losses in the system. In this work, the inverter was controlled through two adaptive neuro-fuzzy Jacobi wavelet (ANFJW)-based controllers-one controller used for controlling the active power, and another for controlling the reactive power delivered by the inverter to the grid. During operation, both the P and Q generated by the plant (microgrid) were compared with the references for P and Q. These differences were provided to the respective ANFJW controllers. Both ANFJW controllers operated on the difference and generated the corresponding reference currents (id* for active power and iq* for reactive power). Finally, the inverter switching commands/signals were generated using hysteresis current control method as shown in Figure 5.   It combines the numbers of the input variables, and are then transferred to the next layer by the nodes from the first layer, which is written as follows: Each controller was modelled in seven layers, as shown in Figure 6. The first three layers formed the antecedent part, and the next four layers formed the consequent part of the ANFJW controller. The number of inputs in the first layer was equivalent to the n number of nodes, which were used for further distribution as inputs.

First Layer:
It combines the numbers of the input variables, and are then transferred to the next layer by the nodes from the first layer, which is written as follows:  First Layer: It combines the numbers of the input variables, and are then transferred to the next layer by the nodes from the first layer, which is written as follows: where i = 1, 2, . . . , m and k stands for the number of nodes and iteration, respectively.

Second Layer:
In this layer, the fuzzy system receives the linguistic terms and their degree of membership of each input. The Gaussian membership function (GMF) is used for computing the linguistic terms of each input.
where m ij and σ ij denote the center and variance of GMF, respectively.
Third Layer: In this layer, the product of membership function is performed, where the M in operator is used to find the output value.
Fourth Layer: The Jacobi wavelet function is used in this layer, which is written as follows: here,x = N 4 i , where the input of this layer is N 4 i (k) = ψ α+β nq (N 4 i ), and the output of this layer is written as follows: Energies 2020, 13, 4721 8 of 20 The main objective is to reduce the error between the reference power and desire power. The proposed controller works on the error, e, which is the difference between the reference power and desire power, as illustrated in Figure 7. The proposed control strategy processes the error, and it is written as follows: Fifth Layer: In this layer, the output of the antecedent and consequents parts is multiplied, and then added for each input.
Sixth Layer: The summation of rules (third layer output) is performed in this layer.
Seven Layer: In this layer, the output of ANFJW is calculated as follows: This output is used in the duty cycle to generate the control commands to the switches of the inverter.
Seven Layer: In this layer, the output of ANFJW is calculated as follows: This output is used in the duty cycle to generate the control commands to the switches of the inverter. Below, it is explained how the parameters of ANFJW controller are updated. The output of the proposed controller is given as follows: and the objective function to be minimized is given as follows: The parameters to be updated are the following: These parameters are updated online through the gradient back propagation method. The Below, it is explained how the parameters of ANFJW controller are updated. The output of the proposed controller is given as follows: and the objective function to be minimized is given as follows: Energies 2020, 13, 4721 9 of 20 The parameters to be updated are the following: These parameters are updated online through the gradient back propagation method. The gradient-based update equations are given as follows: where e = y d − y Now, for simplification, ∂y ∂u inv = 1, and ∂u inv ∂ξ is evaluated using the chain rule. The updated equations are written as follows: By calculating the partial derivative for the individual parameters, it is obtained as follows: Energies 2020, 13, 4721 So, Equation (31) becomes: Similarly, Using the values of Equations (20), (33), and (34) in Equations (25)-(27), the following final updated equations are obtained.

Energy Management and Supervisory Control System
A supervisory control approach was designed to provide the required power demand during the day and after sunset by using the proposed algorithm, as illustrated in Figure 8.
The proposed supervisory control system controls the subsystems (PV, UC, battery, and power converters), as well as the whole microgrid. According to the implemented algorithm, the net load demand must be satisfied from the generation of the PV array. If PV cannot satisfy the net demand, then battery bank will supply the remaining power, if its charge level is sufficient, i.e., above 20% (state 1). If the PV and battery bank cannot provide the total demand, then the remaining power will be taken from the SC if its charge level is above 20% (state 2), followed by the utility grid (state 3). Similarly, if PV generates more power than the demand, the remaining power will be used to charge the battery and then the SC, if their states of charges are below 90% (state 4 and state 5). If the battery and SC are charged, then the remaining power will be transferred to the public grid (state 6). The proposed supervisory control system controls the subsystems (PV, UC, battery, and power converters), as well as the whole microgrid. According to the implemented algorithm, the net load demand must be satisfied from the generation of the PV array. If PV cannot satisfy the net demand, then battery bank will supply the remaining power, if its charge level is sufficient, i.e., above 20% (state 1). If the PV and battery bank cannot provide the total demand, then the remaining power will be taken from the SC if its charge level is above 20% (state 2), followed by the utility grid (state 3). Similarly, if PV generates more power than the demand, the remaining power will be used to charge the battery and then the SC, if their states of charges are below 90% (state 4 and state 5). If the battery and SC are charged, then the remaining power will be transferred to the public grid (state 6).
The EMSCS layer power provides the required control signals to the power converters connected to the inputs/outputs of the components used in the microgrid. The descriptions of the parameters are defined in Table 1.
The working of the algorithm is discussed as below.
1. All of the control signals are generated, i.e., PPV, PG, PL, PB, PU, SB, and SU. 2. Check P L = P PV ± P G ± P U ± P B , go to 1 if this condition is true, and if not then follow next step. 3. Check PL>P PV , if it is true, go to step 9, and if not then check the next condition. 4. Check SB >20%, if it is true, then discharge the battery, and go to next step, otherwise go to step 2. 5. Check the condition P L − P PV − P B > 0, if this is true, then go to the next step, otherwise go to step 6. 6. Check SU>20%, if it is true, then discharge the UC, and go to the next step, otherwise go to step 8. 7. Check the condition P L − P PV − P B − P U > 0, if it is true, then go to the next step, otherwise go to step 1. The EMSCS layer power provides the required control signals to the power converters connected to the inputs/outputs of the components used in the microgrid. The descriptions of the parameters are defined in Table 1. The working of the algorithm is discussed as below.

1.
All of the control signals are generated, i.e., P PV , P G , P L , P B , P U , S B , and S U .

2.
Check P L = P PV ± P G ± P U ± P B , go to 1 if this condition is true, and if not then follow next step.

3.
Check P L > P PV , if it is true, go to step 9, and if not then check the next condition.

4.
Check S B > 20%, if it is true, then discharge the battery, and go to next step, otherwise go to step 2.

5.
Check the condition P L − P PV − P B > 0, if this is true, then go to the next step, otherwise go to step 6. 6.
Check S U > 20%, if it is true, then discharge the UC, and go to the next step, otherwise go to step 8. 7.
Check the condition P L − P PV − P B − P U > 0, if it is true, then go to the next step, otherwise go to step 1. 8.
Using all of the remaining deficient power reference to the grid and go to step 1. 9.
Check S B > 90%, if it is not true, then charge the battery and go to the next step, otherwise go to step 11. 10. Check the condition P L − P PV − P B < 0, if true, then go to the next step, otherwise go to step 1. 11. Check S U > 90%, if it is not true, then charge the UC and go to the next step, otherwise go to step 13. 12. Check the condition P L − P PV − P B − P U < 0, if true, then go to the next step, otherwise step 1. 13. Provide all of the net surplus power to the utility grid and go to step 1.

Simulations
The proposed microgrid was simulated for a complete full day under real weather patterns, i.e., ambient temperature ( • C) and solar irradiance (W/m 2 ), taken at Islamabad, Pakistan. Both parameters were recorded on an hourly basis, as presented in Figure 9. The intensity of irradiance fluctuated during the day, depending on the sunrise and sunset. From Figure 9, the sun appeared at 07:00 a.m. and set at 17:20 p.m. The average solar irradiance during the daytime was 990 (W/m 2 ). Likewise, the average temperature during the daytime reached 40 • C, while at night, it went down to 19 • C.

13.
12. Check the condition P L − P PV − P B − P U < 0, if true, then go to the next step, otherwise step 1. 13. Provide all of the net surplus power to the utility grid and go to step 1.

Simulations
The proposed microgrid was simulated for a complete full day under real weather patterns, i.e., ambient temperature (°C) and solar irradiance (W/m 2 ), taken at Islamabad, Pakistan. Both parameters were recorded on an hourly basis, as presented in Figure 9. The intensity of irradiance fluctuated during the day, depending on the sunrise and sunset. From Figure 9, the sun appeared at 07:00 a.m. and set at 17:20 p.m. The average solar irradiance during the daytime was 990 (W/m 2 ). Likewise, the average temperature during the daytime reached 40 °C, while at night, it went down to 19 °C.   Figure 10 illustrates the power generated by the PV (denoted as violet), battery (denoted as red) main inverter (denoted as dark goldenrod), UC (denoted as light green), utility grid (denoted as black), and total demand (denoted as light blue). In order to explain Figure 10, it is divided into six states, as indicated in the flow chart ( Figure 8). From t = 00:00 to 07:10 a.m., the PV output power was zero because of the nonappearance of sun irradiance. The overall demand was applied on the battery system. During this interval, the proposed EMSCS checked the state of charge (SoC) of the battery, and as its SoC was greater than 20%, the battery provided the required net power (around 150 kW). The battery SoC was reduced to 68%, as shown in Figure 11. The EMSCS was operating in state 1. At t = 07:10 to 09:00 a.m., the PV system started producing power, but it was still not enough to overcome the demand. Meanwhile, the output power of the PV started to increase. At the end of the interval, the PV and battery provided 90 kW each with the battery SoC at 62%. The EMSCS was still operating in state 1. At t = 09:00 to 09:48 a.m., because of the slow response time of the battery, the cumulative power supply (battery (52 kW) + PV system (179 kW)) exceeded the power demand (198 kW). Therefore, the UC started charging using 33 kW of power when the SoC went from to 84% from 73%, and the EMSCS was shifted to state 5.
3. At t = 14:40 to 17:36 p.m., the PV output power started decreasing because of the evening time. The battery could fulfil the power deficiency and kept the EMSCS in state 1. At t =17:36 to 18:15 p.m., the battery, UC, and grid station provided backup to the microgrid because of the deficient power. The EMSCS shifted between states 1, 2, and 3. Whereas at t= 18:15 to 24:00 p.m., with no PV power and also because of the non-peak hours, the grid and battery fulfilled the load demand, and the battery SoC dropped to 21%. In this interval, the EMSCS moved between states 1 and 3. The operating states for 24 hours are shown in Figure 12. In this manner, the power exchange and sharing among PV, battery, UC, utility grid, and domestic load happened for 24 hours under EMSCS.   For better power quality and power flow from the DC link to the rest of the system, the inverter was controlled via ANFJW controllers. The results of the proposed ANFJW controllers were compared with the existing intelligent controllers, such as NFC and fuzzy logic controller (FLC), as well as the classical controller (i.e., PID), using the same weather and load conditions. Figure 13 shows the performance of the inverter (active power) for the different controllers in terms of power transfer. At t = 09:48 to 11:30 a.m., the PV not only provided sufficient power to the load, but also charged the battery and UC. In this interval, the EMSCS was in states 4 and 5. At t = 11:30 to 11:39 a.m., 12:10 to 13:27 p.m., and 14:03 to 14:40 p.m., the PV output power suddenly dropped due to partially clouded conditions. In this crucial time, the UC assisted the microgrid and fulfilled the power gap with slight support from the grid station. In this interval, the EMSCS rapidly shifted to states 2 and 3. At t = 14:40 to 17:36 p.m., the PV output power started decreasing because of the evening time. The battery could fulfil the power deficiency and kept the EMSCS in state 1. At t =17:36 to 18:15 p.m., the battery, UC, and grid station provided backup to the microgrid because of the deficient power. The EMSCS shifted between states 1, 2, and 3. Whereas at t= 18:15 to 24:00 p.m., with no PV power and also because of the non-peak hours, the grid and battery fulfilled the load demand, and the battery SoC dropped to 21%. In this interval, the EMSCS moved between states 1 and 3. The operating states for 24 h are shown in Figure 12. In this manner, the power exchange and sharing among PV, battery, UC, utility grid, and domestic load happened for 24 h under EMSCS.
For better power quality and power flow from the DC link to the rest of the system, the inverter was controlled via ANFJW controllers. The results of the proposed ANFJW controllers were compared with the existing intelligent controllers, such as NFC and fuzzy logic controller (FLC), as well as the classical controller (i.e., PID), using the same weather and load conditions. Figure 13 shows the performance of the inverter (active power) for the different controllers in terms of power transfer. The load condition had two peaks of 275 kW and 307 kW at t = 11:00 a.m. and 21:00 p.m., respectively. The zoomed figures show the performance of the difference controllers in detail. It can be clearly noticed from the zoomed figures (Figure 13) that the proposed controller, ANFJW (denoted as red), and reference signal (donated as dashed-blue) superimposed each other, while the other controllers also tried to track the reference signal, but were unable to because of overshoots. Similarly, Figure 14 gives the performance of the inverter in terms of the reactive power transfer. For instance, from the zoomed portion (i.e., at 04:45 to 04:48 a.m.) in Figure 14, the proposed controller tracked the reference power very quickly, while the other controllers took some time with the overshoots. The same performance can also be seen at 19:57 to 20:03 p.m. in the zoomed portion. Hence, the proposed ANFJW controllers show a better performance at different intervals for both real and reactive power transfer.  For better power quality and power flow from the DC link to the rest of the system, the inverter was controlled via ANFJW controllers. The results of the proposed ANFJW controllers were compared with the existing intelligent controllers, such as NFC and fuzzy logic controller (FLC), as well as the classical controller (i.e., PID), using the same weather and load conditions. Figure 13 shows the performance of the inverter (active power) for the different controllers in terms of power transfer. The load condition had two peaks of 275 kW and 307 kW at t = 11:00 a.m. and 21:00 p.m., respectively. The zoomed figures show the performance of the difference controllers in detail. It can be clearly noticed from the zoomed figures ( Figure 13) that the proposed controller, ANFJW (denoted as red), and reference signal (donated as dashed-blue) superimposed each other, while the other controllers also tried to track the reference signal, but were unable to because of overshoots. Similarly, Figure 14 gives the performance of the inverter in terms of the reactive power transfer. For instance, from the zoomed portion (i.e., at 04:45 to 04:48 a.m.) in Figure 14, the proposed controller tracked the reference power very quickly, while the other controllers took some time with the overshoots. The same performance can also be seen at 19:57 to 20:03 p.m. in the zoomed portion. Hence, the proposed ANFJW controllers show a better performance at different intervals for both real and reactive power transfer. Furthermore, the power quality analyses in terms of the THD and frequency of all of controllers was performed and are illustrated in Figures 15 and 16, respectively. According to IEEE standards, the standard limits for frequency and THD are ±0.8% and 5%, respectively. In this work, the operating load voltage RMS and frequency were 440 V and 50 Hz, respectively. The THD shown in Figure 15 is small with the proposed controller, which is around 2.37%. Similarly, the change in frequency was below 0.02%, as it can be seen at different intervals in the zoomed windows in Figure 16.    Furthermore, the power quality analyses in terms of the THD and frequency of all of controllers was performed and are illustrated in Figures 15 and 16, respectively. According to IEEE standards, the standard limits for frequency and THD are ± 0.8% and 5%, respectively. In this work, the operating load voltage RMS and frequency were 440 V and 50 Hz, respectively. The THD shown in Figure 15 is small with the proposed controller, which is around 2.37%. Similarly, the change in frequency was below 0.02%, as it can be seen at different intervals in the zoomed windows in Figure  16.  To show further better the performance, the efficiency of the inverter for all controllers using Equation (1) was calculated for 24 h and is shown in Figure 17. The real and reactive power transfer efficiencies of the inverter with the ANFJW controllers was greater, i.e., 99.05% and 99.08%, followed by NFC, FLC, and then PID.
For further analysis, the dynamic performance of all of the controllers through the index  To show further better the performance, the efficiency of the inverter for all controllers using Equation (1) was calculated for 24 h and is shown in Figure 17. The real and reactive power transfer efficiencies of the inverter with the ANFJW controllers was greater, i.e., 99.05% and 99.08%, followed by NFC, FLC, and then PID.
For further analysis, the dynamic performance of all of the controllers through the index parameters, i.e., integral absolute error (IAE), integral square error (ISE), integral time absolute error To show further better the performance, the efficiency of the inverter for all controllers using Equation (1) was calculated for 24 h and is shown in Figure 17. The real and reactive power transfer   For further analysis, the dynamic performance of all of the controllers through the index parameters, i.e., integral absolute error (IAE), integral square error (ISE), integral time absolute error (ITAE), integral time square error (ITSE), and mean relative error (MRE), under the same operating conditions, were calculated using Equations (38)-(41) for active power, and using Equations (42)-(45) for reactive power, and are illustrated in Figures 18 and 19, respectively. All of the index parameters were much smaller in the case of the proposed controller, which showed a superior dynamic performance. All of the comparisons are summarized in Table 2.

Conclusions
This paper presented a novel improved adaptive NFC of inverter and supervisory energy management of a microgrid. The improvement in the existing NFC was performed by the integration

Conclusions
This paper presented a novel improved adaptive NFC of inverter and supervisory energy management of a microgrid. The improvement in the existing NFC was performed by the integration of the Jacobi wavelet. Because of the excellent time-localized behavior of the Jacobi wavelet, the proposed controller did not stop in the first local minima, but it searched for the optimal minima. This yielded excellent results in terms of power transfer, inverter output efficiency, and load voltage frequency. The EMSCS controlled the individual components as well as the entire system to ensure the following: (1) maximize output power, (2) appropriate sharing of UC/battery power and energy sources, and (3) continuity of power for a 24 h power supply with reliability and lessening the differences in output power under unfavorable weather conditions and inadequate storage.