High Level Controller-Based Energy Management for a Smart Building Integrated Microgrid With Electric Vehicle

This paper presents an effective approach for the modeling and optimization of a smart building integrated microgrid (BIM). The main objective is the development of a smart building energy management system (BEMS) which is in charge of optimally controlling the operation of a building-integrated-microgrid. More specifically, we consider a BIM consisting of a roof-top solar photovoltaic, wind turbine, energy storage unit, electric vehicle, micro-CHP, metering infrastructure, and loads. The BIM loads are used to satisfy the electric needs of occupants, while operating flexibility of thermal loads, which include building heating and hot water demand, are also considered. Emphasis is given to the optimal performance of the BIM, where the objective is to ensure the power balance between production and loads in the microgrid (electric and thermal). A centralized algorithm is implemented for the power management of all components as well as power exchanges with the electrical grid. The developed algorithm is tested through a case study, where the effects of both loads and renewable resources’ variabilities on the operation of the BIM are analyzed via numerical simulations.


INTRODUCTION
Smart grid integration into buildings and different energy management methods have represented a major challenge for new connecting buildings' energy generation. Energy consumption in different residential buildings is increasing due to the new trend of comfort requirement nowadays. Building's energy bills are consequently higher, which affects the householder's financial potential. Microgrids integrated to buildings with/without energy storage systems require different energy management tools and methods based on the configuration of the energy system and on its efficiency, reliability, and reducing the electricity cost from the grid. In the literature, several homes' energy management systems have been treated. In a study by Han et al. (2014) the authors presented the concept of smart home energy systems based on ZIG BEE and PLC techniques with renewable energy integration. It consisted of a new form of energy architecture based on communication blocks and measurement blocks via Zig Bee applications from energy generation using a wind turbine and photovoltaic panels connected to a home server related with the internet weather forecast data. The authors in (Abdeltawab and Mohamed, 2015) developed a real time model predictive control for energy management systems using a hybrid wind battery storage. The goal is to get the maximum net profit from the deregulated electricity market with constraints applied on the daily number of cycles and the depth charging/discharging of the batteries. Several MPC types have been tested in a real case building in Edmonton, Canada. In (Valencia et al., 2016), the authors formulated a robust energy management system for microgrids with model predictive control by using the fuzzy method for the prediction intervals due to the uncertain nature of the wind energy. This method improved the efficiency of the robust method combined with the diesel generator as spinning reserve. In reference (Pellegrino et al., 2016) authors studied the energy consumption management in public buildings. The aim was to implement a new building management system platform into existing buildings to manage different energy devices and is open to future implementations through a three-step application. Authors in (Carli and Dotoli, 2019) developed an algorithm for scheduling energy supplies between smart homes with microgrids and home energy managing systems for each one, based on time peak demand and decentralized control. Their approach is implemented as an iterative algorithm indexing the changing electricity time prices able to send the renewable energy surplus to fill loads in other houses in a coupling form over the time horizon. Reference (Abdelrazek and Kamalasadan, 2016) developed a control approach for managing the battery energy storage system (BESS) based on photovoltaic capacity management and time energy shifting to shave peak load demand. The algorithm simultaneously optimized the PV firming with the energy time shift. The system had been implemented with a real feeder connected to the PV, the grid, and the storage system in the south of the United States. Authors in (Byrne et al., 2018) focused on managing energy storage systems to maintain and enhance grid stability and reliability. The optimization was completed with linear programming, where mixed integer linear programming was applied to the BESS. Authors in (Shen et al., 2016) proposed an energy management system for a microgrid, taking into account the intermittent behavior of renewable energy sources, electricity costs, and consumers' load. They presented a stochastic optimization-model-based two layers scenarios. A distributed scheduling optimization framework for the power load of a set of smart homes in discussed in (Joo and Choi, 2017). The framework is formulated as a centralized optimization problem that is decoupled in two-stage optimization. Reference (Byrne et al., 2018) reviewed the energy management tools for grid energy storage, defining optimization techniques and the related architecture. Authors in (Khalid et al., 2018) presented an energy-managementframework-based demand side management and load shifting approach to optimize the energy consumption of a smart home. The sizing of renewable generators and energy storages in a household, taking into account various pricing models, is investigated in (Zhou et al., 2018). Authors in (Xu and Shen, 2018) proposed an optimal control strategy for managing a set of energy stores with the aim of securing the balance among generation and demand in a microgrid. Reference (Lee et al., 2019) proposed a reserve power-procurement-approach-based resilient energy management system. Authors in (Hou et al., 2019) studied the scheduling of physical equipment using a holistic approach. Furthermore, they developed a home energy management system considering charging/discharging strategies for both electric vehicles and energy storage systems. Reference  developed an energy management framework for multi-microgrid systems integrating renewable sources. Authors in (Cui et al., 2019) presented a sustainable energy management for a cluster of buildings. The results demonstrate the economic benefits of their framework. A twostage energy management approach to optimally schedule the distributed energy resources and smart buildings is proposed in (Jin et al., 2019). Reference (Luo et al., 2020) presented a home energy management system to optimally schedule the operation of home energy resources. Authors in (Tsioumas et al., 2020) proposed a strategy based on integrated control of genetic algorithms to optimally provide a balance among the objectives. Authors in (Wu et al., 2019) proposed an integrated architecture for residential multi-energy system. Reference (Kannan et al., 2019) investigated an energy management system to reduce building cooling load demand. A transactive energy management framework for buildings in a residential neighborhood was introduced in (Nizami et al., 2020). Authors in (Chakraborty et al., 2019) addressed the problem of scheduling thermostatic devices with the objective to minimize power fluctuation and maximize users' thermal comfort. Reference (Lu et al., 2020) investigated the fundamentals and business mechanisms of resource aggregators in the electricity market. Authors presented a comprehensive overview of the current state of the art mechanisms and an analysis of the business strategies for resource aggregators. A forecasting framework with the objective to support load aggregators to predict the existing aggregated smart households' demand response capacity is reported in (Wang et al., 2020a).
The above literature discussion shows that previous works present complex methods and models that are challenging to implement in real scenarios and necessitate a computation time requirement. Furthermore, some of the previous methods are computationally intensive or not appropriate for real-time implementation, or may generate suboptimal solutions. Compared to previous works, the strength of this paper might be summarized in proposing a reduced and accurate high-level control framework able to offer optimal control of the operation of the whole building integrated microgrid (BIM).
The main contribution of this paper can be summarized in developing and implementing a smart building energy management system with the capability of optimally controlling the operation of a building-integrated-microgrid in respect to standard living comforts, which are defined as electric and thermal loads and the electric vehicle-charging load. A control framework is formulated and implemented as a finite horizon scheduling optimization problem for the power management of all components, as well as power exchanges with the electrical grid. A centralized algorithm is used to optimize control of the operation of the BIM, with a focus on power management, charge/discharge state of the energy storage system and the electric vehicle, and the state of the micro-CHP. This paper aims to spread smart grids' use by proposing practical energy management methods and control approaches that are Frontiers in Energy Research | www.frontiersin.org November 2020 | Volume 8 | Article 535535 easy to implement. These strategies may contribute to the transition to active buildings. The challenge is to propose an applied framework that allows efficient practical energy management and accurate control of electric and thermal loads. The proposed centralized control algorithm can be considered as a practical solution to address the smart energy management challenges in buildings. Moreover, it may be taken as an applied strategy that might be effectively considered in practical scenarios.

