# A Comparative Study of Genetic Algorithm and Particle Swarm Optimization for Hybrid Renewable Systems with Battery and Hydrogen System

Aqib Khan, Mathieu Bressel, Arnaud Davigny, Dhaker Abbes, Belkacem Ould Bouamama

► To cite this version:

Aqib Khan, Mathieu Bressel, Arnaud Davigny, Dhaker Abbes, Belkacem Ould Bouamama. A Comparative Study of Genetic Algorithm and Particle Swarm Optimization for Hybrid Renewable Systems with Battery and Hydrogen System. The 26th European Conference on Power Electronics and Applications, GDR SEEDS France & EPE Association, Mar 2025, Paris, France. 10.34746/epe2025-0249. hal-05088256

HAL Id: hal-05088256

https://utc.hal.science/hal-05088256v1

Submitted on 28 May 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A Comparative Study of Genetic Algorithm and Particle Swarm Optimization for Hybrid Renewable Systems with Battery and Hydrogen System

Aqib Khan$^{a,b,*}$, Mathieu Bressel$^b$, Arnaud Davigny$^{a,c}$, Dhaker Abbes$^{a,c}$, Belkacem Ould Bouamama$^b$

$^a$JUNIA - Grande Ecole d'ingénieurs, F-59000, Lille, France

$^b$Univ. Lille, CNRS, Polytech Lille, UMR 9189 CRISTAL, F-59000, Lille, France

$^c$Univ. Lille, Arts et Metiers Institute of Technology, Centrale Lille, Junia, ULR 2697-L2EP, F-59000, Lille, France

*Corresponding Author E-Mail: aqib.khan@junia.com, aqib.khan.etu@univ-lille.fr

## ACKNOWLEDGMENT

This work was funded by the French National Agency for Research through the COSMAC project (ANR-22-CE05- 0013, Optimal Design of a Multi-Energy System Applied to Commercial Buildings).

*Index Terms*—Hybrid Renewable Energy System, Genetic Algorithm, Particle Swarm Optimization, Optimal Sizing, Energy Storage System.

*Abstract*—This paper presents a comparative study of Genetic Algorithm (GA) and Particle Swarm Optimization (PSO) for optimal sizing of two hybrid renewable energy systems: Solar with Battery and Grid, and Solar with H2 System and Grid. Real-time energy consumption data from a university is used to model these systems, aiming to minimize costs while meeting energy demands and ensuring reliability. The performance of GA and PSO is compared based on solution quality, convergence speed, and computational efficiency. Results show that GA provides robust configurations, while PSO offers faster convergence. These findings support efficient and practical hybrid system design.

## I. INTRODUCTION

The rising demand for sustainable energy has led to significant interest in Hybrid Renewable Energy Systems (HRES), which integrate renewable sources like solar and wind with storage systems and grid connections. HRES offer reliable, eco-friendly alternatives to conventional systems, particularly in areas with fluctuating energy demands or unreliable grid access [1]. However,

designing optimal HRES configurations is challenging due to the intermittency of renewable resources and the complexity of balancing objectives such as cost minimization, system reliability, and efficiency.

Optimal sizing of HRES components (solar panels, storage units, and grid connections) is crucial for ensuring system performance and minimizing costs. Meta-heuristic algorithms like Genetic Algorithm (GA) and Particle Swarm Optimization (PSO) are widely used for HRES optimization due to their ability to handle complex, nonlinear, multi-objective problems [2]. Traditional methods like linear programming are often inadequate for these multi-dimensional tasks, making GA and PSO ideal alternatives.

Research has extensively explored HRES configurations with battery storage, but hydrogen (H2) storage is gaining attention for its higher energy density and longer operational life, despite higher initial costs [3], [4]. Proper sizing of HRES components is critical, as incorrect configurations can lead to higher costs or insufficient energy supply.

GA and PSO have shown great promise in optimizing HRES. GA, inspired by natural selection, explores diverse solution spaces, avoiding local optima but may suffer from slower convergence. PSO, based on social behavior, offers faster convergence, making it suitable for real-time applications, though it may struggle with local optima in complex problems [5]–[7].

Several comparative studies have examined GA and PSO in HRES optimization, revealing strengths and weaknesses in both. GA tends to provide more stable solutions, while PSO is favored for faster convergence
[8], [9]. However, limited research has explored HRES with hydrogen storage using real-time data.

