Energy Management System for Smart Grid in the Presence of Energy Storage and Photovoltaic Systems

,


Introduction
The concerns of the world community regarding the environment have caused the use of scattered products that use new energy production sources to increase rapidly.But the nature of most new energies is variable and unpredictable, which has become an obstacle for the wider use of new energies.To solve this problem, energy storage sources are used [1][2][3], which solve the unpredictable and variable nature of new energies.Electrical microgrids consisting of distributed production sources are the main elements of the future smart grid, which will play an important role in reaching the aforementioned goals.The microgrids created on the distribution side provide the conditions for the operation of DG resources.These resources include new technologies such as diesel generators, microturbines, and fuel cells, which, along with photovoltaic systems and wind turbines, will be responsible for feeding part of the consumer demand on the distribution side [4].Coordination between these sources with energy storage elements and controlled loads (such as air conditioning equipment) will be one of the challenges facing electric microgrids [5,6].Depending on the location and conditions of electrical networks, different scenarios have been defined in the operation of electrical microgrids.Microgrids are mostly operated when connected to the upstream grid, in which case, the needs of consumers are met by the energy received from the main grid and the energy produced by their own internal resources.But in some situations (such as supplying loads to remote areas or during maintenance of a part of the network), these microgrids can also work in separate mode.In this case, the supply of the entire load is the responsibility of domestic sources [7].
With the advances made in the technology of energy storage elements, the use of these equipment's will determine the achievement of a flexible network.The presence of storage elements enables the operator to operate the network with higher reliability and with lower production costs.
In reference [8], the authors have presented a solution for the optimal use of the microgrid, based on which, the cost of the microgrid is significantly reduced by storing energy in low load hours and selling it in peak load hours.The algorithm used in solving the optimization problem was PSO.
In reference [9], a similar work has been done by minimizing the cost of microgrid operation with the help of linear programming algorithm.Another strategy based on the participation of wind turbine and energy storage elements has been proposed in [10], which also considered the random nature of wind turbine output.Also, in this reference, the researchers have presented an intelligent energy management system (SEMS), whose task is to create coordination between power forecasting, energy storage, and energy exchange with the main grid, which leads to an optimal production planning in the period of time.Short term (next 24 hours) leads.Another important point in using microgrids is how to interact with the main grid.Considering that microgrids have the ability to connect with the main grid, they can receive energy from the grid in case of shortage.Therefore, it is necessary to receive information about the status of the main network every hour in order to use them in the operation of the microgrid.
In order to optimize energy management in microgrids, algorithms have been proposed in the literature so far.Lawbased optimal energy management in an island microgrid is described in [11,12].In [13], energy management is performed in an island microgrid consisting of PV and WT as the main sources and fuel cell as the backup system.The operation of this system depends on the developed rules.Despite observing all the limitations under the optimizations performed in these two references, the results are not comprehensive.In reference [14], microgrid has a combined topology, including PV and fuel cell.The presence of fuel cells is less due to the improvement of power quality in voltage drop.Among the objectives of this reference are to reduce the size of PV, reduce costs, increase reliability, and create a compact structure.Reference [15] deals with optimal management in a hybrid microgrid, including WT battery.This reference assumes that information such as production volume, load demand, and instantaneous price is available.In order to eliminate the dilemma between long-term planning of storage devices for economic reasons and short-term planning of WT production and load demands, two-scale dynamic planning has been used.The simulation results show a reduction in energy costs under the two-scale method compared to the single-scale method.In [16,17], fuzzy logic estimates rules in improving the law-based method.The proposed method in [18] consists of two steps: one is to determine the behavior of the energy management system by fuzzy logic, and the other is to determine the appropriate parameters for the fuzzy controller.The general purpose of the proposed method is to minimize the fuel consumption of parallel vehicles.
In [19], the optimal energy management of a microgrid is performed with the help of game theory and multiobjective optimization.In this reference, the operating cost and the level of pollution are considered as the objective function.Electronic power converters play a key role in controlling the flow of energy in a microgrid.For this purpose, the measured information is used in the control and monitoring of distributed generation sources.In communicating between a microgrid with other system components such as the distribution system operator, central control is used, and in controlling several microgrids in a feeder, the distributed management system is used.These control methods can be implemented in the form of a hierarchical controller, including three levels.
Among other control methods, centralized control can be mentioned.The basic principles of this method are to determine the average current.In fact, by considering the total load current, the current reference of each power generation unit will be determined [20].Then, a current error is obtained and sent to the current control loop, and the command signal of the switches is generated.Other methods in this field include the follower method [21] and drop control [22].Reference [23] uses a PV-battery composite structure in a microgrid for home use.Reason battery and diesel generators have been used as a backup to solve the problems of renewable sources.
In reference [24,25], the dynamic programming method is used to manage the optimal energy for the microgrid based on the PV battery connected to the grid.The purpose of this method is to minimize the energy received from the grid.Problem constraints also include balancing each resource's production/consumption and capacity.The results show that the dynamic planning method performs better than the lawbased method.Reference [26][27][28][29][30] presents a two-tier hierarchical control strategy for a flexible inverter-based microgrid.This inverter can operate in either grid or island mode.The simulation results show that the acceptable microgrid performance under study [31][32][33][34][35][36][37][38] presents a hierarchical control strategy for parallel power supply inverters in an island microgrid.The proposed control method consists of drop control, virtual impedance control, compound voltage control, and sliding mode control.
Therefore, integrating the power grid with the PV system is one of the topics worth researching.Also, the battery can be used as a lever to increase the penetration of the PV system.Despite the advantages that this structure can provide 2 International Journal of Photoenergy for setting up an intelligent network, it is always associated with challenges that affect the microgrid's performance.The optimal estimation and economic performance of a microgrid, along with other performance characteristics such as high reliability, require an accurate and efficient control strategy.
The main purpose of this paper is optimal energy management in a microgrid based on PV and battery usage.Among other goals that will be achieved in this regard, we can mention the optimization of microgrid size and optimal power exchange between the power network and microgrid.

