Coordinated Demand Response and Distributed Generation Management in Residential Smart Microgrids

Nowadays with the emerging of small-scale integrated energy systems (IESs) in form of residential smart microgrids (SMGs), a large portion of energy can be saved through coordinated scheduling of smart household devices and management of distributed energy resources (DERs). There are significant potentials to increase the functionality of a typical demand-side management (DSM) strategy, and typical implementation of building-level DERs by integrating them into a cohesive, networked package that fully utilizes smart energy-efficient end-use devices, advanced building control/automation systems, and an integrated communications architecture to efficiently manage energy and comfort at the end-use location. By the aid of such technologies, residential consumers have also the capability to mitigate their energy costs and satisfy their own requirements paying less attention to the configuration of the energy supply system. Regarding these points, this chapter initially defines an efficient framework for coordinated DSM and DERs manage‐ ment in an integrated building and SMG system. Then a working energy manage‐ ment system (EMS) for applications in residential IESs is described and mathematically modeled. Finally, the effectiveness and applicability of the proposed model is tested and validated in different operating modes compared to the existing models. The findings of this chapter show that by the use of an expert EMS that coordinates supply and demand sides simultaneously, it is very possible not only to reduce energy costs of a residential IES, but also to provide comfortable lifestyle for occupants.


Introduction
The present intelligent energy networks together with the future smart electricity grids could highly affect the process of energy generation, transmission, distribution, and consumption at different levels (e.g., industrial, commercial, and residential sectors) in an efficient, reliable, and secure manner.By the use of these emerging technologies and advanced components in micro/ macro scales, not only the energy can be delivered to householders and business owners more cost-efficient, but also more renewable energy sources (RESs) can be exploited in a greener way.Through the joint operation of smart energy management systems (SEMSs) and advanced components within a smart microgrid (SMG) environment, it is possible to enable two-way digital communications between the utility and household devices and to provide the users with appropriate tools to improve their energy efficiency, consumption behavior and comfort levels [1].On the other hand, optimal design, control and operation management of energyrelated production and consumption units have been attracting an increasing interest over the past decade and turning into a major part of energy management programs.Although the term "Energy Management" is widely used nowadays in literature and interpreted differently based on different operating scenarios, this chapter covers the subject of monitoring, controlling and conserving energy in building units and in residential SMGs, in broader perspective.In these environments, the users not only produce energy from several local and distributed generation (DG) units and play a "prosumer" role, but also participate in different incentive-based demand response (DR) programs to change their consumption behavior during different times of a day.However, integration of end-users as active components of future SMGs can inject unwanted risks and uncertainties in planning and operation phases [2,3].To address these issues suitably, this chapter first outlines an efficient framework for coordinated DR and DG management in an integrated building and SMG system.Then, a fully-featured SEMS for managing loads at demand-side and domestic controllable generation units at the supply-side is described, mathematically modeled and validated.

Smart microgrids (SMGs)
In many parts of the world, the existing electricity networks at transmission and distribution levels use technologies, digital communication, control systems, and strategies that are many decades old.To update this aging infrastructure and to create an energy network that meets the ever-growing needs of today's power market, developed societies are aiming at creating intelligent facilities so as to use advanced sensing, communication, and control technologies to generate and distribute energy in a more efficient, economic, and secure fashion.Moreover, pursuing other objectives such as potential lower cost, higher service reliability, better power quality, increased energy efficiency and energy independence, is becoming the driving force to advocate the utilization of distributed energy resources (DERs) and to focus on what is called "Smart Microgrid", as the future of power systems.While details about the characteristics of a SMG vary greatly, key features include [4]:

• Reliable and resilient
By the use of advance technologies such as smart metering, sensing, and state estimation, SMG improves fault detection and allows self-healing of the network without the intervention of technicians.This will ensure more reliable supply of electricity, and reduced vulnerability to natural disasters or attacks.SMG can also help utilities to speed outage restoration following major events, reduce the total number of affected customers, and improve overall service reliability to reduce customer losses from power disruptions [5].