This paper addresses these gaps by applying both GA and PSO to optimize two HRES configurations: (1) Solar with Battery and Grid, and (2) Solar with H2 System and Grid, using real-time data from a university building. The study specifically focuses on these two distinct storage systems, as each offers unique advantages and addresses different energy storage challenges. While hybrid storage systems, integrating both batteries and hydrogen, could provide a more versatile and efficient solution by leveraging the strengths of both technologies, this remains outside the scope of the current study. However, investigating such hybrid configurations presents an intriguing and valuable direction for future research, offering potential to address a wider range of energy management challenges. This study aims to provide practical insights into the performance of GA and PSO in real-world HRES optimization.

The dynamic aspects of the hybrid energy system are modelled at 10-minute intervals, updating energy production, consumption, and storage. This approach balances computational efficiency with accuracy, allowing real-time optimization of energy flows between components (solar, battery, hydrogen storage, and grid) based on supply and demand. It enables a detailed evaluation of system performance and cost-effective energy management.

The paper is organized as follows: Section II explains the system modeling, Section III presents the methodology including the problem formulation and the application of GA and PSO, Section IV provides the simulations and results, Section V discusses the results, and the conclusion and future work is drawn in the final section.

## II. HYBRID RENEWABLE ENERGY SYSTEM MODELLING

The two hybrid systems integrate solar photovoltaic (PV) panels, energy storage (either battery or hydrogen), and a grid connection to ensure a reliable and sustainable power supply.

For System 1, solar PV panels are coupled with battery storage and supported by the grid, as shown in Fig. 1. The battery stores excess energy generated by the solar panels during the day, which is discharged when solar energy is unavailable, such as during the night or cloudy conditions. The grid serves as a backup to meet any additional demand not covered by solar generation and battery storage.

<figure><img src="image_2.png" /><figcaption>Fig. 1. System 1: Solar PV with Battery and Grid Backup</figcaption></figure>

For System 2, solar PV panels are integrated with hydrogen system and supported by the grid, as shown in Fig. 2. In this system, excess solar energy is used to produce hydrogen through an electrolyzer. The hydrogen is stored in tanks and converted back into electricity using a fuel cell when needed, ensuring continuous energy supply during low solar generation periods. The grid supplements the system during times of high demand or insufficient solar and hydrogen availability.

<figure><img src="image_3.png" /><figcaption>Fig. 2. System 2: Solar PV with Hydrogen System and Grid Backup</figcaption></figure>

### A. PV System Model

The average power model ($P_{PV}$), which has been widely used for management or sizing by many researchers [10] is expressed by (1).

$$P_{PV} = \eta_{PV} \times A_{PV} \times I_{r} \quad (1)$$

Where:

* $\eta_{PV}$: Yield of the PV generator.

* $A_{PV}$: Surface area of the PV generator (m²)

* $I_r$: Irradiance (W/m²).

Equation (2) defines the PV yield ($\eta_{PV}$):

$$\eta_{PV} = \eta_{r} \times \eta_{PC} \times [1 - \beta_{t} \cdot (T_{C} - T_{STC})] \quad (2)$$

Where:

* $\eta_{r}$: Efficiency of PV modules

* $\eta_{PC}$: Performance ratio excluding thermal losses

* $\beta_t$: Coefficient of PV losses per temperature
* $T_c$: Cell temperature (°C)

* $T_{STC}$: Cell operating temperature (°C)

The key variables for the sizing of the PV system are surface area of PV panels ($A_{PV}$) and irradiance ($I_r$).

## B. Battery System Model

The Equivalent Model of the battery [11], specifically formulated for lithium-ion batteries, is represented by (3) and (4)

$$V_{bat} = E_b - R_o \times i(t) \quad (3)$$

$$E_b = E_0 - \frac{K \times Q}{Q - i(t) \times t} \times (i(t) + i^*) + A \times \exp(-B \times i(t)) \quad (4)$$

Where:

* $V_{bat}$: Terminal battery voltage at time t (V)

* $E_b$: Battery voltage (V)

* $R_o$: Battery internal resistance (in Ω)

* $i(t)$: Dynamic current at time t (A)

* $E_0$: Constant battery voltage or fully charged voltage (V)

* $K$: Polarization constant (V/Ah)

* $Q$: Discharged capacity (Ah)

* $A$: Amplitude in the exponential zone (V)

* $B$: Time constant inverse in the exponential zone ($Ah^{-1}$)

* $i^*$: Current filtered through polarization resistance (A)

The state of the battery storage system is represented by its state of charge in (5):

$$SoC = SoC_{initial} + \eta_{ch/dcg} \times \frac{I_{bat} \times \Delta_t}{Q} \quad (5)$$

The key variable for sizing the battery system is its capacity ($Q$), while the key variable for managing energy flow (charge/discharge) is the state of charge (SoC).

## C. H2 System

