1 Introduction

Electricity is very important for improving the living standards of people and for a country's economic growth. The majority of the population living in developing nations belongs to rural communities. A large chunk of this rural population relies entirely on biomass or fossil fuels to cook food or to satisfy other needs for energy, but the burning of fossil fuels pollutes the atmosphere and creates greenhouse gas (GHG) emissions that cause global warming and are not good for human health (Chauhan and Saini 2015; Dey et al. 2019; Lu and Wang 2020). In addition to that, the regular supply of electricity to most rural areas is limited to a few hours, for many reasons, such as an inadequate distribution system, energy theft, the reluctance of local people to pay electricity bills, etc. These issues can be resolved by utilizing locally available renewable energy resources for distributed power generation. It is also observed that the whole world is looking to increase the contribution of renewable energy resources to make the power sector more reliable and more efficient. Further, the Ministry of New and Renewable Energy (MNRE), India, has an ambitious target of 175 GW by the end of 2022 (MNRE 2020). It is common knowledge that most renewable energy resources fluctuate in nature, necessitating additional backup for energy storage systems. If battery energy storage is utilized as a backup, it will enhance the cost of the system and the cost of energy (CoE) as well. To overcome these issues, a hybrid energy system (HES) can be developed by utilizing all the locally available renewable energy resources.

Many researchers have employed extensive methodologies such as simulation (Anand et al. 2017), graphical construction (Borowy and Salameh 1996; Markvart 2006), probabilistic (Karaki et al. 1999; Lujano et al. 2013), iterative (Li et al. 2012; Zhang et al. 2013), artificial intelligence (Alturki et al. 2020; Askarzadeh 2013b, a; Alaaeldin et al. 2018; Chauhan and Saini 2017; Delnia et al. 2020; Mubaarak et al. 2021; Paliwal et al. 2014; Li et al. 2020; Wu et al. 2020; Das and Hasan 2021), etc. to address critical issues related to the optimum design and sizing of the equipment used in a HES. Moreover, several authors applied intelligent approaches like Genetic Algorithm (GA), Particle Swarm Optimization (PSO), Harmony Search (HS), Ant Colony Optimization (ACO), Biogeography-Based Optimization (BBO), and Grey Wolf Optimization (GWO) to optimize HESs to maximize economic benefits.

Delnia et al. carried out research for optimal sizing of micro-grid based on solar photovoltaic (SPV)/Wind/Battery and SPV/Wind/Battery/Electric Vehicle, by using PSO and the SPV/Wind/Battery system was found to be more economical (Delnia et al. 2020). Arévaloa et al. investigated five types of storage batteries for hybrid systems such as lead-acid, lithium-ion, vanadium redox flow, and hydrogen, hydrogen-vanadium redox flow were analyzed using HOMER (Hybrid Optimization of Multiple Energy Resources) software, and the vanadium redox flow battery was revealed to be the most effective in terms of net present cost (NPC) and cost of energy (CoE) (Arévaloa et al. 2020). Li et al. proposed a model based on universal size optimization for the hybrid SPV-wind-battery system using the PSO algorithm to determine the optimal configuration of a water pumping system. The developed model was able to meet the power requirements of the system (Li et al. 2020). Alaaeldin et al. proposed an efficient grid-integrated SPV/Wind hybrid system using the hybrid PSO-GWO method for operating a desalination plant for reverse osmosis. In this research, systems such as SPV/Wind/battery and SPV/Wind/Hydrogen storage have been compared in terms of both cost minimization and CO2 emissions. The results demonstrate that the SPV/Wind along with the battery storage system is more economical and environmentally friendly (Alaaeldin et al. 2018).

The study of the optimal sizing of renewable HESs by Bartolucci et al. revealed two findings. Firstly, the fuel cell (FC) system affects the stability of the grid, and secondly, the correct size of the SPV power plant allows the battery to be used more intelligently and gives less reliance on the energy exchanged with the grid (Bartolucci et al. 2018). Chauhan and Saini have proposed a Discrete Harmony Search (DHS)-based approach to optimize the size of a hybrid power system to reduce NPC (Chauhan and Saini 2016). The technique of HS optimization to size a grid-dependent SPV-based system for homes located in Iran was also applied by Zebarjadi and Askarzadeh. The results conclude that the SPV system is more economical in circumstances wherein the price of electricity rises from the current perception (Zebarjadi and Askarzadeh 2016). Singh et al. proposed an ABC algorithm for optimum sizing of a hybrid system for electricity generation in the rural areas of Punjab state in India. The results obtained were found to be more economical as compared to PSO and HOMER (Singh et al. 2016). Eteiba et al. conducted a techno-economic analysis of an off-grid hybrid system consisting of SPV/biomass/battery for meeting Egypt's electricity demand. In the research, three types of batteries, namely flooded lead-acid, Nickel Iron, and Lithium Ferro Phosphate, were considered, and optimal sizing has been done using four optimization techniques, viz. the Flower Pollination Algorithm (FPA), ABC, HS, and the Firefly Algorithm (FA). FA provides more accurate results with minimum execution time (Eteiba et al. 2018). The FA was also employed by Sufyan et al. for economic scheduling and optimization of the battery capacity of an isolated micro-grid. The results were also compared with those obtained by applying ABC, HS, and PSO, and a 50% decline in operating cost was obtained with the use of the proposed FA algorithm (Sufyan et al. 2019).

