Proposing a Stochastic Model for Failures of the Upstream Grid While Optimally Scheduling of Microgrid

In this paper, optimal scheduling of home appliances as well as dispatchable distributed generators are determined within a residential microgrid for a specific day. In this regard, stochastic nature of non-dispatchable distributed generators such as wind and solar is modeled taking advantages of Markov model. Also, there are other uncertainties in the model stem from time of failure as well as duration of failure in the upstream grid which is taken into account in the problem formulation. The effectiveness of the proposed method is shown by minimizing cost of providing customers with electricity in a residential microgrid.


I. INTRODUCTION
C ERTAIN amount of losses in the conventional power system stems from long distance transmission systems [1][2][3]. Also, conventional way of producing electricity using fossil fuel based generators can lead to releasing more and more greenhouse gas emissions [4]. Thus, it is clear that the traditional hierarchical, centrally controlled grid, cannot solely be a suitable solution to prevent the aforementioned ordeals [5], [6] and finding ways to reduce loss or recapturing waste energy is of high significance [7]. In [7], a new application of fuzzy logic method is proposed for reducing loss and increasing the efficiency by recapturing the waste energy.
The future electricity distribution system can be operated in a mesh configuration and will be an intelligent system known as smart grid [8], [9]. Smart grid includes Advanced Metering Infrastructure (AMI) such as phasor measurement units (PMUs), distribution automation, communication systems, and distributed energy resources [8], [10], [11]. The desired smart grid should possess certain functionalities including: self-healing, optimal asset utilization, optimal operation and maintenance, etc. [8], [12], [13]. Furthermore, many of the above stated functionalities can be further improved by solving certaing optimization problems. For example, in [12], the self healing characteristic of smart distribution grids have been reinforced by a novel method of optimally allocating the control and protective devices in the grid. Along the same line, a microgrid which is a building block of future smart grid, can be defined as a network of small scale power generating units including renewable energy resources [14], storage devices, and loads [15][16][17], portable loads such as electric vehicles [18][19][20]. A In microgrids, small scale power generating units are assigned within the scope of distribution systems so that the generated power can directly provide customers with electricity without any need to transmission systems. In case of power generation shortage, microgrids can use the stored energy in the storage devices unless the stored energy is not sufficient which microgrids are forced to import electricity from the upstream grid under this circumstance [4]. Another pro of the microgrid-based architecture is that customers can be supplied power even if the microgrid is disconnected from the upstream grid which is known as islanding mode of operating a microgrid [18]. As a result, a microgrid including renewable generation units that connected to the grid under advanced power electronics technologies can be operated in both grid connected and islanding modes [21].
The problem of optimal scheduling of various tasks subject to limited amount of resources is a well known problem in different areas including microgrids [8]. In microgrids, the problem of optimally dispatching various distributed generation units is a common problem which has been comprehensively analyzed in [22]. Also, in a residential community; which can be considered as a microgrid, there are numerous home appliances which fall into two different categories. Most of the home appliances consume electricity in a continuous and tight fashion like refrigerators. The other home appliances can be operated in a distributed and flexible fashion [4], [23]. As a result, optimal scheduling of home appliances is of paramount importance [4], [24], [25].
There are many papers in the literature of energy management perspectives [26][27][28][29][30]. However, all of the mentioned optimization scheduling problems have considered a given energy profile. Authors in [8] have optimally scheduled a microgrid in a residential microgrid but the probability of failures in the upstream grid is overlooked. In [31], a novel TTtransform based method is proposed for fault analysis in series compensated lines. This approach can be used in a microgrid so that it results in a fast recovery in the case of faults for having a resilient system. This paper proposes a Mixed Integer Linear Programming (MILP) model for optimally scheduling of flexible home appliances as well as dispatching controllable small scale power generating units for a residential microgrid. Also, the uncertainty of islanding mode of operation due to failures in the upstream grid is modeled. In fact, the main technical contribution of this paper is to model the stochastic nature of time of a failure as well as duration of a failure in the upstream grid; which leads to islanding mode of operation.
The remaining of this paper is as follows: Section II allocates to the wind and solar power stochastic models based on Markov chains. The problem formulation is considered in section III. The case study which is a simple residential microgrid is introduced in section IV. Simulation results are presented in section V, and finally, the conclusions are drawn in section VI.

