Multi-time scale energy management framework for smart PV systems mixing fast and slow dynamics

We propose a multi-time scale energy management framework for a smart photovoltaic (PV) system that can calculate optimized schedules for battery operation, power purchases, and appliance usage. A smart PV system is a local energy community that includes several buildings and households equipped with PV panels and batteries. However, due to the unpredictability and fast variation of PV generation, maintaining energy balance and reducing electricity costs in the system is challenging. Our proposed framework employs a model predictive control approach with a physics-based PV forecasting model and an accurately parameterized battery model. We also introduce a multi-time scale structure composed of two-time scales: a longer coarse-grained time scale for daily horizon with 15-minutes resolution and a shorter fine-grained time scale for 15-minutes horizon with 1-second resolution. In contrast to the current single-time scale approaches, this alternative structure enables the management of a necessary mix of fast and slow system dynamics with reasonable computational times while maintaining high accuracy. Simulation results show that the proposed framework reduces electricity costs up 48.1% compared with baseline methods. The necessity of a multi-time scale and the impact on accurate system modeling in terms of PV forecasting and batteries are also demonstrated.


Introduction
The reduction of CO 2 emissions and achieving a sustainable future motivate a broader integration of such renewable energy sources as solar and wind into energy systems worldwide. In particular, using renewable generators that are close to the demand-side instead of centralized generation can reduce transmission losses [1]. However, the massive introduction of renewable energy can cause supply-demand mismatches and the frequency change of electricity due to its variability [2]. To address such energy issues, the renovation of conventional grids toward a smart energy system is critical for effectively using renewable energy. A smart energy system is an advanced power scheme that can make such systems more resilient, energy-efficient, and eco-friendly by integrating renewable generation and demand control [3].
To put smart energy systems into practice, an energy management system (EMS) has the most critical role [4]. EMS's main function is to are deemed to be promising EMS applications [10]. Regarding demand control, household appliances, which can be shifted in time, e.g., washing machines and tumble dryers, are often scheduled using a mixed-integer programming (MIP) model [11]. Each appliance is modeled with detailed energy consumption profiles that correspond to their operational cycle. A appliance scheduling is an effective solution so that the demand-side fits the electricity price policies [12] and minimizes electricity peaks as well as the consumption rate of photovoltaic (PV) generation [13]. Many researchers have reported the effectiveness of a battery system and appliance scheduling combination. A previous work [14] proposed a home energy management system (HEMS) controller based on a multi-objective MIP model to minimize electricity costs and peaks. An economic analysis was performed on battery investment with appliance scheduling in residential sectors. The mixed-integer non-linear programming (MINLP)-based EMS is was formulated [15], which considers electrical or thermal demand control and day-ahead energy storage scheduling. Sensitivity analysis concludes that the best option to reduce operation costs is electrical demand control with battery scheduling. The above methodology usually solves the scheduling problem once a day, but the forecast errors of PV generation and the latest state of the battery system is ignored during the day.
On the other hand, model predictive control (MPC) is widely used in EMSs as an optimization process. MPC's main advantage is the ability of adjusting the control input that depends on the latest system state by iterating the prediction of future system behavior and optimization for a finite time horizon. In particular, MPC is applied to such EMS applications as the battery system scheduling to deal with renewable uncertainties by wind turbine and PV panels attached to the house [16], the indoor climate control with the heating, ventilation, and air conditioning (HVAC) scheduling in the house [17] or in office buildings [18], and the cooperative energy management for networked energy communities [19]. With the recent growth of computing resources, the scale of problems that can be handled by MPC has been expanding. Another study proposed a comprehensive HEMS [20] that includes quadratic cost functions with a huge number of variables and constraints for thermal and energy storage as well as appliances and PV generation. The mixed-integer quadratic programming (MIQ)-based MPC obtains solution with 15 min resolution based on such future predictions as occupancy to improve human comfort and reduce operation costs. Meanwhile, the performance of MPC mainly depends on the accuracy of prediction models. The prediction model was integrated [21] for renewable generation and integrated the demand load, and the MIPbased MPC provides an effective solution for battery scheduling. In general, MPC performance mainly depends on the accuracy of the prediction model. To guarantee both prediction accuracy and solution quality, MPC's planning horizon includes up to a few days with such coarse-grain resolution as 15 min or one hour.
Although much literature has studied the scheduling of the smart energy system, they are only dealt with slow dynamics, which affects the subsequent 24 hour horizon with hourly or tens of minutes of resolution. Not considering such fast dynamics as short-term PV fluctuations or battery's transient response leads to real-time energy imbalance that will cause energy loss.
The time scale of the control sequence of an EMS is a non-negligible factor in its performance. In practice, most smart system contexts exhibit a mix of fast and slow dynamics, which puts too much stress on the run-times when accuracy must also be maintained. As presented above, an EMS application should consider a daily change of renewable generation and electricity demand for a longer time scale up to a few days [22]. Furthermore, demand control (e.g., appliance scheduling), which is also either performed daily or hourly [23], effectively matches the demand-supply in local energy communities, including buildings and homes with many appliances. On the contrary, for a short time scale with a time resolution of a few seconds, the real-time energy imbalance between renewable generation and demand can directly cause energy loss. Real-time decision-making generally employs a rulebased control approach [24] or a fuzzy-logic [25] controller to balance the demand-supply mismatch rather than the prediction-based optimization. These approaches do not require detailed systems; however, the solution's optimality is not guaranteed because only simplified models and real-time information are considered. Therefore, we must precisely optimize the battery's operation based on forecast information for expected renewable generation to achieve optimal real-time control. The time scales vary widely that should be managed by the EMS to properly control the system; the purpose of different time scales also differs. Thus, when accuracy is paramount, an EMS design suitable for each purpose and each time scale is required to simultaneously meet all these criteria. We tackle this problem in this paper by employing a multi-time scale energy management framework.
Several studies have proposed a multi-time scale MPC like the one introduced in this work. Abreu et al. [26] proposed a hierarchical MPC method to manage a set of different sub-systems, such as appliances and their loads. Its upper layer calculates the maximum power limit, and its lower layer individually optimizes load schedules; however, the paper ignores renewable energies and batteries. Another work [27] also proposed a hierarchical EMS that focused on a building, a battery system, and PV generation. It integrated a scheduling upper layer with a 7 hour horizon and a pilot lower layer with a 5-minute horizon. A hierarchical EMS was developed [28] for dealing with day-ahead schedules and intra-hour adjustment in an office building that contained PV systems and batteries in electric vehicles. However, none of these above papers addressed appliance scheduling. Their demand flexibility is also limited. The PV forecasting model is also relatively simple, and short-term PV fluctuation does not receive sufficient attention. A hierarchical two-layer HEMS [29] reduced daily electricity costs and increased PV self-consumption. In its upper layer, the scheduling of the battery system and the appliances were performed for the next 24 h, using the previous day's PV generation profiles as PV forecast data. Although the lower layer is a rule-based real-time controller that compensates for PV fluctuation, it is relatively simple algorithm based on no short-term PV forecast data.
The scheduling of the battery system and the appliances were scheduled for the next 24 h. Although the lower layer is a rulebased real-time controller that compensates for PV fluctuation, it is a relatively simple algorithm based on no short-term PV forecast data. The importance of accurate PV forecasting in energy management has been proved [30] and significantly affects the EMS performance [31]. Finally, none of these papers provided a detailed view of PV forecasting and battery states at the level of seconds and minutes. Combining them in the inner time loop is crucial for the accurate management of supply-demand balance.
In this paper, we developed a multi-time scale energy management framework for a smart PV system that exhibits a mix of fast and slow dynamics. Our smart PV system is a local community with several buildings and homes equipped with batteries, PV panels, and controllable appliances. For implementing real-time control, the MPC approach is employed by accurately forecasting PV generation and the most recent battery state. We also introduce a detailed battery model that accurately captures the I-V characteristics and the state-of-charge (SOC) to achieve precise energy management in a smart PV system. Our proposed framework's multi-time scale structure successfully treats the fast and slow dynamics of energy management in one integrated optimization loop by dividing the time scale into two-time scales: coarse-grained and fine-grained. In this way, the modeling capability and computational time are improved. The main contributions and originality of this work are shown below: • The multi-time scale energy management framework presents real-time optimizing methodology to reduce electricity costs while taking into account a mix of such fast and slow dynamics as PV, energy demand fluctuations, and battery transient responses.
Two time scales are introduced: coarse-grained and fine-grained.
• With a comprehensive approach, three detailed component models are integrated: (1) a time-shiftable appliance model, (2) a physics-based PV forecasting model that provides a fine-grained forecast with 1-second resolution, and (3) a parameterized battery model that represents accurate I-V characteristics and SOC levels. • The model predictive control (MPC) approach copes with the forecast error of PV and reflects the latest battery state. The predictions of PV generation and the battery system's state are iterated as well as the optimization of the schedules of the batteries, the appliances, and power purchases. • Simulation results show that the proposed framework reduces electricity costs up to 48.1% compared to baseline methods. The computational time is short enough to allow for real-time control of smart PV systems. We explored the effect of PV forecasting error and battery capacity and investigated the necessity of the multi-time scale structure by comparing single-time scale methods.
This paper is structured as follows. First, an overview of the proposed framework and its multi-time scale structure are given in Section 2. Section 3 explains the introduced system models in detail, and Section 4 describes the mathematical formulation of a multi-time scale optimization problem. Finally, we demonstrate the effectiveness of the proposed method by simulations with measured data in Section 5 and summarize it in Section 6.