Anand et al. exploited the PSO algorithm for the optimal design and sizing of the SPV/biomass/biogas and battery-based hybrid system for rural electrification, which includes eight different models. The finding indicates that the configuration comprising of SPV/biogas/biomass performed better than other configurations (Anand et al. 2019a). The same authors attempted to optimize the size of a grid-integrated hybrid SPV/biogas/biomass/battery system for meeting the demand for electricity in Haryana (India).Various configurations are considered and contrasted by employing the GWO algorithm in both off-grid and grid-connected scenarios. It has been concluded from the results that the configuration connected to the grid was found to be the best configuration for the selected area (Anand et al. 2019b). The same authors also carried out the optimal design of a hybrid system consisting of renewable energy resources using two configurations, i.e., hybrid grid-integrated and off-grid systems using the HS algorithm. It has been revealed from the results that a grid-integrated hybrid system comprising SPV/Wind/ biogas/biomass with a battery is the most economical (Anand et al. 2020). Ghaffari and Askarzadeh proposed a modified Crow Search Algorithm (CSA) for the optimal design of hybrid SPV/DG/FC for the minimization of total NPC. It is concluded from the research that the proposed model gave more accurate results when compared with the original CSA, PSO, and GA (Ghaffari and Askarzadeh 2020). Wu et al. used the Salp Swarm Algorithm (SSA) to optimize the size of a grid-connected HES associated with a pumped-storage system. Various configurations of HES have been examined and found the optimal solution. The findings revealed that the power exchange with the grid could be minimized by the proposed HES (Wu et al. 2020).

A detailed literature survey reveals that, while integrating different types of renewable energy sources, it is essential to assess different facets of energy sources, such as technical, financial, and certain other external aspects, in order to obtain the optimum configuration of HES. In recent times, intelligent approaches have become more popular and are able to produce remarkable results. Most of the analysis related to grid-connected scenarios has been done using simulation tools like HOMER, etc. Comparatively, less research is available for grid-integrated HES using intelligent approaches. Further, biogas and biomass-based power generation have been rarely considered by researchers, which are important and potentially valuable resources, particularly in rural areas. Due to this circumstance, there is a research gap and a lack of specialized work in HES by selecting the optimal hybrid configuration depending on the renewable energy resources at a specific site by evaluating various economic and technical factors, etc. Hence, recognizing all these facts, the goal of this proposed work is to select the optimum configuration and sizing of the different components employed in the HES through different intelligent methodologies, viz., an improved HS named as IHS, a newly developed approach, and PSO, for the study area located in the northern region of India (Haryana).

2 Methodology

2.1 Site Selection

A group of four villages (Khanpur Kalan, Kakana, Kasanda, and Sargathal) situated in the district of Sonipat, Haryana state, has been considered in the present study. These villages are located at the latitude of 29.00 °N–29.15 °N and the longitude of 76.75 °E–77.01 °E (Anand et al. 2019a).

2.2 Assessment of Renewable Energy Resources at Selected Site

A comprehensive investigation was carried out to estimate the potential of renewable energy resources for the selected site. The collected data are shown in Table 1, which reveals that the study area has a huge potential for different renewable energy resources. These resources can be used to meet all of the energy needs of the rural people of that area. However, the annual average wind speed of 3 m/s available in the study area is not sufficient for power generation. Biomass has the maximum potential, followed by biogas and solar energy. Further, Khanpur Kalan village has the maximum potential for renewable energy resources among all villages in the study area. Therefore, this village has been chosen for the installation of a renewable energy-based power generation system.

Table 1 Assessment of potential of renewable energy resources at selected areas

2.3 Electrical Load Demand Assessment

To design a hybrid model for electrification of the considered site, the electrical load demand has been estimated by keeping in mind the living standards of the local people and the possible types of electrical appliances to be used by them. The average monthly temperature of the research area during the year lies from 4 to 46 °C. This variability in the study area's average temperature and climatic conditions influences the energy pattern used by different appliances. Therefore, for the present study, the whole year has been sub-divided into three seasons, such as the summer season (April–July), the moderate season (August–November) and the winter season (December–March). Further, the electrical load is characterized as municipal/governmental premises, commercial, residential, and agricultural loads. The residential load of 533 households in the study area includes loads like a fan, LED, TV, refrigerator, mobile charger, cooler, and water pump, etc., as shown in Table 2. The load demands of the school, health centre, veterinary hospital, and street lights are incorporated into the category of Municipal/Governmental load. Shops and water lift pumps are involved in commercial and agricultural loads, respectively.