The H2 system includes the electrolyzer, storage tank, and fuel cell. The following provides an overview of the models for each component of the hydrogen storage system [12], specifically a proton exchange membrane (PEM) fuel cell and a PEM electrolyzer.

1) Fuel Cell Model: A basic fuel cell model that can be used for managing and sizing is summarized by equations (6) and (7).

$$P_{FC} = \eta_{FC} \times HV_{H2} \times Q_{FC} \quad (6)$$

Where:

* $P_{FC}$: Power output of the fuel cell (kW)

* $\eta_{FC}$: Power efficiency of the fuel cell

* $HV_{H2}$: Constant heating value of hydrogen (33.33 kWh/kg)

* $Q_{FC}$: Hydrogen consumption by the fuel cell (kg)

$$P_{FCmin} \leq P_{FC} \leq P_{FCmax} \quad (7)$$

2) Electrolyser Model: Equations (8) and (9) provide an overview of an electrolyser model that is appropriate for managing and sizing.

$$Q_{EL} = \frac{P_{EL} \times HV_{H2}}{\eta_{EL}} \quad (8)$$

Where:

* $Q_{EL}$: Hydrogen production by the electrolyser in (kg)

* $P_{EL}$: Input Power for the electrolyser (kW)

* $HV_{H2}$: Constant heating value of hydrogen (33.33 kWh/kg)

* $\eta_{EL}$: Power efficiency of electrolyser

$$P_{ELmin} \leq P_{EL} \leq P_{ELmax} \quad (9)$$

3) H2 Storage tank Model: Equation (10) defines a model for Storage capacity of hydrogen tanks.

$$Q_{H2_{tank}} = Q_{H2_{tank_{initial}}} + Q_{EL} - Q_{FC} \quad (10)$$

Where:

* $Q_{H2_{tank}}$: H2 Storage tank capacity (kg)

* $Q_{H2_{tank_{initial}}}$: Initial H2 tank capacity (kg)

* $Q_{EL}$: Hydrogen production by the electrolyser (kg)

* $Q_{FC}$: Hydrogen consumption by the fuel cell (kg)

The key variables for the sizing of the H2 system are H2 Storage tank capacity ($Q_{H2_{tank}}$), Input power required for Electrolyser ($P_{EL}$) and Fuel cell output power ($P_{FC}$).

## III. METHODOLOGY

The methodology for this study focuses on the optimal sizing of two HRES using GA and PSO. The two systems under consideration are (1) Solar with Battery and Grid, and (2) Solar with Hydrogen (H2) System and Grid. The real-time data from a university building is used to model the energy demand, while the objective is to minimize the total cost of energy, subject to ensuring reliable power supply. A concise rule-based control strategy for energy management is described as shown in Fig. 3. The variables used in this Fig. 3 are defined as follows: $P_{PV}$ is the generated solar power, $P_L$ is the load power, $S_{ES}$ is the state of charge of the energy storage system, $I_{rr}$ is irradiance and Temp represents temperature.
<figure><img src="image_4.png" /><figcaption>Fig. 3. Flow Chart of Rule-based Control Strategy</figcaption></figure>

For this study, ideal operations for static converters were assumed, and the dynamic responses of the electrolyzer and fuel cell were not explicitly modelled. This simplification was made to focus on evaluating the performance of the optimization algorithms.

## A. Real-Time Data Collection

The energy consumption data for the university building is collected in real time over a period of one month shown in Fig. 4. This data provides detailed load profiles, which have daily variations in energy demand. Solar radiation data are also gathered to accurately model solar energy production throughout the month.

<figure><img src="image_5.png" /><figcaption>Fig. 4. Load profile of 1 month</figcaption></figure>

## B. Optimization Problem Formulation

The optimization problem is formulated with the objective of minimizing the total cost of energy over the system's lifetime. The cost model includes the following components: the cost of PV panels, battery or hydrogen system, and grid energy cost. For System 1, the two key variables to be optimized are the sizing of the PV system and the capacity of the battery storage. For System 2, the four key variables are the sizing of the PV system, capacity of hydrogen storage, and the sizing of the fuel cell and electrolyser, as these directly impact both costs and energy efficiency.

The objective functions for System 1 and System 2 to be minimized are given in 11 and 12, respectively:

$$F_{System1} = \sum_{t=1}^{T} C_{PV}(t) + C_{BT}(t) + C_{GRID}(t) \quad (11)$$

$$F_{System2} = \sum_{t=1}^{T} C_{PV}(t) + C_{H2}(t) + C_{GRID}(t) \quad (12)$$

Where:

