Energy Flow Management and Size Optimization for Photo-Voltaic and Wind Renewable Sources Integrated with Vehicle-to-Grid Technology

The energy management process can increase the reliability of the energy flow to cover the load in a Hybrid Renewable Energy System (HRES), especially in light of the development of new technologies such as Vehicle-to-Grid (V2G) technology that helps the grid handle with peak load coverage. This paper deals with a connected hybrid system With the grid is used to operate a residential building in the Sabha region in southern Libya


Introduction
The inability of the electrical grid to meet the energy demand led to thinking about finding ways to support the public electricity grid, among these means is the use of renewable energies to increase the energy supply at the lowest possible cost [1].Renewable energy technologies have become desirable, whether in connected or off-grid systems, especially after proving their reliability in energy supplies, and despite the importance of renewable energy sources in energy supplies, they are of an intermittent nature in energy generation, so these problems can be addressed by means of copying systems.Reserves such as storage batteries, Diesel Generators, and energy management systems [2], [3].Improving the management of energy flow in Libya and in the study area is of great importance in terms of reducing the costs of energy production through the diversification of energy sources, as well as increasing the reliability of energy supply by renewable energy systems which stimulates this to address energy outages during peak energy demand, as the executive body for renewable energy in Libya has developed plans until 2030 to achieve sustainability [1], [4].The energy flow of hybrid Photo-Voltaic systems can be managed through different optimization techniques with different energy levels.Multiple energy flow management studies have been conducted for hybrid systems to support the public grid.In reference [5] a hybrid system of Photo -Voltaic energy (PV), Wind Turbine (WT), and Diesel Generator (DG) was modeled and simulated, and this led to the possibility that renewable energy sources could be a solution for electric energy generation to replace traditional energy sources at the lowest costs.A feasibility study for a hybrid energy system consisting of (PV / Wind / Battery) was conducted to improve the size and cost of the system components, where a computational comparison was implemented between the hybrid algorithm (Invasive Weed Optimization (IWO) -Particle Swarm Optimization (PSO)) and the evaluation of the hybrid system based on the Net Present Cost (NPC) and the Leveled Cost of Energy (LCOE).And it was shown that the hybrid algorithm (IWO-PSO) gives better results compared to other algorithms [6].A methodology based on finding the optimal size to increase energy reliability at the lowest cost of a hybrid system (PV / WT / BT) in the grid-connected system was proposed in [7] where the study showed that this system simulation led to the effectiveness of the proposed study.Recently, in some studies, energy flow is managed by integrating electric vehicles with the grid, in addition to renewable energy sources as a hybrid system, This technology is called (V2G), in [8] put forward an integrated micro-grid system with (PV / WT / BT / EV) that aims to increase the Renewable Energy Fraction (REF), and the study showed that the proposed system can be achieved and reduce dependence on the public grid using (RESs) because of its high potential.There are many optimization algorithms used in energy system optimization such as Particle Swarm Optimization (PSO) [9], Genetic Algorithm (GA) [10], Cuckoo search algorithm (CSA) [11], Ant Lion Optimizer (ALO) [12], Dynamic Programming algorithm (DP) [13].Those interested in the field of energy management are seeking to find suitable ways to integrate the grid with various renewable energy sources, including V2G technology.
The study aims to maximize the Renewable Energy Fraction (REF), minimize the Levelized Cost of Energy (LCOE), and minimize the Loss of Energy Supply Probability (LPSP), as the system operation mode is proposed in this paper by using search algorithms PSO and CSA.The organization of the article is summarized in the introduction to the subject of the study, the mathematical modeling of the proposed system, the optimization and sizing of the system, the study methodology, the results and their discussion.In this research, a hybrid energy system consisting of (PV / WT / BT / EV) connected to the grid was studied to cover the load of a residential building located in the city of Sebha, southwestern Libya.

System Model 2.1 Vehicle-to-Grid Technology
Vehicle-to-Grid (V2G) is a technology that enables electric vehicles to use their battery to send energy back to the electric grid, providing benefits to the grid.EV batteries can also be used as a mobile energy source, allowing energy to be extracted when the vehicles are not used for transmission when the Grid-to-Vehicle (G2V) mode is in place.This is particularly useful for balancing the energy demand on the grid, which can be difficult for energy plants to handle on their own [14], [15].Figure (1) shows the block diagram of the bidirectional energy flow of EV technology to the grid.2) shows the grid-connected hybrid energy system which consists of two buses, one of which is the Direct Current (DC) carrier connected to the wind turbines, Photo-Voltaic, and system energy storage system while the Alternating Current (AC) carrier is connected to the electric grid, electric load, and electric vehicle.The Direct and Alternating Current carriers are connected through a dual transformer to convert the current between them.Because of the importance of managing the energy flow between the components of the system, they connect to a control unit to monitor the management of the energy flow of the entire system.