Table 2 Assessment of load demand for selected area

The daily demand for energy for the research area during the summer season, moderate season, and winter season is computed as 2997.58 kWh/day, 2357.98 kWh/day, and 1286.149 kWh/day, respectively. The annual energy consumption for the chosen location is computed as 809,002.4 KWh/year.

2.4 Objective Function with Design Constraints

The present research aims to minimize the NPC of the proposed system, described as:

Min. NPC

$${\text{NPC }} = {\text{ NPC}}_{{{\text{PV}}}} + {\text{ NPC}}_{{\text{W}}} + {\text{ NPC}}_{{\text{M}}} + {\text{ NPC}}_{{\text{G}}} + {\text{ NPC}}_{{\text{B}}} + {\text{ NPC}}_{{{\text{inv}}}} - \, C_{{{\text{GS}}}} + \, C_{{{\text{GP}}}}$$
(1)

where NPCPV, NPCW, NPCM, NPCG, NPCB, and NPCinv represent the net present cost of the SPV system, wind energy system, biomass generator, biogas generator, battery, and inverter, respectively. CGS defines the selling price of excess electricity to be sold to the utility grid, and CGP represents the cost of deficient electricity to be purchased from the utility grid.

This NPC shall be minimized subjected to the various constraints on the system components as described in the subsequent sections.

2.4.1 Description of System Components

The size of the system components, i.e., the number of SPV panels (NPV), number of batteries (NB), power of biomass generators (PM) and power of biogas generators (PG), varies according to the load demand in the proposed system. The lower and upper limits of these components are, therefore, specified as:

$$N_{{{\text{PV}}}} = {\text{ Integer}}, \, N_{{{\text{PV}}}}^{{{\text{Mn}}}} \le N_{{{\text{PV}}}} \le N_{{{\text{PV}}}}^{{{\text{Mx}}}}$$
$$N_{{\text{B}}} = {\text{Integer}}, \, N_{{\text{B}}}^{{{\text{Mn}}}} \le N_{{\text{B}}} \le N_{{\text{B}}}^{{{\text{Mx}}}}$$
$$P_{{\text{G}}} = {\text{ Integer}}, \, P_{{\text{G}}}^{{{\text{Mn}}}} \le P_{{\text{G}}} \le P_{{\text{G}}}^{{{\text{Mx}}}}$$
$$P_{{\text{M}}} = {\text{ Integer}}, \, P_{{\text{M}}}^{{{\text{Mn}}}} \le P_{{\text{M}}} \le P_{{\text{M}}}^{{{\text{Mx}}}}$$

2.4.2 Battery Storage Capacity Limits

For safe operation of the battery, the maximal (EBmx) and minimal (EBmn) energy storage capacity of the battery are considered and specified as:

$$E_{{{\text{Bmn}}}} \le E_{B} (t) \le E_{{{\text{Bmx}}}}$$
(2)

These battery storage capacity limiting values can be determined using the following Eqs. (34) (Anand et al. 2019a):

$$E_{{{\text{Bmx}}}} = \frac{{N_{{\text{B}}} \times \, V_{{\text{B}}} \, \times \, Q_{{\text{B}}} }}{1000} \, \times \, Q_{{{\text{Bmx}}}}$$
(3)
$$E_{{{\text{Bmn}}}} = \frac{{N_{{\text{B}}} \, \times \, V_{{\text{B}}} \, \times \, Q_{{\text{B}}} }}{1000} \, \times \, Q_{{{\text{Bmn}}}}$$
(4)

where the VB indicates the nominal voltage of the battery (V), the QB denotes battery capacity (Ah), and the QBmn and QBmx indicate the minimum and maximum battery state of charge, respectively.

2.4.3 Constraint for Power Reliability Evaluation

In this study, loss of power supply probability (LPSP) is presumed as a power reliability constraint. If the electrical load demand surpasses the available generation, the user may not have electricity. LPSP is therefore calculated by (Chauhan and Saini 2016):

$${\text{LPSP = }}\frac{{\text{Non served load at hour (t)}}}{{\text{Total load at hour (t)}}}$$
(5)

The LPSP range is considered from 0 to 1. Also, the maximum and minimum limits for the LPSP are as follows:

$${0} \le {\text{LPSP}} \le {\text{LPSP}}^{{{\text{mx}}}}$$
(6)

where LPSPmx is the LPSP’s maximum limit. LPSP is assumed to be zero in the present work.

2.5 IHS-based Intelligent Approach

