Stochastic Operation of a Solar-Powered Smart Home Capturing Thermal Load Uncertainties

: This study develops a mixed-integer linear programming (MILP) model for the optimal and stochastic operation scheduling of smart buildings. The aim of this study is to match the electricity demand with the intermittent solar-based renewable resources proﬁle and to minimize the energy cost. The main contribution of the proposed model addresses uncertainties of the thermal load in smart buildings by considering detailed types of loads such as hot water, heating, and ventilation loads. In smart grids, buildings are no longer passive consumers. They are controllable loads, which can be used for demand-side energy management. Smart homes, as a domain of Internet of Things (IoT), enable energy systems of the buildings to operate as an active load in smart grids. The proposed formulation is cast as a stochastic MILP model for a 24-h horizon in order to minimize the total energy cost. In this study, Monte Carlo simulation technique is used to generate 1000 random scenarios for two environmental factors: the outdoor temperature, and solar radiation. Therefore in the proposed model, the thermal load, the output power of the photovoltaic panel, solar collector power generation, and electricity load become stochastic parameters. The proposed model results in an energy cost-saving of 20%, and a decrease of the peak electricity demand from 7.6 KWh to 4.2 KWh.


Introduction
Concerns such as global warming, unfair distribution of fossil sources, and fluctuating fossil fuel prices have caused governments to consider alternative strategies like applying renewable energy supplies [1]. In the future, renewables will have to compete with other energy resources without demand-side policy support [2]. Under a regime with no support storage, system profitability will widely hinge on suitable energy management and operation. The optimal energy management of the residential sector has also attracted more attention because 30 to 40 percent of the world's primary energy consumption is spent on buildings [3,4].
Smart homes, as a chief component of the Internet of Things (IoT) and smart grids, is the network of physical devices that provide electronic, sensor, software, and network connectivity inside a home [5]. A smart home is a domain of IoT, which are automated buildings with installed detection and control devices, such as air conditioning, heating, and ventilation. Smart homes enable the energy systems of the building to operate as an active load in smart grids. How to control these loads, forecast the energy consumption and production of the system, and manage the integrated system, are vital factors for smart buildings to serve effectively in energy systems aimed at energy-saving, load peak shaving, load shifting, and compensating for the fluctuations due to variable renewable power production.
Different methods such as load disaggregation algorithms [6] or forecasting methods [7] can be used to determine consumption of different loads in residential buildings. In the residential energy management, considering an integrated energy system including heating and electrical demands is a reasonable strategy. Previous studies [8,9] indicate that this integration improves the efficiency of the energy systems. Authors of [10] developed an MILP model to minimize the energy costs and greenhouse gas emissions of 30 smart homes under two different tariff schemes including real-time price and peak-demand charge. The results showed that the proposed model in this study tunes a trade-off between the cost of greenhouse gas emissions and the electricity bill. Authors of [11] used MILP model to investigate the impacts of various demand response programs on the residential customers' profit. Another study [12] introduced an MILP model to minimize the energy operating costs of a smart house. Lighting, heating, ventilation, and air conditioning loads were included as controllable loads to participate in its demand response plans. The developed model achieved up to 7 percent reduction in energy costs. MILP model is used in [13] for smart home energy management using hybrid stochastic optimization and robust optimization.
Variable renewable resources (wind and solar supplies) impose fluctuations on energy systems. Separating renewable energy supplies from the grid by applying energy storage systems could solve the issues such as fluctuating power generation to avoid instability because of an imbalance between the supply-side and demand-side. Furthermore, these energy storages could reduce the cost of clean energies through load shifting, peak shaving, etc. Battery units and thermal storages (water tank) are the most common energy storage devices used in the residential sector [14,15]. A study [16] considered heat pumps and thermal storage as flexible loads to integrate fluctuating renewable power resources into the electricity grid. Instead of modeling heat pump energy conversion as linear for simplification, this study proposed a heuristic method for scheduling a smart home with a photovoltaic system aiming to minimize the costs of electricity exchange with the grid.
Controllable loads in the smart buildings mainly include electric water heater, heating, ventilation and air-conditioning, washing machines and dryers, electric vehicles, dishwashers, thermal storage devices, and batteries. Among all these devices, thermostatically controlled loads [17,18] such as electric water heaters and heating, and ventilation and air-conditioning, have received substantial attention in recent years. However, the majority of models proposed for optimal scheduling of smart buildings in previous studies were either too complicated or had limited applications. For instance, the electric water heater models introduced in studies [19,20] require too many measurements for scheduling. Another study [21] developed a mixed-integer nonlinear model to find the optimal operation of conventional cooling chillers and decrease the energy costs. Thermal loads such as heating, ventilation and air conditioning, and the water heating system make a significant contribution to the power consumption of a typical residential load, which is over 50% of the total residential energy consumption [22,23].
The optimal energy management in a building is affected by various factors, such as technical, economic, social, and environmental parameters, which are inherently ambiguous and uncertain. Studies [24,25] that dealt with stochastic optimization problems in smart grids, including renewables, clearly showed that taking uncertainties into account in the process of optimizing the energy building operation leads to more reliable and accurate results. Uncertainty can be captured using sensitivity analysis methods or optimization under stochastic methods in this field [26,27]. The sensitivity analysis methods are able to identify the most influencing uncertain parameters while they cannot determine the optimal operation under conditional uncertainties [28].
It is common among studies [29][30][31][32][33] to only consider one uncertainty aspect (demand-side or supply-side) in the optimization problems of scheduling smart buildings. To the best of the authors' knowledge, none of the previous studies in this field consider at the same time both the uncertainties of thermal demand for heating, and also the energy demand for the hot water required by the washing machine and dishwasher in the optimal scheduling of smart buildings. In the proposed model in this study, the uncertainties of the supply-side (the intermittent energy generation of photovoltaics and solar collectors) and the demand-side (heat demand and electricity load) are represented by the Monte Carlo (MC) [34] method as different scenarios. In the current study, the proposed method makes the uncertain parameters used for scenario generation effective.
This study proposes a stochastic model in order to find the optimal scheduling of a smart home using the flexibility offered by smart controllable devices, and match the load with intermittent variable renewable resources profile, thereby mitigating the uncertainties in both demand and supply sides. This study includes three steps: (1) system modeling and gathering historical data; (2) generating scenarios and choosing best scenarios, and; (3) optimal stochastic scheduling for one day.