Mathematical Modelling of the system's components
The modelling process has been done using mathematical equations that help us understand and know the behaviour and interactions of the hybrid system.Mathematical modelling of Photo-Voltaic panels can be given as: Where: Ppv out (t): output power generated from the PV in (W) G (t) : solar irradiance in (W/m 2 ) P(pv rated ): rated power for PV in (W) at standard test condition (STC Tc stc : is the cell temperature in (℃) T amb : is the ambient temperature in (℃) NOCT: is the nominal operating cell temperature in (℃) [16].Also Mathematical modelling of Wind Turbine is represented as: Where: v cut_out : is the height known as furlong speed ( m s ) P r : rated power speed (W) v r : rated wind speed ( m s ) P WT : the generated output power of the WT (W) When WT high is varying, wind speed approximated as Where: V1, V2: are the wind speed ( P BATT (t) = [P l (t) − P wt (t)] * η inv − P pv (t), (10) Where: C B : is the nominal capacity of the Battery (Ah) E L : is the daily average load demand AD: autonomy days DOD: is the depth of discharge (%) η inv : is the inverter efficiency (%) η b : is the Battery efficiency (%) SOC: The Battery State of Charge (%) P b (t): is the power delivered from the Battery (W) P pv (t): is the total power produced from PV (W) P WT (t): is the total power produced from WT (W) P l (t): is the total energy demand (W) σ: is the self − discharge rate of the Battery ( % h ) SOC(t): state − of − charge of the Battery in time (t) [17].
In modelling of the electric vehicle charging station, we use the following mathematical equations as: Where: S rated : is the station rated capacity (VAr) K load : is the overload factor N slot : is the amount of charging slots for each EV P EV : is the maximum power rating of each EV (KW) cos ∅ : is the power factor [18].The inverter efficiency is shown in equation ( 12) and mathematical equations for modelling of the grid are in equation ( 13) and (14).
Where: P inv (t): The inverter rating (W) P l m (t): the peak load demand (W) η inv : the inverter efficiency (%) [19].: The per hour summation of annually buying electricity from the grid for one year ($MWh) [20].

System Size Optimization 3.1 Cost of Energy (COE)
Considering objective function aims to REF maximization while minimizing LSPS and COE.The Discounted Cash Flow (DCF) analysis method is used to calculate COE.DCF can be used to estimate the investment value based on the expected future cash flow.
COE is provided in the following Equation (15).

COE =
(CRF * ∑ NPC x )+C grid −R grid x E served +E grid_selling (15) Where the Capital Recovery Factor (CRF) is given as In equation ( 16) i is the real interest rate and n is the payback period/system life equal to the life of the Photo -Voltaic panel.
The Net Present Cost (NPC) (in dollars), including operating and maintenance cost, replacement cost, and present cost can be using equation (17).
TAC is Total Annual System Cost, and Egrid_sale means electricity sales, and in equation ( 15) Eserved means primary load service in (KWh/y) [21].

Loss of Power Supply Probability (LPSP)
The reliability of the system is determined using LPSP, which is considered a second objective function to be minimized, gives as: Here Pdeficit (t) is the annual power surplus and Pdemand (t) is the total load demand for the same period.In addition, values in the LPSP range 0 < LPSP < 1, where 1 represents an unsatisfied load and 0 is a satisfied load.Also, the lowest number indicates the high reliability of the system [21].

Renewable Energy Fraction (REF)
The next objective function considered to be maximized is the REF, which is defined as the energy transferred to the load generated by RES and can be calculated as: Among them, Δt represents the change over time, which is equal to 1, and Pgrid purchase is the electricity purchased from the grid every year.Maximized REF can be minimized by the Grid Contribution Factor (GCF) given as: The required energy demand is met by minimizing REF [22], [23].

Constraints and Uncertainties A. Constraints 3.4.1 The state of charge of the battery for the proposed system
In the process of charging and discharging the battery, setting limits for the State of Charge (SOC) of the battery is taken into account to extend the operational life of the battery and taking into account the operating requirements of the hybrid energy system, where the battery bank subsystem is calculated, i.e.The State of Charge SOC can be determined by constraints through the inequality in equation ( 21) SOC_BTmin ≤ SOC_BT(t) ≤ SOC_BTmax (02) Where the terms SOC_min and SOC_max refer to the lowest and highest charge levels in a grid system, respectively [24].

Electric vehicle
Limit the exchange rate of Battery energy.The exchange rate must stay within the permitted ranges for the sake of Battery health and safety.PBattery_min ≤ PBattery_batt(t) ≤ PBattery_max (22) Where PBattery denotes the Battery exchange energy rate, PBattery, min the lowest permissible rate, and PBattery, max the highest permissible rate.

Limit for Battery SOC
EV Battery SOC needs to be kept within the pre-defined range to reduce Battery degeneration.Additionally, the EV Battery must be kept partially charged while keeping a specific level of energy available for EV driving, and electric vehicle constraints can be expressed as: SOCEV_min ≤ SOCEV_BT(t) ≤ SOCEV_max (09) Where SOCEV is the SOC of the EV, SOCEV_min is the lowest SOC that the EV is permitted to have, and SOCEV_max is the highest SOC that the EV is permitted to have.

Availability of EVs
In order to provide the V2G service, EVs must be connected to the power grid; otherwise, they will not be able to use it [25].

B. Uncertainties
The change in weather conditions affects the continuity of electricity production from renewable energies due to its dependence on the climate, as the fluctuation of these renewable energies results in the difficulty of their integration with the public grid, which leads to a decrease in the efficiency of hybrid systems [26].The characteristics of renewable energies are also affected by several factors that reduce their efficiency, for example, the thermal effect on the Photo-Voltaic module, as a result of the manufactured materials, which must be taken into account during system design.The performance of the system is also considered one of the cases of uncertainty, and this is due to the long-term operational life of the system, as the longer the operating period, the less output and performance of the system with the same efficiency, which should be taken into account [27].

Methodology
The flow chart in Figure (3) shows the methodology of the study, where the data that includes climatic data, the load demand for the electric vehicle and the residential building, and the economic data of the proposed system are recalled.The Photo-Voltaic geographic information system and global solar atlas were used[28], [29], then the data were processed by MatLab software for HRES optimizing [30].It was taken into account during the simulation that the system is a hybrid system connected to the grid and integrated with the electric vehicle, and that the system meets the energy requirements of the residential load and the electric vehicle.PSO is a search space, includes particles where each particle is a possible solution with velocity, position, and fitness characteristics.In PSO optimization, the particle's position indicates a possible solution, while its velocity determines the direction and distance of its movement in each iteration.By updating their velocities, the particles move in the search space and get closer to the optimal solution.The quality of each particle is evaluated using a fitness function.In a standard PSO optimization process, the initial positions and initial velocities of particles are randomly assigned to create a starting swarm.The particle velocity and position i are denoted as Xi=[xi1, xi2,…, xiD] and Vi= [vi1, vi2,…, viD] respectively.The update of the object and the velocity of the particle is done according to the equations as follows: The variables in this equation are represented by different parameters where: k represents the iterations,    and   +1 represent the velocity vector, and particle position i at k-the iterations, respectively.   is the personal best positions for the particle i at the iteration k,   is the global best vector in the entire location, c1, and c2 have acceleration coefficients of 1rand and 2rand random numbers between [0,1], [9].

Cuckoo Search Algorithm (CSA)
To simplify the explanation of the cuckoo search algorithm, three rules are used.Rule one each cuckoo lays one egg at a time and tosses it randomly into a nest.Then rule two the best nests with high-quality eggs are passed on to the next generation.Rule three the number of available host nests is fixed, and the host may detect alien eggs with probability Pa [0, 1].In this situation, the host bird can either dispose of the egg or leave the nest and construct a fresh one at a new location.To make things simpler, let's say that a fraction Pa of n nests is replaced with new ones (containing random solutions at newer positions).In terms of maximizing performance, the fitness or quality of a solution is directly proportional to the objective function.Similarly, other kinds of fitness can be determined by utilizing the fitness function in GA.So, in summary, the fundamental steps of cuckoo search algorithms can be described as follows in pseudo-code.When creating a new solution,  (+1) , for example, cuckoo i, a Lévy flight is performed as: The step size α is related to the scales of the problem, so it should have a positive value.In the majority of cases, we can expect α to be O (9).The product ⨁ is an acronym that means multiplying items one at a time.Lévy flight is essentially a random walk, but their random steps are drawn from a Lévy distribution for large steps, which has an infinite variance and infinite mean as Here, the sequential jumps of a cuckoo essentially resemble a random walk that follows a energy-law steplength distribution with a long tail [11].

Results and discussion 6.1 Total Load demand
The electrical load can be estimated to know the amount of energy required, as it varies seasonally throughout the year.Fig. (5) shows the daily consumed load for the seasons of the year for a residential building in the city of Sebha for the current year.We note that the highest electrical load is in the summer and then winter due to the operation of heating and cooling devices.The peak load is at noon and the lowest load is after sunset.As for the fall and spring seasons, they are the least consuming load during the year due to the mild climate and the lack of use of devices that consume a high load.Figures ( 6), ( 7) and ( 8) also show weather data hours in terms of temperature, solar radiation and wind speed for one year, respectively.

System Component Specifications
Knowing the specifications of the components of the system is important because it enters into giving all the necessary data on the basis of which the energy management in the system is improved and analyzed after preparing the mathematical formula for each component.Table1 shows the proposed specifications.
Table 1: Technical Specifications of the system [31].

System Performance
The study relied on CSA and PSO algorithms to design a grid-connected system consisting of (PV / WT / BT / EV) as shown in Fig. (2).The proposed system in the study area of the Sabha region in Libya to cover the total load in section 6.1.The proposed system is designed to take advantage of RESs and V2G technology in energy exchange and assist the public grid in covering the electric load, taking into account the climate data of the study area and the mathematical modeling of the system components in addition to the objective functions and constraints.

V2G Energy exchange
Figure (10) shows the balance of energy flow, where the black, green, red, blue and purple colors represent the load, the purchase of energy from the grid, the energy generated from the battery, the wind energy and the photo-voltaic energy respectively, Which is managed through BT and V2G.The positive impact on load coverage can be seen in terms of the state of charge and discharge of batteries SOC% for one week in a year.The study also takes into account the importance of V2G technology in Figures (11) and ( 12), which represent the exchange of energy between the electric vehicle and the grid, and vice versa, the charging state of electric vehicles.Used in the system for (10) electric vehicles as a reliable energy source to increase the reliability of energy supplies in the absence of RESs and batteries in the system.Simulation is implemented in MATLAB codes for PSO and CSA optimization.The optimal system configuration obtained is depicted in Table 2.Note that the results obtained based on CSA and PSO are approximately same each other, the obtained results show better performance values such as (0.0340) $/KWh, (0.0769) %, and (0.5476) % for COE, LPSP, and REF, respectively.Additionally, the optimum size values such as (350), (5), and (4) for PV modules, WTs, and BTs.
Table 2: Optimum size of proposed System.

Table 3:
The results of the energy generated for an optimal size system.

Convergence of CSA & PSO algorithms
The results showed that the CSA can perform faster than the PSO to obtain the best sizing of the components of the system with minimum cost, as shown in

Conclusion
The study demonstrates the effectiveness of incorporating V2G into a system configuration that uses PV-WT-BT with AC residential load plus EV load and the system is connected to the grid system by selecting the optimal size of the system, improving its performance, and reducing losses costs while increasing reliance on energy sources, as well as the use of algorithms inspired by nature, such as CSA and PSO, and comparing the results between them.The study also takes into account weather data and seasonal changes to improve system performance.The proposed system performs better compared to the measurement test using three test functions, and the study site has high energy production capabilities with the RES used.Therefore, the proposed system could be a viable solution to reduce dependence on the main grid and increase the use of renewable energy sources.

R
grid : the revenue accrued from sales of energy to the utility grid rate feed−in : the feed − in tariff rate ( $ KWh )E grid(selling) : is the selling energy price ($MWh) C grid : the cost power from the grid C p : is the cost of buying electricity from the grid (

JOPASFig. 3 :
Fig. 3: Flowchart for energy flow management and optimization of a hybrid system 5. Optimization algorithms for the hybrid energy system 5.1 Particle Swarm Optimization (PSO)

Figure ( 4 )Fig. 4 :
Figure (4) shows the use of the proposed approach for the (CSA) and (PSO) algorithms in the following flowchart along with setting the parameters to achieve the objective functions (REF), (LPSP) and (LCOE).The planned objective functions were accomplished because the study area is privileged to experience a variety of weather conditions.

Fig. 8 :
Fig. 8: Annual wind speed data for a year Also as shown in figure (9) the daily electric vehicle load demand, which assumed to be constant.The total load can be computed from the residential building consumption combined with the electrical vehicle's load.

Fig. 9 :
Fig. 9: Daily load demand of the electric vehicle