THE SMART BUILDING-INTEGRATED-MICROGRID MODELING PV Module Generators
The PV module is modeled according to the following equations: where, where I sc,ref and I mp,ref are, respectively, the module short circuit and the maximum power currents. V mp,ref and V oc,ref are, respectively, the maximum power and open circuit voltages of the module. G in and G st are, respectively, the solar irradiation and the standard light intensity. The total power and voltage output of the PV modules are given by: where β pv, s and β pv, p are, respectively, the serial and parallel number of modules.

Wind Turbine Generator
The power output of the wind turbine is given by: Where v(t) is the expected wind speed at the hub height of the wind turbine and P r is the rated power.

Plug-In Electrical Vehicle Modeling
The electrical vehicle (EV) can operate under two main modes: in the charging mode it can be considered as a load, while in the discharging mode the EV can be regarded as a source of power. This flexibility can participate in enhancing the operation and the power management in the microgrid, especially during the scheduling time horizon for the EV, by allocating the charging and discharging periods. If we consider that the EV is equipped with an energy control, this would enable the vehicle to communicate through a smart metering infrastructure once connected to the charging infrastructure. The EV can transmit data related to battery capacity. The state of charge of the EV can be expressed as follow: where t ∈ [t A ev t D ev ] is the scheduling time horizon, t A ev and t D ev are, respectively, the arrival and departure times of the EV, P pev,ch (t) and P pev,dch (t) are respectively the charged and discharged powers, and, η ev,ch and η ev,dch are respectively the charging and discharging efficiencies.