* $C_{PV}$: Cost of the PV system, including the area of the PV panels and their cost per unit area.

* $C_{BT}$: Cost of the battery storage system, calculated based on the battery's capacity in ampere-hours (Ah) and the cost per Ah.

* $C_{H2}$: Cost of the hydrogen storage system, which includes the cost of the hydrogen tank (based on its capacity in kg), the fuel cell, and the electrolyzer (both based on their power capacity in kW).

* $C_{GRID}$: Cost of grid energy, calculated based on the power drawn from the grid over time t, the time step $\Delta t$, and the cost per kilowatt-hour (kWh).

The specific cost terms are given by:

$$C_{PV} = A_{PV} \times \text{cost/m}^2 \quad (13)$$

$$C_{BT} = Q \times \text{cost/Ah} \quad (14)$$

$$C_{H2} = Q_{H2_{tank}} \times \text{cost/Kg} + P_{EL} \times \text{cost/KW} \quad (15) \\ + P_{FC} \times \text{cost/KW}$$

$$C_{GRID} = \sum_{t=1}^{T} P_{GRID}(t) \times \Delta t \times \text{cost/KWh} \quad (16)$$
The following constraints should be taken into account in the optimization problem, with the corresponding maximum and minimum values for each constraint outlined in Table I:

$$A_{PV_{min}} \leq A_{PV} \leq A_{PV_{max}} \quad (17)$$

$$Q_{min} \leq Q \leq Q_{max} \quad (18)$$

$$SoC_{min} \leq SoC \leq SoC_{max} \quad (19)$$

$$P_{EL_{min}} \leq P_{EL} \leq P_{EL_{max}} \quad (20)$$

$$P_{FC_{min}} \leq P_{FC} \leq P_{FC_{max}} \quad (21)$$

$$Q_{H2_{tank min}} \leq Q_{H2_{tank}} \leq Q_{H2_{tank max}} \quad (22)$$

### C. Optimization Algorithms

In this study, both GA and PSO were employed to optimize the HRES configurations. The choice of algorithm parameters, including population size and number of iterations, plays a critical role in determining the efficiency and effectiveness of the optimization process.

For both PSO and GA, the population size was set to 100, and the number of iterations was set to 40. These values were chosen based on preliminary testing and personal judgment to balance between exploration and computational efficiency. A population size of 100 ensures a diverse set of potential solutions, which helps the algorithms avoid local optima, while 40 iterations were deemed sufficient for convergence, given the problem's complexity and available computational resources.

1) **Genetic Algorithm (GA) Approach:** GA is applied to optimize the system size by evolving a population of candidate solutions over multiple generations. Each candidate solution represents a specific configuration of the hybrid system, including the size of solar PV, battery or hydrogen storage, and grid reliance.

**GA Procedure:**

**Initialization:** Create a random population representing potential system sizes for solar PV, storage, and grid.

**Selection:** Evaluate fitness based on cost and load demand; select the best individuals for reproduction.

**Crossover and Mutation:** Combine parent solutions and introduce random changes to explore new solutions.

**Termination:** Repeat until minimum cost is achieved or maximum generations are reached.

Fig. 5 illustrates the flowchart of the GA.

<figure><img src="image_6.png" /><figcaption>Fig. 5. GA Flowchart</figcaption></figure>

2) **Particle Swarm Optimization (PSO) Approach:** PSO is a population-based optimization technique that simulates the social behavior of a flock of birds. Each particle in the swarm represents a potential solution, and particles move through the solution space based on their personal best position and the best-known position in the swarm.

**PSO Procedure:**

**Initialization:** Randomly initialize a swarm of particles, each representing a potential HRES configuration.

**Velocity and Position Update:** Each particle updates its velocity and position based on its own best solution and the global best solution found by the swarm.

**Fitness Evaluation:** Evaluate each particle's fitness based on total system cost and load satisfaction.

**Termination:** Repeat until a convergence criterion is met (e.g., minimum cost or maximum iterations).

Fig. 6 illustrates the flowchart of the PSO.

PSO is favored for its simplicity and fast convergence, making it effective for real-time and large-scale optimization tasks.
<figure><img src="image_7.png" /><figcaption>Fig. 6. PSO Flowchart</figcaption></figure>

## D. Comparison Criteria

The performance of GA and PSO is compared based on several criteria:

1) *Convergence Speed*: The number of iterations required for each algorithm to reach an optimal or near-optimal solution.

2) *Solution Quality*: The total cost of energy of the system.

3) *Computational Efficiency*: The time taken by each algorithm to complete the optimization process.

# IV. SIMULATION AND RESULTS