HS has gained popularity in the past few decades as an efficient solution for solving difficult optimization issues. In the existing HS algorithm, the final position obtained from the harmony memory is utilized toward the location of the search space that is directed toward finding the optimal solution (Askarzadeh 2013b, a; Kamboj et al. 2016). This action may lead to a trap in the local optimum solution. Another offshoot is the reduction of the diversity of the population and HS to drop into the local optimum. To overcome these impediments, an improved harmony search (IHS) algorithm is proposed. The advancement includes a novel search strategy allied by selecting and amending steps, which consists of a dimension learning-based hunting (DLH) search strategy. In the IHS algorithm strategy, each individual harmony memory is well-read by its neighbors to be one more candidate for the latest position of \(X_{i} (t)\). The steps below show how the standard HS and DLH search techniques produce two distinct candidates.

DLH Search Strategy In the original HS, for each harmony memory, the latest position is produced from the given population. As a result of this, HS has a sluggish convergence rate, the population loses diversity too soon, and chimps get stuck in the local optima. To address these flaws, the suggested DLH search technique considers an individual local position that is learnt from its neighbors. Each dimension of the new location of harmony memory \(X_{i} \left( t \right)\) is computed by Eq. (7a) in the DLH search strategy, in which this particular harmony memory is learnt by its various neighbors and a randomly picked population. Then, as well,\(r_{i} (t)\), another candidate for the latest position of harmony memory \(X_{i} \left( t \right)\) named \(X_{{I - {\text{DLH}}}} (t + 1)\), is generated by the DLH search strategy. To achieve this, initially, a radius \(r_{i} (t)\) is calculated by the Euclidean distance between the present positions of \(X_{i} \left( t \right)\) and position \(X_{{{\text{IHS}}}} \left( {t + 1} \right)\) by the Eq. (7b).

$$X_{{i - {\text{DLH}},d}} \left( {t + 1} \right) = X_{i,d} \left( t \right) + {\text{rand}} \times \left( {X_{n,d} \left( t \right)\; - \;X_{r,d} \left( t \right)} \right)$$
(7a)
$$r_{i} \left( t \right) \, = \left\| {X_{i} \left( t \right) \, - \, X_{{{\text{IHS}}}} \left( {t + 1} \right)} \right\|$$
(7b)

Then, the neighbors of \(X_{i} \left( t \right)\) represented by \({\text{N}}_{{\text{i}}} {\text{(t)}}\) are constructed by Eq. (7c) with respect to \(r_{i} \left( t \right)\), where \(D_{i}\) is the Euclidean distance between \(X_{i} \left( t \right)\) and \(X_{j} \left( t \right)\).

$$N_{i} \left( t \right) = \left\{ {X_{j} \left( t \right) \, D_{i} \left( {X_{i} \left( t \right), \, X_{j} \left( t \right)} \right) \, \le r_{i} \left( t \right),X_{j} \left( t \right) \in {\text{Pop}}} \right\}$$
(7c)

Once the neighborhood of \({\text{X}}_{{\text{i}}} {\text{(t)}}\) is constructed, multi-neighborhood learning is performed by Eq. (7a), where the dth dimension of \(X_{{I - {\text{DLH}},\,d}} \left( {t + 1} \right)\) is determined by using the dth dimension of a random neighbor \(X_{n,\,d} \left( t \right)\) selected from \(N_{i} \left( t \right)\), and a random harmony \(X_{r,\,d} \left( t \right)\) from the population (Pop).

Attacking Phase In this phase, first the superior candidate is elected by comparing the fitness values of two candidates \(X_{IHS} (t + 1)\) and \(X_{I - DLH} (t + 1)\) by the Eq. (7a).

Then, in order to update the latest position of \({\text{X}}_{{\text{i}}} {\text{(t + 1)}}\), if the fitness value of the selected candidates is less than \({\text{X}}_{{\text{i}}} {\text{(t)}}\), \({\text{X}}_{{\text{i}}} {\text{(t)}}\) is updated by the elected candidate. Otherwise, \({\text{X}}_{{\text{i}}} {\text{(t)}}\) remains unchanged in the population.