• Efficient and sustainable
By the emergence and deployment of SMGs, efficiency improvement of energy infrastructures is expected.More than half of potential reductions in greenhouse gas (GHG) emissions would be achieved, transmission losses would be reduced, peak-load would be managed and transparency in electricity prices would be increased.By having a better understanding of equipment conditions through real-time equipment monitoring, utilities could also keep vital components operating at high efficiency.Moreover, through integration of digital technologies to the modernization of many sectors of the economy, higher efficiency gains, new opportunities, and greater productivity can be also guaranteed.
On the other hand, with the increasingly serious energy shortage and global warming, sustainable development can be obtained via integration of smart grid technologies, sustainable energy resources and low carbon emissions in power systems.The improved flexibility of the smart grid permits high penetration of green and sustainable RESs such as solar power and wind power, even without the addition of energy storage.However, the difficulties in dealing with intermittent power and the low utilization efficiency of power system appeared to be obstacles.

• Flexible and bidirectional
Figure 1 illustrates the way how the future smart electricity grids are different from the ones we know today.Our conventional energy networks have been designed and controlled in a way to support unidirectional flow of electricity and information from centralized large power generation units toward the end-use passive consumers, while the SMG relies more on bidirectional communication between consumers, suppliers and smart devices.The flow of energy across the network is also based on a mesh-grid structure rather than a unidirectional top-down system [6].
• Demand-side management support SMG technology will allow customers to make more informed decisions about their energy consumption, adjusting both the timing and quantity of their electricity use.Such an ability which is called demand-side management (DSM) allows supply and demand sides to interact in an automated way in real-time, coordinating demand to flatten spikes.By doing this, the cost of adding reserve capacity is mitigated, wear and tear costs are reduced, and the life of equipment is increased.In a like manner, participating in DSM programs allows users to cut their energy bills by telling low priority devices to use energy only when it is cheapest.It should be noted that DSM programs comprise two different activities, demand response (DR) and energy efficiency/conservation (EE/C).A DR action transfers customer load during periods of high demand to off-peak periods and can reduce critical peak demand while EE/C program encourages customers to give up some energy use in return for saving money and allows them to use less energy while receiving the same level of end service [7].

• Market-enabling
By the use of two-way communications between the suppliers/retailers and consumers it is possible to introduce more flexibility in operational strategies and enable effective market environments for suppliers who want to sell energy at higher prices and consumers who are willing to pay less.On the other hand, the development of market-driven operation procedures of the SMG will lead to a significant reduction of market power exerted by the established generation companies (GenCos).Widespread application of modular plug-andplay micro-sources may contribute to a reduction in energy price in the power market.Moreover, micro-sources may be used to provide ancillary services and further increase their market share in voltage support and stability services [8].
As a whole, SMG can be defined as an ingenious self-healing system that can be operated automatically by any source of fuel such as renewable energies and/or non-conventionals.It is an efficient way of RESs utilization and pollutant emission reduction.A SMG can realize existing overloads throughout the network and has the ability to reconfigure the network so as to impede potential outages.It is a base that enables active participation of und-users as informed consumers, accommodates all energy generation and storage options, advocates advanced products, markets or services, enables high penetration of intermittent sources, optimizes assets, resists attacks, and provides the energy quality for the range of needs in a digital economy [6,9,10].

Integrated energy systems
Integrated energy systems (IESs) provide the infrastructure to use SMGs to enable different mechanisms such as DR through SEMS.Smart energy management is an innovative approach to managing loads at the demand-side and domestic controllable units at the supply-side.It incorporates the conventional energy use management principles represented in DSM, DR, and DER programs and merges them in an integrated framework that simultaneously addresses permanent energy savings, demand reductions, and temporary peak load mitigations.In the context of residential SMGs, this is accomplished through an integrated dynamic system comprised of intelligent end-use devices (such as smart home appliances, lighting systems, and heating, ventilation, and air conditioning (HVAC)) and DERs with highly advanced sensing, controls and communications capabilities that enable real-time management of the system as a whole.A main residential SEMS consists of four components: • Smart energy efficient end-use devices

• Smart DERs
• Advanced building control/automation systems

• Integrated communications architecture
The aforementioned components are built upon each other and interact with one another to provide an infrastructure that is intelligent, highly energy-efficient, automated, reliable and robust.The result is a system of systems that is capable of working in unison to optimize overall operation based on consumer requirements, utility constraints, available incentives and other variables such as weather and building occupancy.In the following section, the predominant characteristics of each of these four components are summarized.

