Dynamic Simulation and Optimization of Off-Grid Hybrid Power Systems for Sustainable Rural Development

: This paper analyzes dynamic modeling for rural HPS to address GHG emissions’ environmental impact on floods and climate change. The aim is to integrate renewable energy sources, such as solar energy, with traditional generators to mitigate emissions and enhance energy access in rural communities in Pakistan. The system is designed using a DC-DC converter, MPPT, LCL filter, and a DC-AC inverter. Utilizing software tools like PVsyst 7.4 and HOMER Pro-3.18.1, the study evaluates system sizing, energy consumption patterns, and optimization strategies tailored to site-specific data. The expected re-sults include a reliable, environmentally friendly hybrid power system capable of providing consistent electricity to rural areas. The analysis of a connected load of 137.48 kWh/d and a peak load of 33.54 kW demonstrates the system’s promise for reliable electricity with minimal environmental impact. The estimated capital cost of USD 102,310 and energy generation at USD 0.158 per unit underscores economic feasibility. Dynamic modeling and validation using HIL examine the system’s behavior in response to variations in solar irradiance and temperature, offering insights into operational efficiency and reliability. The study concludes that the hybrid power system is scalable for rural energy access, which is a practical solution achieving a 100% renewable energy fraction, significantly contributing to emission reduction and promoting sustainable energy practices.