The optimization process was simulated using MATLAB, with custom code developed to implement both GA and PSO, in accordance with the predefined rules outlined in the previous section. These simulations specifically focused on the variable load power profile, consisting of one month of load data from the university building, recorded at 10-minute intervals, as shown in Fig. 4. Additionally, solar radiation data and temperature were used to model solar energy generation.

For context, the simulations were carried out on a system with a 12th Gen Intel(R) Core(TM) i7-1255U

processor (1.70 GHz), 16 GB RAM, and a 64-bit operating system with an x64-based processor. This hardware configuration provides valuable insight into the computational time performance of the optimization algorithms used in the study.

Prior to conducting the simulation, it was imperative to gather information about the system parameters and associated costs for each system, as presented in Table I. These parameters correspond to the variables used in the objective functions (e.g., $C_{PV}$, $C_{BT}$, $C_{H2}$, and $C_{GRID}$). These parameters were derived from reliable sources, including manufacturer data, market reports, and regional statistics [13]–[19].

<table><caption>TABLE I
KEY TECHNICAL AND ECONOMIC PARAMETERS OF THE HYBRID ENERGY SYSTEMS (*SOURCES: [13]–[19])</caption><thead><tr><th>System</th><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td rowspan="3">PV System (C<sub>PV</sub>)</td><td>PV Surface Area (A<sub>PV</sub>)</td><td>0-2000 m<sup>2</sup></td></tr><tr><td>Cost / m<sup>2</sup></td><td>300 EUR</td></tr><tr><td>Lifetime</td><td>25 years</td></tr><tr><td rowspan="6">Battery System (C<sub>BT</sub>): Lithium-ion</td><td>Battery Capacity (Q)</td><td>0-2.1 × 10<sup>5</sup>Ah</td></tr><tr><td>Cost / Ah</td><td>5 EUR</td></tr><tr><td>Lifetime</td><td>10 years</td></tr><tr><td>SoC min</td><td>10%</td></tr><tr><td>SoC Initial</td><td>10%</td></tr><tr><td>SoC max</td><td>90%</td></tr><tr><td rowspan="12">H2 System (C<sub>H2</sub>)</td><td>Electrolyser Power</td><td>20-200 kW</td></tr><tr><td>Fuel Cell Power</td><td>10-100 kW</td></tr><tr><td>H2 Tank Capacity</td><td>0-500 Kg</td></tr><tr><td>Electrolyser Cost / KW (C<sub>EL</sub>)</td><td>650 EUR</td></tr><tr><td>Fuel Cell Cost / KW (C<sub>FC</sub>)</td><td>400 EUR</td></tr><tr><td>Tank Cost / Kg (C<sub>H2 tank</sub>)</td><td>125 EUR</td></tr><tr><td>Electrolyser Lifetime</td><td>25 years</td></tr><tr><td>Fuel Cell Lifetime</td><td>15 years</td></tr><tr><td>H2 Tank Lifetime</td><td>30 years</td></tr><tr><td>Initial H2 Tank Capacity</td><td>10%</td></tr><tr><td>Min H2 Tank Capacity</td><td>10%</td></tr><tr><td>Max H2 Tank Capacity</td><td>90%</td></tr><tr><td>Grid (C<sub>GRID</sub>): France</td><td>Cost/KWh</td><td>0.2525 EUR</td></tr></tbody></table>

*Sources: Manufacturer Data [13]–[15], Market Reports [16]–[18], European Grid Electricity Costs [19]

Both GA and PSO were applied to optimize the size of the solar PV system and storage capacity (battery or hydrogen). Each optimization algorithm aimed to minimize the total cost. Both algorithms were run multiple times with different random initializations, and the reported values represent the averages obtained from
these trials. This approach ensures that the comparison between GA and PSO is not biased by any specific initialization.

## A. System 1: Solar with Battery and Grid System

The Solar with Battery and Grid system was simulated using both GA and PSO. The results for each algorithm are presented in Table II.

<table><caption>TABLE II
RESULTS OF OPTIMAL SIZING FOR SYSTEM 1 USING GA AND PSO WITH ALGORITHM PARAMETERS</caption><thead><tr><td>Parameter</td><td>GA</td><td>PSO</td></tr></thead><tbody><tr><td>Number of Iterations</td><td>40</td><td>40</td></tr><tr><td>Population Size</td><td>100</td><td>100</td></tr><tr><td>Number of Variables</td><td>2</td><td>2</td></tr><tr><td>Time (seconds)</td><td>9019.58</td><td>5698.87</td></tr><tr><td>Total Cost of Energy (EUR)</td><td>5468.99</td><td>5475.67</td></tr><tr><td>Optimal Solar PV Area (m²)</td><td>1995.92</td><td>1990.35</td></tr><tr><td>Optimal Battery Storage (Ah)</td><td>3746.82</td><td>4126.46</td></tr></tbody></table>

