1 Introduction

As an essential element of modernizing power grids to form future smart grids, distributed generations (DGs) have developed rapidly in recent years. Serving as the buffer between DGs and the main grid, the microgrid (MG) mitigates the impact of the randomness and intermittency of DGs on external grid [1]. By coordinately controlling DGs and energy storage (ES), the MG is able to ① efficiently manage and control a large number of DGs, and ② maximize economic and environmental benefits [2].

The key to MG application is the control and operation technology. The previous works related to the operation and control of MG can be grouped into three layers that work coordinately with each other, as shown in Fig. 1 [3].

Fig. 1
figure 1

Three hierarchical control layers for microgrid

The first layer focuses on the converter’s design of distributed energy resources (DERs) [4, 5] to implement a fast response rate (in milliseconds) to track MG load variations and maintain voltage and frequency stability. The second layer focuses on the MG mode controller to seamlessly switch the operating modes between grid-connected and islanded modes [6, 7]. The third layer comprises the methods of smart energy management and optimal load scheduling [8, 9], which performs relatively long time-scale optimization compared to the above two layers. The upstream controller generates instructions to the underlying device controllers through communication network.

Similar to the energy management system (EMS) in the main grid, the EMS of MG includes day-ahead power scheduling and real-time energy management [10]. Based on distributed generation availability, load forecasting, the purchasing/selling electricity price (forecasted clearing price in the power market), the MG control center optimally schedules the power output of DGs, ES, and controllable load the next day. The schematic is shown in Fig. 2. Moreover, the ultra-short term load forecasting is implemented to help adjust the day-ahead operation scheduling to reduce the errors in real-time MG EMS.

Fig. 2
figure 2

Microgrid control process of day-ahead optimal scheduling

The algorithms and techniques for day-ahead energy management and optimal scheduling in the MGs with DGs and ES controls have been discussed [1118]. If there are high cost dispatchable sources in the MG, such as diesel generators or micro-turbines (MTs), the operational economic efficiency becomes more important and the objective is to minimize total cost or maximize the generation profit. Due to the high-energy cost of dispatchable sources, the principle of determining power generation based on heat/cold amount is applied in grid-connected MG. In this case, ES can be a useful tool for MG EMS. The electricity market restructuring brings various price mechanisms, which make energy management and optimal control of grid-connected MGs a hot topic for both academia and industry.

In existing literatures [14], the objective of the ES control is to minimize the cost of purchasing power from the main grid to perform peak shaving or frequency regulation with consideration of the technical limitations of ES. In peak shaving mode, ES discharges during the 6–10 peak hours, and charges during the 3–5 valley hours. In frequency regulation mode, ES charges during the 6–8 valley hours and the remaining energy is prepared for regulating frequency. These control strategies consider the physical characteristics of ES including charging power rate limitation and lifetime cycles as constraints [19, 20]. However, they are only proposed for a specific type of power markets, such as time of use (TOU) mechanism.

The optimal operation of ES in the electricity market has been investigated and some artificial and computational intelligence technologies are employed to optimize the MG with regard to ES charge and discharge scheduling in order to maximize the benefits related to the electricity price differences. In [16], a novel dynamic optimal control strategy for battery energy storage station (BESS) based on the wind power forecasting was proposed to smooth the wind power fluctuations. Its operating principle was built on the wind power forecasting to minimize the offset of SOC. The optimal control model also considers the performance of the ES media. In [17], an intelligent scheduling system was developed to reliably schedule the charge and discharge cycles and operate the BESS. An online control algorithm is applied to mitigate the errors of load forecast through continuous adjustments of initial charge and discharge schedule based on load profile forecast.

Most present approaches are restricted to ① various MG policies and power market regulation in different countries. ② the limitations of ES lifetime cycles, operating cost, and depreciation cost. To address the above issues, a day-ahead optimal scheduling method for grid-connected MG based on ES control is proposed in this paper, which has the following features:

  1. 1)

    Creatively adapting various market structures with strong robustness; By modelling the operating cost function of each stage in the dynamic programming, the impact of different market structures is limited to each stage rather than the whole scheduling horizon.

  2. 2)

    Comprehensively considering the related factors including charge/discharge efficiency, self-discharge, and depreciation cost of ES; The deprecation cost of each cycle and the energy loss of ES are taken into account in the decision-making process of each stage, which makes the optimal scheduling more practical.

  3. 3)

    The optimal operating cost under different energy levels of ES in each stage can be quickly obtained, which is helpful for the decision-making of MG the operators.