Introduction
Energy is vital for enhancing human welfare, promoting economic advancement, and stimulating economic prosperity [1].It is commonly recognized that energy is the benchmark for measuring economic growth and improving everyone's living level [2].In contemporary society, energy ranks alongside fundamental human needs such as food, clothing, and shelter.It exerts both positive and negative influences on humanity.From a utility perspective, energy facilitates the alleviation of arduous tasks by providing convenient access to larger quantities of affordable, safe, and clean energy sources [3].Energy deficiency poses a significant challenge for many developing nations, stemming from issues like generation shortages, inefficient power transmission, and outdated distribution equipment.Consequently, affected countries resort to load shedding, a controlled measure of disconnecting the grid supply from specific regions for several hours daily; prolonged effects can significantly impact the economic advancement of a nation.
The World Bank notes that persistent electricity shortages have adversely impacted economies in Pakistan, Sri Lanka, South Africa, and India.The energy systems of most nations, whether already developed or in the process of development, predominantly rely on fossil fuels.However, this reliance contributes significantly to environmental issues such as global warming and air pollution.These environmental concerns not only pose health risks but also impact the overall quality of life for affected populations [4].As per the agenda of the Paris Agreement, leaders around the globe have agreed to restrain the increase in the average global temperature to stay "well below" 2 °C above pre-industrial levels and endeavor to remain below a warming of 1.5 °C [5].Nearly 90% of the entire GHG emissions stem from CO2 released through the combustion of fossil fuels [6].
Figure 1 illustrates that using fossil fuels generates CO2 emissions, which are responsible for global warming and climate change and significantly impact our environment.Conversely, both developed and developing nations are fulfilling their energy needs by heavily depending on fossil fuels.This reliance not only harms the environment within their borders but also contributes to global climate change, which disproportionately affects underdeveloped countries.Located in Asia, Pakistan boasts the 10th largest economy in the region.Pakistan is grappling with significant challenges such as energy security and the environmental repercussions of energy consumption.Pakistan is heavily reliant on energy imports, accounting for nearly a third of its energy demand.In the fiscal year 2017-2018, energy imports amounted to approximately USD 14.4 billion, marking an increase from USD 10.9 billion in the preceding year.About 75% of the USD 3.5 billion surge in energy imports resulted from elevated energy prices, with only around 25% attributed to increased import volumes.This significant price escalation ripples through the entire energy supply chain, leading to elevated business costs and a higher cost of living in Pakistan.Such heavy dependence on imported energy is unsustainable for Pakistan's economy, which has grappled with a persistent current account deficit for over two decades [8].Pakistan has a global 0.8% share in CO2 emissions and it has increased 114% since 2000 [9].This alarming trend is underscored by a notable rise in the consumption of natural gas, coal, and electricity, increasing by 41%, 52%, and 11%, respectively, within Pakistan [10].Figure 2 shows the categories and trends of CO2 emissions in Pakistan and the percentage of energy supply by source and Figure 3 shows the Pakistan's energy supply by source.Severe weather phenomena like heavy precipitation and flooding can inflict significant harm on both human communities and the natural world.The frequency of heavy precipitation events, which significantly contribute to flooding, has notably risen in various regions of the Northern Hemisphere in recent years, largely attributable to humaninduced climate change and driven by heightened greenhouse gas emissions [13].Global warming stands as a primary catalyst for shifts in global climate patterns.Pakistan, ranking among the top ten nations affected by this aftermath phenomenon, is witnessing severe repercussions.Presently, the country grapples with extreme flooding, impacting approximately 33 million individuals and resulting in the destruction of 1.5 million residences, along with USD 2.3 billion in crop losses.Furthermore, over 2000 km of roads have been damaged, impeding connectivity to provinces and major urban centers.Notably, record-high temperatures, such as 40 °C in various regions and a staggering 51 °C in Jacobabad, underscore the intensity of the situation [14].
The Khyber Pakhtunkhwa province in Pakistan has been a focal point for natural disasters, particularly floods, causing significant adverse effects on its land, infrastructure, healthcare, education, socioeconomic development, and human lives.While efforts towards recovery are underway, the province still lags behind others in terms of progress.Situated amidst the Karakoram, Himalayas, and Hindu Kush Mountain ranges, Khyber Pakhtunkhwa is home to glaciers and extensive high-altitude ice reserves.Table 1 shows the loss incurred on Pakistan's economy due to the flooding.These towering mountains, coupled with Pakistan's major rivers, including the Indus River, give rise to steep waterways such as Swat, Kabul, Kunhar, and Panjkora, traversing the plains of Khyber Pakhtunkhwa [16].Along with global warming issues, Pakistan is facing severe energy crises.Pakistan's electricity industry grapples with several challenges, including a widening gap between supply and demand, frequent power cuts, escalating fuel import expenses, and rising environmental pollutants.To fulfill its commitments under the Paris Agreement to reduce carbon dioxide (CO2) emissions, Pakistan has introduced various incentives and mechanisms to promote renewable energy production.Therefore, it is imperative to conduct a long-term evaluation of these policy incentives and mechanisms to determine their effectiveness in achieving the CO2 emissions reduction target [17].A significant portion of the population, particularly in rural areas, lacks access to electricity and turns to the burning of fossil fuels to meet their energy demands.The situation is alarming, with only 60% of the country's population connected to the grid.Presently, Pakistan is contending with a power supply shortage of 3-5 GW [18].
The adoption of renewable energy holds paramount significance globally due to the escalating energy consumption, surpassing the capabilities of traditional energy sources and leading to energy crises.However, the fluctuating nature of solar radiation and wind speed, influenced by climate and weather dynamics, poses challenges to the consistent operation of renewable energy systems, resulting in output fluctuations.To address this issue, hybrid renewable energy (HRE) systems, integrating multiple renewable energy sources, emerge as a highly efficient solution with promising potential [19].Ensuring adequate electricity supply in rural areas is crucial for fulfilling basic living requirements and fostering economic development.However, extending the grid over long distances through challenging geographical terrain is often economically impractical as a solution to this challenge.Internal combustion engines and diesel generators, known for their rapid response to fluctuating demand and relatively low initial investment costs, are commonly employed for electricity generation in remote regions.Nonetheless, the utilization of traditional fuels leads to the emission of pollutants.Moreover, given the unfavorable economic conditions, procuring and transporting fossil fuels for power generation purposes proves to be economically unviable [20].
Pakistan's abundant solar potential, with high irradiance levels ranging from 5.0 to 7.0 kWh/m 2 /day and 2200 to 2400 annual sunshine hours, offers a significant opportunity for electricity generation.Estimated at 2.9 million megawatts annually, solar energy exceeds current demand, presenting a sustainable solution for energy shortages.Government initiatives, including large-scale solar projects and residential subsidies, aim to harness this resource for environmentally friendly energy production and meet growing needs.Figure 4 shows the solar irradiance levels in Pakistan.Numerous studies have investigated hybrid energy systems from various angles.Tamoor et al. [22] designed an on-grid photovoltaic system, particularly in the selection of a PV module type and size that can lead to notable energy losses within the system.The study compared PV units of different dimensions and power rankings but with similar effectiveness in two chosen sites.Helioscope simulation software was employed to model these PV systems, enabling the analysis of their monthly and annual energy production as well as system losses.Nawab et al. [23] suggests a self-sufficient solar-biogas microgrid designed for rural communities in the Lakki Marwat district, Pakistan, which is reliant on agriculture and livestock.HOMER Pro simulated the electric power system, while RET-Screen analyzed its economics.The optimized system consists of a 30 kW photovoltaic system, a 37 kW biomass hybrid system, a 64 kWh battery storage capacity, and a 20 kW inverter, producing 515 kWh of electricity and 338.50 m 3 of biogas daily.Iqbal and Iqbal [24] conducted thermal modeling of a standard rural dwelling in Pakistan using BEopt to establish the hourly load profile.These load data were then utilized to design a standalone PV system using HOMER Pro.The proposed system comprises a 5.8 kW PV array along with eight batteries with a 12 V and 255 Ah capacity, coupled with a 1.4 kW inverter.The analysis indicates that this system is capable of primarily supporting lighting and appliance loads in a rural household.Xu et al. [25] examined the feasibility of electrifying rural areas in Sindh province, Pakistan, focusing on solar energy.The results indicate that these regions have favorable solar conditions for electricity generation.By optimizing tilt angles, the solar energy generation capacity can be significantly enhanced.An economic analysis reveals that off-grid solar PV systems offer electricity at PKR 6.87/kWh, which is far cheaper than conventional sources priced at PKR 20.79/kWh.Ur Rehman and Iqbal [26] presented the development of an off-grid PV system for a rural household in Pakistan, aiming to meet its year-round electrical needs, targeting a monthly generation of 40 kWh.Utilizing HOMER Pro software, the system's performance was simulated with locationspecific solar data.It consists of four 140-watt solar panels, four 125 Ah batteries, a 1 kW inverter, and introduces a simple control and data-logging approach for monitoring.Elsaraf et al. [27] worked for the electrification of remote communities in Canada in which the tailored energy systems are tailored to local consumption.Various renewable sources including solar thermal, PV, wind, hydroelectric, and fuel cells were utilized and the microgrid significantly reduced diesel usage by 71%, thus achieving a levelized cost of energy (LCOE) of −0.0245 $/kWh.Kumar et al. [28] designed and installed an off-grid solar PV system in Pakistan's desert region, where approximately 95% of the area lacks electricity access.This endeavor includes a comprehensive sizing and cost analysis to determine suitable specifications for PV solar panels, battery capacity, inverter size, and a charge controller based on the anticipated loads.Ali et al. [29] presented an off-grid photovoltaic (PV) system tailored for a rural household in Pakistan, designed to meet its year-round electricity requirements with an anticipated monthly output of 40 kWh based on household electricity consumption data; the system's performance is evaluated through steadystate modeling using HOMER Pro software.The simulation results forecast the system's annual electrical output, accounting for solar irradiance, temperature, and humidity data specific to the chosen location.Rehmani and Akhter [30] investigated the electrification of a rural community using various renewable resources and conducted an economic analysis under different scenarios.It was found that in the scenario utilizing all available resources including PV, wind, and biomass, the levelized cost of energy decreased to Rs 14.40.Although there was a slight increase in the net present cost to Rs 14.6 million, the payback period was notably reduced to just 2.54 years.
While previous research has primarily concentrated on optimizing and designing photovoltaic systems for site electrification, there is a noticeable gap in addressing the environmental impact stemming from fossil fuel usage, which is a significant contributor to recent flooding in Pakistan.Furthermore, there is a limited exploration of the reliability of hybrid power systems concerning the proportion of renewable energy integrated.Therefore, this study aims to illustrate the optimization and analysis of the design of a stand-alone hybrid power system required for the electrification of a rural area in Khyber Pakhtunkhwa province of Pakistan because of the reliability of the hybrid power system.The key contributions of this research paper to the existing research are as follows:

•
The projected HPS is designed with PVsyst and HOMER Pro software.This entails identifying system loss, the ideal capacity, and the setup of elements to fulfill the power requirements of a system.The procedure encompasses investigating the load profile, evaluating the accessibility of renewable resources, integrating energy storage capacity, establishing the generator capacity, and employing a control system.

•
Utilizing MATLAB Simulink r2023b, the dynamic modeling of the suggested hybrid power system is performed to assess its HPS behavior, voltage fluctuations, system load effects, and the quality of generated power across various settings, all tailored towards the selected site.The practical validation of the designed HPS is being performed by the OPAL-RT OP5707XG HIL real-time simulator.

•
The decreases in CO2 emissions through energy production from the hybrid power system contribute to environmental preservation, thereby lowering the likelihood of floods in Pakistan.
The structure of this study unfolds as outlined: Section 2 explores the factors considered in site selection.Section 3 details the scheme of the hybrid power system.Section 4 discusses the performance analysis and optimization of the HPS utilizing PVsyst and HOMER Pro.Section 5 illustrates the dynamic modeling and simulation of the proposed system using MATLAB Simulink, while Section 6 demonstrates the testing of the system's validity under consideration using HIL.Lastly, a thorough summary and discussion of the entire study are provided.

Site Selection and Description
The site selection process is integral to the design of a hybrid power system, playing a pivotal role in determining its performance and effectiveness.Key considerations include assessing the readiness of renewable resources for instance solar irradiation, wind speed, and hydro potential.Understanding the site-specific load profile is essential for appropriately sizing and configuring system components to meet energy demand.Environmental factors, including terrain, climate conditions, and regulatory requirements, also influence system design.Economic viability hinges on factors such as installation costs, potential energy savings, and payback periods, all of which are influenced by site selection.Ultimately, a well-chosen site maximizes energy generation potential while minimizing environmental impact and operational costs, laying a strong foundation for the hybrid power system's success.
The selected site, "Berru Bandi", is a small community consisting of 10 houses located in the rural area of Abbottabad District, approximately 25 km from Abbottabad city.Perched atop a mountain at coordinates 34°16′38″ N 73°15′18″ E and an altitude of 1456.79 m above sea level, accessing this site is challenging due to the lack of road access and basic amenities.As illustrated in Figure, approximately 66% of power in Pakistan is generated from natural gas and oil through power plants.The state-owned Sui companies, Sui Northern and Sui Southern, manage a combined network of 151,397 km (13,143 km of transmission and 138,254 km of distribution) for natural gas transmission and distribution [31].Additionally, the NTDC (National Transmission and Dispatch Company) oversees an electricity network spanning 28,805 km [32].Despite the extensive natural gas and electricity networks, providing an energy source to this remote area proves challenging due to its mountainous terrain and elevated location.Currently, residents rely on diesel generators (10 × 5 kW) to meet their energy needs, resulting in over 75,000 L of diesel fuel consumption, which ultimately results in CO2 emissions that are harmful to the environment.Therefore, the most feasible solution for electrifying this rural community is the implementation of a hybrid power system.An overhead perspective of the location is illustrated in Figure 5 on Google Maps. Figure 6 presents different real-life views of the selected site.As we can see in the aerial view in Figure 5, there is an ample area available around the community, which is sufficient for the setup of solar PV panels and other elements of the hybrid power system.

Solar Horizontal Irradiance
Solar horizontal irradiance (SHI) holds a crucial role in assessing the solar prospective of a location and determining the feasibility of solar energy projects.It represents the total solar emission obtained per unit area at the Earth's surface in a horizontal plane, without considering the angle of incidence or orientation of surfaces.Moreover, SHI data are essential for conducting solar resource assessments, identifying suitable sites for solar projects, and making informed decisions regarding renewable energy investments.The solar horizontal irradiance data of the selected site are obtained using the NASA Surface Meteorology and Solar Energy Database, facilitated with HOMER Pro software.Figure 7 represents the value of solar radiation which ranges from 2.79 kWh/m 2 /day to 7.46 kWh/m 2 /day, which shows that there exists sufficient sunlight energy at the selected site.Similarly, the clearness index is a dimensionless number that ranges between 0 (when the sky is completely covered) to 1 (when there is perfect sun) whereas at selected sites it ranges between 0.546 to 0.694.
The energy output of a photovoltaic (PV) system is significantly influenced by weather conditions including wind speed, humidity levels, temperature changes, and solar irradiance, along with additional factors like dust accumulation, localized heating, snow accumulation, and tiny fractures.However, the incline and orientation angles of PV setups are crucial in maximizing annual energy production.These angles directly impact the absorption of solar energy by the PV module surfaces, thereby affecting the performance of the installation [33].The solar azimuth angle is the angular distance between the direction of the sun and a reference direction, typically measured clockwise from true north in the horizontal plane.It represents the direction along the horizon where the sun appears to rise and set.The solar azimuth angle changes throughout the day, as the position of the sun overhead shifts from east to west.
It is an important parameter in solar energy applications, as it determines the aligning of solar panels for optimal sunlight exposure and energy capture.The solar elevation, solar azimuth, day length, and solar zenith angle were computed using the online software tool "Solargis", as depicted in Figure 8.