A comparative analysis reveals that PSO demonstrated faster convergence compared to GA but resulted in a slightly higher total cost of energy. This suggests that PSO may be better suited for applications where time efficiency is a priority, while GA might be more advantageous for cost-sensitive objectives.

## B. System 2: Solar with Hydrogen (H2) System and Grid System

The Solar with Hydrogen Storage and Grid system was optimized using the same algorithms. The results are presented in Table III.

<table><caption>TABLE III
RESULTS OF OPTIMAL SIZING FOR SYSTEM 2 USING GA AND PSO WITH ALGORITHM PARAMETERS</caption><thead><tr><td>Parameter</td><td>GA</td><td>PSO</td></tr></thead><tbody><tr><td>Number of Iterations</td><td>40</td><td>40</td></tr><tr><td>Population Size</td><td>100</td><td>100</td></tr><tr><td>Number of Variables</td><td>4</td><td>4</td></tr><tr><td>Time (seconds)</td><td>9479.45</td><td>6443.84</td></tr><tr><td>Total Cost of Energy (EUR)</td><td>6143.82</td><td>6204.02</td></tr><tr><td>Optimal Solar PV Area (m²)</td><td>1978.69</td><td>1984.98</td></tr><tr><td>Optimal Hydrogen Storage (kg)</td><td>3.18</td><td>23.29</td></tr><tr><td>Optimal Fuel Cell Power (kW)</td><td>10.75</td><td>22.65</td></tr><tr><td>Optimal Electrolyser Power (kW)</td><td>20.97</td><td>26.11</td></tr></tbody></table>

For System 2, GA achieved a lower total cost but PSO demonstrated faster convergence. The difference in the optimal hydrogen storage sizing between the algorithms highlights the complexity of the hydrogen-based system. While PSO is faster, GA's broader exploration

seems more effective at optimizing costs in this more complex system.

Notably, the hydrogen system required higher costs compared to the battery system but offered greater energy density and potentially longer operational life, as discussed in previous literature.

Figure 7 illustrates the convergence of GA and PSO for System 1. Both algorithms aim to minimize the cost function. The GA (red line) starts with a higher initial cost and shows a steady decline, eventually stabilizing after a series of iterations. In contrast, PSO (blue line) demonstrates a sharp reduction in cost during the early iterations, converging more quickly to a similar final cost as GA. Both algorithms ultimately achieve comparable final costs, but PSO clearly exhibits faster convergence in the initial stages. Similarly Fig. 8 shows the convergence for the system 2.

<figure><img src="image_8.png" /><figcaption>Fig. 7. Convergence Comparison of GA and PSO for System 1</figcaption></figure>

<figure><img src="image_9.png" /><figcaption>Fig. 8. Convergence Comparison of GA and PSO for System 2</figcaption></figure>

Fig. 9 and Fig. 10 show the output produced by the PV, the stored energy, and the power delivered by the grid over one day for System 1 using both GA and PSO methods. Similarly, Fig. 11 and Fig. 12 show the output for System 2.
<figure><img src="image_10.png" /><figcaption>Fig. 9. Power Distribution of PV, Storage, and Grid for System 1 using GA</figcaption></figure>

<figure><img src="image_11.png" /><figcaption>Fig. 10. Power Distribution of PV, Storage, and Grid for System 1 using PSO</figcaption></figure>

<figure><img src="image_12.png" /><figcaption>Fig. 11. Power Distribution of PV, Storage, and Grid for System 2 using GA</figcaption></figure>

## V. RESULT DISCUSSION

The optimization results obtained from both GA and PSO provide critical insights into the performance of the Hybrid Renewable Energy Systems under study. The findings reveal the effectiveness of each algorithm in determining the optimal sizing of the solar photovoltaic (PV) systems, energy storage, and grid interaction, which are vital for meeting the energy demands of the university building.

<figure><img src="image_13.png" /><figcaption>Fig. 12. Power Distribution of PV, Storage, and Grid for System 2 using PSO</figcaption></figure>

### A. Comparison of GA and PSO Results

Table II summarizes the results for the Solar with Battery and Grid system, while Table III presents the results for the Solar with Hydrogen and Grid system. In System 1, GA achieves a slightly lower total cost compared to PSO, but PSO converges significantly faster. This indicates that PSO is more suitable for time-sensitive scenarios, whereas GA's broader exploration provides marginal cost advantages. The performance of both algorithms is influenced by the population size and the number of iterations, which are identical at 100 and 40, respectively.

