1 Introduction

Owing to rising energy demand and increasing earth warming in recent years, employing clean energy technology to supply demand is expanding (Shakibi et al. 2022). The utilization of clean energies technology has needed strategies, such as siting and sizing of the resources, optimal power dispatch and operation of the energy system with minimum emission and costs (Han and Yu 2023). Wind turbines (WTs) and photovoltaics (PVs) are most main clean energies technology in electrical systems (Lak Kamari et al. 2020). On the other side, the power generation by WTs and PVs depend on weather statutes and is often uncertain. Thus, the storage systems like batteries are major devices for covering energy generated by PVs and WTs (Elhassan 2023). Batteries are the most useful electrical equipment in electrical systems. This equipment has optimal performance in electrical systems; as it can store extra power of PV and WT, it discharged at power shortcomings (Ahmadi et al. 2020). Hence, installing the batteries in the electrical system is optimal for providing economic operation at any time and condition (Fambri et al. 2022).

Power dispatch in energy systems has been studied using different approaches and strategies in the recent years. In Jiang et al. (2021) operation of the microgrids in connected mode to the main grid is studied under the uncertainty of the PV system and energy price. The authors in Chamandoust (2018) present modelling energy systems in various seasons with energy-saving strategies and local conditions. The optimal energy dispatch in integrated electrical and gas systems with demand participation is proposed in Tazvinga et al. (2015). In Hou et al. (2022) genetic algorithm is used for optimal energy system operation with demand-side management modelling. The increasing lifetime of the batteries by optimal scheduling of the demand with WTs output is presented in Huang et al. (2022). In addition, in Mazzeo et al. (2018) load management strategy is proposed to maximization of the battery lifetime and efficiency of the energy storage systems. The economic modelling of the storage systems with WTs and PVs is studied in Zhang and Maleki (2022). The power management of the hybrid energy system is proposed in Kaveh and Vazirinia (2020) with memetic optimization modelling. In Khalid et al. (2018), the reconfiguration approach is employed to maximize energy efficiency and energy system reliability in uncertainty modes of the PVs, WTs and load demand. The peak scheduling strategy of the energy demand alongside the optimal design of the resources is proposed in Jamalzadeh et al. (2020).

In this paper, the quadratic programming approach and heuristic technique is applied to the hybrid power supply system with the aim of minimizing fuel costs, minimizing use of the battery and maximizing use of PV and WT generators. The paper considers the effect of daily energy consumption and renewable energy variations on the system by introducing disturbances in the demand profiles and renewable energy output for both winter and summer seasons. The multi-objective optimization used in this work enables designers, performance analyzers, control agents and decision-makers who are faced with multiple objectives to make appropriate trade-offs, compromises or choices. In following optimal energy generation in off-grid energy systems for AC and DC load demand is presented. The optimal energy dispatch is done to meet demand by a proposed heuristic algorithm. On the other hand, the proposed heuristic algorithm is solved by a nonlinear quadratic programming approach as robust energy optimization. As well, battery storage systems are utilized for feed demand subject to WTs and PVs energy. Therefore, novelties in this study can be listed as follows:

  1. 1.

    The load demand is supplied in an off-grid energy system under an uncertainty approach.

  2. 2.

    The optimal energy generation-based heuristic algorithm is proposed.

  3. 3.

    The nonlinear quadratic programming approach is proposed as a solution method.

  4. 4.

    The battery storage systems are used for covering PVs and WTs' energy output.

2 Energy system overview

In Fig. 1 the energy system overview is depicted. The proposed energy system consists of a diesel generator (DG), WT, AC load, PV, battery and DC load. The energy dispatch of the system is considered for an optimal meet to AC load and DC load. In Fig. 1 energy dispatch to P1, P2, and P3 are energy generated by DG, the energy exchange between AC and DC buses and the energy exchange of battery in charge and discharge modes, respectively. The converter is used to P2 exchange in two modes to meet AC and DC loads. The modes of the converter including inverter and rectifier. The inverter can convert DC to AC, while a rectifier converts AC to DC. In the following subsections, modelling components are given.

Fig. 1
figure 1

Energy system overview

2.1 PV modelling

The mathematical modelling of the PV is formulated as follows (Zhang et al. 2019):

$$P_{{{\text{PV}}}} (t) = \eta_{{{\text{PV}}}} \times A_{{\text{C}}} \times I_{{\text{s}}} (t).$$
(1)

Here PPV(t), ηPV, AC and Is(t) are the power output of the PV at time t, efficiency of PV, area of solar panels and solar irradiance at time t, respectively.

2.2 WT modelling

The power generation of the WT is modelled by Eq. (2) (Bilil et al. 2016):

$$P_{{{\text{WT}}}} (t) = \frac{1}{2} \times \eta_{{\text{t}}} \times \eta_{{\text{g}}} \times \rho_{{{\text{air}}}} \times C_{{\text{p}}} \times A \times V_{{\text{r}}}^{3} (t),$$
(2)