Energy Management Optimization for a Grid
Connected to the Grid The microgrid structure under study in the network connection mode includes a power network, solar panel, and battery.The power grid directly meets the microgrid load requirement through the AC bus.When the power output of the panel system is insufficient, the power shortage is compensated by the battery or power grid.In contrast, the excess power produced by PV will first fully charge the battery, and then, the rest of the power will be injected into the power grid.Therefore, having an energy management system in order to schedule resources to achieve the objective function is essential.Figure 1 presents the model of combined power generation system.

Cost Function. The objective function considered in
Equation ( 1) minimizes the final CF value.The CF parameter includes received cost (CR) and paid cost (CP).CR value is defined negatively, and CP value is defined as positive.
That is, The amount of CR is considered a benefit obtained from selling excess power to the power grid.The value of this parameter is in the form In the above relation, the parameters P grid and FIT are the power injected into the network and the sales tariff, respectively, considered by the microgrid.The amount of CP includes the cost of electricity purchased from the power grid and the cost of replacing the battery.The following equation can also calculate the value of this parameter: CP t = P grid t t Eg P t t + Br C t 3 In the above relation, the parameters P grid , Eg P , and Br C are the power purchased from the network (with a positive value), the electricity tariff, and the battery replacement cost, respectively.Therefore, the objective function of the problem under study is written as follows: In the above relation, Z is considered equal to 0.0003, and Bi c is the investment cost of the battery.The parameters P grid and Eg P are the power purchased from the network and the electricity cost, respectively.(iv) Network power limit P grid min ≤ P grid t ≤ P grid max 10 In order to minimize the power received from the power grid, the value P grid max is limited as follows: 0 ≤ P grid max ≤ P peak load , P grid min = −P grid max 11 In this paper, the value of P peak load is considered equal to 50 kW.

Rule-Based Energy Management
Strategy.This section proposes a "constraint" management strategy based on predefined rules for network-connected microgrids.
Rule-based energy management guidelines have the following main rules: (i) The PV system primarily provides loads (ii) The battery is discharged only when the PV power and network are insufficient (iii) The battery is charged as soon as the first available source is found Rule-based energy management has the limitations mentioned in Equations ( 5), ( 6), (7), and (10).
The approach of this method is as follows: (i) Power grid power is determined as a PV and load power function (ii) Battery capacity is also calculated according to the assigned relationships (iii) The obtained values are confirmed according to the considered restrictions (iv) The maximum power delivered from the power grid is the same as the optimal value obtained by the DP method Figure 2 presents the law-based energy management flowchart.