Analysis of Electrical Load
The electrical load is of paramount importance in hybrid power systems, significantly shaping their design, operation, and overall efficiency.In the selected rural community, there are 10 houses with nearly identical electrical appliances.The details of these appliances, along with their connected loads, are presented in As a result, when households are aggregated, the maximum demand from the group is typically lower than the sum of individual maximum demands due to the diversity in timing.Equation (1) shows the formula for the diversity factor.
This phenomenon reflects the likelihood that peak demands from different households do not coincide.Consequently, as more households are integrated into a system, the maximum demand per household decreases.The greater the diversity factor, the less likely it is that households will have peak energy demands at the same time [35].Considering the diversity factor, the hybrid power system is aimed at a peak load of 33.54 kW, and the system will be tailored accordingly.Figure 9 demonstrates the monthly electricity consumption pattern of the selected site.

Designing of Hybrid Power System
The hybrid power system (HPS) envisioned for the chosen location integrates multiple elements, such as a solar photovoltaic system, MPPT controller, battery bank, DC-DC buck converter, DC-AC inverter, LCL filter, AC power source, and diesel generator.This setup features both AC and DC buses for increased operational versatility and easier upkeep, ensuring uninterrupted power provision.Engineered with backup capabilities, the HPS ensures dependable and sustained energy delivery to facilitate smooth operations.Figure 10 depicts the schematic representation of the proposed hybrid power setup.

Photovoltaic Structure
The primary goal of solar cells is to capture photons and transform light into electricity.The production of efficient solar cells is crucial for overcoming challenges in solar technology optimization.The system comprises numerous solar cells constructed from semiconductor materials like silicon.When sunlight interacts with these cells, it stimulates electrons, generating an electric current.The panels are typically arranged in arrays to generate higher power levels, and they are widely used in residential, commercial, and industrial applications to harness renewable solar energy for electricity generation [36].
Figure 11 shows the circuit diagram of the PV cell.The PV cell's equivalent circuit comprises an ideal current source parallel to a diode.When exposed to solar radiation, current flows from the ideal current source.If the load resistance exceeds that of the diode, the diode conducts current, increasing the voltage across its terminals but decreasing the current through the load.Conversely, if the diode's resistance is higher than the load's, electrons flow easily through the load, resulting in a higher current.However, the voltage difference across the terminals decreases.The ideal solar cell circuit also includes series resistance (Rs) and shunt resistance (Rsh).Shunt resistance accounts for losses when electrons move directly between terminals, like shorts.Series resistance represents current losses due to inefficient charge transfers within the device.
According to Equation (2), I represent the obtained current, where   is the produced current,   signifies the diode current, and  ℎ is the current lost due to shunt resistance.To find out the   (diode current), the following equation is used: Here,  0 denotes the reverse leakage current, n stands for the ideal diode factor, q represents the charge constant, the Boltzmann constant is denoted by k, and the absolute temperature is represented by T.

Buck Converter (DC-DC)
A DC-DC buck converter is a type of power electronic device applied to step down the voltage level of a direct current (DC) power source.It operates by converting a higher input voltage to a lower output voltage while regulating the output current to match the load requirements.This is achieved by controlling the duty cycle of a switch (typically a transistor) in the converter circuit.During operation, the switch is rapidly turned on and off, allowing energy to flow from the input to the output in discrete intervals.The diagram depicting the buck converter circuit is illustrated in Figure 12.The key components of the converter include the transistor switch, and the output LC-type smoothing filter comprising elements L and C, along with a discharge diode.The transistor switch is regulated by a pulse width modulation (PWM) generator, which produces a control signal determined by the calculated duty cycle values, d, computed by the MPPT controller.The initial calculation involves determining the duty cycle, D, using the maximum input voltage, as this results in the highest switch current which can be calculated using Equation ( 4): In the above equation, "η" represents the efficiency of the converter.For the calculation of the values of inductance (L) and capacitance (C), the following equations ( 5) and ( 6) are used: The ripple current refers to the fluctuating or oscillating component of the current that flows through a circuit or device, typically characterized by its alternating nature.In the above equation, ΔIL represents the inductor ripple current and it can be calculated by using Equation (7).