Multi-time scale energy management framework
This section gives an overview of our proposed framework that employs a model predictive control approach: a multi-time scale energy management framework. The key ideas of the multi-time scale structure are also discussed in this section. Fig. 1 shows an overview of the proposed framework. Its overall objective is to minimize electricity costs. This framework's input is electricity demand information and forecasting data of PV generation. Its output is an operation plan that includes power purchases from the utility grid, battery charges/discharges, and appliance schedules. We utilize the MPC approach in the proposed framework for real-time energy management.

Overview of proposed framework based on model predictive control approach
MPC is an effective means of dealing with control problems that have many variables and future disturbances [32]. Recent works have successfully applied it to the energy management problem [33]. In the MPC approach, the process of computing the optimal solution that minimizes a given objective for a finite time horizon is performed at every time step. MPC's key idea is to improve a system's operation by iterating predictions and optimizations. At sample time step , a system's predicted behavior is provided as input to solve an optimization problem for a given period. Only the first sample of the solution is applied to the system, and the others are discarded. At next sample time step + 1, the new predicted input appears, and the optimization problem is recalculated for the following receded period. Note that one advantage of the MPC approach is that its feedback structure potentially compensates for the uncertainty of variable load demand and PV generation [34]. Therefore, we apply MPC to the energy management framework.
The main processes of the proposed framework based on the MPC approach are iterated as follows. First, the framework obtains the PV forecasting data for the very near future, such as the upcoming half hour or a few days. Then it optimizes energy utilization to minimize electricity costs from the utility grid. Energy utilization includes battery charges/discharges, power purchases, and appliance schedules. This optimization problem is mathematically formulated, and a mathematical solver can obtain optimal results. Finally, the obtained plan is applied to the system operation. In the next time step, the same process is performed. In this way, the latest system information is reflected for creating a real-time control that interpolates the energy balance.