Model Description
This study develops a mixed-integer linear programming (MILP) model for the optimal and stochastic operation scheduling of smart homes. The rest of this section is organized to describe the stochastic scheduling optimization model in detail.

Uncertainty Factors
Monte Carlo simulation technique is used to generate scenarios for one day in January, the coldest month of the year (as the worst scenario for the amount of thermal demand). Environmental conditions, namely the outdoor temperature and solar radiation, have been considered as uncertainty factors, as a result of which, thermal load, output power of photovoltaic panel, solar collector power generation and electricity load become stochastic parameters. Finally 100 scenarios combining 10 solar irradiance and 10 outdoor temperature have been used to model the scheduling problem.

Solar Radiation
The solar irradiation is an uncertainty factor depending on the weather conditions. Its uncertainty is assumed to follow the beta distribution as (1).
where a I and b I are beta distribution parameters, Γ is the gamma function and I t refers to solar irradiance in each hour.

Outdoor Temperature
The outdoor temperature is assumed to follow the Gaussian distribution as (2).
where σ t and µ t are the parameters of the Gaussian distribution and T o , t is the outside temperature in each hour.

Photovoltaic Array
Photovoltaic electricity generation varies according to the solar radiation depending mainly on the site location and weather conditions. Output power of the photovoltaic (PV) system has been obtained as Equation (3) from studies [35,36].
The efficiency of the PV panel is expressed as Equation (4) from study [35].

Solar Collector
Similar to photovoltaic resources, the power generation of solar collector hinges on solar irradiance. The thermal energy produced by solar collector, has been obtained by applying the Equation (5) from study [35].
The efficiency of solar collector is generally not a fixed value and depends on the outdoor temperature and radiation parameter. The efficiency η sc (s, t) is calculated as Equation (6) from study [35].