Maximum Power Point Track Control
The performance of photovoltaic (PV) systems is directly affected by changing weather conditions, leading to fluctuations in their output.Solar irradiance, determined by the angle of sunlight, plays a vital role in adjusting the electrical characteristics of PV modules.While the voltage output of a PV module remains relatively stable, its output current is significantly influenced by variations in solar irradiance.To maximize the power extraction from the PV system, an MPPT controller is employed.MPPT technology is essential in modern power systems, ensuring that the maximum available power is efficiently delivered to loads, batteries, motors, and the power grid in off-grid and on-grid applications, correspondingly [37].
Figure 13 shows the diagram of MATLAB-designed MPPT.Overtime, various MPPT algorithms like Constant Voltage (VC), Fractional Open-Circuit Voltage (FOCV), Open Circuit Voltage with Pivot PV Cell (FOCVPVC), Fractional Short Circuit Current (FSCC), Look-up Table (LUT), Hill Climbing (HC), DC Link Capacitor (DCLC) and Incremental Conductance (IncCond) algorithms have been designed to optimize the power and efficiency of solar panels.Each method comes with its own set of advantages and disadvantages.In this paper, the Incremental Conductance Algorithm has been selected, as it tracks the MPP by evaluating the instantaneous conductance of the PV array with its incremental conductance.By dynamically adjusting the operating voltage and current, the ICA (Incremental Conductance Algorithm) ensures that the PV system operates at or near its MPP under varying environmental conditions, maximizing the efficiency and power output of the solar panels.The flow chart of the Incremental Conductance Algorithm is shown in Figure 14.In the incremental conductivity method, adjustments to the terminal voltage of the array are made in line with the MPP voltage, leveraging the incremental and instantaneous conductivity of the PV module.Developed in 1993, this algorithm aimed to address limitations observed in the PO (perturbation and observation) algorithm.INC (Incremental conductance) aims to extend monitoring periods and enhance energy production, especially in expansive environments where irradiation levels fluctuate [38].The system calculates the power and conductance of the PV by analyzing its output voltage and current.Based on these measurements, it determines the duty cycle necessary to operate the system at the MPP.When the ratio of the difference in PV power to the variance in voltage reaches zero, it signifies the attainment of the MPP.This state can be characterized by Equations ( 8) and (9) provided below.
In the power voltage (P-V) curve of a photovoltaic system, the slope refers to the rate at which the power output changes concerning voltage.At the MPP, the slope of the curve is zero, indicating that a slight change in voltage does not affect power output.
Table 3 shows various operational scenarios of the IC algorithm.As you move to the left of the MPP on the curve, the slope increases (positive), meaning that a small increase in voltage leads to a greater increase in power output.
Conversely, as movement to the right of the MPP occurs, the slope decreases (negative), signifying that a small increase in voltage results in a smaller increase in power output.Table 3 outlines the various operational scenarios of the Incremental Conductance Algorithm:  In Figure 15, the graphical representations of the current-voltage (I-V) and powervoltage (P-V) properties for the photovoltaic (PV) array utilized in this study across varying temperature levels have been described.The performance of PV panels is influenced by temperature and solar irradiance.Higher temperatures typically lead to a lower voltage but a higher current due to decreased bandgap energy.Conversely, increased solar irradiance boosts photon absorption, raising both current and voltage.These variations are critical for optimizing PV system design and performance across different environmental conditions.

LCL Filter
The widespread adoption of the LCL filter in contemporary power generation setups is attributed to its superior ability to reduce high-frequency noise, as well as its compact dimensions, and economical nature.The precise and appropriate parameter design for the LCL filter is crucial for cost-saving and enhancing filtering effectiveness [39].Figure 16 illustrates the schematic representation of the LCL filter circuit.The LCL filter effectively reduces current ripples despite having small inductance values, but it can also introduce resonances and instability.Hence, it is crucial to precisely design the filter based on the converter's parameters.One significant aspect of the filter is its cutoff frequency, which should be at least half of the converter's switching frequency to ensure sufficient attenuation within the converter's operational range.Equation ( 10) can be used to find the value of   : The initial stage in determining the filter components involves designing the inverterside inductance, denoted as   which can be calculated using the following Equation ( 11): The inverter-side inductor is tailored to restrict the ripple current to a specified level, typically 10% of the rated current (k = 0.1).The capacitor in the filter should be sized to accommodate a grid power factor fluctuation of up to 5% (x = 0.05).For calculating the value of the filter capacitance, the following equation is used (12): Here,   represents the nominal apparent power and   denotes the RMS voltage between lines; the inductor on the grid side is engineered to restrict the dominant harmonic current amplitude to a defined threshold.
In Equation ( 13),   represents HOMER Pro, the amplitude of the dominant harmonics   , and is the desired amplitude level of the dominant harmonics.To minimize filter oscillations and instability, adding a resistor in the series with the capacitor is recommended, known as "passive damping".While effective and straightforward, this approach increases heat losses and significantly reduces filter efficiency.The damping resistor's value can be determined using the following calculation in Equation ( 14): By use of all the above-mentioned equations, the values of filter resistance Rf, filter capacitance (Cf), resonance frequency (fres), inverter side inductance (Li), and grid-side inductance (Lg) are calculated as 0.0575 Ω, 64 µF, 1.39 MHz, 521 µH, and 316 µH, respectively.

DC-AC Inverter
A crucial element within photovoltaic (PV) systems, the DC-AC inverter, commonly referred to as a power inverter, facilitates the transformation of direct current (DC) electricity produced by solar panels into alternating current (AC) electricity, which is compatible with various appliances and devices.In this paper, a three-phase multi-level inverter is used, which is a type of power inverter used to alter direct current (DC) electricity into a three-phase alternating current (AC) with multiple voltage levels.
Figure 17 represents the schematic diagram of a three-phase multi-level inverter.Its operation hinges on employing three distinct inverter switches, with each switch assigned to one of the three output phases.These switches are meticulously controlled to produce a balanced and synchronized AC output waveform.These inverters offer benefits such as reduced lower switching losses and improved voltage waveform quality.The THD is calculated by measuring the root mean square (RMS) value of all harmonic components present in the waveform and expressing it as a percentage of the RMS value of the fundamental frequency.A lower THD value indicates a waveform with less distortion and a closer resemblance to a perfect sinusoid.In the case of voltage source inverters (VSIs), which are a type of multi-level inverter, additional parameters include DC link voltage, output frequency, load current, and load impedance.The voltage source inverter (VSI) is employed to transform the 50 Hz AC voltage into DC voltage through a diode rectifier.DC link capacitors operate in parallel to store energy and regulate voltage ripples on the DC bus.Pulse width modulation (PWM) is essential for controlling both voltage and frequency.

Performance Analysis of System Using PVsyst Software
The performance ratio serves as a key metric for assessing PV efficiency, with values varying based on factors like environmental conditions, mounting setup, and electrical design.PVsyst, developed in Geneva, is a simulation software utilized for analyzing and optimizing PV system operations.It aids in configuring system setups and estimating energy output, considering geographical location.The simulation results may offer insights into system performance across different time scales, and the "Loss Diagram" feature identifies potential design weaknesses [40].The following is the scheme of work in the performance analysis of the system using PVsyst software.

