1 Introduction

Recently, using renewable energy in residence has been increased due to an increase in consumption. The consumption will grow to 20–40% of the global energy consumption in the future and has an essential fact in the electricity market (Sarker et al. 2015). Inspired by the concept of microgrid (MG), the traditional habit of using energy for customers and metering methods of electrical energy will be completely changed.

Driven by the concept of giving priority to energy saving, it is required to obtain the intelligence of devices, which will encourage and help the customers to use electric power carefully. A MG contains a mix of distributed energy resources (DERs), energy storage systems (ESSs), loads and tools (Katiraei et al. 2008; Nejabatkhah and Li 2015). The operation of a MG requires energy management strategy (EMS) which controls the power in the microgrid by planning the power bought/sold to adjust their operation within the MG (Jiang et al. 2013). The MG configuration integrated many types of converters used between different power sources and the loads. Generally, DC–DC, DC–AC and AC–DC converters are used in the power system due to the different natures of the output voltages. Several techniques have been studied to solve energy management system (EMS) in MG, in the literature including dual decomposition (Zhang et al. 2013) to develop a distributed EMS in MG, neural networks (Siano et al. 2012), genetic algorithms (Fathima and Palanisamy 2015), particle swarm optimization and game theory (Zhao 2012). The use of those methods does not prove the optimal solution. In addition, using linear and dynamic programming methods can ensure the optimal solution if it is feasible. However, they consider the renewable energy (RE) as non-dispatchable sources, and accordingly, energy storage systems (ESSs) are scheduled for balancing production and demand (Nejabatkhah and Li 2015; Shi et al. 2015; Marra and Yang 2015).

Several examples of energy storage systems could be used in MGs such as batteries, plug-in-hybrid vehicle (PHEV) batteries, supercapacitors and flywheels (Tsikalakis and Hatziargyriou 2008). An important research has been adopted in the integration of power sources and ESS into the MG. The output power of different REs and ESSs requires to be controlled and coordinated to improve the reliability of the MG. While the ESSs and REs are used into the MG, the need for real-time power management starts and requires more attention. Optimizing energy management between different sources of MG, certain categories of research have been conducted out. A control strategy of a DC microgrid developed (Xu and Chen 2011), consisting of a hybrid system (wind turbine, energy storage system and DC load). The obtained result presents different problems related to the integration of MG with the grid. The intermittent power requires ESSs in a decentralized generation system (Tani et al. 2015).

To keep a constant production between different sources like solar energy (PV), power plants and ESS, an energy management strategy is suggested. This strategy tries to control the SOC level to a reference value (Beltran et al. 2013). However, improving the performance of the batteries the charge and discharge cycle is recommended (ISCC21 2008). In Hooshmand et al. (2014), an approach for limiting the deep of discharge (DOD) to 30% has a disadvantage since the ESS charged from the grid is first utilized instead of using the surplus energy stored from the renewables. Considering ESS with REs will contribute to the cost minimization, energy-efficient and secure solutions to the MG. Charging and discharging modes of ESS have a necessary function in power management. However, unplanned charging and discharging modes can affect the proper operation of MG by significant problems such as power quality and voltage variations (Pahasa and Ngamroo 2015). Proper scheduling for charging and discharging of ESS required a sound strategy for EMS. Newly, many methods have been published in the literature for the same. A mathematical model for EVs to grid integration is implied based on various charging and discharging efficiencies of ESS (Das et al. 2014). In this sense (Singh et al. 2013), to control the charging and discharging rates of ESS of EVs a fuzzy-based controller is proposed. Controlling the state of charge of ESS (SOC) and limiting the energy generated by REs a control strategy are suggested (De Matos et al. 2013). In Li et al. (2012), the authors used a standard droop control method to schedule the diesel generators (DGs) and ESS in MG. By keeping the balance between state of charge (SOC) and the output power of ESS, gain-scheduling techniques for power sharing and energy management system based on voltage control are studied (Kakigano et al. 2013). A robust control strategy was proposed to manage the parameter uncertainties in the problem of heating a steel rod (Triki et al. 2017). Recently, in microgrids, the trend is to increase local consumption instead of exporting the surplus power generated by REs (Castillo-Cagigal et al. 2011). This trend can avoid the fluctuations in the voltage at the main grid (Sangwongwanich et al. 2015).