Multi-time scale structure
The main idea of a multi-time scale structure is to solve one integrated optimization loop that covers two-time scales: coarse-grained and fine-grained. These time scales take into account appliance scheduling, a variation of demand load, PV generation, and accurate battery characteristics. First, the coarse-grained time scale is responsible for energy management in the near-term period (up to a few days) based on coarse changes in time resolution for demand and PV generation. PV forecasting models suitable for the long-term, such as artificial intelligence, are usually less accurate when the time resolution is less than a few minutes [35]. Hence, resolution for coarse-grained loops can be rough, e.g., 15 min. Next, real-time control achieves a shortterm energy balance in the fine-grained time scale between highly fluctuating renewable generation and fast-varying battery storage under the demand conditions derived from the long-term planning loop. The time resolution in the fine-grained loop should be under a few seconds for real-time control and managing the short-term variation of PV generation. This is because the electrical time constants of PV panels are a few seconds and above. The energy production of PV panels mainly depends on both PV cell temperature and solar irradiance. The PV cell temperature responds to such fast-varying weather conditions as the irradiance and wind, and its fastest thermal time constants are a few seconds and above [36]. The irradiance has a significant impact on the power output of PV panels, and the fastest time constants are also minimally a few seconds due to moving cloud coverage [37]. The irradiance variation, which would vary even faster, is expected to be negligible in magnitude differences. Furthermore, the most critical electrical time constants of a battery system are also at least a few seconds and match that of PV generation. Clearly, the EMS framework deals with different problems that act on different time scales: appliance scheduling and demand load on the one hand and the fluctuation of PV generation and battery operation. However, the proposed framework can still treat these problems in one integrated optimization loop (not independently) as needed to obtain high accuracy for optimizing the balance.
Based on the above description, we formulated a multi-time scale structure for a smart PV system (Fig. 2). Let be a set of the global time steps for the whole process, where multi-time scale optimization is dispatched at every control point with resolution . Since optimization problems are discretized in time, time windows (planning periods) are divided by a given resolution. First, a coarse-grained time scale with time index , which corresponds to slower system dynamics, is designed to consider a daily variation of demand and PV generation.   is 24 h, and is 15 min. By solving a coarse-grained optimization, rough schedules of a smart PV system are obtained. Following the MPC approach, the solution of the first is usually applied to the system and interpolated by solving a fine-grained optimization to consider such fast system behavior as real-time energy balancing. Optimal schedules with fine time granularity are calculated using the solution for the first as a reference set-point. Keeping the time scale consistent, the planning period of fine-grained time scale generally equals . The fine-grained time scale's time window is divided by fine resolution whose value is typically 1 s. Finally, as marked by the red window in Fig. 2, the obtained solution is applied to the system.