The rest of this paper is organized as follows. Section 2 presents an overview of the MG control strategies under different electricity market structures. Section 3 discusses the characteristics and operating cost of ES and their impact on the economy of MG. Section 4 proposes an optimization model for MG day-ahead optimal scheduling and illustrates the solution algorithm based on dynamic programming. Section 5 demonstrates the simulation results and numerical analysis to clearly verify the proposed method. Finally, Section 6 concludes the paper.

2 Market and microgrid control strategies

2.1 Energy management and operating costs

Due to the random nature of renewable energy, the power generation of DGs, such as wind turbines (WTs) and photovoltaic (PV) panels, is irregular and intermittent. MG can keep real-time supply–demand balance by exchanging power with main grid and coordinating controllable generation units, loads, and ES.

$$w_{k} = L_{k} - G_{k} + x_{k}$$
(1)

where w k is the energy exchange between MG and the main grid at time interval k; G k and L k are the forecasted power generation and load respectively at time k, and the network loss is incorporated into L k ; x k is the charge/discharge power of ES equipment; and x k is positive when charging and negative when discharging. The units of above variables are all kWh or MWh.

Since the scale of MG is usually small and the length of distribution line is short, the potential network loss could be incorporated into forecasted load demand. Hence, its impact on the optimal scheduling can be ignored. Different from the traditional grid, all of the four variables in (1) can participate in energy management control in MGs. The discrete expression of the objective function is to minimize the total operating cost as below.

$$\hbox{min} \;v = \sum\limits_{k = 1}^{K} {v_{k} }$$
(2)

where K is the total number of time intervals; v k is the operating cost in k th time interval, including cost of purchasing electricity from the main grid, fuel cost of DGs, power loss cost, and depreciation cost of ES, which could be formulated as (3).

$$v_{k} = v_{{{\text{W}}k}} (w_{k} ) + v_{{{\text{X}}k}} (x_{k} ) + v_{{{\text{G}}k}} (\Delta G_{k} ) + v_{{{\text{D}}k}} (\Delta L_{k} )$$
(3)

where v Wk (·) and v Xk (·) are the cost functions of power purchasing/selling from MG to main grid, and ES charging/discharging in k th time interval, respectively; v Gk (·) and v Dk (·) are the cost functions for DGs and loads dispatch; ΔG k is the change of DGs power output; and ΔL k is the load curtailment through demand response or direct load control.

2.2 MG scheduling strategies and its operating price

The coordinated control is used to maximize the benefits for both MG owners and the users, while providing the thermal and electric demands to its local area. The control methods are determined by their operating cost.

2.2.1 MG energy management with adequate power supply

When DGs cannot satisfy the load, there are several possible actions that MG can take: ① discharging ES equipment; ② purchasing power from the main grid; ③ increasing the generation of controllable DGs; and ④ load shedding.

Here, this paper adopts the following strategy: discharging ES is considered as the first priority. Meanwhile, the other actions are still necessary due to the limitation of ES capacity. The minimum operating price of the k th time interval ρ Wk can be expressed as:

$$\rho_{{\text{W} k}} = \hbox{min} (\rho_{{\text{B} k}} ,\rho_{{{\text{G}}k}} ,\rho_{{{\text{L}}k}} )$$
(4)

where ρ Bk is the price of MG to buy power from main grid; ρ Gk the unit cost of DG power output, and ρ Lk the unit cost of load control at k th time interval.

Based on the assumption that dispatchable sources, such as MT combined cooling/heating and power (MT-CCHP) or fuel cell, have a high energy cost determined by heat/cold production, (4) can be replaced by ρ Wk  = ρ Bk when taking the follow assumptions: ① No power exchange limitation on tie-line in the grid-connected mode; ② To improve the efficiency, the principle of determining power generation by heat/cold demand is applied; ③ The controllable DGs in MG, like MTs, have a higher operating cost than ρ Bk ; ④ Without demand response in MG, ρ Lk is substituted by outage cost, which is much larger than the cost of power purchasing.