Battery Energy Storage System
It is worth mentioning that the energy storage system can be charged directly from the renewable generators and/or from the main grid. However, the energy storage system is discharged mainly to satisfy the needs of the BIM and the EV. The charging of the main grid is allowed only during a period of energy shortage. The charging state of the storage system is given as follows: where p Ch (t) and p Dis (t) are, respectively, the charged and discharged powers at the instant t, β Ch is the charging efficiency, and β Dis is the discharging efficiency.

Loads
We assume in this paper that the load includes electric and thermal loads. The thermal load is defined as the desired hot water and preferred building temperature. This will allow for assessing the effects of the thermal loads on the operation of the BIM. It is assumed that the required thermal power is ensured by the micro-CHP. The main objectives can be summarized by controlling the consumption patterns while maximizing the use of the local available renewable energy production, smoothing the load profile, and minimizing the cost of the energy purchased from the main grid. The temperature state of the water storage is given as follows: where q T is the water storage volume, C water is the specific heat of water, and T cold (t) is the temperature of cold water. The building temperature is defined by the following equation: where C air is the inside air' heat capacity, R BIM is the thermal resistance, and T out (t) is the outside temperature.

Control Algorithm
The BEMS aims to optimally control the operation of the BIM in autonomous mode or by connecting the BIM sub-systems and the high-level central controller. The BEMS is in charge of collecting data and implementing forecasts of energy production and power loads. Furthermore, it makes an interface of communication for sending/receiving control signals to the BIM components. The high-level BIM central controller manages the power flows by accurately consenting the optimal operation of the BIM. The main objective of the central controller is to provide a high-level control to generate optimal set points for all components and for the energy exchanges. The central controller decides the state of the energy storage system (charging/discharging), the energy exchanges with the main grid (selling/purchasing), EV state, and the state of the micro-CHP. The control algorithm operates using the receding horizon scheme to project the behavior of dynamics and uncertainties in the BIM and to provide a trajectory of future states and control variables, fulfilling the optimal operation and its constraints. The constrained optimization problem is solved over a prediction time horizon based on updated data and a new optimal control routine is re-calculated at every time step. Specifically, the optimal control is determined at each prediction time slot, however only the first step of control signals are applied. The control algorithm is implemented using the following steps: • At t 1, initialize with the actual current state of the BIM • Compute an optimal control sequence, for the selected rolling optimization horizon, based on loads and renewable energy for the next prediction periods • Implement the first control period operation • Update the information available for the next period, i.e., storage system state, loads, renewable energy power generation. Then, move to the next sampling instant, and repeat the same algorithm.
The forecasting accuracy may affect the performance of the proposed receding algorithm. The adoption of very-short-term predictions may minimize and mitigate the influences on the optimal results. Further information on e forecasting accuracy of the PV power output considering different time scales can be found in Wang et al., 2020a;Wang et al., 2020b). A day-ahead PV power prediction framework, combining a deep learning approach and time correlation principles, is described in (Wang et al., 2020a). Authors in (Wang et al., 2020a) presented a minute solar irradiance prediction model considering the real-time surface irradiance mapping method to attain higher prediction accuracy. A PV-load decoupling model is investigated in  to increase the performance of customer baseline load estimation considering distributed photovoltaic systems.