Smart energy efficient end-use devices
The availability of system-wide electricity generation and transmission capacity can be increased for other uses through an investment in end-use energy efficiency.End-use energy efficiency, often referred to as a "negawatt", can be noted as a resource available to remove the mismatch between energy supply and demand, just as is done with other resources such as non-conventional or renewable power generations.Similar to other resources, saved energy from end-use efficiency is available in different amounts and levels of investment.When considering costs over the lifetime of an investment, end-use energy efficiency can be one of the lowest-cost means of meeting energy demand and of reducing GHG emissions [10].On the other hand, to increase energy efficiency and reduce GHG emissions from the residential sector, there exist a number of solutions from which utilizing smart energy-efficient end-use devices is seemed to be a wise solution.Generally these devices includes but not limited to: efficient personal computers and peripherals (e.g., printers, scanners, and speakers), television and other audio-visual equipment, personal care appliances (e.g., hair dryers and electric toothbrushes), kitchen appliances (e.g., coffee makers, toasters, and microwaves), refrigeration and freezers, dishwashers, clothes washers and dryers, lighting, space conditioning, and integrated HVAC-water heating systems with the highest energy efficiencies.It is noteworthy that the smart end-use devices should be equipped with embedded features allowing for twoway communications and automated control.

Smart DERs
Over the past few years, the utility industry has made significant progress in defining common grid-supportive functions for distributed resources such as photovoltaics (PV), diesel engines, micro-turbines, and fuel cells (FCs), and also in defining the open standard communication protocols needed to make them smart and to connect these devices into SMGs.The functions include, for example [11,12]:

Advanced building control/automation systems
Advanced building control/automation system is the key component of the future smart buildings that benefits from several communication domains, including the smart meter domain Advanced metering infrastructure (AMI), the internet domain and building area network (BAN).It is a system that receives information about task operating status, usage requests and network signals and sends control actions back to the smart devices, i.e., it optimizes the performance of end-use devices and DERs based on operational requirements, user preferences and external signals from the utility, end-user or other authorized entity.Such a system also provides the occupants with useful feedbacks about energy usage pattern, and helps making control decisions more autonomously.To identify solutions based on different objectives (e.g., energy saving and living comfortably), it also gathers information from the home's environment as well as the outside situation [13].
Other controllers that allow for two-way communications and those that have the ability to learn from past experience and apply that knowledge to future events are also playing crucial role in an advanced building control systems.

Integrated communications architecture
A typical integrated communication architecture allows automated control of smart end-use devices and DERs in response to various signals such as pricing or load reduction signals from the utility, weather forecast in an hourly/daily basis, and bidirectional data transmission (such as external alerts as well as end-user signals) between multiple nodes.It also allows the enduse devices, DERs and/or control systems to send operational data to external parties (e.g., advanced meters that communicate directly with utilities).Figure 2 shows an example of an energy management infrastructure applied to a generic residential building.As can be seen, building energy management systems (EMSs), and to a broader extent BAN, are not single-technology networks, but combine various specialized networking technologies.Interoperability and coexistence are key to guaranteeing the cooperation between all protocols in the same area, especially when building EMSs need to coexist with legacy home automation, home security systems or home A/V systems.In this example, there are two-way communications via the Internet, Ethernet PLM, as well as via the power line or ZigBee.The building is equipped with smart energy-efficient end-use devices, an energy manager, automated controls with data management capabilities, DERs such as rooftop solar PVs, and other on-site generation and storage systems such as electric vehicles (EVs).Thus, energy-efficient devices, controls and DR strategies are coupled with on-site energy sources to serve as an additional energy "resource" for the utility.Not only do all of these elements contribute to the utility's supply-side by reducing building demand, DERs can also feed excess power back to the grid.A SEMS is likely to have a much larger impact on a building's electricity consumption and demand than just implementing energy efficiency and/ or DR on their own.