The ultimate purpose of the proposed study is to maximize the use of REs and consider the ESS as a secondary source when the pick demand reached. Minimize the operation of the grid, and the excess of power produced from REs will be sold into the network.

In this work, a novel structure of EMS for energy storage system-based hybrid microgrids is designed and tested to improve the optimal power references for DERs by taking account their operation modes.

  • The EMS includes the modeling and optimization problem that proposed to minimize grid distribution costs, controlling the stage of charge for ESS.

  • ON/OFF control strategy of the grid and ESS is modeled and tested.

  • Adequate regulation of charging and discharging rates of batteries is secured for proper running of the system during events.

This work is an extension of the previous study presented in El Kafazi and Bannari (2016). The proposed strategy is able to provide a proper and adjustable solution to avoid the maximization of the grid operation, based on the high penetrations of REs and ESS.

The scheduling strategy provides an order of power charge and discharge to the ESS and also informs the SoC-level requirements prior to the schedule period.

This study is directed as follows: Sect. 2 focuses on the operation of the MG with components specified as a case study, Sect. 3 comprises the modeling and the optimization, Sect. 4 introduces and interprets the results and Sect. 6 concludes the work.

2 Problem Description

The studied laboratory building of our school is located in Kenitra, Morocco. Figure 1 represents the view of the studied laboratory building. The laboratory has two floors, and in average, 60 students are working in the laboratory during the day. The suggested system is located on the roof of this laboratory.

Fig. 1
figure 1

View of the studied laboratory

The studied laboratory has four halls on the first floor and four halls and administration office on the second floor. Therefore, we aim to provide the electricity demand for this laboratory by utilizing the proposed hybrid system. It is assumed that the load demand is almost constant during the working day. Figure 2 presents the daily load profile of the laboratory. Peak demand is recorded during the daytime when students are using the laboratory (i.e., 8 am–6 pm).

Fig. 2
figure 2

Daily load profile for the studied laboratory

3 System Description

Figure 3 represents typical power systems with renewable energies, energy storage systems and load demand. For the principal operations of the grid, operating quantities (e.g., voltages, currents and power demand) should be collected to the EMS through data communication infrastructure and monitoring devices. The demand is principally satisfied by the sum of the PV, WT and the battery. If the sum of renewables (PV and WT generator) is over the demand, the surplus energy is stored in the storage system. The MG is made up of different sources of solar energy with 2.4 kW, a wind turbine with 1 kW, battery and electrical loads as presented in Figs. 4 and 5. The grid is used when the power from renewables and the battery cannot ensure the demand requirements. Regardless of the operation strategy selected, the grid can only supply the deficit of power needed by the load.

Fig. 3
figure 3

Structure of the MG based on renewable energy, energy storage system and load demand

Fig. 4
figure 4

Real site in the laboratory

Fig. 5
figure 5

Microgrid site in the laboratory

The principle functioning of the MG and operating quantities (e.g., voltages, currents, power generation and weather data) will be collected, processed and then saved in the database of the EMS as historical data. During the operation, data communication and devices perform this role with additional functions such as control actions, and these actions can be secured by the EMS via data communication according to the device conditions (Choi et al. 2011).

3.1 PV Model

The PV generator is defined by the current I and voltage V and by the equivalent circuit. Various mathematical models are formed to represent the behavior of PV (Borowy and Salameh 1996; Markvard 2000; Zhou et al. 2007; Lasnier and Ang 1990; Nikraz et al. 2003). In the literature, different methods for PV model such as current and voltage at MPPT and open-circuit voltage are used (Lasnier and Ang 1990).

3.2 Wind Turbine System