In System 2, GA performs better, achieving a lower total cost, although PSO still converges faster. GA's broader exploration is more beneficial in the complex hydrogen system, favoring larger storage capacities to handle variability. In contrast, PSO's focus on local optima tends to favor smaller storage sizes. The choice between GA and PSO thus depends on a trade-off between computational speed and cost optimization, as well as the number of iterations and population size. The complexity of the hydrogen system, including nonlinear dynamics of hydrogen production, consumption, and storage efficiency, further amplifies these differences, highlighting the need for careful parameter tuning and potentially hybrid optimization approaches.

### B. Impact of Storage Type on System Performance

The results also underscore the significant impact of storage type on overall system performance. For the Solar with Battery and Grid system, the optimized battery capacity with PV aligns closely with the load profile, providing backup energy during periods of low solar generation. Conversely, the Solar with Hydrogen Storage system presents higher costs but offers the advantage of greater energy density and longer operational life. This reinforces findings from previous studies indicating that hydrogen storage can be a viable alternative to
batteries, particularly for applications requiring longer storage duration's and higher energy outputs.

The choice between battery and hydrogen storage depends on the specific needs of the application. For short to medium-term energy storage, batteries may be more cost-effective, while hydrogen is advantageous for long-term and larger-scale energy storage solutions.

### C. *Practical Implications*

The findings of this study have practical implications for stakeholders in the energy sector. For energy providers, understanding the cost dynamics between different storage technologies can inform investment decisions and policy-making. Building managers and facility operators can utilize the optimization results to enhance energy efficiency, reduce operational costs, and improve reliability in energy supply, thereby supporting sustainability goals.

### D. *Limitations*

Despite the robustness of the optimization results, some limitations are acknowledged. The study's reliance on historical data may not fully capture future variations in energy consumption patterns or advancements in technology. Additionally, the analysis focused primarily on two storage types, which may not encompass the full spectrum of available solutions. Furthermore, the study used a single profile for load, solar radiation, and temperature, which, while representative of typical conditions at the university building, may not fully capture the variability of energy demand and supply in other scenarios.

## VI. CONCLUSION AND FUTURE WORK

### A. *Conclusion*

This paper explored the optimal sizing of Hybrid Renewable Energy Systems using GA and PSO, applied to real-time energy consumption data from a university building. Two system configurations were studied: Solar with Battery and Grid, and Solar with Hydrogen system and Grid. The comparison revealed that GA, while slower in convergence, provided a more thorough exploration of the solution space, leading to cost-effective designs in complex systems. In contrast, PSO demonstrated faster convergence, making it more suitable for time-sensitive applications where computational speed is critical.

In terms of storage technologies, the hydrogen-based system, though initially more expensive, offers long-term advantages in energy density and sustainability. The battery-based system, while more cost-effective in the

short term, has limitations in long-term energy storage capacity. Thus, the choice between systems and algorithms depends on balancing short-term cost, long-term sustainability, and computational efficiency.

### B. *Future Work*

Future research should focus on the following areas:

1) *Hybrid Optimization Approaches:* A combination of GA and PSO, or other metaheuristic algorithms, could be explored to exploit the strengths of both methods and overcome their individual limitations. Additionally, the use of evolutionary algorithms or reinforcement learning could be considered for further optimization, leveraging the adaptability and robustness of these methods.

2) *Incorporation of Additional Renewable Sources:* Integrating wind, biomass, or other renewable energy sources into the optimization model could provide more comprehensive solutions for HRES, increasing reliability and sustainability.

3) *Evaluation of System Robustness under Varied Conditions:* Future work could explore the system's performance under different load and irradiance profiles to assess the robustness of the optimization results across a broader range of conditions, providing a more comprehensive evaluation of system performance in various real-world scenarios.

4) *Real-Time Implementation:* The algorithms could be further tested with real-time, adaptive control mechanisms to validate their effectiveness under dynamically changing conditions, such as fluctuating energy prices and unpredictable weather patterns.

## REFERENCES

[1] Q. Hassan, S. Algburi, A. Z. Sameen, H. M. Salman, and M. Jaszczur, "A review of hybrid renewable energy systems: Solar and wind-powered solutions: Challenges, opportunities, and policy implications," Results in Engineering, vol. 20. Elsevier BV, p. 101621, Dec. 2023.

[2] A. Bouaouda and Y. Sayouti, "Hybrid Meta-Heuristic Algorithms for Optimal Sizing of Hybrid Renewable Energy System: A Review of the State-of-the-Art," Archives of Computational Methods in Engineering, vol. 29, no. 6. Springer Science and Business Media LLC, pp. 4049-4083, Mar. 16, 2022.