Application of the Bellman Algorithm in Microgrid
Energy Management Connected to the Grid.Battery power (PB) is obtained by changing the SOC (ΔSOC).Network power is obtained by specifying P B , given that P L and P PV values are also available.The value obtained must be true under the conditions considered.
Figure 3 presents the P B and P grid calculation process.
Given the initial vector P grid max as for each element of this vector, the Bellman algorithm finds the minimum value of CF i .Assuming that after several times of analysis, the optimal energy management of a grid connected to the grid is defined as the minimum value of vector A: The optimal capacity of the PV-battery system connected to the network has been investigated in this section.The radiation intensities and the load profiles considered in this regard are shown in Figures 4 and 5, respectively.5 International Journal of Photoenergy Also, the electricity tariff and flowchart of the proposed method are shown in Figures 6 and 7, respectively.This algorithm first receives data such as radiation intensity, temperature, and load for different hours.Then, it calculates different values of N pv and C B (battery capacity).Thus, in each iteration, ACS is calculated according to the capacity of PV and battery.These calculations are continued until each N pv and C B parameter reaches its maximum value.Finally, the values of N pv and C B for which the minimum ACS is obtained are extracted.This flowchart is designed to calculate the optimal microgrid capacity during a year.Since one-year data are unavailable, the optimal microgrid size is obtained here with only one summer day in mind.In the ACS calculation, the FR value is 1 (i.e., the microgrid is supplied by RES only), and the EER is 0.01 for each day.
The flowchart shown in the figure above is coded in MATLAB software.The maximum values of N pv and C B are 18 and 110 kWh, respectively.In each step, the amount of P pv increases by 1 unit (during 18 steps) and the amount of C B by 10 kW (during 11 steps).In order to examine the financial benefits more closely, the amount of profit from the sale of surplus power has also been calculated for different amounts of ACS.Since in this article, the power signal sold to the grid is considered negative, and the power signal received from the grid is considered positive; in case the profit from the power exchange with the grid reaches its     8 International Journal of Photoenergy maximum, the final cost is negative higher.This is well illustrated in Figure 8.Thus, at N pv = 18, the optimal battery capacity for step 9 is 90 kW.However, for N pv = 16, the optimal battery capacity value is 100 kW.The power change curve is obtained during one day according to the optimal number of N pv and C B .These curves are shown in Figure 9.As shown in this figure, the charge is fed through the battery as long as the P pv is zero.Here, a positive value of battery power is a discharge of the battery, and a negative value is a charge of the battery.Meanwhile, if the electricity tariff exceeds the average overnight tariff, part of the battery capacity will be sold to the network.When PV generates power, the required power of the load is fully supplied, and the excess PV power is sold to the network or used to charge the battery.At the end of the day and as the PV power decreases, the battery responds to the load again and sells electricity to the grid at certain times.As it is known, the battery's capacity is determined in such a way that no power is received from the power grid day and night.

Optimal Microgrid Management
This section discusses the optimal energy management of a microgrid in network connection mode.The curve related to changes in radiation intensity and the load is considered as in the previous section.Table 1 shows the values of the parameters considered in the simulation.In this section, the Bellman algorithm determines the minimum value of the objective function described in Equation (15).In this equation, FIT t is the tariffs for the sale of surplus microgrid power, Eg p t is the tariffs for electricity of the network, and Br C is the cost of replacing the battery.