where PWT(t), ηt, ηg, ρair, Cp, A and Vr(t) are WT power generated at time t, the efficiency of the turbine, efficiency of the generator in WT, air density, the factor of power generation, area of the WT rotor and wind speed at time t, respectively.

2.3 DG modelling

The power generation of the DG is dependent on the injected fuel and the power capacity of the DG. Hence, the energy generation by DG can be modelled as fuel cost than power generation (Abedinia et al. 2019):

$$C_{{{\text{DG}}}} = \sum\limits_{t = 1}^{24} {\left\{ {\left( {a \cdot P_{1}^{2} (t)} \right) + \left( {b \cdot P_{1}^{{}} (t)} \right)} \right\}} .$$
(3)

Here CDG and PDG(t) are DG fuel cost and power generation of the DG in time t, respectively. Also a and b are cost factors of fuel.

2.4 Battery modelling

The battery is used to feed demand when energy generation by resources is less than demand. The battery is charged at low demand by WTs and PVs and discharged at shortcoming energy generation in generation. The modelling battery based on the technical and economic indices is as follows (Ding et al. 2020):

$$0 \le P_{{\text{B}}}^{{{\text{DIS}}}} (t) \le u_{{\text{B}}} (t) \times P_{3}^{\max } ,$$
(4)
$$0 \le P_{{\text{B}}}^{{{\text{CH}}}} (t) \le [1 - u_{{\text{B}}} (t)] \times P_{3}^{\max } ,$$
(5)
$$C_{{\text{B}}}^{{{\text{OP}}}} = \sum\limits_{t = 1}^{24} {\left\{ {\left( {c_{{\text{B}}}^{{{\text{DIS}}}} \times P_{{\text{B}}}^{{{\text{DIS}}}} (t)} \right) + \left( {c_{{\text{B}}}^{{{\text{CH}}}} \times P_{{\text{B}}}^{{{\text{CH}}}} (t)} \right)} \right\}} .$$
(6)

Equations (4)–(6) are the power discharge limit, power charge limit and operation cost of the battery, respectively. As well, \({P}_{\mathrm{B}}^{\mathrm{DIS}}\) and \({P}_{\mathrm{B}}^{\mathrm{CH}}\) are discharge and charge powers, respectively. The binary variable (uB) is used to ensure that discharging and charging are not done simultaneously. The \({c}_{\mathrm{B}}^{\mathrm{DIS}}\) and \({c}_{\mathrm{B}}^{\mathrm{CH}}\) are the degradation cost of the battery in discharging and charging modes, respectively.

3 Objective function modelling

The objective modelling function is formulated based on the minimization of the energy generation cost of the DG and battery in Fig. 1. The optimization interval is implemented at 24-ahead and power forecast of the PV and WT. The optimization approach is solved by integrated Quadratic programming with the weight sum method in MATLAB software. The objective function is modelled by (7):

$$\min f = \sum\limits_{t = 1}^{24} {w_{1} \cdot C_{{{\text{DG}}}} (t)} + w_{2} \cdot C_{{\text{B}}}^{{{\text{OP}}}} (t) - w_{3} \cdot P_{{{\text{PV}}}} (t) - w_{4} \cdot P_{{{\text{WT}}}} (t),$$
(7)

where w1 to w4 are weights of decision variables, and which sum of them is equal to 1. In objective function (7), plus sign is considered to CDG and \({C}_{\mathrm{B}}^{\mathrm{OP}}\) in order to minimize the generation costs of the DG and battery, respectively. On the other side, in order to maximize PV and WT penetration, minus sign is used in the objective function. Actually, objective function (7) is modelled based on the minimzing costs of the DG and battery, and maximizing PV and WT penetration. The objective function is optimized subject to optimal energy dispatch of resources by the following equations:

$$P_{1} (t) + P_{2} (t) = P_{{{\text{LAC}}}} (t) - P_{{{\text{WT}}}} (t),$$
(8)
$$P_{2} (t) + P_{3} (t) \le P_{{{\text{PV}}}} (t) - P_{{{\text{LDC}}}} (t),$$
(9)
$$0 \le P_{1} (t) \le P_{1}^{\max } .$$
(10)

PLAC and PLDC are the energy demand of AC and DC loads, respectively. As well, Eqs. (8)–(10) are energy dispatch in the AC bus, DC bus and limit of the DG energy generation, respectively.

4 Solution method

As mentioned before, Quadratic programming is employed to solve optimization problems. Using Quadratic programming, optimal power dispatch can be done to each load demand. Hence, to implement optimal energy dispatch at any time, Eqs. (8)–(10) should be satisfied with minimum cost and high penetration of PV and WT. The Quadratic programming modelling for objective function is as follows (Tazvinga et al. 2014, 2015):

$$\min \left\{ {\frac{1}{2} \cdot x \cdot Hx + fx} \right\}.$$
(11)

And modelling for Eqs. (8)–(10) are as follow:

$$Ax \le b,$$
(12)
$$A_{{{\text{eq}}}} x = b_{{{\text{eq}}}} ,$$
(13)
$${\text{Lb}} \le x \le {\text{Ub}},$$
(14)