Model development
This section provides a detailed overview of the smart PV system and the mathematical model introduced in the proposed framework. It includes a smart PV system model, a PV forecasting model, a battery model, and a smart appliance model, all of which are discussed in more detail.

Targeted smart PV system structure
A smart PV system is a local energy community that is comprised of several building and households. Such isolated energy system communities allow real-time data collection and control. The systems are connected to a network to exchange information with other parts of the systems and obtain such third-party information as meteorological data for PV generation forecasting. Fig. 3 shows a schematic view of our smart PV system model. The main components of the smart PV system are PV panels and battery systems, especially with lithium-ion batteries. The battery system stores the generated energy and supplies demand when (1) the energy generated by PV is insufficient and (2) the EMS decides to supply the required load from the battery rather than the grid. Two sets of appliances are assumed: non-shiftable and shiftable. The former includes lights and refrigerators whose starting times and operation cannot be deferred or interrupted. Shiftable appliances include dishwashers and washing machines whose starting times can be shifted to another time slot to avoid interruptions.
In the framework, both the battery system and the shiftable appliances are scheduled to balance demand and PV production by solving an optimization problem with a constraint of user preferences. The EMS collects information on the energy balance and the system state from the smart PV system while managing the overall energy flow based on the solution obtained by the framework shown in the previous section. The smart PV system buys electricity from the utility grid during power shortages. To prevent grid instability caused by a reverse power flow, we assume that this system is denied from selling surplus generated energy to the utility grid. The surplus energy is consumed by smart appliances and batteries as much as possible; otherwise, it is wasted inside the system.
In general, the energy balance inside the system must be kept at any time , which is formulated by: where , , and respectively denote the energy purchased from the utility grid, the energy generated by the PV system, and the charging/discharging energy of the batteries. Let , ℎ , and respectively be the demand load of the non-shiftable appliances, the demand load of the smart appliances, and the wasted energy. Charging/discharging energy takes a positive value when charging and a negative value when discharging.
In addition, purchased energy and wasted energy cannot be negative values, as given by Eqs. (2) and (3): Note that this model does not consider such components as wind turbines, air conditioning systems, and electric vehicle management because this paper focuses on the effect of PV forecasting and accurate battery models on EMS performance. We can potentially add or remove other components by mathematically formulating their behaviors. However, since our work is ongoing, adding so many complex options in a single paper seems overwhelming and counterproductive.

Accurate physics-based PV forecasting model
PV generation has high fluctuation due to meteorological stochastic phenomena. Therefore, the real-time forecast data of PV generation is necessary to smooth the fluctuation by balancing demand and PV generation with battery scheduling. In this paper, we use the forecast data provided by the PV nowcasting model [38], which can predict short-term generation based on sky images, neural network models, and a highly accurate physics-based modeling framework of PV generators [39]. This model's major benefit is that it provides PV energy forecasting with high temporal resolution. Such forecasts are provided over a horizon of 15 min with a 1-second resolution. Furthermore, the forecast can be updated every minute, a time period which is sufficient for iterating a fine-grained battery scheduling loop.
On the other hand, PV forecasting for the coarse-grained time scale is also important to capture a long-term energy balance for up to a few days. We assume that the PV forecasting data for a coarse-grained time scale are available by a network from a local meteorological station.

Appliance model
Each shiftable appliance is characterized by four parameters [40]: (1) its operating time, (2) its configuration time denoted by , which is the time required to start the appliance, (3) a deadline denoted by , which is the time by which it must finish its task, and (4) the electrical energy required by its operation. Shiftable appliances must be scheduled from their configuration times until their deadlines. The scheduling problem is solved under user preferences, and shiftable appliances automatically start based on the obtained solution.
A brief introduction of the formulation of shiftable appliances is presented here. We model the operating cycle of each appliance. Let be the index of the shiftable appliances. The operating time of each appliance is divided by the time resolution of , and the index of each divided operating phase is represented by . Binary variables , , represent the state of the shiftable appliances; , , = 1 if appliance is in operation phase at time , otherwise 0. We also introduce binary variables , , as a finished flag; , , = 1 if operation phase of appliance is already finished at time , otherwise 0. We can also formulate the shiftable appliance scheduling: , , + , , ≤ 1, ∀{ , , }, , , −1 − , , ≤ , , , ∀{ , }, 2 ≤ ≤ , , , −1 ≤ , , , ∀{ , }, 2 ≤ ≤ , , , , where , is the demand energy of phase of appliance . Eq. (4) aggregates the shiftable demand. Eqs. (5)-(10) shows the scheduling logic of the shiftable appliances. Eq. (11) denotes the user preference for the timing of the appliance usage. This scheduling problem is solved at the coarse-grained time scale.