Orientation
The orientation part in PVsyst 7.4 software serves the purpose of determining the optimal orientation for solar panels to maximize energy production.Field parameters like tilt angle and azimuthal angle are important factors that will assess the yearly incident radiation (transportation factor, loss factor concerning optimum, global on collector plan).The tilt angle of solar panels has been set at 34° to obtain maximum efficiency and a lower loss factor.Figure 18 shows the orientation of PV panels using PVsyst software.

Simulation in PVsyst
PVsyst offers a detailed analysis of irradiance, array, and system losses, allowing users to consider module quality, string mismatches, soiling, wiring, inverter, transformer, and auxiliary losses.It uniquely models degradation and aging effects, which is vital for long-term energy and economic assessment.The projected system aims for a yearly global horizontal radiation of 1657.8 kWh/m 2 and a diffuse horizontal radiation of 702.48 kWh/m 2 , with an average ambient temperature of 14.29 °C.
Moreover, the data underscore the efficiency challenges posed by inverter operation point shifts, indicating the need for optimized system configurations to maximize energy output.The considerable surplus energy of 35.93 MWh/year, coupled with the low fuel consumption estimate of 5551 L for backup generators compared to the community's actual usage of over 75,000 L, highlights the potential for solar power to not only meet but exceed the community's energy needs sustainably.These findings emphasize the importance of ongoing monitoring and adjustment to ensure the optimal performance and long-term viability of solar energy systems in meeting evolving energy demands.Additionally, the comprehensive analysis provided by Figure 19 and Table 4, detailing renewable energy generation and consumption based on predefined parameters, enhances our understanding of renewable energy dynamics, informing future planning and resource allocation strategies for resilient, environmentally friendly energy infrastructure.

HOMER Pro Simulation and Optimization
The design of the hybrid power system is executed using HOMER Pro.HOMER Pro technology was established by the American National Renewable Energy Laboratory in 1993.It serves as a system model capable of evaluating various combinations of components for both grid-connected and off-grid systems.HOMER Pro performs three fundamental functions: simulation, optimization, and the detailed analysis of planned energy systems.During the simulation phase, HOMER Pro conducts hour-by-hour simulations throughout the year to assess the technological feasibility of the proposed systems.Additionally, it evaluates key life cycle cost aspects such as acquisition, repair, service, and maintenance.By considering factors such as energy demand fluctuations, resource variability, and component reliability, HOMER Pro aids in identifying optimal system configurations that not only meet current needs but also anticipate future requirements.Furthermore, its ability to conduct sensitivity analyses offers valuable insights into the resilience of proposed systems, enabling stakeholders to make informed decisions amidst uncertainties in resource availability and market conditions.The flow of work of HOMER Pro is described in Figure 20.Initially, it simulates the system's operation across each time step of the year, considering various factors such as energy demand and resource availability.Following simulation, the software proceeds to optimize the system configuration, aiming to find feasible plans that meet specified constraints while minimizing either the net present cost (NPC) or the cost of energy (COE).Next, a sensitivity analysis is performed to assess how uncertain variables influence both system performance and cost, offering valuable insights into potential risks and opportunities.The optimization results generated by HOMER Pro software are shown in Figure 21.The hybrid power system includes an AC bus for conventional power sources, such as diesel generators, a DC bus connected to photovoltaic (PV) panels, and a battery pack for renewable energy and storage.The diesel generator acts as a backup for the AC bus, while the DC bus utilizes and stores solar energy.Tables 5 and 6 provide technical specifications for the batteries and PV panels, highlighting their capacities and efficiencies.The unit costs of the proposed system, utilized in the simulation, are presented in Table 7.The initial cost of PV panels for the hybrid power system is USD36,685.92,with an operation and maintenance (OM) cost of USD 1317.79 and no replacement cost.The battery bank carries an initial cost of USD 37,800, with an OM cost of USD 13,573.89and no replacement cost.Similarly, the DC-AC inverter has an initial cost of USD 766.66, with an OM cost of USD 309.74 and no replacement cost.Figure 22 shows the results of electricity generation by HOMER Pro.The system is designed to maximize efficiency by facilitating limitless power generation through PV modules.Simulations with HOMER Pro explored 982 configurations of power sources.Table 8 shows that the best configuration includes solar panels, a converter, a battery bank, and a diesel genset, resulting in the lowest net present cost (NPC) of USD 0.102 million and a cost of energy (COE) of USD 0.158.This optimal system significantly reduces costs compared to the current diesel generator cost of USD 1.06, with annual operating costs of USD 2093, saving USD 5207 annually.To show the robustness and impact of key parameter variations on the performance and architecture of the proposed system, a comprehensive sensitivity analysis has been conducted by examining variations in solar global horizontal irradiance (GHI), as detailed in Table 9.This analysis helps to understand how changes in solar irradiance affect the overall system, including energy generation, inverter output, battery usage, and system costs.This approach provides valuable insights into the necessary adjustments and optimizations needed to achieve cost-effectiveness and efficiency in the solar PV system.As shown in Table 9, variations in solar global horizontal irradiance (GHI) significantly impact the key parameters of the proposed system.When the level of solar GHI increases from the scaled annual average of the selected site, which is 5.08 kWh/m 2 /day, more sunlight reaches the solar panels.This increase in sunlight enhances the electrical energy generated by the PV system.Consequently, the inverter has more power to convert, leading to a higher AC output and enabling it to supply more power to meet the demand of the connected load, thus reducing reliance on stored energy.With the increase in PV generation, there is more immediate energy available for use, which reduces the need to draw power from batteries and also improves battery charging.Higher solar GHI will reduce the cost of energy (COE) and the overall cost of the proposed system.Furthermore, there will be no greenhouse gas (GHG) emissions, and the renewable energy fraction will be 100%.Conversely, if the solar GHI decreases, less sunlight is available for generating electricity.In this scenario, the inverter will have less power to convert from DC to AC, resulting in a lower AC output and requiring more power from batteries to meet the load requirements.Additionally, more batteries will be needed to store the energy, which will increase the COE as well as the overall cost of the proposed system.As seen in Table 7, lower solar GHI leads to higher GHG emissions and a reduced fraction of renewable energy.