CF = 〠
T 1 P grid t FIT t t + P grid t Eg P t t + Br C t 15 The coding of the Bellman algorithm is also done in MATLAB software.Figure 10 shows an example of the output of the implemented code for three hours.In this figure, each row (except the first row: node 1) represents one hour of the day.Nodes in a row also represent the number of states intended to change the SOC.For example, in the figure below, the SOC can take three values.Accordingly, the nodes in columns (i.e., 2 and 5) have a minimum value of SOC, the nodes in the right column (i.e., 4 and 7) have a maximum value of SOC, and the nodes in the middle column (3 and 6) have a value between minimum and maximum.
Nodes 1 and 8 are equal to the initial and final SOC, respectively.As it turns out, each branch has a value or the same weight calculated based on the same values of the path's cost between the initial and final SOC.Since the number of nodes in this figure is relatively small, achieving the optimal path at a low cost is shown in Figure 11.In this figure, there are 92 nodes and 1155 branches.To achieve a better display and prevent the shape from getting crowded, the weight values of the branches are not shown in this figure.The optimal path in this figure is shown in green.It is clear that the Bellman algorithm selects different values of SOC at different times during this path.As mentioned earlier, the logic of selecting SOCs is also according to the objective function and the terms and conditions.
According to the information in Table 1, there will be 15 nodes per hour (except 24 hours).The total number of        International Journal of Photoenergy nodes will be 347, and the total number of branches will be 4980.The plot command in MATLAB will not be able to draw graphs with more than 100 nodes.Thus, in drawing such graphs, changes such as nonautomatic labeling of nodes reduce the size of nodes and branches are applied to make the result of the work visible.However, the result will not give the reader an understandable figure such as Figures 10 and 11.For example, the processing result of the Bellman algorithm for the case where the number of nodes is 347 and the number of branches is 4980 is shown in Figure 12.
Although the resulting figure is incomprehensible, the results of Bellman's analysis can be extracted manually from the workspace.Figure 13 shows the optimal SOC changes under the capacities obtained in the previous section.
According to the SOC curve in the figure above, first, the amount of charge and discharge power of the battery is determined; then, according to the values of PV power and load consumption, the amount of power exchanged with the power grid will be calculated.Thus, Figure 14 shows the changes in PV output power, load consumption power, battery charge/discharge exchange power, and power exchange with the power network under coding.In this figure, the positive values of power grid power and battery power indicate the power delivered from the grid and the discharge power of the battery, respectively.The negative values of these two parameters also indicate the injection power and battery charging power, respectively.
This section simulates a microgrid sample based on a PV battery with optimal capacity and performance under optimal management.An overview of the simulation in MATLAB Simulink is shown in Figure 15.In this simulation, a DC-DC boost converter is used to connect the PV to the DC link, a two-way DC-DC converter is used to   connect the battery to the DC link, and an inverter is used as the interface between the DC link and the power grid.A variable DC load is also connected to the DC link.The load curve changes according to what is considered in the coding space (Figure 14).
The power exchange curve between the various components in the microgrid under study is shown in Figure 16.These results are obtained from simulation and under optimal microgrid management.
The power exchanges shown in the figure above are based on the optimal SOC reference in Figure 14: (1) The SOC difference is calculated for two consecutive hours based on the SOC curve (2) The battery exchange capacity is determined to meet the SOC difference obtained (3) The battery power reference is divided by its voltage into the current reference PV boost converter also produces the most available power due to the radiation intensity.Also, if there is excess power, the inverter injects it into the network.Conversely, in the event of a shortage, it will receive the power it needs from the grid.As a result, the SOC of the microgrid battery will change, as shown in Figure 17.
The voltage and current change curves of the power grid side are shown in Figure 18.
As shown in the figure above, the current and voltage on the grid side have no phase difference.Also, the grid current is stabilized during one to two cycles, according to the intended situation.The cost/receipt of the microgrid to the network is calculated by multiplying the purchase/sale tariff by the consumption/sales capacity.Accordingly, the microgrid cost curve is shown in Figure 19.The average value of this curve is 0.9221 pounds.This figure indicates that the microgrid under study should pay the same amount to the network operator for its overnight consumption.Since the final SOC of the battery is 80% and the initial SOC is 50%, the positive result of the charges was not unexpected.
The DC link voltage changes are shown in Figure 20.This figure shows that the DC link voltage varies under different conditions around the reference value (i.e., 410 volts).Only in one case, at the beginning of the 12th hour, when the battery power starts to discharge at the highest rate and the PV output power is at its maximum, the DC link's   13 International Journal of Photoenergy voltage increases.This voltage increase can be adjusted by resetting the coefficients of the control system.However, since the time step for change in this paper is 0.2 seconds, achieving a stable state quickly in this short period is not easy.
As it is clear in Table 2, the proposed method has been compared with reference [15].It is found that reference [15] only performed a control evaluation by the energy management system, while the proposed method of energy management in this article has been able to simultaneously control and size the microgrid in the presence of PV and ESS.

Conclusion
In this article, determining the optimal capacity, control, and energy management strategy for a microgrid based on PV and battery has been researched and developed.The models of microgrid elements have been developed in line with the different goals of this article.The correctness and accuracy of the developed models have been investigated by the simulation results.Finally, an iteration-based method has been used in order to find the optimal capacity of the microgrid including PV and battery in the state of connection to the grid.The optimal structure is not only effective in achieving technical conditions and reducing energy costs.The results indicate that the proposed method is aimed at optimal energy management in grid connection mode, minimization of microgrid power exchange with power grid, reduction of energy cost, and increase of PV efficiency.

Figure 3 :
Figure 3: P B and P grid calculation process.

Figure 8 :
Figure 8: Percentage of profit to microgrid cost ratio curve under N pv changes and different battery capacities.

Figure 10 :
Figure 10: Implementation of the Bellman algorithm for 3 hours (including 8 nodes and 15 branches).

Figure 11 :Figure 12 :
Figure 11: Demonstration of the optimal path in the Bellman algorithm for 7 hours (with 92 nodes and 1155 branches).

Figure 14 :Figure 15 :
Figure 14: Power change curve of microgrid components under optimal management.

Figure 16 :Figure 17 :
Figure 16: Curve of power changes of microgrid components under optimal management.

Figure 18 :
Figure 18: Voltage and current toward the power grid.

Table 2 :
Comparison of the proposed energy management method with reference[15].