2.2.2 MG energy management with power supply shortage

When DGs exceed the demand, there are several possible actions that MG can take: ① charging ES; ② selling power to main grid; ③ Reducing the generation of DGs. Taking the strategy that renewable DGs maximize their production, charging ES, and selling power to the main grid become feasible options to deal with the redundant energy. The revenue of selling power to main grid can be seen as negative operating cost. The minimum operating price ρ Wk can be expressed as:

$$\rho_{{{\text{W}}k}} = \rho_{{{\text{S}}k}}$$
(5)

where ρ Sk is the power selling price from MG to main grid.

Base on the aforementioned analysis, the following assumption is adopted in the proposed energy management model: to address the unbalance between supply and demand, besides ES charging/discharging, the power exchange between MG and main grid is used in priority for generation unit adjustment and load control. Its cost rate is determined by the power purchasing/selling price.

2.3 Market environment and costs for power unbalance

The positive direction of power exchange w k is defined as from the main grid to MG, thus the MG costs for the power exchange can be expressed as:

$$v_{{{\text{w}}k}} (w_{k} ) = \rho_{{{\text{W}}k}} (w_{k} ) \cdot w_{k}$$
(6)

where ρ Wk (w k ) is the price function of w k based on the price mechanism of the main grid. There are two cases:

  1. 1)

    If the power exchange through the tie-line is determined by the agreement between main grid and MG, ρ Wk (w k ) contain the penalty of violating power limitations. When ρ Wk (w k )→+∞, it means that the cost of power exchange is extremely high; when ρ Wk (w k ) ≤ 0, it means MG cannot supply power to the main grid or the exported power will not be paid.

  2. 2)

    If there is no power exchange limit agreement between the main grid and MG, the purchasing/selling price is irrelevant to power exchange. Therefore, ρ Wk (w k ) is replaced with ρ Bk or ρ Sk , which are determined by the power purchasing/selling price of MG from/to the main grid.

The existing popular market pricing mechanisms include: ① real-time pricing (RTP), in which MG can participate as a market bidder to determine the price. ρ Bk and ρ Sk are the market clearing prices of the main grid for generation and consumers in the k th time interval, respectively; ② TOU pricing, determined by the agreement between utilities and consumers, and generally updated each season. ρ Bk is the TOU price in the k th interval and ρ Bk is the feed-in tariff for DGs.

3 Characteristics and operating cost of ES in MG

3.1 Energy management based on ES control

In the proposed method, several assumptions are made: ① The forecast values of DGs output and load demand are known; ② The day ahead purchasing/selling prices are predictable; ③ Only energy type ES is considered and other types of ES devices are considered equivalent to energy type ES; ④ The response time of ES is much less than the control period, and ES holds the same working status within one control period.

To make the model solvable and trackable, the continuous status of ES needs to be transformed to a discrete form. Dividing the SOC operation range of ES into N intervals, the SOC status set S can be expressed as

$$S = \left\{ {\left. {s_{n} = \;\underline{SOC} + \frac{{n(\overline{SOC} - \underline{SOC} )}}{N},n = 0,1,2, \ldots ,N} \right\}} \right.$$
(7)

where \(\overline{SOC} /\underline{SOC}\) are the maximum/minimum values of SOC for the ES; s n is the SOC of ES at the end of nth time interval, which is also regarded as the decision variable in energy management.

The shifting process of discrete energy status of ES is shown in Fig. 3. Due to the limitation of charge/discharge current, the SOC variation between two adjacent SOC is restricted. For each time interval, the charge/discharge of ES must satisfy.

Fig. 3
figure 3

ES discrete SOC transition process