Dynamic Modeling of Proposed Hybrid Power System in MATLAB Simulink
Assessing the functionality and dynamics of a system heavily relies on dynamic modeling and simulation.MATLAB Simulink simulations are conducted to delve into the dynamic behavior of the envisaged hybrid power system, with a specific emphasis on power quality, voltage fluctuations, and load impacts.The PV array's output characteristics, including V-I and V-P characteristics, exhibit non-linearity and are significantly influenced by environmental factors.These factors include solar irradiation levels, ambient temperature variations, and the extent of partial shading affecting the PV array.The dynamic modeling of a photovoltaic (PV) system, particularly in terms of the ASTM G173 spectrum, involves simulating its performance under varying atmospheric conditions.The ASTM G173 spectrum considers factors such as air mass, ozone content, and aerosol concentration, affecting the spectral distribution of sunlight reaching the Earth's surface.In this modeling, the PV system's reaction to changes in solar irradiance and temperature is analyzed using mathematical models implemented in the software.The Simulink MATLAB design of the proposed hybrid system is shown in Figure 23.Setting the initial irradiance value to around 1000 watts per square meter (W/m 2 ) is common practice to simulate standard solar radiation conditions.Solar cell temperatures may fluctuate within simulations, ranging from approximately 25 °C to 60 °C.However, higher temperatures can also lead to an increase in current output due to enhanced electron excitation within the panel's semiconductor material.These effects demonstrate the complex relationship between irradiance, temperature, voltage, and current in PV panels, ultimately impacting their overall performance and efficiency.
Table 10 represents the scenario of variations in solar irradiance and temperature of PV panels and how they will affect the dynamics of the proposed hybrid power system.This detailed analysis helps optimize PV system design and operation, contributing to the efficient utilization of solar energy resources and the advancement of renewable energy technologies.To visualize the effects of variations in solar global horizontal irradiance (GHI) and temperature, adjustments were made to the parameters of the PV array's solar GHI and temperature within MATLAB Simulink.Initially, the system operated under standard conditions with a GHI of 1000 W/m 2 and a temperature of 25 °C.Figure 24 represents the variations in solar GHI and temperature and their impact on the output voltage and current of the PV panel.Subsequently, at time 0.5 s, the GHI was reduced to 400 W/m 2 to mimic decreased sunlight, while the temperature was incrementally increased to 35 °C.As the irradiance level decreased the voltage and current level between 0.5 to 1.5 s, at time 2 s, the temperature increased to 55 °C and the irradiance level increased to 1000 W/m 2 .Elevated temperatures result in a decrease in current and voltage, whereas higher GHI levels lead to an increased voltage output from the PV array.This analysis enhances the comprehension of the system's behavior under diverse environmental conditions and facilitates performance optimization.The charging process of batteries in photovoltaic systems is significantly influenced by variations in irradiance and temperature.Higher levels of irradiance typically result in increased charging currents and voltages, as more solar energy is available for conversion into electrical energy.Conversely, decreases in irradiance lead to reduced charging currents and voltages.Temperature also plays a crucial role, with higher temperatures generally accelerating charging rates due to enhanced chemical reactions within the battery.In Figure 25, a shift in irradiance occurs at 0.5 s, leading to a discharge of the battery bank until 1.5 s.Subsequently, when the irradiance rises from 400 to 1000 W/m 2 after 1.5 s, the battery begins to recharge and stabilizes at 2 s.
During a power outage, the PV system activates the generator and integrates a Phase-Locked Loop (PLL) into the MATLAB simulation.The system continuously monitors power output to detect shortages, prompting immediate generator activation.Concurrently, PLL parameters, such as reference signal frequency and phase, are set.The PLL block, comprising phase detectors, filters, and oscillators, synchronizes the generator's output with the grid or reference signal.This integration within the MATLAB Simulink model ensures efficient connectivity and interaction among system components.Figure 26 demonstrates the consistent phase-to-ground voltage and current delivered to the connected load through the designed HPS.

Experimental Validation Using Hardware in Loop
Validating a hybrid power system in real-time for a rural community is essential to verify its feasibility, reliability, and efficacy in addressing the community's energy requirements.The OP5707XG by OPAL-RT Technologies serves as an advanced real-time simulator, utilizing FPGA technology to ensure swift and accurate simulations with minimal latency.It excels in facilitating HIL checking for diverse applications, including photovoltaic (PV) systems.With powerful processors and precise I/O interfaces, it accurately replicates load current and voltage dynamics, which is crucial for optimizing PV system performance.Figure 27 shows the hardware structure of the simulator.The OP5707XG can be integrated with MATLAB Simulink, a popular environment for modeling and simulating dynamic systems.The required model to be simulated has been created in Simulink, representing the components and behaviors.Once the model is developed, it can be compiled and executed in real-time on the OP5707XG hardware.This integration allows for HIL testing, where the simulated system interacts with the physical system as well as the design under testing along with components connected to the OP5707XG, representing real-world conditions.Real-time monitoring and logging provided by Simulink enable the analysis of the performance of the simulated system and validate its behavior.Figure 28 shows the hardware architecture of the OP5707XG simulator.The block set has been developed to enable distributed processing, inter-node communication, and signal input/output within the MATLAB Simulink model.Following the simulation using OPAL-RT, the system consistently provided a three-phase load voltage and current, affirming the practical applicability and efficacy of the designed system.