Accurate parameterized battery model
Battery system models are critical tools for designing energy management systems in terms of scheduling and simulation. The main contribution of this paper is building a battery module model from a battery cell model [41] and leveraging it to accurately follow SOC profiles and charge-discharge loss. As described in Section 1, most related studies have utilized a simple battery model that linearly represents such losses without accurately capturing the battery characteristics.
Assuming that each cell is identical in the battery module, the battery module's configuration is shown in Fig. 4. and are a number of series-and parallel-connected cells. We use the equivalent circuit model as a battery model that shows good agreement with the measurements of battery run-time and non-linear I-V characteristics [41].
Based on a previous work [41], an aggregated equivalent circuit model of the battery module used in this paper is shown in Fig. 5. The left part of the equivalent circuit expresses the battery lifetime. Here voltage source represents the stored energy level of the battery, i.e., SOC, ranging from 0.0 (0%) to 1.0 (100%). The terminal current of battery is positive when it is discharging and negative when it is charging. In addition, the nominal capacity of the battery module, denoted by , is calculated from cell capacity : . These parameters are a function of the SOC level and given by: where { , ∀ = 1 … 21} are the coefficients of the battery cell. We use the values provided in the literature [41]. Finally, terminal voltage and charge-discharge energy in kWh are calculated: where and are the voltage of the left parallel RC branch and the voltage of the right one, calculated by the following equations: In this paper, a full equivalent circuit model is used in the system simulation to estimate accurate battery states. The modified equivalent circuit model is implemented in the optimization problem to obtain effective battery utilization with reasonable computation time. The details of the battery model's modification are described in the following section.

Mathematical formulation of multi-time scale optimization
The proposed framework's objective is to calculate the optimal schedules of a smart PV system, which includes power purchases, a  battery system, and shiftable appliances. As mentioned in Section 2.2, the proposed framework employs a multi-time scale MPC composed of multiple optimization problems. First, we show the optimization flow implemented in the proposed framework and introduce a detailed mathematical formulation. Fig. 6 shows the multi-time scale optimization flow of the proposed framework. The optimization loop, which is composed of multiple optimization problems, is executed in every internal period of . First, coarse-grained time scale optimization is performed. This time scale has two optimization problems: (1) appliance scheduling (AS) and (2) coarse-grained energy management (CGEM). The AS problem is solved to determine the schedule of shiftable appliances. The CGEM problem is solved with the obtained appliance schedule to calculate the battery's reference solution. The CGEM includes the equivalent circuit battery model, and the battery characteristics are precisely considered. The planning period is still long at these optimizations, and the PV generation forecasting is roughly updated with coarse-grain resolution. After that, fine-grained time scale optimization decides the precise control. The PV forecasting model, mentioned in Section 3.2, generates PV energy profiles, and fine-grained energy management (FGEM) optimization is solved with forecast information and reference values obtained by coarse-grained optimization. The reference values consist of the demand profiles of the shiftable appliances and the battery energy profiles of charging and discharging. The fine-grain schedules of the battery system calculated by the FGEM are directly applied to the system. Based on optimal schedules, actual behavior is simulated with the full equivalent circuit battery model, and the battery state is updated. The AS, CGEM, and FGEM formulations are described in the following section.

Appliance scheduling
This section shows a detailed mathematical formulation of AS. Because of the coarse-grained time scale, the time index is with a time resolution of . The problem includes some binary variables, and AS is a mixed-integer linear programming (MIP) problem. The following formulation describes AS's optimization problem: subject to where is the electricity price of the power company. Note that AS employs the simplified battery model obtained by fixing battery terminal voltage to the constant nominal value, i.e., the I-V characteristics of the battery are not considered in AS. This is because the AS formulation includes integer variables, and an AS with non-linear equivalent circuits is too complex to solve. This simplification is compensated in the following CGEM by re-solving the battery scheduling concern with the equivalent circuit model.
The objective is to minimize electricity costs, and the AS solution contains optimal scheduling for the shiftable appliances, the battery, the wasted energy, and power purchases from the utility grid. Only the optimal schedule of shiftable appliances, ℎ and , , , is applied to the system and other optimizations. The rest are discarded and recalculated in the following problem.