Various factors that define the output generated from the wind energy are: The output power can be determined as a purpose of aerodynamic power efficiency, mechanical transmission, power conversion and wind speed distribution. There are many current models to measure the power generated from wind turbine such as linear (Bueno and Carta 2005), quadratic (Lin et al. 2002; Chou and Corotis 1981) and cubic (Hocaoglu et al. 2009). Adaptive control theory is used for nonlinear dynamic systems for stability and tracking based on fuzzy logic systems (Chaoui and Gualous 2017).

3.3 Data Collection

Data were collected by using Vantage Pro 2 Weather Station (http://www.ges-lyon.fr) (see Figs. 5 and 6). The data estimated for 1 day (24 h) to be used in order to test the proposed strategy (see Fig. 7 ) in the system are presented in Fig. 3.

Fig. 6
figure 6

Hourly wind speed (m/s) and temperature (°C) for 1 day

Fig. 7
figure 7

Operational process of the power system scheduling in the laboratory

3.4 Forecasting

A proper forecasting requires knowledge of the RE generation and the load profile. In addition, it is important for the effectiveness of operation of the EMS. However, RE generation and load profile are generally forecasted the day before. With scheduled forecasting, EMS can decide on the reserve quantity and risk strategies for grid operation in advance. An adequate method to correct such quantities is studied (Beyer et al. 2009) using real-time measurements. In addition, ARIMA model, linear regression and polynomial curve fitting are used (El Kafazi and Bannari 2016; El Kafazi et al. 2017) to predict load demand and energy production. In order to improve the use of PV generator and wind turbine, a scheduling strategy is proposed in El Kafazi et al. (2018). Besides, to reduce the intermittence impacts caused by PV panel, an energy storage system is proposed to maintain the energy produced in Vieira et al. (2018).

3.5 Tables

Table 1 presents the type of energy used for all the periods in the day. The shifting from a source to the other one is scheduled at the time required.

Table 1 Distribution energy per period in the day (24 h)

Table 2 shows the system parameters for photovoltaic (PV), wind turbine (WT) and battery that indicate the total ratings of renewables (Table 3).

Table 2 Parameter system
Table 3 Parameter of the battery

4 Proposed Scheduling Control and Optimization Model

The WT and PV are considered to be connected meeting the entire load demand. However, the grid constraints are taken on consideration. The proposed model in this work solves the optimization problems of minimization cost of the grid and economic scheduling simultaneously. The performance of the approach is dependent on the control parameters and constraints handling. The daily operational process in the laboratory is summarized in Fig. 8. The energy forecasting was made at 17:00 before the day of operation.

Fig. 8
figure 8

Proposed strategy control

Load demand is an input; the estimated power of renewable energy and the power of the ESS is an obligation to verify whether the ESS with renewables can meet the power load or not. On the one hand, if the renewables with storage system are equal to power demand, then it is a regular operation. On the other hand, if the power load is superior or inferior to the renewables with ESS, we should use the power from the grid. During the scheduling, SoC information from ESS and forecasting from RE will be used to inform the scheduler of the energy available. Based on this information, the optimization strategy-based controller can decide the import or export from the grid.

4.1 Optimization Model

The optimization problem addressed in this work aims to minimize the grid cost by getting the optimal scheduling of power generation in the working day while responding to the load demand requirements. The selected study is a hybrid system composed PV–wind–battery microgrid oriented to the self-consumption operation, and selling energy to the grid, namely the power exchange with the grid, is allowed (Fig. 9).

Fig. 9
figure 9

Process optimization strategy used in this work

As mentioned, the control of the grid can be performed using ‘ON/OFF’ control. In particular, the power variables to be scheduled are the power of the battery, the power used from the grid, defined as a dispatchable source, and the power for the REs, which are defined as non-dispatchable sources, corresponding to the WT and PV, respectively. The power profiles correspond to the predicted generation of the non-dispatchable sources that, in this case, are equal to the predicted power in maximum power point (MPPT) for the REs as shown in Fig. 10.

Fig. 10
figure 10

Input data: power profiles and forecasted power shown in a PV and b WT generators, respectively (Color figure online)

4.2 Objective Function

The objective is to find a proper solution of ON/OFF control of the grid that minimizes its operating cost. In addition, a method should be used for taking the final optimal solution such that it can define the preferences of the microgrid. Different methods have been suggested in this area (Farzin et al. 2017).

The REs is working as the principal source of energy with the ESS considered as an emergency supply source. In addition, if a deficit of power from the RE sources and the ESS battery is detected, the grid is turned on. Considering the grid is switched ON/OFF and the REs and ESS battery are easily controlled to satisfy the demand, the objective function below is expressed as a mixed-integer programming.

$$ {\text{OF}} = \mathop \sum \limits_{t = 1}^{T} \left( {P_{\text{sell}}^{\text{grid}} \left( t \right)\Delta t C_{\text{sell}}^{\text{grid}} \left( t \right) - P_{\text{buy}}^{\text{grid}} \left( t \right)\Delta t C_{\text{buy}}^{\text{grid}} \left( t \right)} \right) \lambda_{t} $$
(1)

where \( \lambda_{t} \) is a discrete switching that enables to manage the energy by sending ON/OFF controls. \( \lambda_{t} \) = 0 signifies that the grid is turned off during the time t, while \( \lambda_{t} \) = 1 signifies that the grid is turned on.

Constraints: the power balance (2) is the first condition that the model should include between generators, renewables, storage systems and demand in the microgrid. The formulation can be shown as follows:

$$ \mathop \sum \limits_{t = 1}^{T} P^{\text{grid}} \left( t \right)\Delta t \lambda_{t} + \mathop \sum \limits_{i = 1}^{2} P_{{{\text{res}},i}} \left( t \right)\Delta t + P_{\text{bat}} \left( t \right)\Delta t = P_{\text{l}} \left( t \right)\Delta t X_{\text{load}} $$
(2)

The first term is related to the energy absorbed from the grid and inserted into the grid, respectively. The second term is the energy provided by the renewables. In turn, the third expression corresponds to the cost related to disconnect the load, which is equal to 0 if the load is connected (\( X_{\text{load}} \) = 1).

In addition, the boundaries related to the output of the renewable energy and utility grids are defined as follows:

$$ 0 \le P_{{{\text{res}},i}} \left( t \right) \le P_{{{\text{res}},i}}^{\hbox{max} } \left( t \right) \leftrightarrow P_{\text{res}} = P_{\text{pv}} + P_{w} $$
(3)
$$ 0 \le P_{\text{sell}}^{\text{grid}} \left( t \right) \le \mathop \sum \limits_{i = 1}^{2} \lambda_{t} P_{\hbox{max} }^{\text{grid}} \left( t \right) $$
(4)
$$ 0 \le P_{\text{buy}}^{\text{grid}} \left( t \right) \le \left( {1 - \lambda_{t} } \right) P_{\hbox{max} }^{\text{grid}} \left( t \right) $$
(5)
$$ 0 \le \lambda_{t} \le 1 $$
(6)

4.3 Energy Storage System

The generated power from the REs and the load demand at any interval t define whether the battery is charging or discharging. The constraints related to the ESS are defined as follows:

$$ ES_{t}^{\text{bat}} = ES_{t - 1}^{\text{bat}} + P_{{{\text{ch}},t}}^{\text{bat}} \eta^{{{\text{bat}},{\text{ch}}}} - P_{{{\text{dis}},t}}^{\text{bat}} /\eta^{{{\text{bat}},{\text{dis}}}} $$
(7)

where \( ES_{t}^{\text{bat}} \) is the energy storage in the battery, \( P_{{{\text{ch}},t}}^{\text{bat}} \) and \( P_{{{\text{dis}},t}}^{\text{bat}} \) are the power charging and discharging of the battery, and \( \eta^{{{\text{bat}},{\text{ch}}}} \) and \( \eta^{{{\text{bat}},{\text{dis}}}} \) are the battery charging or discharging efficiency.

Moreover, the boundaries related to the output of the ESS are defined as follows:

$$ \left( {1 - B_{t} } \right) + B_{t} = 1\quad \forall t \in T $$
(8)
$$ 0 \le P_{{{\text{ch}},t}}^{\text{bat}} \le B_{t} P_{{{\text{ch}}.\hbox{max} ,t}}^{\text{bat}} \quad B_{t} \in \left\{ {0, 1} \right\}\;\forall t \in T $$
(9)
$$ 0 \le P_{{{\text{dis}},t}}^{\text{bat}} \le \, \left( {1 - B_{t} } \right)P_{{{\text{dis}}.\hbox{max} ,t}}^{\text{bat}} \quad B_{t} \in \left\{ {0, 1} \right\}\;\forall t \in T $$
(10)
$$ ES_{\hbox{min} }^{\text{bat}} \le ES_{t}^{\text{bat}} \le ES_{\hbox{max} }^{\text{bat}} $$
(11)
$$ ES_{t = 0}^{\text{bat}} = ES_{t = 24}^{\text{bat}} $$
(12)

5 Results and Discussion

The aimed process control is executed by combining SPSS 20.0 software and GAMS environment solved by OSICPLEX solver working on an Intel® Core™ i5 4200 CPU (1.73–2.30 GHz) PC with 8 GB RAM. It is connected to renewable sources as defined in Figs. 3 and 10, and characteristic of ESS unit is given in Table 2. The real data of load demand, solar, and wind generation at different hours are given in Figs. 2, 6 and 10.

The simulation study is carried out for 1 day. The optimization model is tested by using real data of generation and consumption of a day, with time holes of 1 h (\( \Delta t \) = 1).

The power scheduling for all systems is performed in accordance with the general technical conditions in order to reduce the costs of the power grid. The proposed and studied strategy reduces the cost of the utility grid. Based on the economic scheduling strategy, each variation that happens during operation is accorded by the minimum cost among grid and energy storage systems, which can be controlled, so that the scheduled value can be met.

Generally, EMS takes into consideration both economic and ecological factors. The performance of EMS is defined by presenting numerical results from the scheduling strategy. In addition, among the most important input data for power scheduling are the power forecast data for the planning horizon.

The figures below present the forecasted and actual power of WT and PV in 24 h. The forecast has been provided with an acceptable accuracy.

The optimization process is executed by applying real data of wind speed and solar irradiance of a summer day. The scheduling and optimization problem is resolved by using the software GAMS as algebraic model language, and the solver CPLEX is used to measure the power references obtained for the proposed model. The system is implemented to minimize the cost of consuming energy from the grid and to generate the charging and discharging schedules of the battery.

5.1 Forecasting Production

In order to approve the performance of the proposed strategy, the power profiles for PV and WT, shown in Fig. 10a and b, have been collected based on real data of irradiance and wind speed obtained from http://www.ges-lyon.fr, as mentioned. The SPSS software was used to estimate the calculation of the output power of PV–wind-based hybrid system (Fig. 10).

The generation profiles used in the scheduling process are presented as \( P_{\text{forecasted}} \) in Fig. 10a and b, while the experimental verification is executed by using the \( P_{{{\text{real}}\;{\text{power}}}} \) profile of REs. They have been selected to explain how the system performs with enough local power to meet the load demand and when the MG has to use the energy from the main grid. A controller included a power conditioning system, and battery control system is connected directly to the laboratory EMS. The grid is connected to the laboratory from a distribution transformer. It can absorb surplus power from laboratory or can supply power to laboratory. For scheduling and experimental verification, the initial condition of SoC is set as 80%. Besides, the operation of the MG is performed with the EMS.

The exchange power with utility grid will be represented in this section. In this case, the forecasting production is necessary for expecting in advance if the local energy is enough to supply the load without absorbing energy from the main grid.

The implemented strategy control is able to maintain the main grid off as long as the storage system is fully charged, which means the battery can ensure the threshold value. From 20 to 7 h, the PV power generation is 0 W.

It reaches the peak amount (2.4 kW) from 13 to 15 h. In addition, the WT power generation reaches the peak amount (1 kW) from 9 to 10 h and 16 to 18 h. At 8 h, electricity load of the laboratory starts consuming the power generation from REs. As a typical load change in the laboratory, the amount of electric power load reaches peak consumption from 11 to 17 h, between 2.94 and 3.19 kW.

The energy storage battery supplies the insufficient power in the microgrid and absorbs surplus energy from the microgrid when REs is surpassing the electric load.

When there is an exceed energy in the microgrid, surplus energy is provided to the grid. During the weekend, all energy produced by the REs will be sold to the grid in order to offset the deficit cost during the working week. Besides, in this period the load demand is disconnected by \( X_{\text{load}} \) = 0.

The findings illustrate that the PV generation has a huge part of supplying in energy production, which has reached the highest percentage of excess energy. Moreover, developing the performance of PV power and WT allocates a basic part of the energy generation, thereby increasing the battery and inverter sizes.

As can be observed, there is surplus energy during the day and just part of the energy is employed, while some reduction is used. Moreover, the power profile corresponded to the presented grid. In this case, the profile is positive when microgrid injects power into the grid (sells) and negative when receives power (buys). On the contrary, the profiles of selling and buying power to the utility are shown in Fig. 11. Figure 12 (result obtained by GAMS) shows that the surplus REs is sold to the grid where the local production is sufficient to provide the load, and thus, it is not required to buy energy from the grid.

Fig. 11
figure 11

Related measured variables of scheduling power with utility grid and MG. Top to bottom: Power of PV, power of load, power of wind, power of battery and state of charge

Fig. 12
figure 12

Exchange power with utility grid obtained by GAMS

From the experimental results of the MG presented in Fig. 13, the optimization strategy schedules to consume power from the grid during the day, when the consumption of energy increases and the WT, PV and the battery cannot contribute to ensure the energy demand. In addition, from 08 h the part of the energy generated by wind energy is used in the local consumption and, at the same time, is required to buy energy from the utility because the energy provided by the WT, PV and battery is not enough to meet the demand. However, the battery is charged in the day before as shown in Fig. 13 for managing the imbalance between RE generation and load demand during the periods. The scheduled power profile, state of charge and the charging/discharging of the battery during the day are presented in Figs. 11 and 13. As can be pointed out, the battery is discharged when the power stored from the REs is low, while it is charged when there is high power in the REs.

Fig. 13
figure 13

Power of battery during the day (24 h) obtained by GAMS

As shown in Fig. 13, the scheduling obtained by GAMS keeps the level of the battery to manage the power at the end of the day when the WT and PV do not generate energy. The technical methods were validated experimentally by performing the MG with the EMS. It is possible to conclude that the EMS enables reducing the cost of the utility grid in the MG and also can include technical restriction for managing the storage system in the correct way.

6 Conclusion

The renewable energy generation forecast is a necessary part of an efficient MG-based EMS operation. These energies, connected with a battery system, would contribute to system reliability, making it proper for stand-alone applications.

In this study, the MILP was used to achieve the optimal solution for the economic utilities of the hybrid system installed in the laboratory. The proposed strategy has been used to set optimal power references for the distributed resources of the microgrid. Besides, it has been used to minimize the running cost of the utility grid. Related to the results of the energy production, it was concluded that the WT production contributes to the 21.65% of total energy production per week, while PV generation produces 78.35% total energy per week. The monthly energy production was estimated to be 775.3 kWh, while the monthly energy consumption is 607.7 kWh. Moreover, it is noted that the hybrid system can supply 167.6 kWh per month of excess power to the laboratory with the optimal solution. As future work, the optimization strategy can be improved by considering the cost of load demand disconnection.