Optimal Scheduling
The amount of stored energy in the thermal storage is obtained as the summation of the remaining thermal energy from the previous hour (by considering the thermal loss), thermal power generation of solar collector and the electric heater in that hour, minus the hourly thermal demand. To obtain power consumption of electrical boiler, Equation (7) and constraints (8) and (9) are considered. The thermal energy waste or loss of the thermal storage (water tank) is considered as 0.03% per hour [37].
The electric boiler has a limitation for generating thermal power (Q eb ) which is its designed capacity (Cap eb ) and considered in the model as: The stored energy in the thermal storage (Q tank ) cannot exceed its designed capacity (Cap tank ), which is described as: To reach a balance between the supply-side and the demand-side and avoid electricity shortage, the electricity demand (p l ) must be met by photovoltaic electricity generation (p pv ), the battery discharge (dch bat ) and the purchasing power from the grid (p grid ) minus the battery charge (ch bat ) and the power sold to the grid (p sold ). The electrical power's exchange with the grid has been calculated as in Equation (10). The amount of PV power production in excess is sold to the grid as in Equation (11).
where the electricity demand (p l (t)) has been obtained from Equation (12). The electricity demand refers to uncontrollable loads (p l0 ), such as electricity consumption of the electric boiler and other controllable loads such as the dishwasher.
Allowed operation time of each component has been controlled by constraint (13).
Constraint (13) represents the particular preferences of households, namely their preferred time intervals for operating the smart appliances. These tasks must be completed within and cannot be operated outside of their specific time intervals. The required length of operation for each component is reached by applying constraint (14). This second constraint is applied to satisfy the required operation time of each smart appliance.
The dryer machine needs to operate after completing the washing procedure, which is considered in the model as (15).
The amount of stored energy in the battery is calculated as Equation (16).
where E bat is the hourly stored energy and η bat represents the efficiency of the battery. The hourly stored energy cannot exceed its designed capacity which is described as: The hourly battery charge and discharge are limited, which are considered as constraints (18) and (19). It is assumed that the battery has no stored energy at the beginning of the day. The battery must discharge the stored electricity to its initial state by the end of each day.
where r bat is the maximum charge/discharge rate of the battery storage which is defined as a share of the battery capacity [10,38]. Finally, minimizing the expected electricity payment for the entire day as objective function has been formulated as (20).
where α(s) is the probability of each scenario with summation of 1.

Thermal Load
The thermal energy from the solar collector and the boiler is stored into the water tank for providing hot water and heating and ventilation demands. Hourly thermal load for each scenario has been calculated as Equation (21).
where Q h (s, t) refers to the required thermal energy for heating system and Q wt (s, t) shows the hot water energy demand. It is assumed that the indoor temperature should be maintained in a predetermined range 22 • C ≤ T s r,t ≤ 24 • C when the household is occupied based on ASHRAE Standard 55-2013 for 30% humidity. It is assumed indoor temperature follows Equation (22) from study [35].
where Q h (s, t) depicts the required thermal demand for the heating and ventilation load for each scenario.
In this model, it is assumed that the daily average hot water demand for the benchmark is a linear function of the bedrooms number [39], which is summarized in Table 1. Hot water energy demand is classified to controllable loads (thermal energy consumption of washing machine and dishwasher) and uncontrollable loads (thermal energy needed for shower, sink, and bath) as Equation (23).
Thermal energy consumption of washing machine and dishwasher are assumed as variable factors in the optimal scheduling problem as Equations (24) and (25).

Simulation Results and Discussion
A two-bedroom smart home in Shiraz city, Iran was considered as the case study. The household was equipped with solar collector (SC), photovoltaic array (PV), thermal storage tank, electrical boiler, battery storage (see Figure 1) and other loads of different types such as electric washing machine, washing dryer, dishwasher, water supply pump, and uncontrollable loads. The boiler and solar collector provide thermal energy for heating and ventilation system, and also deliver hot water for washing machine, dishwasher, sink, bath, shower, and other hot water outlets with a hot water storage tank.

Input Data
Shiraz temperature data for every 10 minutes at the height of 10 m in 2008 are available on [40]. Temperature of each hour for Shiraz during one year can be seen in Figure 2. It is assumed that the smart home was equipped with 14.6 m 2 PV panels, 3.12 m 2 solar collector and 1 KWh lithium-ion battery. The photovoltaic panel considered in this study was SPR-E20-327 made by SunPower and the modeled solar collector was assumed to be APSE-10 made by APRICUS company. Solar radiation data for this case study were taken from the Iranian Renewable Energy Organization (SUNA) database [40] shown in Figure 3 and average daily radiation was equal to 5.48 KWh/m 2 /d. Electricity price was considered as $0.044 /KWh for (1-19) time interval and $0.053 /KWh for (20-24) time interval [41]. It was assumed that the feed-in tariff for solar electricity was equal to $0.23/KWh [42]. Electric loads were classified into two categories: controllable loads and uncontrollable loads. A constant load (Figure 4), was considered to represent uncontrollable loads in the proposed model. Controllable loads include washing machine, cloth dryer, dishwasher, and water pump. The rated power consumption of controllable smart appliances, the allowed interval time for operation, and the required operation time during one day in winter are summarized in Table 2. The required thermal parameters of the smart home are given by detail in Table 3.