Coarse-grained energy management
This section shows the detailed mathematical formulation of CGEM, which is the outer loop for the battery scheduling that shares an identical time scale with AS. In the CGEM, capacitances and are removed from the circuit model (Fig. 5) because the dynamics of the transient response represented by these capacitances are very fast: 20 s -4 min. It makes no sense to include these dynamics in the coarsegrained time scale. Hence, the battery equation is reformulated using resistance value : Because the CGEM includes non-linear equations of the battery model, it is a non-linear programming (NLP) problem. CGEM's formulation is finally described: subject to where the objective is identical with that of the AS to minimize electricity costs. The CGEM contains optimal scheduling for the battery, the wasted energy, and power purchases from the utility grid. The obtained battery schedule is more effective than the AS solution because the CGEM contains equations that accurately expresses the I-V characteristics. The reference value of battery energy is input to the FGEM, as defined by: where the FGEM decides the fine-grained battery schedule based on , and this prevents a greedy solution that discharges the battery system to minimize electricity costs.

Fine-grained energy management
FGEM is the inner loop for battery scheduling to interpolate high fluctuations of PV generation. The time index is with resolution, and length normally equals resolution . The full equivalent circuit of the battery module is employed to express the battery dynamics, i.e., the transient response. In addition, the battery trajectory in the fine-grained time scale should follow the schedules of the coarsegrained time scale. Thus, based on the reference value from the CGEM denoted by , the charging/discharging energy of the battery is constrained by Eq. (29): where denotes the relative error from the reference value, e.g., it is set to 5%. Because FGEM includes the non-linear equations of the battery model, it is an NLP problem. The following formulation finally shows FGEM's optimization problem: subject to where the AS solution for appliances ℎ is also input, and the objective is identical as the other problems to minimize electricity costs. The FGEM solution contains the optimal scheduling for the battery, the wasted energy, and the power purchases from the utility grid.
We applied these optimal solutions to the smart PV system and simulated actual battery behavior with a complete equivalent circuit model in the system simulation. Note that the simulation of the battery system remains a critical step in the actual implementation. Since the battery's internal state cannot usually be directly measured, simulation is required to accurately estimate such battery states as SOC.

Simulation results
In this section, we explain several key simulation experiments to demonstrate the effectiveness of our proposed framework with practical assumptions. The experimental setup is first described, and then the case studies are performed under different settings of the proposed framework. The impact of PV forecasting error on the performance is also investigated. Finally, the proposed framework is compared with other baseline methods in terms of electricity costs.

Simulation setup
The parameters of the proposed framework are shown here. In all the experiments, the simulation period is ten days, and every simulation day starts at 12 p.m. midnight. The time resolutions in the coarse-and fine-grained time scales were set to 15 [42]. CGEM and FGEM comprise an NLP problem solved by an open-source solver called IPOPT [43]. The computing platform on which the simulation is run uses an Intel Core-i7 6600U CPU with two cores, a 2.60 GHz clock frequency, and 16 GB of DDR3 RAM.
The battery parameters in the optimization problems are described in Table 1. The coefficients of battery cell { , ∀ = 1 … 21} are provided by the literature [41]. The relative error of the charging/ discharging energy between CGEM and FGEM denoted by is set to 0.05 (5%). The electricity price is the time-of-use (TOU) policy widely employed in Japan: 21.66 ¥/kWh during daytime (7 a.m.-11 p.m.) and 10.7 ¥/kWh during nighttime (11 p.m.-7 a.m.) [44].
The PV generation profiles and other environmental data were collected with 1-second resolution at the University of Oldenburg from June to July, 2015 [38]. Ten days (June 18 to 27) are used as input for the simulation, and PV generation profiles are scaled by a constant value as to simulate a 15 kWp PV system (Fig. 7). It has to be noted that the simulated days were rather cloudy. Therefore, the simulated PV generation is highly fluctuating, and forecasting such PV generation profiles is extremely complex. Hence, high forecasting error can be expected; in other words, this simulation study is under a worst-case scenario to test the worst-case performance of the proposed method. Regarding PV forecasts, the fine-grained forecast of PV generation is provided by the PV forecasting model [38], whose average forecasting error is less than 12% even with cloudy scenarios. The coarse-grained forecast of PV generation is manually generated by adding error distribution to the actual measured profiles, and its average error is 20%. Thus, we assumed a Gaussian distribution as the error distribution, whose relative standard deviation is set to 20% of the mean value of the measured PV generation profiles.
The demand profiles of the non-shiftable appliances, which are based on the Dutch Residential Energy Dataset (DRED) [45], were collected from July to December 2015 with a 1-second resolution. Ten days of demand profiles (July 5 to 14) are extracted from the dataset and used as input for the simulation. As for the PV generation profiles, also demand profiles are scaled by a constant value. The mean value of the non-shiftable appliances per day was set to 50.1 kWh. The shiftable appliances profiles are shown in Table 2. We assumed three shiftable appliances: a washing machine, a tumble dryer, and a dishwasher. There are four appliances in each type, i.e., there are totally twelve shiftable appliances. Each appliance is operated once a day. The configuration time is randomly generated within the range shown in Table 2, and the deadline is decided by adding the shiftable time to the configuration time. The power profiles of each shiftable appliance with 1-second resolution are provided by the dataset [46].