SEMS operation from an integrated perspective
As described earlier, smart end-use devices which benefit from advanced highly efficient controls, sensing and communications capabilities are regarded as key components of a SEMS.These devices can dynamically communicate with other smart components and adjust their performance in response to external reference signals.This marks an emergence from static to dynamic end-use devices with advancements in distributed intelligence.In addition to electric end-use devices, a SEMS would also include DERs such as solar PV systems, wind turbines (WTs), micro-combined heat and power (micro-CHP) units, diesel generators, and FCs.The performances of these DERs are also programmed to operate in an integrated manner with end-use devices at the facility so as to be able to optimize overall system performance based on the predefined goals and objectives.Here, we use "smart device" as a common term referring either to an energy-efficient end-use device or to a controllable DER.Each programmable smart device has its own control strategy, which assures optimal performance of the device based on external reference signals coming from SEMS and a variety of external parameters such as weather conditions, energy price signals, consumer habits and user's preferences.For interoperability among the smart devices and other components within a SEMS's domain, advanced meters with two-way communications infrastructure are also required.This will enable the SEMS to connect the electric meter and smart devices in the building to the BAN, thereby giving the SEMS direct access and control of these devices.Depending on the hourly energy price or other external parameters and based on the predefined objectives and available constraints, the smart devices equipped with the responsive controls automatically respond to the external signals and optimize entire system performance, say within the user "comfort range" to minimize energy costs.For autonomous operation in response to environmental conditions and other influential parameters within the controlled space, SEMS must be capable of very abstract decision making, ranging from determining a meaningful balance between cost and comfort for current conditions, to the very physical, such as turning a smart device on or off.Within a building unit, the response strategy of each smart device is also networked and interacts with the response strategies of other devices in a way to optimize the entire system performance.The system should be also able to execute a fully automated control strategy with override provisions, i.e., although the system is able to control multiple devices automatically, user preference may be dominated to autonomous operation and direct control is adopted accordingly.Likewise, for devices that are controlled indirectly, signaling approaches with some means of indication (such as blinking lights, colored LEDs) can be applied for the occupants' awareness to assist them when is propitious to run these appliances.For a SEMS to be able to interact effectively with its environment and learn from prior experiences without being explicitly programmed, learning functionalities with learning logic and artificial intelligence can be also integrated into the system.In this way, the system searches through data to look for patterns.However, instead of extracting data for human comprehension, machine learning is used to process data, improve the program's own understanding and adjust program actions accordingly.

SEMS modeling and design for IESs
Energy management for an IES includes optimal scheduling and running of different energyrelated generation devices as well as consumption units considering predefined goals such as energy conservation, environment protection and cost savings.It is also connected tightly to the people's way of life and their comfort zones.In this regard, a residential energy management (REM) strategy can be seen as a multiple-criteria optimization and decision-making problem that should be handled in a way to meet the system's goals and constraints.For this problem, it is crucial to model the components of the IES carefully.In the following subsections different compartments of a REM problem are introduced and mathematically modeled.

Heat transfer and thermal modeling of a residential building unit
For diagnosis and control strategy analysis, there is a strong need to develop suitable thermal model for different components of a residential building unit.Based on a simplified lumped capacitance model, the thermal resistance across a layer of area (A), thickness (x), and thermal conductivity (k) is as follows [2]: where R value denotes the insulation level of the layer.As an example, for a multi-layer exterior wall such as one depicted in Figure 3, the total thermal resistance can be calculated as follows: where RT 1 and RI F,i are the thermal resistances in insulation and framed wall, respectively.RI I,i is the thermal resistance in insulated portion.RT 2 is the thermal resistance between the planes bounding the inner and outer faces of the metal framing members, and RT 3 is the resistance of remaining components.Likewise, R T is the total thermal resistance.Having calculated thermal resistances for different materials and components of a house structure using the same procedure, one can easily evaluate the amount of heat flows between different nodes as follows: ( ) ( ) ( ) ( ) ( ) ( ) in which, φ io , is the heat flow between the indoor air node and the outdoor environment through thermal resistance R io , φ fi is the heat flow between the floor and the indoor air through thermal resistance R fi , and φ fg is the heat flow between the floor and the ground through thermal resistance R fg , as shown in Figure 4.In a similar manner, T in (h), T out (h), T f (h), and T g (h) are the temperatures of the indoor air, the outdoor environment, the floor, and the ground at hour h.
Regarding to an under-floor heating/cooling system (RFH/CS) as a heat node in the house, the amount of thermal energy that is supplied to the floor is determined as follows: where u HP is a binary variable stands for heating ("1") or cooling ("0") status, and P HP [0, P HP,max ] is the power consumption of the heat pump at hour h.η H [η H,min , η H,max ] and η C [η C,min , η C,max ] are the heating and cooling coefficients of performance (COPs) which are roughly linear functions of outdoor temperature.
As another source of thermal energy, solar radiation has a great effect on the heating/cooling load of a building.During different months in a year, the Sun's path varies across the sky and affects the overall thermal behavior of the building by its direct and diffuse radiation [14].As shown in Figure 5, the hourly heat flow into an exterior surface of a building due to solar radiation can be introduced as follows:

s eq out surf h h A T h T h A h A T h T h h A T h T h
Figure 5.The solar radiation effect on heating/cooling load of a building.
where h o is the combined convection and radiation heat transfer coefficient, α s is the solar absorptivity, ε is the emissivity of the surface, ϕ solar is the solar radiation incident on the surface and σ is Stefan-Boltzmann constant.T surf and T surr are the average temperatures of the exposed surfaces and other surrounding surfaces, respectively.Likewise, T eq_out is the equivalent temperature of outdoor air considering the effect of solar radiation.The previous equation can be rewritten as: Once T eq_out is available, heat transfer through an exterior surface with the overall heat transfer coefficient of U, thermal resistivity of R si , and surface area of A s into the indoor environment can be expressed as: The internal heat gain of a building unit is also affected by a number of factors such as the heat generated by the occupants (i.e., occupant metabolisms), lights and appliances (e.g., stove, television, and radio).Although this heat gain cannot be determined exactly, its average amount can be estimated from the people's lifestyle.As an example, Table 1 shows the metabolic rates per unit body surface area for various activities [15]:  where m is the mass of the body in kilogram, and L is the height in meter.
Considering all the heat flows described earlier, the thermal behavior of a building in terms of temperature update functions can be determined as [2,12]: where m f (m i ) and c p,f (c p,i ) are the floor (indoor air) mass and specific heat capacity coefficients, respectively, and Δh step is the time step.Likewise, φ bp (h) is the house background power calculated by the hourly internal heat gain of the building.φ sf (h) denotes the heat obtained from direct solar radiation: where α f and A sf are the solar absorptivity and the area of the floor on the sunny side.

Schedulable tasks and residential load model
To derive the electrical load model of a residential building unit, it is very important to understand the behaviors of different household appliances and devices.From controllability prospective, in-home appliances are normally categorized into Class I (i.e., non-schedulable) and Class II (i.e., schedulable) appliances.Class I devices which is also labeled as "manually operated" or "non-schedulable" tasks have their own fixed power consumption rates (P Dfix ) and must be operated upon the user's request.From the other side, Class II appliances which are further sub-classified as "temperature-shiftable" and "time-shiftable" tasks have the capability to be controlled either automatically or manually [2].HVAC and refrigerators are examples of "temperature-shiftable" devices that are normally running hour after and can be stopped once in a while provided that an acceptable temperature interval is guaranteed.Differently, a number of appliances such as washing machine, dishwasher, and dryer which are regarded as "time-shiftable" tasks can be operated at planned or desired time-intervals.For optimal operation of such devices, there exist several parameters that need to be set by residents [13]: • utilization time range (UTR i = [h s,i , h f,i ]) during which, task i is valid for scheduling, • preferred time range (PTR i = [h e,i , h l,i ]) during which, task i is better to be scheduled according to the user's preferences, • length of operation time (LOT i ) during which the task operation is completed, and • estimated energy consumption (EEC i ).
Through these definitions, the power consumption of shiftable task i at hour h would be: where s i (h) is a binary variable showing the i th device status as "scheduled: 1" or "dropped: 0 ".There are also several constraints that must be met suitably for each task i ∈ N: First, task i must be completed before the end of optimization time h f,i : Second, some tasks need to run once within a time window and should not be turned off before the completion: Third, one task (e.g., task j) may depend on the completion of another task (e.g., task i): where h s = min(h s,i ,h s,j ), 0 < λ < 1, and H(•) is the Heaviside step function.The following constraint must be also considered if a definite time gap between the operations of two consecutive tasks is desired: ; ,

Ord h H s h s h Ord h H s h s h h UTR h UTR
in which, Λ i,j denotes the largest allowed time gap and Ord(•) shows the time order in the examined period.Maximum power consumption of a building unit (P House max ) must be also included as a technical constraint:

Modeling of distributed generation and storage units
In a typical IES there exist some means of energy generation and storage both in forms of nonconventionals and renewables.This section presents the mathematical modeling of low voltage (LV) grid-connected distributed generation (DG) units.