Uncertainty
Historical data of solar radiation for 30 days of January ( Figure 3) were used to obtain the beta PDF parameters by curve fitting coded into MATLAB software. In the next step, 1000 scenarios were generated for each hour based on the obtained beta PDF. The possibility of each hourly datum was calculated based on that hour's specific beta distribution. As shown in Figure 5, 10 final solar irradiance scenarios were chosen using SCENRED2 coded into GAMS software. Similar to solar irradiance, the parameters of the Gaussian distribution were estimated using 30 historical data in January 2008 for Shiraz (see Figure 2). Then, 1000 scenarios were generated for each hour based on the obtained PDF. The probability of each hourly datum was calculated based on that hour's specific Gaussian distribution. Finally, 10 outdoor temperature scenarios were chosen using SCENRED2 in GAMS software as illustrated in Figure 6.

Optimal Scheduling
The described stochastic scheduling problem was coded into GAMS software and was solved as a mixed-integer linear programming (MILP) model. For the proposed scheduling, the weighted average cost of optimal scheduling of 100 scenarios for one day in January was equal to $0.05 , which was 20% less than the operation without scheduling ($0.06). This cost reduction mostly came from shifting controllable loads from higher-cost on-peak periods to lower-cost off-peak time intervals.
As mentioned in previous section, the indoor temperature should be maintained in a predetermined range 22 • C ≤ T s r,t ≤ 24 • C when the household is occupied. The weighted average indoor temperature of 100 scenarios are depicted in Figure 7, which shows the indoor temperature was set about 22 • C for reducing energy consumption.   Figure 8a depicts the electricity consumption and the optimal schedule for operating the dishwasher set to operate between 9:00 am to 11:00 pm. The required operating period for the dishwasher was 2 h. To decrease the energy costs, the dishwasher operated during off-load periods. The operation of the dryer depended on the operation of the washing machine. It was assumed that the dishwasher had the capacity to wash dishes of three meals, which took 2 h. It meant the dishwasher washed the dishes of the dinner the previous evening, breakfast, and lunch. The allowed operation interval for the washing machine, which was between 9:00 am to 3:00 pm, forced the model to run the washing machine from 1:00 pm to 2:00 pm. As shown in Figure 8, the operation time of the dishwasher, dryer, and the electric heater (partially) was shifted to early morning and late afternoon to increase the sold electricity to the grid and profit from the feed-in tariff. The electric pump benefited from freedom in operation time throughout the studied 24-h period. This device needed to operate for 3 h to meet the demand, which is illustrated in Figure 8c. Figure 8b shows the optimal timing for the operation of these devices. Figure 9 illustrates the optimal operation of the battery storage. The battery was charged early in the morning to cover a part of electricity demand after sunrise and increase the amount of electricity that was fed into the grid. In the afternoon, the battery was recharged to provide electricity during the on-peak period and thereby decrease the overall costs.  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23   In the proposed model, the thermal load was categorized into two types: (1) the thermal demand for heating and ventilation, and (2) the thermal demand for the hot water. These thermal loads are illustrated in Figure 10a,c as the average of the 100 proposed scenarios (weighted average based on the probability of each scenario). The peak hot water demand occurred at 8 am with thermal demand of 3.2 KWh, while the demand for heating and ventilation reached 3 KWh maximum at 4 am. The weighted average amount of stored thermal energy in the thermal storage for the 100 scenarios is described in Figure 10b. Solar collector with 3.2 KWh thermal power generation (see Figure 11b)provided around 10% of the total thermal energy demand. The optimal operation schedule of the electric boiler is depicted in Figure 8d. The electric boiler operated from 3:00 am to 7:00 am with its full capacity in order to let the user benefit from the feed-in tariff after sunrise by selling photovoltaic electricity to the grid. In the late afternoon, the electric boiler was rerun to its the full capacity at 6:00 pm and 7:00 pm to avoid the higher electricity cost after 7:00 pm (on-peak period with higher-cost). The required thermal energy for the dishwasher and the washing machine are illustrated in Figure 12a,b. The results indicate in weighted average for the 100 proposed scenarios the thermal demand for the dishwasher (1.1 KWh) and washing machine (3.4 KWh) accounted for 15% of the total thermal energy demand. Running the washing machine (7:00-8:00 pm) and dishwasher (9:00-10:00 pm) in the evening, as in the operation without scheduling, increased the thermal energy demand of these devices (5% for the washing machine and 13% for the dishwasher) due to different outdoor temperature. Ignoring the thermal energy demand of these devices in optimal scheduling of smart appliances could cause inaccurate results.
The weighted average power generation for the 100 proposed scenarios of the photovoltaic panels and the solar collectors are illustrated in Figure 11a,b. The maximum power generation culminated at 1:00 pm. The exchange electricity between the grid and the proposed energy system is shown in Figure 13. In the proposed operation schedule, the peak electricity demand was 4.2 KWh at 6:00 pm, which was around 45% less compared to the peak for the operation without scheduling (7.6 KWh at 9 pm). The results indicate that the total electricity demand during on-peak hours (20)(21)(22)(23)(24) with the optimal scheduling was 4.7 KWh, while this value was equal to 15.6 KWh without scheduling (see Figure 13). As discussed in the introduction, variable renewable resources, including solar and wind power, are non-dispatchable and generate fluctuating power due to their inherent intermittency. Mismatches between the variable renewable power generation and electric demand can cause instability in electricity systems. The solutions to avoid imbalance between the supply-side and the demand-side, such as energy storage and demand response, play a chief role in the deployment of variable renewable resources [38]. The proposed model in the current study shifted a portion of the controllable loads from the on-peak time intervals to off-peak time intervals. Due to this shift and the described constraints for the allowed operation periods (see Table 2), the renewable power self-consumption increased compared to the base scenario without scheduling. The portion of photovoltaic electricity generation, which was consumed by the smart house, is defined as self-consumption. The excess photovoltaic electricity generation decreased from 78% (8.1 KWh) for the base scenario without scheduling to 67% (6.9 KWh) for the optimal scheduling, which was beneficial for the stability of the electricity system. The excess renewable generation refers to a share of the renewable power generation exceeding the load demand which was fed into the electric grid. Because of renewable feed-in tariffs, a higher share of the excess renewable generation increased the profit margin of the households with renewable generators. On the other hand, this excess renewable generation could cause instability in the electricity system and force additional costs on the system.