where H and f are the matrices of the second-and first-degree coefficients, respectively. A and b are unequal equations; Aeq and beq are equal equations. Finally, Lb and Ub are lower and upper of the decision variable, respectively.

5 Numerical simulation

In this section, a heuristic algorithm for optimal energy dispatch of the resources is implemented in Fig. 2. The energy demand and power forecasted of the PV and WT are shown in Fig. 3. It should be mentioned power forecast of the PV in winter and summer is assumed. In addition, the system data are extracted from Refs. Tazvinga et al. (2015) and Tazvinga et al. 2014).

Fig. 2
figure 2

Heuristic algorithm for optimal energy generation

Fig. 3
figure 3

Power forecast PV, WT and load demand

6 Results

The results of the energy system are provided as two operations modes (two cases) in Table 1. In this table, the operation of the PV and WT penetration (weights w3 and w4) in both cases are considered equal. However, to show the battery's performance, the weight w2 in case 2 is more than in case 1. Thus, DG, due to having high-cost fuel factors, the weight related to DG in case 2 is less than in case 1. Figures 4 and 5 depict the energy dispatch of the energy system in cases 1 and 2 for the summer season. When comparing Fig. 4 with 55 the power generation of the DG in case 1 at hours 1 and 2 is more than in case 2. The generation cost in cases 1 and 2 for summer are $ 283.3 and $ 253.6, respectively. Hence, with the increasing weight of the battery in case 2 and meeting AC and DC demands at peak hours, generation cost is reduced by % 10.4 in comparison to case 1. In case 2, power exchange (P2), because of the high DC demand at hours 1–4, has been decreased than in case 1. The power dispatch in Fig. 5 represents DC demand is more meet by the battery than in Fig. 4.

Table 1 Operation modes in the energy system
Fig. 4
figure 4

Energy dispatch in Case 1 for summer

Fig. 5
figure 5

Energy dispatch in Case 2 for summer

In Figs. 6 and 7, power dispatch in the winter season for both cases is shown. In Fig. 6, due to the reduction in the PV energy in winter, the power generation of the DG has been increased than Fig. 4, with the same weights in case.1. In addition, in Fig. 7. DG has more contribution in feed demand because of the low power production by PV and unavailable power discharge of battery at hours 1–11 and 21–24. The value of the generation cost for the winter season in cases 1 and 2 is $ 298.3 and $ 297.4, respectively.

Fig. 6
figure 6

Energy dispatch in Case 1 for winter

Fig. 7
figure 7

Energy dispatch in Case 2 for winter

According to the obtained results for the summer and winter seasons, it can be concluded that the battery system depends on PV power and positively impacts generation costs in summer and winter. The battery in both cases is used at peak demand to minimize power generation by DG with high-cost factors of fuel. Power exchange (P2) between AC load and DC load at peak demand is also done for battery charging and to meet demand.

7 Discussion

When the two cases are compared, there is a minor increase in the operational cost in favour of the cases. The cases may be considered a more economic dispatch strategy that minimizes system costs. The case 1 is a case where fuel cost is given more weight, and the cost increase is due to increased usage of the DG, depicting the importance of balancing and prioritizing the objectives. In the case 1, the DG supplies the load and this may be an unfavourable option for any decision maker, as it results in high cost of DG. The system in this case limits the battery usage, resulting in battery life being prolonged at the cost of fuel. In such a case the DG supplies power during the hours to complement what is coming from the battery. The optimization results thus provide a platform for designers, performance analyzers, control agents and decision-makers who are faced with multiple objectives to make appropriate trade-offs, compromises or choices. The results demonstrate that the proposed model can be used to balance the system’s operational cost effectively.

7.1 Annual performance of the hybrid energy system

In this subsection, the performance of the hybrid energy system is analyzed annually. This section is proposed for verification and confirmation of the proposed optimization in 1 year. In addition, two operation modes in Table 1 is considered, and the average value of the AC load, DC load, WT, and PV powers are considered as input data in the 8760 h (1 year). In Fig. 8, annually performance of the hybrid energy system based on costs of the DG and battry in cases 1 and 2 is shown. The total cost of the DG and battery in case 1 is equal to $44,879.3; whereas in case 2 total cost is $42,896.6. The reduction of the total cost in case 2 is due to more participation of the battery with more weight than case 1.

Fig. 8
figure 8

Annually performance of the hybrid energy system

8 Conclusion

This paper presents the optimal energy dispatch of the resources in an off-grid energy system. Using Quadratic programming and the weight sum method, optimization of the energy dispatch in the summer and winter seasons is implemented. The battery system is used as storage energy to cover energy at peak demand. The main objective function is minimizing energy generation costs and maximizing renewable energy resource participation. The two case studies in each season are considered under the equal operation of the system. The results of the numerical simulation for case studies shown the effective and optimal role of the battery system in meeting energy demand at peak times and minimizing generation costs. In addition, optimal model results reveal how the system power flows change in response to the chosen combination of the components of the cost function. A practical platform for decision making has been presented. Future work will include a techno-economic analysis of the system, taking into account various cost combinations.