$$X_{i} \left( {t + 1} \right) = \left\{ {\begin{array}{*{20}l} {X_{{{\text{IHS}}}} \left( {t + 1} \right) \, ;} \hfill & {if \, f \, \left( {X_{{{\text{IHS}}}} } \right) < f\left( {X_{{I - {\text{DLH}}}} \left( {t + 1} \right)} \right.} \hfill \\ {X_{{I - {\text{DLH}}}} \left( {t + 1} \right);} \hfill & {{\text{otherwise}}} \hfill \\ \end{array} } \right.$$
(7d)

Finally, after repeating this method for all individuals, the iteration counter is incremented by one, and the search can be repeated until the predetermined number of iterations is reached.

The step-wise method of implementing the IHS algorithm for optimization is discussed below.

2.5.1 Problem Formulation

The problem of optimization concerning an objective function f(X) can be expressed as:

Min. f(X) subject to

$$x_{i}^{{{\text{mn}}}} \le x_{i} \le x_{i}^{{{\text{mx}}}} \left( {i \, = \, 1, \, 2, \, 3, \, 4, \ldots , \, n} \right)$$

where X = [× 1, × 2, × 3,…xn]T denotes a set of decision variables and n denotes the number of decision variables or problem dimensions.

Furthermore, various steps are summarized for implementing the IHS code as:

2.5.2 IHS Parameter Initialization

Adjustable IHS parameters, which include Harmony Memory Size (HMS), Pitch Rate (PR), Harmony Memory Consideration Rate (HMR), and Generation Bandwidth (BW), are also initialized.

The initialization of elements of the harmony memory matrix is done by using the following equation.

$$X_{ij} = X_{{\text{i}}}^{{{\text{mn}}}} {\text{ + rand (}}X_{i}^{{{\text{mx}}}} { - }X_{i}^{{{\text{mn}}}} {)}$$
(8a)

where j = 1,2,3, 4…n; i = 1,2,3,4……HMS. where \(X_{i}^{{{\text{mx}}}}\) and \({\text{X}}_{{\text{i}}}^{{{\text{mn}}}}\) denote upper and lower bounds on ith decision variable; rand denotes random values distributed in the 0–1 range. Mathematically, the harmony memory (HM) matrix is represented as:

$${\text{HM}} = \left[ {\begin{array}{*{20}l} {x_{{11}} } \hfill & {x_{{12}} } \hfill & {x_{{13}} } \hfill & {..........x_{{1n}} } \hfill \\ {x_{{21}} } \hfill & {x_{{22}} } \hfill & {x_{{23}} } \hfill & {..........x_{{2n}} } \hfill \\ {x_{{31}} } \hfill & {x_{{32}} } \hfill & {x_{{33}} } \hfill & {..........x_{{3n}} } \hfill \\ \begin{gathered} . \hfill \\ . \hfill \\ x_{{{\text{HMS}}1}} \hfill \\ \end{gathered} \hfill & \begin{gathered} \hfill \\ \hfill \\ x_{{{\text{HMS}}2}} \hfill \\ \end{gathered} \hfill & \begin{gathered} \hfill \\ \hfill \\ x_{{{\text{HMS}}3}} \hfill \\ \end{gathered} \hfill & \begin{gathered} \hfill \\ \hfill \\ ..........x_{{{\text{HMS}}n}} \hfill \\ \end{gathered} \hfill \\ \end{array} } \right]_{{{\text{HMS}} \times n}}$$
(8b)

2.5.3 Development of New Harmony

A new harmony vector is developed based on experience and is referred to as improvisation or adjustment of harmony. To generate new harmony, i.e., Xnw = [xnw, 1, xnw, 2, xnw, 3,…xnw, n], the following stages are carried out for all decision variables:

Stage (i): A new random number (RN) is generated in the range of 0–1.

If RN > HMR, then the decision variable \(X_{ij}^{{{\text{nw}}}}\) is generated by using the following equation.

$$X_{ij}^{{{\text{nw}}}} = X_{j}^{{{\text{mn}}}} + {\text{ rand }}(X_{j}^{{{\text{mx}}}} - X_{j}^{{{\text{mn}}}} )$$
(9)

where j = 1,2,3, 4…….n; i = 1,2,3,4……HMS.

If, on the contrary,\({\text{RN}} \le {\text{HMR}}\), then one of the decision variables stored in the current HM is chosen at random using the following equation:

$$X_{ij}^{{{\text{nw}}}} = \, X_{ij}$$
(10)

where i = 1,2,3,4……HMS; j = 1,2,3,4…….n;

Stage (ii): HS considers a pitch adjustment mechanism through which the new harmony can move to a neighboring value in respect of the possible range. To execute a pitch adjustment mechanism, a uniformly distributed random number (rand) is generated between 0 and 1 after stage (i). If \({\text{rand}} \le {\text{PR}}\), the new harmony will move to a neighboring value using the following equation.

$$X_{ij}^{{{\text{nw}}}} = \, X_{ij}^{{{\text{nw}}}} + \, B_{{\text{W}}} \times \, ({\text{rand}}{ - }0.5) \, \times \, (X_{j}^{{{\text{mn}}}} { - }X_{j}^{{{\text{mx}}}} )$$
(11)

where BW denotes bandwidth;

Further, the iteration-wise value of variables PR and BW is calculated as follows (Anand et al. 2020):

$${\text{PR}}\left( {{\text{itr}}} \right) \, = {\text{ PR}}_{{{\text{mn}}}} + \, \frac{{\left( {{\text{PR}}_{{{\text{mx}}}} { - }{\text{ PR}}_{{{\text{mn}}}} } \right)}}{{{\text{itr}}_{{{\text{mx}}}} }} \times \left( {{\text{itr}}} \right)$$
(12)
$$B_{{\text{W}}} \left( {{\text{itr}}} \right){ = }B_{{{\text{Wmx}}}} {\text{ exp }}\left( {{\text{a.itr}}} \right)$$
$$a{ = }\frac{{{\text{Ln }}\left( {\frac{{B_{{{\text{wmn}}}} }}{{B_{{{\text{wmx}}}} }}} \right)}}{{{\text{itr}}_{{{\text{mx}}}} }}$$
(13)

where PR (itr) represents an iteration wise pitch adjustment rate; itr denotes an iteration index; PRmx and PRmn denote the maximum and minimum value of the adjustment rate of the pitch. BWmx and BWmn denote maximum and minimum bandwidth values.

Stage (iii): The population obtained from Eq. (11) is further updated using a DLH-based search strategy.

2.5.4 Updation

If the newly created harmony vector \(\left( {X_{ij}^{{{\text{nw}}}} } \right)\) delivers better results as compared to the worst \(\left( {X_{ij}^{{{\text{wst}}}} } \right)\) harmony in HM, the new harmony vector is taken into account in the HM instead of the existing worst harmony and it is mathematically represented as:

$$X_{ij}^{{{\text{wst}}}} = \left\{ {\begin{array}{*{20}l} {X_{ij}^{{{\text{new}}}} ;} \hfill & {f \, \left( {X_{ij}^{{{\text{new}}}} } \right) \, < \, f \, \left( {X_{ij}^{{{\text{wst}}}} } \right)} \hfill \\ {X_{ij}^{{{\text{wst}}}} ;} \hfill & {\text{ Otherwise}} \hfill \\ \end{array} } \right\}$$
(14)

Based on the obtained solution, the best value of the objective function is calculated as:

$$f^{{{\text{bst}}}} = \, \min \, \left( {f_{i} } \right) \, ; \, i \, \in \, 1, \, 2, \, 3, \, 4.......{\text{HMS}}$$
(15)

2.5.5 Check Stopping Criteria

If no. of iterations exceeds, then the algorithm will cease to work, else step 2.5.3 and step 2.5.4 are repeated.

2.6 PSO-based Intelligent Approach

PSO is a stochastic-based optimization approach that has been propelled by the communal performance of bird congregating, which initializes with inhabitants of random solutions known as particles and sees the optimal solution by updating generation.

In PSO, the particle is represented by a vector having m decision variables. Initially, m particles are arbitrarily initialized in the search space. Each particle is trying to get a better position than the present one. The memory information comprises the best experience expressed by the group (Gbest) and the best experience gained by the particle (Pbest). The updating expression at each iteration (i) is given by the equation as (Anand et al. 2019a; Askarzadeh and Leandro 2015; Mahesh and Sandhu 2019):

$$V_{j} \left( {i + 1} \right) = w \, \times \, V_{j} \left( i \right) + C_{1} \times \, r_{1} \, \left( {P_{{{\text{best}}j}} \left( i \right){ - }x_{j} \left( i \right)} \right) + C_{2} \times \, r_{2} \, \left( {G_{{{\text{best}}j}} \left( i \right){ - } \, x_{j} \left( i \right)} \right)$$
(16)
$$x_{j} \left( {i + 1} \right) = V_{j} \left( {i + 1} \right) + \, x_{j} \left( i \right)$$
(17)

where i = 1,2,3,…….imax; j = 1,2,3,4……SP. where Vj denotes the velocity of jth particle; xj represents the position of jth particle; SP denotes the size of particles; C1 and C2 are the learning coefficients; r1 and r2 represent random numbers lying in the range of 0 to 1; imax is the maximum number of iterations.

Further, w known as inertia weight factor is used to provide a balance among the local and global search. A larger value of w results in a global search, whereas a small value leads to a local search. Generally, the value of w is varied by using the following equation.

$$w \, (i) \, = \, w_{{{\text{mx}}}} - \, \frac{{w_{{{\text{mx}}}} - w_{{{\text{mn}}}} }}{{i_{{{\text{max}}}} }} \, \times \, i$$
(18)

where wmn and wmx are the initial and final values of inertia weight.

Further, the following steps for implementing the PSO algorithm are described as:

2.6.1 Initialization of the Problem with PSO Parameters

The first step is to formulate the problem (objective function along with constraints). Besides, the adjustable PSO parameters are also defined.

2.6.2 Initialization of Particles

In the second step, m particles have been initialized in the search space with randomly generated decision vectors. The initialization of each particle is done using the following equation.

$$x \, \left( 0 \right) \, = \, x_{{{\text{mn}},j}} + {\text{ rand }}\left( {x_{{{\text{mx}},j}} \, { - } \, x_{{{\text{mn}},j}} } \right)$$
(19)

where xmx and xmn denote the initial and final value of x for all particles.

2.6.3 Fitness Function Evaluation

Based on the value of decision variables associated with each particle, the value of the objective function is determined.

2.6.4 Updation

Pbest is calculated for each particle and Gbest is selected among the population based on the best particle. Further, each particle is allowed to move to the next new position. More specifically, the velocity of each particle and its position are updated by employing Eqs. 16 and 17, respectively.

2.6.5 Stopping Criteria

If the maximum number of iterations is completed, the algorithm stops and Gbest is considered as the optimal solution. Otherwise, steps 2.6.2 and 2.6.4 are repeated.

2.7 Database for Techno-Economic Evaluation

The techno-economic database required as input to optimize the size and operation of the proposed system is detailed as:

2.7.1 Electrical Load Requirements (kW)

The hourly load demand in the study area throughout the summer, moderate and winter seasons is demonstrated in Fig. 1. The maximum load demand for the study area is estimated in the summer, winter and moderate seasons as 177.71 kW, 177.71 kW and 182.12 kW, respectively.

Fig. 1
figure 1

Electrical load demand of the proposed location

2.7.2 Average Solar Irradiance (kWh/m.2/day)

For the selected area, the availability of monthly average solar energy is depicted in Fig. 2. It is found to be highest in the month of May (7.08 kWh/m2/day) and lowest in December (3.23 kWh/m2/day) (NASA 2020).

Fig. 2
figure 2

Available monthly average solar energy for study area

2.7.3 Mean Air Temperature (°C)

The air temperature for different months of the year at the proposed location is presented in Fig. 3. It has been observed that the ambient temperature of the research area lies in the range of 8 °C–42 °C during the year.

Fig. 3
figure 3

Available mean air temperature for study area

2.7.4 Scheduling of Biogas and Biomass Generators

Bio-generators have been scheduled for operation when the load reaches the peak value for the proposed research area and are demonstrated in Table 3.

Table 3 Scheduling of biogas and biomass generator for study area

2.7.5 IHS and PSO Algorithm Parameters

For optimizing the objective function, various IHS algorithm parameters are detailed as: itrmx = 150; HMR = 0.95; PR = 0.1; HMS = 5; PRmx = 1; PRmn = 0.1. The following parameters are set for the PSO algorithm: m = 4, C1 = 2, C2 = 2, Sp = 30, and imax = 150.

2.7.6 Economical database of Hybrid System Components

The economic database of particular components of the hybrid system is listed in Table 4.

Table 4 Database of hybrid system (Anand et al. 2019b, 2020)

2.7.7 Project Parameters

In present research, the life of the system is 25 years with an 11% interest rate.

3 Result and Discussion

A concerted effort has been made to achieve the optimal size and design of the hybrid system made up of renewable energy resources. Firstly, under the off-grid mode, the three models of renewable energy-based systems are considered in the present study, as elaborated below:

  1. (a)

    Model M11: SPV/Biomass/Battery

  2. (b)

    Model M12: SPV/Biogas/Battery

  3. (c)

    Model M13: SPV/Biomass/Biogas/Battery

The hourly simulations for each model have been conducted in MATLAB for one year. The parameters were optimized with the goal of minimizing the system's NPC, which was achieved by employing the IHS and PSO algorithms. The SPV/biomass/biogas/battery model connected to a grid has also been simulated on an hourly basis using both algorithms to validate the results. Finally, the results from off-grid models are compared with the grid-connected hybrid model, and the optimal option has been found.

The selected off-grid models are simulated for fulfilling the load demand of the proposed location on an hourly basis using IHS and PSO algorithms by simulating in MATLAB. The obtained result after hourly simulation along with the optimum size of each component is shown in Table 5.

Table 5 Result of hybrid renewable energy system for off-grid scenario

It is observed that the most optimal off-grid model M11 comprises a 229.13 kW (975 nos.) SPV system, a 166 kW biomass gasifier system, and 544.8 kWh (227 nos.) of battery bank storage system along with a 100 kW converter. The optimum NPC of the model is calculated as $7.17 * 105 and a CoE of $0.105/kWh. It has also been reported that IHS gives more promising results compared to PSO.

3.1 Optimization Results of Grid-Integrated Hybrid Model

The optimization of the grid-integrated hybrid model, which consists of SPV/Biogas/Biomass/battery using IHS and PSO algorithms, was carried out, and the results are presented in Table 6.

Table 6 Results of grid-connected model using IHS and PSO algorithms

It is concluded that the IHS model has given more accurate results as compared to the PSO algorithm. The optimal size of the grid-connected model obtained by the IHS algorithm is a 226.31 kW SPV array, a 41 kW biomass system, a 98 kW biogas system, a 55.2 kWh battery bank storage, and a 100 kW converter, with NPC and CoE calculated as $6.00 * 105 and $0.081/kWh, respectively.

3.2 Comparative Analysis of Off-Grid and Grid-Connected Models

The grid-integrated model is compared with off-grid models in terms of NPC and CoE. Tables 5 and 6 reveal that the grid-integrated model has a lower value for NPC and CoE than the off-grid models. Besides, it is also observed that the grid-connected model has the lowest battery storage capacity of 55.2 kWh to meet the full load demand. As a result, the grid-connected model is better and is proposed for the selected area given economic concerns. Further, the results of different parameters of the proposed model are presented in the forthcoming sections.

3.3 IHS and PSO Algorithm Convergence Curve for Proposed Model

The convergence curve for the IHS and the PSO algorithm of the proposed grid-connected model is shown in Fig. 4.

Fig. 4
figure 4

Convergence curve of IHS and PSO algorithm for best model

From Fig. 4, it is observed that IHS converges completely and provides a fixed value at the 128th iteration. However, PSO has converged to a constant value after the 140th iteration. Therefore, it is obvious that IHS has a faster convergence than PSO. Besides, to test the efficacy of the proposed IHS optimization model, a set of different benchmark functions is considered, which comprises three major benchmark feature classes: Uni Modal (UM) benchmark functions F1, F2, F3, F4, F5, F6 and F7; Multi-Modal (MM) benchmark functions F8, F9, F10, F11, F12, and F13; and benchmark problems of Fixed Dimensions (FD) are considered (Bhattacharya et al. 2021; Dhawale et al. 2021). The values of the mean, standard deviation (SD), best value, worst value, median, quartile, Wilcoxon sum test, statistical T test, and simulation time result are computed for each of the objective functions for 10, 30, 50, and 100 dimensions, respectively, and demonstrated in Tables 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 and 18. In the present work, 30 trial runs are considered, and the proposed model is simulated for a maximum of 500 iterations. The proposed optimization model was tested at 2.60 GHz on Intel ® Core TM and i7-5600 CPUs.

Table 7 Test result of UM benchmark functions using IHS algorithm for 10, 30, 50, and 100 dimensions
Table 8 Quartile result for UM function using IHS algorithm (10, 30, 50, 100 dimensions)
Table 9 Test result of UM benchmark functions using IHS algorithm for 10, 30, 50 and 100 dimensions
Table 10 Simulation time of UM benchmark functions using IHS algorithm for 10, 30, 50 and 100 dimensions
Table 11 Test result of MM benchmark functions using IHS algorithm for 10, 30, 50 and 100 dimensions
Table 12 Quartile result for MM test function using IHS (10, 30, 50, 100 dimensions)
Table 13 Test result of MM benchmark functions using IHS algorithm for 10, 30, 50 and 100 dimensions
Table 14 Simulation time of MM benchmark functions using IHS algorithm for 10, 30, 50 and 100 dimensions
Table 15 Test result of FD benchmark functions using IHS algorithm for 10, 30, 50 and 100 dimensions
Table 16 Quartile result for FD test function using IHS (10, 30, 50, 100 dimensions)
Table 17 Test result of FD benchmark functions using IHS algorithm for 10, 30, 50 and 100 dimensions
Table 18 Simulation time of FD benchmark functions using IHS algorithm for 10, 30, 50 and 100 dimensions

3.4 Annual Energy Generation by Grid-Connected Optimal Model

The contribution of different renewable energy resources to the annual generation of electricity by the proposed grid-connected model is shown in Fig. 5.

Fig. 5
figure 5

Share of renewable energy resources in annual energy generation

The obtained result clearly shows that the SPV array produced the maximum amount of electricity of 450,570 kWh/year (65.56%), followed by biomass with 182,885 kWh/year (26.61%) and biogas with 53,822 kWh/year (7.83%).

3.5 Cost-wise Breakup of NPC

The proportion of the cost breakup in the overall NPC of the proposed model is given in Table 19. The cost of grid purchase was found to have the highest share of $280,400 among all costs.

Table 19 Cost-wise breakup of NPC

3.6 Component-wise Breakup of NPC

The contribution of different system components is shown in Fig. 6. Biomass has been observed to have the biggest part of a total of 50% of NPC, followed by biogas with 19%, the SPV panel with 14%, the battery with 11% and the converter with 6%.

Fig. 6
figure 6

Share of different renewable energy resources in NPC

3.7 Seasonal Energy Sale and Purchase to/ from Grid

Seasonal energy sold and purchased from the utility grid has been shown in Table 20. It is concluded that in the summer season, the proposed model buys more energy, followed by the moderate and winter seasons. It is due to the increased demand for energy during the summer. Furthermore, grid sales and grid purchases are relatively lower in the winter than in the summer and the moderate seasons due to lower energy demand.

Table 20 Seasonal sale and purchase of energy to grid

4 Conclusion

In this research, the modeling and optimization of the hybrid energy system based on renewable energy resources has been carried out in the remote area of Sonipat, India. Based on the available renewable energy resources, different configurations for off-grid and grid-connected scenarios are developed and presented. From the developed configurations, an optimized model is selected to electrify the given location based on NPC and CoE. The IHS, a newly developed algorithm, and PSO algorithms have been used to optimize the hybrid energy system.

The size optimization of the hybrid renewable energy system for the grid-connected scenario is obtained as a 226.31 kW SPV array, 98 kW biogas system, 41 kW biomass system, 100 kW converter, and 55.2 kWh of battery bank storage. The total NPC and CoE are estimated to be $6.00 * 105 and $0.081/kWh, respectively. The findings of the study may be used to develop a hybrid renewable energy system for other related areas having the same geographical parameters.