A. Wind Turbine
Wind speed at every hour is correlated with the wind speed at previous hours; hence, wind cannot be described by any probability distribution function [4]. A first order Markov chain is used in order to predict wind speed based on the historical data over many years. Suppose that S = s 1 , s 2 , ... is the historical hourly wind speed time series over 3 or more years for a specific region. Also, W represents the states associated with the wind speed time series. Then, the first order Markov transition matrix is as 1 [ which p ij can be calculated using 2 where w j=1 p ij = 1 and w ij represents the total number of transitions from state i to state j for the next hour of synthetic time series. By and large, if the wind speed for hour h is v(h) in m/s, the power produced by wind turbine is as 3 where ρ, A, and C p represent the air density in kg/m 3 , swap area of turbine in m 2 , and Betz limit (maximum 0.59), respectively. It should also be noted that practical wind turbines are just capable of producing power in a specific range between their cut-in and cut-off speeds.

B. Solar Panel
In climatology, Markov models of historical solar radiation data are commonly used in order to synthesize solar radiation data for the future [4]. Solar radiation states can be expressed using first order Markov transition probability matrices as 4-5 [4].
where k is the total number of radiation states and γ i represents the intensity of solar radiation for the state i in W/m 2 . Finally, using 4-5, the uncertain power produced by a solar panel can be revealed as 6 where n is the number of photovoltaic cells in the panel, e c is the efficiency which may be different at various hours based on ambient temperature, internal impedance, global irradiation, etc. K c shows the critical radiation point in W/m 2 above which an increase of radiation leads to a smaller increase in efficiency.

III. PROBLEM FORMULATION
The smart home optimal scheduling is formed as a MILP problem. In this problem, daily power consumption of home appliances as well as set point power of dispatchable units are optimally opted in order to provide customers with electricity with the minimum cost. Furthermore, since under various circumstances, operating in the islanding mode is uncertain, the optimal scheduling problem of a microgrid becomes a challenging and complex problem [32]. Thus, in order to have a robust optimum scheduling for the home appliances as well as dispatchable generators, stochastic nature of occurring a failure in the upstream grid should be taken into consideration.
It has been assumed that the smart buildings are considered as a residential microgrid which includes various decentralized energy resources including: wind generator, solar panels, Combined Heat and Power (CHP) generator, boiler, thermal and electrical storages. Another assumption is that the microgrid is capable of selling electricity to the upstream grid when there is surplus electricity generation.

A. CHP
Due to physical limitation of the CHP, there is an imposed constraint on the CHP; which should be taken into consideration as 7, where P CHP (h) and P CHP are the generated power of the CHP at time interval h and the maximum capacity of the CHP in kW , respectively. Moreover, T is the time of study in hour which assumes to be 24.

B. Boiler
Similar to CHP, boiler is not also allowed to produce more than a maximum amount of P boiler as 8

C. Electrical Storage
Stored electricity at the storage device at time h correlates to the state of charge of the device at time h − 1 as 9 where E ES (h) is the stored energy in electric storage at time h in kW h, η ES is the electric storage efficiency, ∆h is the time interval duration in hour, and rate ES,ch (h) and rate ES,dc (h) are the charge and discharge rates at time h in kW , respectively. Moreover, it is assumed that the stored electric energy of a storage device at the end of a day should be equal to the initial stored energy at the beginning of the same day as represented in 10 where E ES (0) and E ES (T ) are the stored energy of the storage device at the beginning and at the end of a day, respectively. Also, the stored energy at the electric storage is restricted to its maximum capacity as shown in 11 where E ES is the maximum storable energy in the storage.
The charge and discharge rates of electric storage device are restricted to maximum charge and discharge rates, respectively as shown in 12-13 where rate ES,ch and rate ES,dc are maximum allowable charge and discharge rates associated with electric storage device, respectively.

D. Thermal Storage
Stored heat in the thermal storage at hour h, similar to that of electrical storage, depends on the stored thermal energy at hour h − 1 and charge and discharge amounts during this time interval as formulated in 14 where E T S (h) is the stored thermal energy in thermal storage device at time h in kW h, η T S is the thermal storage efficiency, and rate T S,ch (h) and rate T S,dc (h) are the charge and discharge rates at time h in kW , respectively. Moreover, it is assumed that the stored thermal energy of a storage device at the end of a day should be equal to the initial stored thermal energy at the beginning of the same day as represented in 15 where E T S (0) and E T S (T ) are the stored energy of the storage device at the beginning and at the end of a day, respectively. Also, the stored thermal energy at the storage is limited to its maximum capacity as shown in 16 where E T S is the maximum storable thermal energy in the storage.
The charge and discharge rates of thermal storage are limited to maximum charge and discharge rates, respectively as brought in 17-18 where rate T S,ch and rate T S,dc are maximum allowable charge and discharge rates of thermal storage device, respectively.

E. Smart Home's Appliances
In a specific home of a residential microgrid, there are various tasks which need electricity and heat in order to be performed. Thus, their operation time can be scheduled in order to minimize cost of energy, provided that they have consumption time flexibility. In this paper, different tasks in a smart home are assumed to have an earliest starting time and a latest finishing time. In other words, the starting time of each task cannot be earlier than the given earliest starting time as represented in 19 where s j,i is the earliest starting time of task i in home j and T start (j, i, h) is a binary variable which is one if task i in home j starts at time h, and zero otherwise. Moreover, the finishing time of each task cannot be later than the latest ending time as shown in 20 where e j,i is the latest ending time of task i in home j and also T end (j, i, h) is a binary variable which is equal to one if task i in home j finishes at time h, otherwise zero. It has been assumed that every single task in a smart building should operate continuously for the needed processing time as shown in 21-22 where P j,i is the needed processing time of task i in home j, and C(j, i, h) is a binary variable which is equal to one if task i in home j is consuming energy at time h, otherwise zero. Based on 21, if task i in home j starts at time h, it should be finished at time h + P j,i . Also, 22 represents the continuously being operated of every single task.

F. Energy Balance
The total demanded electricity of a microgrid at every hour of a day is supplied through both dispatchable and nondispatchable energy resources existing in that microgrid. In case of energy shortage, either the electricity can be imported from the upstream grid into the microgrid unless a failure is occurred in the upstream grid or stored energy in the storage devices can be utilized. The electric power balance is presented in 23 where P HA (i), Im(h), and Ex(h) are the electric power consumption of home appliance i, imported power from the upstream grid, and exported excess power to the upstream grid in kW , respectively. However, the probability of occurring a failure in the upstream grid; which can be modeled as a probability distribution function [32], is not still modeled in the equation. Furthermore, there should be a power balance for thermal power as 24 where P T (h) is the total demanded heat power at time h and ratio is the heat to power ratio of the CHP.

G. Objective Function
The goal of this problem is to minimize total daily cost of providing customers with electricity and heat as shown in 25 where M w , M s , M ES , and M T S are the maintenance cost of wind turbine, solar panel, electric storage, and thermal storage in $/kW h, respectively. Moreover, G p is the gas price, and p b (h) and p s (h) are the price of buying electricity from or selling that to the upstream grid in $/kW h, respectively. Since the discussed optimization problem is a MILP, the global optimum solution can be found using available optimization packages such as MATLAB or CPLEX [33].

IV. CASE STUDY
The case study here is assumed to be a residential area as a small microgrid as shown in Fig. 1. It has been assumed that there are 30 smart homes in this microgrid with a lot of home appliances that need either electricity or heat to be performed. In the simulation, we assume 360 appliances distributed over these 30 household customers so that every single household customer possesses 12 appliances. Such appliances include flexible and non flexible tasks such as washer drier and refrigerator, respectively. The data associated with these appliances in every home is given in TABLE I. Moreover, the total heat demand profile which is generated for each building using CHP Sizer Version 2 Software is given in Fig. 2.
Furthermore, in this microgrid, there are 10 identical wind turbines with radius 0.8 m, air density 1.28 kg/m 3 , cut-in wind speed 5 m/s, cut-off wind speed 25 m/s and C p = 0.59, and photovoltaic energy sources with maximum radiation: 1000 W/m 2 , photovoltaic panel area 50m 2 , and with a maximum production capacity of 1.5 M W h. The amount of electricity from the renewable energy resources is predicted for every time step (15 minutes) in a day by using the renewable energy models presented in Section II. In order to generate synthetic time series for both wind turbine and solar panels in one day, the historical data of National Climate Data Center of National Oceanic and Atmospheric Administration is extracted [4]. Also, the microgrid includes dispatchable power resources such as CHP and boiler as well as electric and thermal storage devices.
It should be noted that the data associated with the CHP as well as boiler is given in TABLE II. Moreover, the data of the storage components are given in TABLE III. A grid connection; which allows importing and exporting of electricity while operating in parallel to the grid, is also taken into consideration. The electricity price for different times of a day is given in Fig. 3. As it can be seen in Fig. 3, there are two peaks in the electricity price of the upstream grid which are related to afternoon and the evening when the people are coming back home from their work. Also, when the electricity is sold to the grid, there is a contract between customers and the grid operator based on which the grid buys electricity with a price of 1 ¢ kW h [8].     Fig. 3: Electricity price for different hours of a day [8] V. SIMULATION RESULTS A. Simulation Results with no Upstream Failure Modeling When a time window is considered for the electricity consumption of home appliances, the domestic tasks as well as the equipment operation time are scheduled in order to make the total operation cost minimum. Tasks such as electricity consumption of refrigerator or lightening purposes, have fixed electricity consumption time period and cannot be postponed to the future during electricity consumption peak period. On the other hand, tasks with flexible operation time can be scattered as much as possible in order to prevent electricity consumption peaks. It should be noted that due to cheaper nature of provided electricity by the local generators, it is preferred for customers to provide their electricity locally; however, there are time periods when importing electricity from the upstream grid is cheaper. Thus, under this circumstance, parallel grid is the main electricity provider of the customer needs. In this section, the optimal scheduling of both home appliances as well as local generators is conducted in grid connected mode. The total cost imposed on the microgrid for providing electricity and heat in a day is shown in TABLE IV for three various cases as following: • When the home appliances start consuming electricity and heat exactly at the earliest starting time; • When the home appliances finish consuming electricity and heat exactly at the latest ending time; • When the home appliances are flexible to start consuming electricity and heat between the earliest and latest starting time. As it can be seen from TABLE IV, when there is a flexibility for home appliances to consume electricity, there is certain amount of money savings. These savings can even be more significant when the microgrid operation is considered for more days for a bigger region. The total electricity consumption for these three cases is shown in Fig. 4. As depicted in Fig. 4, the electricity consumption peaks is somehow shaved when the third case is employed for microgrid operation, i.e., home appliances' flexibility can lead to a flatter power consumption profile. Thus, the need for power generators; which should be idling most of the time, is prevented.
Hence, it is fair to say that this method of microgrid operation is applied to home appliances in most of the cases. The optimal electricity balance, optimal set points of the dispatchable power generators, and the storage devices charge and discharge rates for the residential microgrid based on the third scenario are presented in Fig. 5. As it can be seen in Fig.  5, the electric storage device is charged when the electricity demand is low in order to use that when the electricity demand is high.

B. Simulation Results Considering Upstream Failure Modeling
One of the most important features of a microgrid is its ability to operate in the islanding mode due to occurring disturbances in the upstream grid with the goal of protecting microgrid components and allowing an uninterrupted supply of demand.However, when a disturbance occurs in the upstream  grid, type and extent of the disturbance as well as the recovery time is not usually disclosed to the microgrid operators [32]. Hence, there is an inevitable need for proposing a model in which the stochastic nature of the failure occurrence as well as recovery time is taken into consideration. To properly investigate this issue, this paper presents a stochastic model for time of occurring a failure in the upstream grid and for recovery time for a happened failure. In this model, instead of minimizing the objective function in 25, the expected cost is minimized, knowing the probability distribution functions of failure time or recovery time as 26.
where P en is the penalty factor imposed on the microgrid operator due to curtailing the amount of LC(h) from total loads in hour h. The expected cost is as 27 where π h is the probability distribution function of time of a failure or duration of a failure in the upstream grid.
It should be noted that the constraint 23 in the previous section should be updated as 28.
In this paper, in order to analysis the effectiveness of the proposed method, two different scenarios are considered. In the first scenario, it has been assumed that time of occurring a failure in the upstream grid has a uniform distribution from 12 PM to 4 PM. However, in the second scenario, the duration of exciting a failure has a uniform distribution between 2 hours of failure and 6 hours of failure. Also, it has been assumed that in the second scenario, the failure has occurred at 12 PM. The expected values for optimal scheduling of both scenarios are depicted in Fig. 6 and Fig. 7, respectively. As it can be seen in Fig. 6 and Fig. 7, in both scenarios, the charge and discharge trend of storage devices as well as load curtailment amount is determined so that the power balance equation is met in all the day. Furthermore, it should also be noted that the expected costs imposed on the system in the first and second scenarios including the costs associated with penalties are 72.2$ and 81.1$, respectively. The more cost associated with the second scenario is due to the fact that the upstream grid is disconnected for more time than the first scenario. Also, due to certain imposed penalties due to not supplying loads in some times, the expected costs in both scenarios is more in comparison with a case in which the failure in the upstream grid is not considered.

VI. CONCLUSION
In this paper, optimally scheduling of home appliances as well as dispatchable distributed generators were performed in a small residential microgrid considering the stochastic nature of renewable energy resources. In the last part of this paper, optimally scheduling of home appliances and distributed generators were performed considering a failure occurring in the upstream grid. The nature of these kinds of failures can be uncertain so that the time of failure and duration of failure can be uncertain. Thus, these stochastic parameters made the optimization problem more complex. Indeed, by modeling the failures in the upstream grid, optimal scheduling of microgrid has become more robust against the failures.