Objective Function
The objective function is formulated to satisfy the comfort of occupants in terms of desired indoor temperature and charging the EV. In addition, the objective function considers the operation of the storage system around a reference value to ensure the quality of service and to minimize exchanges with the main grid, aiming to increase the use of local renewable energy production. The optimization problem is formulated as a multi-objective optimization problem subject to quadratic cost function where the objective function includes four main parts. The first part aims to track the temperature reference signal of the building, defining the thermal comfort of the occupants, while the second part aims to maximize the stored energy. The third part aims to minimize interaction with the main grid and give priority to the use of renewable energy produced locally. The last objective aims to minimize the maximum divergence from the desired departure state of the EV.
The objective function to be minimized in defined as follows: Where T in (t) is dynamic reference state representing the desired temperature of the BIM, SOC pev (t dep ) is the desired EV departure state, and ξ, θ, λ, and β are weighting factors.

State Equations and Constraints
The predicted power balance Δũ bal (t) of the BIM is given by the following equation: Δũ bal (t) u wt (t) + p pv (t) + u elc chp (t) − l nc (t) u g,s (t) + p Ch (t) + P pev,ch (t) − β Dis p Dis (t) − u g,p (t) where u g,p (t), and u g,s (t) are, respectively, the power purchased and sold from/to the electric grid, and u elc chp (t) is the electric power output of the micro-CHP. The energy storage system is constrained by capacity limits: The battery of the EV is constrained by capacity limits.

RESULTS AND DISCUSSION
In this case study, the expected total electrical load is reported in Figure 1, while Figure 2 displays the desired hot water load in the BIM. The cold water temperature, outdoor temperature, and indoor building temperature are stated in Figure 3. The water storage volume is set to be 150 L. The rated electric and thermal powers of the micro-CHP are set to equal, respectively, 3 and 5 kW. Furthermore, the micro-CHP unit is characterized by electric and thermal efficiencies equal, respectively, to 0.3 and 0.5. The maximum capacity of the energy storage system available in the BIM is assumed to equal 20 kWh. Furthermore, the water storage temperature is assumed to range between 50 and 70°C with an initial state equal to 60°C, whereas the building's temperature is set to follow the desired temperature signal reported in Figure 3, with an initial state equal to 18°C.The microgrid includes a wind turbine of 5 kW and a PV system of 1 kW composed of four high performance polycrystalline solar PV modules of 250 W each. The renewable power generation is reported in Figure 4. The multi-objective optimization problem has been solved considering two scenarios. The first one considers giving the priority to satisfying the comfort of the occupants, while the second one aims mainly to give priority to maximize the energy storage system state. Figure 5 reports the variation of the energy storage state according to the two scenarios. In the first scenario (ξ β 1, θ 0.001), the energy storage system responds actively by regulating its operation (charging/discharging modes) according to the power loads. In the second scenario (θ 1, ξ β 0.001 ), the priority is given to maximize the stored energy. It can be seen that the energy storage system is mainly set to operate in charging mode.
We mention that the micro-CHP unit is dedicated to retaining the water storage heated through its thermal power output. The latter is set to feed the hot water demand and keep the building's  FIGURE 4 | Renewable energy production.
Frontiers in Energy Research | www.frontiersin.org November 2020 | Volume 8 | Article 535535 6 desired temperature. However, the electric power output that is defined as a fraction of the thermal power is considered to support the BIM in covering its electric load.
The optimal operation of the micro-CHP as defined by its electric and thermal power is stated in Figure 6. It can be observed that the micro-CHP reached its maximum capacity only from 17:00 to 19:00; this is mostly because the operation of the unit tracks the temperature reference signal as well as the hot water demand, defining the standard comfort of the residents. The proposed algorithm responds to the variation of the thermal loads and regulates the operation of the unit to track the reference signal.
The trend of the optimal building's temperature is shown in Figure 7. It can be seen that the desired temperature defining the comfort of the occupants is satisfied. We mention that the initial temperature state of the building is 18°C. Furthermore, the micro-CHP unit must satisfy both constraints related to building temperature and hot water. Results shown in Figure 6 validates the effectiveness of the proposed control strategy to track the reference signal.
The optimal state of the energy storage system is expressed in Figure 8. The energy storage system compensates the dynamics and intermittent trends of renewable sources and loads, fulfilling the electric load when possiblea. It is observed that the stored energy level displays different tendencies that can be divided in three parts: L1 [8:00, 16:00], L2 [17:00, 3:00], and L3 [3:00, 7:00]. In intervals L1 and L3, the energy storage system is charging energy according to the power balance in the BIM, where the maximum stored energy attains 16 kWh, while in interval L2, the energy storage system is set in discharging mode until it reaches the minimum limit. This can be explained by the presence of the plugin electric vehicle and starting the charging process.
The charging state of the electric vehicle is expressed in Figure 9. In this case study, it is supposed that the electric vehicle operates only in charging mode and V2B option is not  permitted. In addition, the arrival time is set to be 17:00, while the departure time is supposed to be 8:00. The energy purchased from the main grid is shown in Figure 10. It can be seen that the BIM starts purchasing energy from the main electric grid at 17:00. This is mainly due to the presence of the electric vehicle and absence of the PV system support. The microgrid ends purchasing energy starting around 3:00, defining the full charge of the electric vehicle.
The time-varying charging/discharging states of the energy storage system are reported in Figure 11. The charging/ discharging modes mostly follow the resources' availability and the dynamics of the electric loads of the BIM. The main aim is to maximize the use of the local renewable energy production. It can be observed that the energy storage system is set in discharging mode starting from 17:00, which is the arrival time of the electric vehicle. Whereas, during daytime, the energy storage system take advantage of the absence of the electric vehicle to store energy.   The time-varying total electric load dispatch in the microgrid is expressed in Figure 12. It is shown that the total load is covered mainly by the wind turbine and the micro-CHP with minor contributions from the PV. Starting from 17:00, the microgrid purchased a considerable part of its needs, and the storage system is activated in the discharging mode to support in fulfilling the total loads.