$$\left\{ \begin{array}{ll} s_{k} - s_{k - 1} { \le }\gamma_{\text{C}} \,\quad \;\,{\text{if}}\;s_{k} \ge s_{k - 1} \;\,{\text{(charge)}} \hfill \\ s_{k - 1} - s_{k} { \le }\gamma_{\text{D}} \,\;\;\,\,\,\,\,{\text{if}}\;s_{k} \le s_{k - 1} \,\,\;{\text{(discharge)}} \hfill \\ \end{array} \right.$$
(8)

where γ C and γ D are the maximum charge and discharge rate of ES respectively, whose values are determined by the physical characteristics of ES.

Considering charge/discharge rate of ES equipment, the boundary values of SOC set for k th time interval are:

$$\left\{ \begin{aligned} s_{k,\hbox{min} } = \hbox{max} (\hbox{min} (S_{k - 1} ) - \gamma_{\text{C}} ,\underline{SOC)} \hfill \\ s_{k,\hbox{max} } = \hbox{min} (\hbox{max} (S_{k - 1} ) + \gamma_{\text{D}} ,\overline{SOC} ) \hfill \\ \end{aligned} \right.$$
(9)

where S k−1 ⊂ S is the SOC set of (k − 1)th time interval.

3.2 Operating cost of energy storage

The battery lifetime is affected by the depth of discharge (DOD), discharge rate, temperature, battery maintenance program, over charge, current ripple, etc. [19], [20]. Among all those factors, DOD and discharge current are directly related to the energy management in the MG.

The charge/discharge efficiency, self-discharge energy, and the charge/discharge impact on ES equipment deprecation should be considered in the construction of the ES operating cost model for the MG energy management. If the ES charges/discharges at an average rate, the discharge current and DOD are dependent on the discharge energy. The composite operating cost of ES is expressed as

$$v_{{\text{x} k}} (s_{k} ,\;x_{k} ) = \left\{ \begin{aligned} \sigma_{\text{sdr}} s_{k} \,\rho_{{{\text{S}}k}} \quad \quad \quad \quad \quad {\text{if}}\quad x_{k} > 0 \hfill \\ \left| {x_{k} } \right| \cdot \rho_{\text{R}} + \sigma_{\text{sdr}} s_{k} \rho_{{{\text{B}}k}} \quad {\text{if}}\quad x_{k} \le 0 \hfill \\ \end{aligned} \right.$$
(10)

where σ sdr is the self-discharge rate of ES; ρ R is the deprecation cost considering the equipment installation cost and lifetime. x k is the charge/discharge power in the k th time interval, which is determined by the characteristics of ES and the energy status from s k−1 to s k . x k  > 0 means charging, while x k  < 0 means discharging. The MG purchasing price ρ Bk is used to value the cost of energy loss due to the self-discharge.

The mathematical formulation is expressed as.

$$x_{k} = \left\{ \begin{aligned} &\frac{{s_{k} - (1 - \sigma_{\text{sdr}} )s_{k - 1} }}{{\eta_{\text{C} } }} \cdot Q_{\hbox{max} } \quad \, \, {\text{if}}\, \; s_{k} \ge s_{k - 1} \,\text{(charge)} \hfill \\ &[s_{k} - (1 - \sigma_{\text{sdr}} )s_{k - 1} ]\eta_{\text{D} } Q_{\hbox{max} } \; \, \, {\text{if}} \;s_{k} < s_{k - 1} \;{\text{(discharge)}} \hfill \\ \end{aligned} \right.$$
(11)

where Q max is the capacity of ES, in kWh; η C and η D are the charge and discharge efficiency of ES, respectively.

4 Energy management and control method in MG

4.1 Day-ahead optimal scheduling model based on ES

The main idea of MG EMS proposed here is based on the forecasted power generation of DGs and load, and the operating cost is minimized through the dynamic consecutive decision making of energy status s k in each time interval. If s k is determined, x k and w k are determined correspondingly, according to (2) and the operating cost of energy management in the kth time interval is:

$$v_{k} (s_{k} ) = v_{{\text{w} k}} (s_{k} ,w_{k} ) + v_{{\text{x} k}} (s_{k} ,x_{k} )$$
(12)

The optimization objective over the scheduling horizon is expressed as:

$$\begin{aligned} f_{k}^{ * } (s_{k} )& = \mathop {\hbox{min} }\limits_{{x_{k} \in X_{k} (s_{k} )}} \{ v_{k} (s_{k} ) + f_{k - 1}^{ * } (s_{k - 1} )\} \hfill \\ \quad \quad \;\;\; &= \hbox{min} \sum\limits_{k = 1}^{K} {v_{k} (s_{k} ) + } f_{0}^{ * } (s_{0} ) \hfill \\ &\text{s} .\text{t}.\quad \quad s_{k} \in S \hfill \\ \end{aligned}$$
(13)

where s 0 is the initial condition of ES; and f *0 (s 0) is the cost for reaching the status s 0, which is usually zero.

The line limits and network losses could affect the ES control in MG energy management. However, MGs are small-scale networks with lines over short distance. The distribution line limits are usually not violated under normal conditions. MW limits and networks losses are not considered in the proposed model. Figure 4 demonstrates the process of solving the above model. This model is formulated as a multi-stage decision-making problem and can be solved by dynamic programming.

Fig. 4
figure 4

Multi-stage process for solving the proposed model

4.2 Solution of the day-ahead optimal scheduling model

Based on the model in (13), this paper proposes an improved dynamic programming method for the day-ahead optimal scheduling in MG. The detailed process is described as follows:

Step 1: Detect the initial status of ES as s 0, then the set of ES status is obtained, S 0 = {s 0}.

Step 2: k = k+1, for the k th time interval, k ∊ K = {1, 2, ···, K}, execute the following steps.

Step 3: According to the maximum charge rate, discharge rate, and the allowable decision variable set S k−1 in the previous time interval, the decision variable s k and its corresponding set S k in the k th time interval can be determined based on (9).

Step 4: Select s k  ∊ S k sequentially, and perform the calculation according to the steps from Step 5 to Step 10.

Step 5: Based on the selected s k , for the elements in the status set of the previous time interval S k−1, the charge/discharge power x k is determined according to (11). If (8) is satisfied, then it is a feasible transition state, otherwise, another element in S k−1 needs to be selected.

Step 6: For the feasible transition state in Step 5, determine the exchange power w k corresponding to x k based on (1). Index function v k (s k ) is obtained through (12), and f k (s k ) is obtained through (13).

Step 7: Repeat Step 5 and Step 6 until all the paths reaching s k and its corresponding f k (s k ) in S k−1 have been traversed.

Step 8: For everys k  ∊ S k , select the scheme whose index function f k (s k ) is the minimum of the optimal solution \(f^{*}_{k} \left( {s_{k} } \right)\) and save the results \(f_{k}^{*} \left( {s_{k} } \right),x_{k}^{*}\), and path[s k−1s k ].

Step 9: Repeat Step 4 to Step 8 until all the elements in S k have been traversed and complete the decision making process for the k th time interval.

Step 10: Repeat from Step 3 to Step 9 and achieve the optimal scheduling of every time interval until the energy management period ends.

Taking the operation cost of each stage as the length of the path and the SOC of ES as decision operating points, the main idea of the solving process is to search the minimum paths, i.e., minimizing the total operating cost, while maintaining the balance between supply and demand in MG. The memory space requirements and the computational efforts are limited because the only information that needs to be recorded for a given state is its optimal previous state, or path. The intermediate result of each time interval is the minimum operating cost under present state, which can be listed by tabular form and provide direction for comparison and the decision-making of operators.

Based on the ES status at the end of the energy management period, the optimal scheduling solution can be acquired from [s k−1, s k ] in each time interval and then the corresponding x k and w k values are also obtained. The reverse search process for ES optimal scheduling is shown in Fig. 5.

Fig. 5
figure 5

Reverse search process for optimal scheduling

With the dynamic modelling and algorithm, the optimal control problem of ES is decoupled to multiple stages so that the optimization can be implemented for each stage. Therefore, the proposed model can adapt to various market mechanisms since only market price information is needed for the optimization in a specific stage.

5 Case study

Two cases have been studied in this section. An illustrative numerical example on a simple MG system is used to present the process of the proposed method. Further, a practical MG project in China is adopted demonstrate its effectiveness.

5.1 Simple microgrid system

The topology of the simple MG system is shown in Fig. 6. The day-ahead optimal scheduling is implemented based on the forecasted PV output and load. In this case, the proposed model and solution method are presented with the first 4 time intervals. The real-time price of the main grid, selling/purchasing price, and the forecasted distribution generation and load are shown in Table 1. The parameters of ES are listed in Table 2.

Fig. 6
figure 6

Structure of the test microgrid

Table 1 Electricity price, forecasted DG output and load data
Table 2 Main parameters of storage device

The MG adopts 200 kWh lithium batteries as ES, whose SOC range is [0.2, 1.0]. To clearly illustrate the process, the work range is divided into 5 intervals. The decision-making set can be obtained as S = {0.2, 0.4, 0.6, 0.8, 1.0} based on (7). Substituting the parameters in Table 2, the function of the decision variable of energy management s k and its corresponding charge/discharge energy x k can be obtained with (11). Substituting this into (10), the operating cost function of ES is acquired. Based on the forecasted DG and load data in Table 2, the exchange power between MG and the main grid can be obtained according to (1). Substituting the purchasing/selling data into (6) and combining with the operating cost of ES, the cost index function v k of each time step in the energy management period is acquired.

When k = 1, the initial condition of ES is s 0 = 0.4 and S 1 = {0.2, 0.4, 0.6, 0.8}, according to (8). When the decision variable of the time interval s 1 = 0.2, the charge energy from s 0 to s 1 is x k  = −34.96 kW according to (11). It indicates that there are 34.96 kW of power discharged from ES with considerations of the charge/discharge efficiency and self-discharge rate. The exchange power between MG and the main grid is w 1 = −98.96 kW based on (1). Then the operating cost of energy management is v(s1) = −48.78 CNY according to (10). Since the initial status f *0 (s 0) = 0, the operating cost of this stage is f 1(s 1) = −48.78 CNY according to (12). Similarly, the values of f 1(s 1) are calculated as 30.47, −9.25, and 18.88 CNY, for s 1 = 0.4, 0.6, and 0.8 respectively. At this stage, for every s 1, there is only one path from s 0 to s 1, which is denoted as the minimum operating cost index f *1 (s 1). Other results, such as the charge/discharge energy x *1 (s 1), exchange power with the main grid w *1 (s 1), and the path [s 0, s 1], are shown in Table 3, in which the path indicates the SOC change from the beginning to the end of the stage.

Table 3 Results of 1st control stage in case study

When k = 2, based on the status of the previous stage S 1, we can obtain S = {0.2, 0.4, 0.6, 0.8, 1.0} according to (8). If the decision variable of this stage is s 2 = 0.2, which is obtained from the previous status s 1 = 0, then we have x 2 = 1.52 kW, w 2 = 21.52 kW and the operating cost of ES is v 2(0.2) = 10.76 CNY. Since f *1 (0.2) = −48.78 CNY, then f 2(0.2) = −38.02 CNY. If it is obtained from s 1 = 0.4, x 2 = −34.96 kW, and w 2 = −14.96 kW, then, v 2(0.2) = −6.78 CNY; Since f *1 (0.4) = −30.47 CNY, then f 2(0.2) = −37.25 CNY. Similarly, if it is obtained from s 1 = 0.6, then f 2(0.2) = −33.54 CNY. The minimum value of above three situations is f *2 (0.2) = −38.02 CNY. To acquire the minimum operating cost when the SOC of ES is s 2 = 0.2, the path is [0.2, 0.2]. For s 2 ∊ S 2, the process is similar and the results are shown in Table 4. When k = 3 and k = 4, the results based on the above algorithm are shown in Table 5 and Table 6. Based on the dynamic optimization for each stage, the overall optimal scheduling scheme is obtained by only a small amount of computation.

Table 4 Results of 2nd control stage in case study
Table 5 Results of 3rd control stage in case study
Table 6 Results of 4th control stage in case study

The final status of energy management can be determined with the artificial participation and selection after the analysis of the last stage. If the initial status s 4 = 0.4 in the optimization progress is kept, the operating cost during the period is f *4 (0.4) = 3.51 CNY, as shown in Table 6. If the initial status is s 4 = 0.2, the operating cost will be f *4 (0.2) = −14.25 CNY, which means that ES has a reduced SOC of 0.2 and the MG operator gains 14.5 CNY. If the final status of SOC is 0.6, 0.8, or 1.0 the required operating costs of the MG are 20.36, 42.83 and 66.31 CNY, respectively. According to the path of each stage, the feasible path can be found through backwards search. Then the optimal operation scheme is acquired for each stage over the scheduling horizon, as is shown in Table 7.

Table 7 Optimal scheduling results for the microgrid

With the above steps, the ES control based energy management model is built and solved through dynamic programming. The market environment, the operation efficiency, and depreciation cost of ES are only related to the operating cost function in one time interval, but independent in the entire algorithm process.

5.2 Practical MG pilot project

The effectiveness of the proposed method is verified by a practical MG project. The structure of the MG system can be found in [9], including 2 MTs with a 30 kW capacity, 120 kW residual heat recovery device, 120 kW heat exchanger, 100 kW gas-fired boiler, 50 kW PV panels, and 200 kWh batteries. The parameters of batteries are the same with the previous case, the efficiency of MTs, residual heat recovery device, and heat exchanger are 0.3, 0.73, and 0.9, respectively.

With the RTP mechanism of the connected main grid, the optimal scheduling objective is to minimize the operating cost of the MG while satisfying the cold, heat, and electrical loads in the MG. The heat and cold load can be supplied by MTs. The flue gas absorption refrigerating machine and residual heat recovery device are installed with MTs. The high temperature flue gas produced by the MTs can be used to produce hot water to meet the heat load and any shortage will be satisfied by the gas-fired boiler [21]. Since the cost of natural gas is high, the principle of determining generation based on heat demand is applied.

The daily typical heat, electrical load, and PV output of a MG in a commercial building is shown in Fig. 7. The day-ahead energy management will be analyzed through the proposed method. The allowed operation range of batteries is divided into 10 intervals equally. The time interval is 15 min and there are 96 intervals during one day. The TOU pricing mechanism is adopted and shown in Table 8. According to the policy in China, the surplus power of a MG can be exported to the main grid with low price.

Fig. 7
figure 7

Predicted curves of system load and PV output

Table 8 TOU periods division and price fluctuations

The control process is as follows: firstly, dispatch MT-CCHP according to the principle of heat load determining power and then combine the power of MT-CCHP with PV output as one power source, which will later be scheduled using the proposed method in this paper. If there is cold load, the shortage will be met by a motor compressor and the power consumed by the motor compressor is taken as electricity load. The output results of power and heat with MT-CCHP in the MG are shown in Fig. 8.

Fig. 8
figure 8

Output result of power and heat load with MT-CCHP in the microgrid

Figure 9 shows the output power of MTs and PVs as well as the electrical load. It can be seen that the MG needs to purchase power from the main grid or ES discharges to maintain supply–demand balance except when the distributed generation is larger than load. Since the purchasing prices are different at different time, ES needs to be optimally scheduled to minimize the operating cost during the whole study period.

Fig. 9
figure 9

Difference between DGs and power load

If the energy in ES keeps unchanged at the beginning and end of the period, the SOC is 20 %. Based on the proposed algorithm, the optimal scheduling scheme of ES is shown in Fig. 10. The day-ahead optimal scheduling is shown in Fig. 11.

Fig. 10
figure 10

SOC scheduling and charge/discharge power of ES

Fig. 11
figure 11

Day-ahead optimal scheduling result

As previously stated, ES could be a source or load, whose power is positive when charging and negative when discharging. Figure 11 shows that the electrical load can be satisfied by the combination of all types of generation. From Figs 10 and 11, it can be observed that the charging period of ES lies in the 23–29 time interval (5:00−7:00) and 71–72 time interval (17:30−18:00). In the former period, the energy is stored in the ES and released when the generation is insufficient. In the later period, the ES is charged based on the TOU pricing mechanism. ES discharges when the distributed generation is insufficient during the peak hours when the electricity price is high.

6 Conclusion

This paper proposed an ES control based day-ahead optimal scheduling method for the grid-connected MG to address the impact of various electricity market environments. Through the dynamic modelling and algorithm, the optimal control problem of ES is decoupled to multiple stages so that the optimization can be implemented for each stage. Therefore, the proposed model can adapt to various market mechanisms since only market price information is needed for the optimization in a specific stage. Moreover, the depreciation cost, self-discharge, and round-trip efficiency of ES are considered comprehensively. The effectiveness of the proposed method and algorithm are demonstrated through cased studies.