[3] B. Ould Bilal, V. Sambou, P. A. Ndiaye, C. M. F. Kébé, and M. Ndongo, "Optimal design of a hybrid solar-wind-battery system using the minimization of the annualized cost system and the minimization of the loss of power supply probability (LPSP)," Renewable Energy, vol. 35, no. 10. Elsevier BV, pp. 2388-2390, Oct. 2010.
[4] Y. Zhang, A. Lundblad, P. E. Campana, and J. Yan, "Comparative Study of Battery Storage and Hydrogen Storage to Increase Photovoltaic Self-sufficiency in a Residential Building of Sweden," Energy Procedia, vol. 103. Elsevier BV, pp. 268-273, Dec. 2016.

[5] E. Sadeghibakhtiar, A. Naeimi, S. Naderi, G. Pignatta, and A. Behbahaninia, "Size optimization of a stand-alone solar-wind-battery hybrid system for net zero energy buildings: A case study," Energy and Buildings, vol. 313. Elsevier BV, p. 114204, Jun. 2024.

[6] J. Kennedy and R. Eberhart, "Particle swarm optimization," Proceedings of ICNN'95 - International Conference on Neural Networks, Perth, WA, Australia, 1995, pp. 1942-1948 vol.4,

[7] O. H. Mohammed, Y. Amirat, and M. Benbouzid, "Particle Swarm Optimization Of a Hybrid Wind/Tidal/PV/Battery Energy System. Application To a Remote Area In Bretagne, France," Energy Procedia, vol. 162. Elsevier BV, pp. 87-96, Apr. 2019.

[8] F. S. Mahmoud et al., "Optimal sizing of smart hybrid renewable energy system using different optimization algorithms," Energy Reports, vol. 8. Elsevier BV, pp. 4935-4956, Nov. 2022.

[9] S. A. Adetoro, L. Olatomiwa, J. Tsado, and S. M. Dauda, "A comparative analysis of the performance of multiple meta-heuristic algorithms in sizing hybrid energy systems connected to an unreliable grid," e-Prime - Advances in Electrical Engineering, Electronics and Energy, vol. 4. Elsevier BV, p. 100140, Jun. 2023.

[10] J. K. Kaldellis, D. Zafirakis, and E. Kondili, 'Optimum autonomous stand-alone photovoltaic system design on the basis of energy pay-back analysis', Energy, vol. 34, no. 9, pp. 1187-1198, Sep. 2009,

[11] S. Lavety, R. K. Keshri, and M. A. Chaudhari, 'A dynamic battery model and parameter extraction for discharge behavior of a valve regulated lead-acid battery', Journal of Energy Storage, vol. 33, p. 102031, Jan. 2021,

[12] H. Dagdougui, A. Ouammi, and R. Sacile, 'Modelling and control of hydrogen and energy flows in a network of green hydrogen refuelling stations powered by mixed renewable energy systems', International Journal of Hydrogen Energy, vol. 37, no. 6, pp. 5360-5371, Mar. 2012,

[13] IEA (2022), Solar PV Global Supply Chains, IEA, Paris https://www.iea.org/reports/solar-pv-global-supply-chains, Licence: CC BY 4.0

[14] IEA (2024), Batteries and Secure Energy Transitions, IEA, Paris https://www.iea.org/reports/batteries-and-secure-energy-transitions, Licence: CC BY 4.0

[15] IEA (2024), Global Hydrogen Review 2024, IEA, Paris https://www.iea.org/reports/global-hydrogen-review-2024, Licence: CC BY 4.0.

[16] IRENA (2024), Renewable power generation costs in 2023, International Renewable Energy Agency, Abu Dhabi. Available:

https://www.irena.org/Publications/2024/Sep/Renewable-Power-Generation-Costs-in-2023

[17] 'Levelised Cost of Electricity Calculator – Data Tools', IEA. [Online]. Available: https://www.iea.org/data-and-statistics/data-tools/levelised-cost-of-electricity-calculator

[18] 'Comparison of the emissions intensity of different hydrogen production routes, 2021 – Charts – Data & Statistics', IEA. [Online]. Available: https://www.iea.org/data-and-statistics/charts/comparison-of-the-emissions-intensity-of-different-hydrogen-production-routes-2021

[19] 'Statistics Eurostat'. Accessed: Dec. 20, 2024. [Online]. Available: https://ec.europa.eu/eurostat/datab browser/view/nrg_pc_205/default/table?lang=en