Findings
This research article introduces an innovative method to fulfill the energy requirements of distant and isolated communities by proposing and executing a hybrid power system.Highlighting the importance of innovative energy solutions in remote regions, the research underscores the capability of hybrid power systems to provide a reliable and enduring electricity supply.Incorporating a range of elements, the hybrid power system proposal encompasses solar panels, MPPT, a DC-AC inverter, a buck converter, a diesel generator, battery storage, and an electrical load.The performance analysis and ideal configurations are achieved using PVsyst and HOMER Pro software; the dynamic modeling of the system is conducted in the MATLAB Simulink conditions to assess its performance.Additionally, experimental validation is performed via Hardware-in-the-Loop simulations using the real-time OPAL-RT Technologies' OP5707XG simulator.The primary findings of the study are summarized as follows:

•
Considering the recent floods in Pakistan, attributed largely to climate change induced by greenhouse gas emissions from fossil fuels, there is an urgent call for transitioning to renewable energy sources with minimal greenhouse gas emissions.Leveraging Pakistan's ample solar global horizontal irradiance, solar photovoltaic systems play a crucial role in bolstering the electricity output of hybrid power systems.This addresses the specific energy needs of such facilities while amplifying economic advantages, thereby making advancements consistent with broader energy sustainability goals.

•
Using HOMER Pro, 982 simulations were conducted, resulting in an optimal system with a renewable energy fraction of 100%.

•
The hybrid power system's energy cost is USD 0.158, resulting in substantial savings of USD 0.902 in contrast to the present expenses of USD 1.06.Additionally, the system's annual operating cost of USD 2093 signifies significant savings of USD 5207 in contrast to the current cost of USD 7300.

Conclusions
This study underscores the vital role hybrid power systems can play in advancing sustainable energy solutions for rural communities.By integrating renewable energy sources such as solar panels with traditional generators and employing advanced simulation tools like PVsyst and HOMER Pro, it has been demonstrated that it is feasible to develop reliable, cost-effective, and environmentally friendly energy systems tailored to rural needs.The dynamic modeling and validation, conducted through MATLAB Simulink and Hardware-in-the-Loop simulations, further validate the system's operational efficiency and resilience to variations in environmental conditions.The implementation of such hybrid systems not only helps in reducing the dependency on fossil fuels but also significantly mitigates greenhouse gas emissions, contributing to global efforts against climate change.Furthermore, the economic analysis reveals that the adoption of the HPS can lead to substantial savings in energy costs, enhancing the economic stability of rural communities.As rural areas continue to face unique challenges in accessing reliable energy sources, the findings of this study offer a promising pathway toward achieving energy independence through sustainable practices.It encourages stakeholders, including policymakers and renewable energy developers, to invest in hybrid systems that leverage local resources and technological advancements to meet the increasing energy demands while fostering environmental management.

Figure 5 .
Figure 5.A view of the site captured from above on Google Maps.

Figure 6 .
Figure 6.Actual perspective of the selected site.

Figure 7 .
Figure 7. Selected site solar GHI and clearness index.

Figure 9 .
Figure 9. Monthly electricity usage pattern at the chosen location.

Figure 10 .
Figure 10.Diagram illustrating the proposed hybrid power system.

Figure 11 .
Figure 11. Circuit diagram representing a photovoltaic cell.

Figure 15 .
Figure 15.I-V and P-V curves of selected PV panel.

Figure 18 .
Figure 18.Orientation of the PV Panels.

Figure 19 .
Figure 19.PVsyst simulation outcomes for the proposed system.

Figure 20 .
Figure 20.The operational procedure of the HOMER Pro software in sequential order.

Figure 21 .
Figure 21.Optimization results of HOMER Pro.

Figure 22 .
Figure 22. Results of electricity generation by optimal designing of the HPS in HOMER Pro.

Figure 23 .
Figure 23.MATLAB Simulink dynamic model for the proposed hybrid power system tools like MATLAB Simulink.

Figure 24 .
Figure 24.(a) Variations in solar irradiance, (b) variations in temperature, (c) PV panel output voltage, and (d) PV panel output current due to variations in solar GHI and temperature.

Figure 25 .
Figure 25.(a) %SOC of battery bank, (b) voltage of battery bank, and (c) current of battery bank.

Figure 26 .
Figure 26.(a) Voltage delivered to the load in three phases (RMS).(b) Current supplied to load across three phases (RMS).

Figure 27 .
Figure 27.Hardware structure of the simulator.

Figure 29 .
Figure 29.Three-phase output load voltage as a result of experimental validation.

Figure 30 .
Figure 30.Three-phase output load current as a result of experimental validation.

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Daily radiation (kWh/m²/day) Clearness Index Daily radiation (kWh/m²/day) Clearness IndexTable 2 .
Specifics regarding the electrical load at the chosen location.Energy load profiles provide insights into the consumption patterns of energy over time, capturing the interactions between different subsystems at various spatial and temporal scales.Due to diverse factors, individual households exhibit distinct energy demand patterns, with peak energy usage occurring at different times.

Table 3 .
Various operational scenarios of the Incremental Conductance Algorithm.

Table 4 .
Details of renewable energy generation and consumption based on predefined parameters.

Table 5 .
Specifications of battery used in HPS.

Table 6 .
Specifications of PV panel used in HPS.

Table 7 .
Per unit cost of components used in HPS.

Table 8 .
Results of system optimization in HOMER Pro.

Table 9 .
Sensitivity analysis of the system design by variations in the solar GHI.

Table 10 .
Scenarios of variations in solar irradiance and temperature in MATLAB Simulink.