Comparison study with baseline methods
In this section, we compared the proposed framework with several representative baseline methods to evaluate the effectiveness of appliance and battery scheduling. The baseline methods are described as follows: D. Watari et al. Fig. 7. PV generation profiles for ten days (June 18 to July 27) used in simulation, collected at University of Oldenburg.  Table 3 Comparison of electricity cost results for ten days and improved rates of electricity costs of proposed method with three different methods: ASAP, NBS, and ASAP-NBS.   Table 3 shows the results of the electricity costs for ten days and the improved rate of Proposed with respect to the other methods. The proposed framework achieved the lowest electricity cost in all methods, and the maximum improving rate was 48.1%. Appliance scheduling can fill the energy gap between generation and demand. Electricity costs were clearly reduced. We also identified battery scheduling as the major contributing factor for reducing electricity costs. When the battery is charged and discharged by such constant current as NBS, the battery cannot control the balance between renewable generation and demand. As a result, the purchased energy increases to ensure that demand is fulfilled.

Impact of planning period on coarse-grained time scale
In this section, the impact of the planning period on the coarsegrained time scale is investigated. The proposed framework is performed with different planning periods from six to 48 h. Table 4 shows the electricity costs over ten days and the mean value of the computational times for each optimization problem. Electricity costs decrease until the planning period increases to 24 h. However, when the planning period exceeds 24 h, electricity costs increase. This is because that the battery operation solution changes depending on whether 36-and 48 hour planning periods are chosen. The end state of the battery's SOC after a ten-day simulation is 53.1% when it employs a 24 hour period, and its value is 65.1% and 65.8% when it employs 36-and 48 hour periods. From a longer input perspective, the battery operation solution changes, and the remaining energy in the battery increases. Also, shiftable appliance schedule solution also change. When it employs 24 hour periods, some shiftable appliances in the last simulation day were shifted to the next day (outside the evaluation period). In contrast, employing 36-and 48 hour periods, these appliances were scheduled within that day. Over a 24 hour period, we assume that the reduction of electricity costs is saturated.
On the other hand, the computational time of each optimization problem increases as the planning period increases. When the planning period reaches 48 h, the computational time of AS significantly increases. This is because the longer the planning period, more decision variables and smart appliances must be scheduled. However, since the sum of the computational time is much less than the length of time resolution , our proposed framework is applicable for all the simulated planning periods. In addition, daily (24 h) planning is most efficient with home and building applications because of the repetitive nature of some of the daily demands of the occupants. When the planning period of the coarse-grained time scale is set to 24 h, the proposed framework achieves good performance.

Impact of number of smart appliances
Next we demonstrate the impact of the number of smart appliances on the computational times. Every type of smart appliances was increased from 2 to 10, i.e., the total number of smart appliances was changed from 6 to 30. Since each appliance is scheduled once a day, the AS daily calculates the optimal schedule for 6-30 appliances.
D. Watari et al.  Table 5 shows the average computational times for each optimization problem. Naturally, the computational time of AS increases with more appliances. However, the requirements for the computational times, that every optimization flow must be completed within = 900 s, are always met, and the computational time is appropriately short. Thus, if a smart PV system has several buildings and as many as 30 smart appliances or more, AS is sufficient in both accuracy and time complexity for planning shiftable appliances.

Impact of PV forecasting error and battery size
In this section, we analyzed the performance of our proposed framework with different PV forecasting errors. We used the same method described in Section 5.1 to generate the coarse-grained forecast of PV generation, and its average forecasting error was set to 20, 30, or 40%. In the fine-grained time scale, two different forecasting schemes are compared: energy forecasting [38] and power forecasting [38]. The average forecasting errors for the 15-minute horizons of the energy and power forecasting are about 12 and 20%. As an ideal case, we would employ the perfect forecasting method, assuming that the forecasting error for both time scales is 0%. To investigate the effect of battery sizing, we also changed the battery capacity from 3 to 18 kWh. Fig. 8 shows the results of electricity costs for various PV forecasting errors and battery capacities. Detailed values of the electricity costs are shown in Table 6. In Fig. 8, the black line indicates the electricity costs during perfect forecasting, and the red and blue lines denote the energy and power forecasting for fine-grained time scales. As seen from these results, when the battery capacity is too large (such as 18 kWh), the improvement of electricity costs is often saturated or reduced. This is because the negative effect of misunderstanding future PV generation is also enhanced as the battery size increases; i.e., the effect of battery misoperation due to PV forecasting error exceeds the effect of reduction in electricity costs from more battery capacity. Note that we did not choose larger battery sizes for practical reasons, including high capital costs.
On the other hand, looking at the forecasting error for the coarsegrained time scale, when the battery capacity exceeds 9 kWh, the smaller is the forecasting error, and the lower is the electricity costs. However, when the battery capacity is 3 or 6 kWh, the coarse-grained prediction error has little effect on electricity costs. The PV forecasting scheme for the fine-grained time scale greatly improves the electricity costs: better forecasting equals energy forecasting. Therefore, the accuracy of the forecasting scheme for the fine-grained time scale is a significant factor for the performance of energy management. A 10% improvement in fine-grained forecast error is equivalent to a remarkable 30%-50% reduction in battery size and achieves identical electricity costs.