CONCLUSION
In this paper, we developed a smart BEMS to optimally control the operation of a BIM in respect to standard living comforts, which are defined as electric and thermal loads and the electric vehicle charging load. Compared to previous works, the strength of this paper might be summarized in proposing a reduced and accurate high level control framework able to optimize control of the operation of the whole BIM. The challenge is to propose an applied framework allowing efficient practical energy management and accurate control of electric and thermal loads. The proposed centralized control algorithm can be considered as a practical solution to address the smart energy management challenges in buildings. Moreover, it may be taken as an applied strategy that might be effectively considered in practical scenarios. Emphasis is given to the optimal performance of the BIM, where the objective is to ensure the power balance between production and loads in the microgrid (electric and thermal). A centralized algorithm is implemented for the power management of all components, as well as for power exchanges with the electrical grid. The main advantage of the proposed algorithm lies in its ability to cope with the intermittent and stochastic behavior of data of loads and generation. This paper  aims to test and validate a reduced control algorithm and its integration into a residential building through electric and thermal optimization. Both electric and thermal loads are satisfied mainly by the local energy production in 85%, including the CHP production and the renewable energies. The power purchased from the main grid was only 15%. The findings validate the effectiveness of the suggested control algorithm in managing and optimizing the operation of the BIM. The proposed framework may be generalized in a largescale district by adopting other control schemes and approaches like decentralized, team theory, multi-agent, and distributed control. The forecasting accuracy can be enhanced by adopting ultra-short-term predictions to reduce the influences of the random and intermittent behavior of renewable energy sources. Further information on the forecasting accuracy of PV power outputs considering different time scales can be found in Wang et al., 2020a;Wang et al., 2020b).

DATA AVAILABILITY STATEMENT
The datasets generated for this study are available on request to the corresponding author.