Wind-powered electrical generators (wind turbines)
Today's utility-scale LV grid-connected WTs are extensively utilized for grid-support applications as well as empowering local loads.The amount of power generated at a WT site depends on the wind speed (V), air density at the location (ρ), the turbine power rating and its technical specifications such as performance coefficient (C p ) and generator and gearbox efficiencies (N g and N b ).In this regard, the electrical power output of a wind-powered electrical generator can be described as [2]:

PV power system
Similar to other RESs, photovoltaic power systems (PVs) can be used for electrification of domestic demands.PVs are ranged from small-scale systems with power capacities of kilowatts (such as rooftop-mounted or building-integrated) to large utility-scale power plants with several megawatts capacity.The amount of electric power generated by a PV module is also depended on multiple factors including but not limited to, the array rated capacity (Y PV ), system derating factor (f PV ), cell temperature in real operating and standard test conditions (T c , T c,STC ), temperature coefficient of power (α p ) and solar radiation incident in real and standard test conditions (G T , G T,STC ) [13]: . 1

Micro-combined heat and power system (micro-CHP)
FC based micro-CHP is another highly-efficient, low-maintenance means of cogeneration at residential places where quiet operation is also intended.Similar to other combined heat and power facilities, a FC-based micro-CHP system encompasses three subsystems including a hot water storage tank (DHW), a FC unit and an auxiliary boiler.As shown in Figure 6, a typical micro-CHP consumes natural gas g CHP and converts it into the heat (P th CHP ) and electricity (P e CHP ) with corresponding efficiencies (η e , η th ) considering electrical/thermal power limits and ramp-rates as follow [2]: To mathematically model the behavior of a hot water storage tank, the energy equivalent of the stored water should be considered as follow: in which Q st (h) is the energy content of the storage at hour h, P th D (h) and P th loss (h) are the heat demand and heat losses at hour h, respectively.From the above equation, the temperature update function of the hot water at each time step can be derived as follow [2]: where T cw and T b (h) are the entering cold water and environment temperatures at hour h, V tot , and V th D are the total tank volume and hourly hot water demand (HWD) in liter, respectively.
A st denotes the area of the storage tank covered by a material with insulation level of R st .

Energy storage system (ESS)
ESSs are becoming an important part of today's smart grid applications where high penetration of renewable energies and reliable power generation is required.The behavior of an ESS which is labeled as battery in this chapter, can be presented based on an energy state update function as: where SOC(h) stands for the battery state of charge at hour h, SOC min (SOC max ) is the lower (upper) bound of battery's SOC, and E Batt is the battery capacity in kWh.Likewise, P ch Batt and P dch Batt are the charging and discharging power of the battery which are limited by the following constraints: where u Batt is a binary variable denotes the operating status as charging "1" or discharging "0".

Objective functions
As shown in Figure 7, flowchart diagram, a residential energy scheduling and management problem can be viewed as a multi-criteria decision-making model and an optimization problem with different objectives as follows:

• Objective 1: minimizing total operation cost
The total cost of operation in short-term for a typical building includes the energy consumption costs as follows: where ρ grid (h) and P grid (h) are the utility bid and the amount of power exchanged with utility at hour h, respectively.ρ gas is the natural gas price and G CHP (h) and G aux (h) are the total amount of gas consumed by the CHP and the auxiliary boiler at hour h, respectively.Likewise, ρ WT and ρ PV are the bids and the hourly output power of the internal RESs such as WT and PV, respectively.δ is the user's subscription rate denotes the energy share of each resident from the SMG according to ratios of investment.
• Objective 2: maximization of the user's convenience level (UCL) As mentioned beforehand, all schedulable tasks in a home have their own utilization and preferred time ranges, which can be used as measurement tools for the UCL and satisfaction degree could be obtained when those tasks are executed at different times.To quantify the user's satisfaction level, the following formulation could be introduced: ( ) where w i is a significance factor showing the operating priority of task i, and CV i (h) is the degree of convenience experienced by the user when task i is executed at hour h: ( . exp

i e i e e i i l i l l i h PTR H h h h h CV h Oth
where α e , α l ∈ R + are the leading coefficients of the natural exponential functions used for controlling the penalty values over the optimization process.

• Objective 3: maximization of the thermal comfort level (TCL)
Thermal comfort for occupants of a building mainly depends on three factors including the indoor air temperature, relative humidity of the environment, and air motion from which the insider air temperature has the greatest effect on TCL.Based on the surveys done on thermal comfort zone of human, it has been found that majority of clothed people feel comfortable in the operative temperature range of 23-27°C [14].Regarding this point, one can measure occupant TCL as follow: ( ) where CL th (h) could be quantified as:

T h T T T h T T CL h T h T T T
where T set is the user-specified set-point for indoor temperature and ∆T ther is the threshold temperature difference.β c , β h ∈ R + are also the leading coefficients of the natural exponential functions used for adjusting the penalty values assigned to the undesirable lower and higher temperature differences, respectively.

Optimization model for energy and comfort management
Since optimal energy management of a residential building inherently involves multiple, conflicting and incommensurate objectives as mentioned before, a mixed objective function can be introduced as the model of optimization for coordinated energy and comfort management [13]: where the weighting coefficients ζ 1 and ζ 2 denoting the relative significance of TCL and UCL from the user's prospective.The above mentioned optimization problem must be solved considering the following power balance equation together with all other existing constraints for a REM problem:

Coordinated DR and DG management in a sample IES
In this section of the chapter, a number of computer simulations are presented to show the performance of a typical SEMS for coordinated DR and DG management in an integrated building and SMG system as shown in Figure 8.It is also worthy of note that the algorithm coding and computer simulations are carried out in MATAB/Simulink and General Algebraic Modeling System (GAMS) with Cplex/Dicopt solvers on a core i5 computer with 2430M processor @ 2.4 GHz.The house roof and the walls have similar insulation level (R value = 6.25).The floor structure for this building unit is also shown in Figure 9.All the smart controllable devices and schedulable loads described in the previous section are also included in the examined IES using the parameters tabulated in the following tables.For the mentioned house, the total internal heat gains is calculated from a load profile of typical household electrical loads and occupancy to be 3.5 W/m 2 of floor area averaged over a 24-hour period.
To simulate DGs in the proposed IES different realistic models have been used.The windpowered generator is implemented based on a direct-driven, variable-speed, pitch-controlled Morphic SWT20 turbine with a nominal power of 20 kW at a wind speed of 9 m/s.Table 2 shows the specification of such system.The PV system is also simulated based on a 0.25 kW Hyundai mono-crystalline module whose technical data is tabulated in Table 3.
The FC co-generation system is also a fusion of Viessmann's highly efficient, boiler-based heating technology and the FC technology of Panasonic whose main specifications are introduced in Table 4.Likewise, the features of the proposed RFH/CS are shown in Table 5.
In our simulation analysis, the ESS is modeled based on a lithium-ion battery pack mounted on a Nissan Leaf electrical vehicle considering the features mentioned in Table 6.Other information such as schedulable tasks specifications and user's preferences during different times is expressed in   In the performed simulations, total power consumption of the building is limited to 5.5 kW at each time slot.As shown in Figure 10, different energy pricing mechanisms such as flat rate pricing (FLR), time of use tariffs (TOU) and RTP are also studied within the examined IES.The natural gas is also priced as 33 ¢/m 3 .To study the effect of heating and cooling cases, we consider different outdoor air temperatures and conduct a number of simulations in the presence of different EMSs and conditions as shown in Figures 11 and 12.
Table 8, shows a detailed comparison of the performances between the proposed SEMS and a naïve one (NEMS) under different operating conditions.As observed in Table 8, economic task scheduling is achieved by using a NEMS, however user's preferences are not considered as another key point.On the contrary, cost-effective operation of in-home devices as well as comfort-aware task scheduling is perfectly done by the SEMS which use advanced controlling features.It is clearly understood from the numerical results that the mixed objective function (J) is improved about 26% by the use of RTP-based SEMS in different time frames of a hot weather condition and about 21% in similar condition but with a TOU-based SEMS.The performance of the proposed EMS is also getting better compared to the NEMS in a cold weather condition mainly due to the Sun's effect on the cooling load of the building.SEMS not only reduces energy consumption cost of the residential unit, but also satisfies optimal task scheduling and provides a thermal comfort zone for inhabitants.It can be also observed from the simulation results that the optimal performances of the mentioned EMSs are highly affected by several parameters such as pricing mechanism and time frames.As an example the running cost of the IES decreases once RTP is utilized and it increases when FLR pricing is applied.In a like manner, the operating cost of the IES is higher in a hot season compared to the one in a cold season.The same trend can be observed for weekends and weekdays.Due to the presence of occupants and their pattern of consumption, the energy cost of a building unit is slightly higher in weekends compared to weekdays.As illustrative examples, a number of related computer simulations are also presented to get more insight into the performance of SEMS. Figure 13 illustrates the performance of the proposed residential SEMS as applied to the heating/cooling scenarios for the given building in different weather conditions [17].Optimal coordinated DR and DG management for the studied IES by using SEMS is also indicated in Figure 14.This figure shows the optimal operation of smart household devices, FC-based micro-CHP unit and battery along with the amount of power exchange between the building and the utility for the given demand profiles in a typical hot weather condition [18].Based on the temperature differences between different nodes in indoor air and outdoor environment, heat can be easily transferred via the building structures and affects the thermal behavior of the residential unit.As can be seen in Figure 13, the building captures the heat from both direct and indirect solar radiation on the exposed surfaces (such as walls and the roof on the sunny side) during the hot summer days and releases that heat later in the day.For this reason, RFH/CS operates more in the cooling mode to satisfy the desired body comfort.In a cold winter day the RFH/CS must be operated in the heating mode to keep the indoor temperature within the comfort range, although the internal and external heat gains of the building assist the heating process.Moreover, as observed from the temperature profiles in heating and cooling cases, the thermal constraints are almost respected and the comfort zone chosen by the customer is satisfied in terms of valid temperature ranges.
It is also observed from Figure 14 that through optimal coordinated management of DR programs and DG units, not only the cost of energy consumption is reduced, but also comfortable thermal and electrical zones are guaranteed.It should be also noted that most of the electrical demand is supplied by the utility during hours when the RTP is relatively low (e.g., 3:00-7:00 and 13:00-15:00).In the same time frames, the batteries are also charged with lower cost.During other times of the day when the energy demand is growing and the electricity prices are higher, distributed generators (such as energy storage devices and co-generation unit) produce more electricity so as to meet the load economically, and make more profits by selling the surplus of energy to the utility.DR programs for optimal task scheduling are also activated in a way to satisfy user's preferences.

Conclusion
In this chapter, a framework was outlined for coordinated DR and DG management in an integrated building and smart micro-grid system.A SEMS for scheduling loads at the demandside and domestic controllable units at the supply-side was also described, mathematically modeled and validated.The proposed SEMS incorporated the conventional energy use management principles represented in DSM and DERs programs and merged them in an integrated framework that simultaneously addressed permanent energy savings, demand reductions, and temporary peak load mitigations.It also captured different key modeling aspects including heat transfer and thermal dynamics of a residential building unit, schedulable tasks attributes, and DG units' specifications.Moreover, it integrated different RESs, storage systems, and domestic thermo-electrical systems to provide a given cost reduction and comfort levels according to the customer needs.

••
Reactive power/power factor • Low-voltage ride through • Load and generation following • Storage systems charge/discharge management • Connect/disconnect • Dynamic reactive current injection (responding to changes in voltage dV/dt) Maximum generation limiting • Intelligent frequency-Watt control • Peak limiting function for remote points of reference

Figure 2 .
Figure 2. Energy management infrastructure for residential buildings.

Figure 4 .
Figure 4. Thermal modeling of a building.

Figure 6 .
Figure 6.Energy flows in a FC-based co-generation system.

Figure 8 .
Figure 8. Architecture of a sample IES including building and SMG systems.

Figure 9 .
Figure 9. Structural layers of the floor.

Figure 12 .
Figure 12.Outdoor wind speed and solar radiation.

Figure 13 .
Figure 13.Different heat flows and optimal operations of RFH/CS based on the thermal demand and user's comfort level: (a) hot weather conditions and (b) cold weather conditions.

Figure 14 .
Figure 14.Coordinated DR and DG management using SEMS.

Table 1 .
Metabolic rates during various activities.

Table 5 .
Under floor heating and cooling system specifications.

Table 6 .
Energy storage device specifications.

Table 7 .
Schedulable tasks data and user's preference.

Table 8 .
Performance comparison between smart and naïve energy management systems under different operating conditions.