Conclusions
In smart grids, buildings are no longer passive consumers, but they are controllable loads, which can be used for demand-side energy management. In this study, a stochastic mixed-integer linear programming model is used to find the optimal scheduling of a smart home using the flexibility offered by smart controllable devices, in order to minimize the total energy cost and address the uncertainties in both demand and supply sides. The weighted average cost of optimal scheduling of the 100 final scenarios for one day in January was obtained as $0.05, which shows 20 percent cost-saving compared to the operation without scheduling. In the meantime, the proposed model in this study shifts the load from on-peak periods to off-peak periods to decrease the energy costs and the peak demand. The results indicate that the proposed model has the potential to decrease the peak electricity demand from 7.6 KWh to 4.2 KWh which is about 45% peak shaving.
To address the uncertainties in the scheduling of smart homes, Monte Carlo simulation technique is used to generate 1000 random scenarios for the two relevant environmental factors, namely the outdoor temperature and solar radiation. As a result, thermal load, output power of the photovoltaic panel, solar collector power generation, and electricity load become stochastic parameters. Modeling the thermal load revealed that around 15% of thermal demand goes to the washing machine and dishwasher. Ignoring the captured uncertainties of thermal demand in smart building scheduling could cause unrealistic and inaccurate results. Furthermore, the thermal energy demand of the washing machine and the dishwasher depends on their operation time and varies during the day. Considering this factor in the scheduling of smart buildings assists in energy saving and in avoiding unnecessary costs. For the current case study, the proposed operation schedule saved one percent of thermal energy by shifting these loads.
Although the model improved the share of the excess renewable generation to 67% from a 78% excess share for the operation without scheduling, a further investigation is required to consider the stability of the electricity grid. Future studies should explore the trade-offs between the share of excess renewable production (the household's profit) and the stability of the power system (the additional costs of the electricity system).