Impact of multi-time scale structure
To investigate the necessity of the multi-time scale structure, the proposed framework is compared with two single-time scale methods for the scenario presented in Section 5.2:   Table 7 shows the results of the electricity costs for ten days and the improving rate of the proposed method with respect to OC and OF. Our proposed framework also achieved the best performance, and the maximum improving rate of the electricity costs was 47.5%. The multi-time scale structure is effective in terms of electricity costs.
Figs. 9 and 10 show the results of the SOC profiles and the battery power profiles for the same day. OF clearly falls into myopic optimization, i.e., where the battery is discharged to reduce electricity costs as long as energy is available from it. Since only OF knows about the upcoming of 15 min without the coarse-grained time scale, its solution is not optimized for longer-term changes of energy demand and PV generation. Comparing the proposed and OC methods, the proposed method reaches higher SOC of the battery system than OC. Although OC provides a solution that captures the long-term changes of PV generation, the accumulated errors of PV fluctuation in the finegrained time scale cause a loss of opportunities to charge the battery with the PV generation. Our proposed method follows the reference solution of the coarse-grained time scale and compensates for the fast variations in the smart PV system at the fine-grained time scale. The multi-time scale structure eventually improves battery and energy management.
The proposed methodology focuses on both the fast and slow dynamics of PV generation and battery. Of course, energy demand is also highly volatile, but the time scales are on the order of many minutes and different from the fast variations in PV generation and battery. As a result we can absorb the energy demand fluctuations in the coarsegrained optimization loop of our multi-time scale approach. The fast responses of battery charges and discharges allow us to effectively deal with energy demand fluctuations, as demonstrated by our simulation results. Indeed, if the demand side becomes more sophisticated and more active in the market, energy demand variations will also become a major constraint to be solved. In the current market situation, although such a development would be challenging, it is currently beyond the scope of this paper and represents future work.     3  3450  3558  3529  3579  3610  3570  3612  6  3146  3309  3292  3360  3437  3404  3477  9  3025  3181  3227  3272  3334  3381  3420  12  2821  3037  3118  3171  3202  3289  3353  15  2739  3004  3094  3185  3182  3271  3379  18  2719  3027  3092  3205  3193  3281  3384   Table 7 Results of electricity costs for ten days and comparison of improving rate of electricity costs among our proposed method, OC, and OF.

Summary
We proposed a multi-time scale energy management framework for a smart photovoltaic (PV) system. In the proposed framework, a model predictive control (MPC) approach is employed that uses PV generation forecasting as input to deal with highly volatile PV generation. The proposed framework simultaneously solves three interconnected optimization problems using the multi-time scale structure and considers long-and short-term system dynamics. The multi-time scale consists of two-time scales: coarse-grained and fine-grained. In the coarse-grained time scale, smart appliances are scheduled to shift operating times, and the battery charge/discharge profiles are optimized to deal with the daily variations of PV generation and demand. In the fine-grained time scale, the battery's precise control is achieved by introducing an accurate battery model that is combined with the fine-grained PV forecasting model. The results, which are compared with representative baseline methods, demonstrate that the proposed framework reduces electricity costs under different scenarios up to a maximum of 48.1%. We also investigated the impact of PV forecasting error and battery capacity on the performance of the proposed framework. If an accurate PV forecasting model were introduced, electricity costs could be significantly reduced, even with small batteries. The combination of accurate PV forecasting and our proposed energy management framework might also reduce installation costs since a smaller battery system could be used.
Future work will extend our proposed framework to multi-objective optimization for maximizing user comfort and minimizing system cost, perhaps incorporating heat ventilation and air conditioning (HVAC) systems. Another important direction is implementing the proposed framework in actual systems with online system management, including data processing, data transmission, and fast-responding decisions. The proposed framework manages the entire system's operation by providing practical solutions as a core part of energy management systems. The modeling result will be validated again by experiments in our implemented system.