Optimal Integration of Renewable Sources and Latent Heat Storages for Residential Application

Given the large amount of energy required in the building sector, an interesting opportunity to reach future sustainable energy systems is the path towards low energy buildings. This work proposes an approach for optimally integrating building-scale energy technologies (both traditional and renewable) to enhance the transformation of the existing buildings (often energetically inefficient) in low-carbon systems. The approach promotes a transition sustainable from both the economic and environmental perspectives. Both operation and design optimization are considered with the aim of suggesting the best set of capacity of the technologies to be installed taking into account the expected operations. The building-scale technologies are integrated with proper storage units: Li-ion batteries and thermal storage (latent heat, that requires low installation space). As a dispatchable renewable technology, a biogas small-scale combined heat and power unit is included in the system. Once the key role played by this component in meeting the loads is proved, an analysis of the impact of the cost of the primary energy carrier of this technology on the system design is carried out. Two optimization approaches have been adopted (both based on non-linear programming). Results show that operation costs can be reduced by up to 29%. The adoption of a combined approach that takes into account both operation and design optimization lead to a reduction in installation and operating costs by up to 27%. In the analyzed cases, the use of the combined optimization confirms that latent heat storage is more suitable to be installed than electric storage (about −4.5% cost).


Introduction
The European Union has set ambitious energy targets aiming at achieving at least a 32% share of renewables by 2030 and reaching net zero carbon emissions by 2050 [1]. The building sector can be a central pillar to achieve the carbon neutrality objective since it is responsible for the 40% of the energy consumption and accountable for releasing more than one-third of all greenhouse gas emissions in the EU [2]. Moreover, about 35% of the buildings in Europe are more than 50 years old, with little or no renewable energy sources (RES) installed, and almost 75% of the building stock is energy inefficient; only 1% is renovated each year. Retrofitting could potentially reduce the EU's total energy consumption by 5-6% and lowering CO 2 emissions by 5% [3]. Therefore, to meet the decarbonization challenge it is necessary to improve the energy performances of the envelope and to include high efficiency and renewable technologies.
In general, the transition of existing dwellings cannot rely on a single RES technology. If, for example, one refers to the construction of new buildings or major renovations of existing buildings, the use of a single technology to supply the whole heat/electricity demand is generally not sufficient to reach the technical target required by the nearly zero energy buildings [4]. In Italy, the obligation to include renewable energy sources is equal to 50% of the expected hot water consumption and to 50% of total consumption for heating, cooling, and hot water. As concerns electricity, the value varies according to the area. Therefore, the integration of high-efficiency generation/conversion devices and suitable energy storage is crucial to achieve energy-autonomous buildings. When it comes to polygeneration, it is well known that such systems are more complicated than the traditional ones because of the interdependence between the different energy products [5]. Moreover, the complexity of the design process, that has to select a proper set of technologies strictly related to the local scale (depending on the building location, topography, and climate conditions that affects parameters such as evolution of solar radiation, wind speed distribution, building thermal demand) makes it necessary an optimization stage in the design process. The integration of various renewable technologies requires a proper optimization tool also to define an overall optimal operation (i.e., which is the production/conversion/storage technology that makes sense to operate at a certain time and what is the best load level at which it is supposed to work).
In recent years, two technologies that were not typically used in the residential sector have become increasingly important to reduce the supply-demand mismatch: small-scale Combined Heat and Power unit (CHP) and small-scale energy storage. The application of these systems in the residential sector transforms consumers into energy prosumers with considerable gains from an economic point of view [6].
The well-known advantage of micro-CHP is the high primary energy efficiency compared to the separate production of heat and electricity [7]. A review of the various cogeneration technologies suitable for residential applications is [8]. Several studies have shown the advantages of cogeneration and trigeneration in buildings. In Ref. [9] a new Combined Cooling, Heat and Power (CCHP) system model is proposed, and the genetic algorithm is used to optimize the installed capacity. Dorer et al. [10] evaluated, in terms of energy and emissions, a number of micro-CHP systems for several building types, occupant-related loads, and grid electricity mixes. The results show that considering a European electricity mix, most mCHP systems offered reductions in terms of primary energy and CO 2 emissions compared to traditional gas condensing boiler and heat pump technologies (up to 34% and up to 22% respectively). Arcuri et al. [11] formulated a model for selecting the optimal typology, size, and operative strategy of a trigeneration system for the civil user, analyzing different cogeneration plants. The mathematical model proposed is nonlinear since the analysis takes into account three nonlinear constraints: the variation in nominal efficiency and unit cost of the cogeneration plant in relation to its size and the decrease in nominal efficiency in part-load configuration. Despite greenhouse gas emission reductions due to higher efficiencies, most micro-CHPs are fueled by natural gas, leading to environmental concerns about local emissions. For this reason, several research efforts have been made studying the performance of small-scale CHPs powered by renewable resources. In Ref. [12] a review of the available solutions of micro combined heat and power systems based on renewable energy sources is presented.
The second component that is becoming increasingly strategic is the electric storage, adopted to counteract the intermittency typical of renewable sources. There are many studies in the literature analyzing the benefits of using batteries in conjunction with renewable technologies such as photovoltaic and wind turbines. In Ref. [13] the photovoltaic-battery energy storage system installed in a low energy building in China is optimized by considering cyclic battery aging, grid relief, and local time-of-use pricing. Parra et al. [14] optimize the community energy storage to perform PV energy time-shift and demand load shifting simultaneously, considering both Pb-acid and Li-ion batteries. Rahimzadeh et al. [15] applied the energy hub model to various energy storage systems for residential buildings considering several scenarios (on-grid, off-grid, and 100% renewable). This research focuses on electrical storage, while thermal energy storage technologies are not considered. Several studies have highlighted the benefits that CHP/thermal storage coupling can bring, especially in residential applications where thermal and electrical demands vary significantly and are not synchronized. Haeseldonckx et al. [16] investigate not only the impact of thermal-storage tanks on the operational behavior of cogeneration facilities but also the impact of thermal storage on the overall CO 2 emissions. Barbieri et al. [17] analyze the profitability of microCHP systems for a single-family dwelling installed in combination with an auxiliary boiler and a thermal energy storage unit. Among the obtained results, the reduction in primary energy consumption and the payback period of the technologies are analyzed as a function of the size of the thermal energy storage unit. There are also various studies that investigate the use of thermal energy storages to reduce the electrical power consumption during peak-load periods, especially with a focus on air conditioning systems. Ref. [18] presents a review on load shifting control using thermal energy storage systems, with a focus on phase change materials. According to this strategy, during periods with low or moderate power demand, thermal energy storage can be used to store heating/cooling thermal energy and then use it during periods with high power demand. Comodi et al. [19] propose a modeling/design computational tool applied to a residential microgrid. In addition to storage technologies, a photovoltaic system and a geothermal heat pump are present as generation technologies. According to the results of the study, the ability to store both thermal and electrical energy usually improves the performance of the building's energy management. However, the high investment cost made them unprofitable for the case study analyzed. In more detail, while thermal energy storage can be profitable if also used for heating system management, batteries are still too expensive to be competitive in the residential market. Therefore, one strategy to be analyzed may be to investigate whether the installation of thermal storage, with its considerably lower investment costs and higher lifetime compared to batteries, can provide economic benefits.
In several studies, the behavior of the CHP unit and electrical storage when incorporated into more complex energy systems (i.e., composed of many productions, conversion and storage technologies with different purposes such as heating, cooling, electricity) is analyzed." Lu et al. [20] obtained the optimal size of renewable energy systems in two cases: considering a single-objective optimization and a multi-objective optimization. The analyzed energy system includes a photovoltaic, wind turbine, biodiesel generator, three electric chillers, and an absorption chiller to meet the electrical and cooling load of the building. In [21] the design and operation of a hybrid renewable cooling system was studied. In particular, the energy system contains a ground heat exchanger borefield, an absorption chiller, a cooling tower, a solar collector, an auxiliary heater, and a hot water storage tank. As far as the optimization of the operation of these systems is concerned, Moghaddam et al. [22] propose a mixed integer nonlinear model to schedule a residential energy hub with a trigeneration system, a photovoltaic plant, an electric, and a thermal storage. Brahman et al. [23] present optimal energy management strategies for a residential energy hub in order to coordinate a trigeneration unit, photovoltaic panels and two types of energy storage, which are a PHEV (Plug-in Hybrid Electric Vehicle) energy storage and thermal energy storage (TES). From their results, they concluded that, thanks to the PHEV's smart management and TES presence, the trigeneration unit has the most contribution in meeting the building load, leading to cost reductions of up to 28% compared to a case without storage.
As highlighted by the literature review, it is clear that microCHP units and storage technologies play a crucial role, and the analysis of their impact cannot prescind from the adoption of a design and operation optimization.
In accordance with this necessity, the present work has the aims of proposing: (a) A tool for the assessment of a seamless technology integration, depending on the characteristics of the demand and the site/type of installation; (b) A technique for the optimal management of the system. Renewable energy sources will be integrated with proper storage units, such as batteries and latent thermal storage units, which allows for reducing the dimension required for the installation. (c) In more detail, two novelties are introduced in the treatment of multi energy systems for residential applications: (d) Analysing whether the benefits of electrical storage can be partly achieved by using only the thermal storage; (e) Investigating how much impact the primary energy cost of the micro cogeneration unit has on the system design process.
A proper algorithm is used with the aim of finding an optimal solution in terms of costs. The proposed tool is shown to significantly improve the integration of renewable sources in a building context. The reduction in costs achieved by the proposed optimizer is discussed. In particular, the impact of the biogas cost on the results is assessed.
The present work is structured as follows: -Section 2 contains, on one hand, the explanation of the adopted methodology and, on the other hand, the description of the case study preceded by the description of the European project. -Section 3 presents the results of the analyzed cases and a comparison between them; -Section 4 includes a discussion of optimization results; -Section 5 draws conclusions obtained from the study.

Optimal Operations
An optimization algorithm is used to identify the optimal scheduling strategy to minimize the cost of the energy supplied. This is the sum of the costs of energy carriers entering the system (the cost of the natural gas, biogas, and electricity), also taking into account that electricity can also be sold to the grid, as shown in Equation (1).
where c e_in is the electricity purchased, c e_out is the electricity sold, c gas_in and c biogas_in are the natural gas and the biogas purchased respectively. These terms are obtained by multiplying the unit cost of the energy carrier times the energy absorbed by the system in the entire time evolution considered. These terms are all expressed in €/day. More in detail, each cost term is defined as follows (Equation (2)) where x is the power absorbed/released by each technology and c is the cost of the energy vector in input. The independent variables of the optimization are: -Power flows (both electric and thermal) produced by each installed generation technology; -Power flows stored/released by thermal/electric storage.
In the presented cases study, the production/conversion technologies are 9 (the technologies will be deeply described in Section 2.2): photovoltaic, wind turbine, natural gas boiler, heat pump, micro combined heat and power unit, electric storage, thermal storage, electricity sold by the system, electricity purchased by the system. Nevertheless, the independent variables of the problem are more than 9, since the optimization cannot be performed separately time by time since the thermal and electrical storage operations make the various timeframes dependent. For this reason, the independent variables of the problem are 9 times the number of the considered timeframes. In the case considered, 96-time intervals (one each 15 min for 24 h) are considered in order to obtain day-ahead energy management of the system.
The relation between the chemical/thermal/electrical power entering and exiting each technology is expressed by the performance curve of each technology. One of the most critical aspects in finding the optimal operation is the deterioration of the performance of system components operating at partial load. This deterioration of the nominal efficiency at partial loads is of particular importance in the residential sector, where load profiles are characterized by wide variability that requires careful modulation to minimize efficiency losses. So, since the efficiencies of the production and conversion technologies depend on the operating condition, the correlation between the source and the energy vector produced is not linear. This makes the optimization problem non-linear. Among the approaches that can be used to solve these kinds of problems, there are Mixed Integer Linear Programming (MILP), Non-Linear Programming (NLP), and Mixed Integer Non-Linear Programming (MINLP). The first approach requires a linearization, a method according to which any equation curve is divided into multiple linear regions in each of which efficiency is constant. This method can provide sub-optimal solution if the efficiency curve is not divided into an adequate number of regions. However, if there are more regions, the variables of the problem increase, and, consequently, the calculation time also increases. The second approach cannot handle the discrete working range of the energy system since a binary variable cannot be defined. The third approach can theoretically be used for every kind of problem, but the convergence can be more difficult.
When analyzing scheduling optimization problems, the minimum power and the inclusion of maintenance costs are the constraints, which mainly need integer variables. In the case of small-scale systems, the devices can often operate in a larger domain with respect to large-scale systems. Furthermore, the maintenance cost for various technologies can be neglected. For this reason, the constraints related to these characteristics are less impactful and often can be neglected. Therefore, when considering the installation of small-scale technologies in buildings, it is possible to use Non-Linear Programming.
A further issue to be considered concerns the modeling of latent energy storage systems. In these cases, the heat release of the latent heat storage changes with the temperature of the system, and therefore with time ( Figure 1). The temperature of the system can be easily related to the heat stored in the system, by means of numerical simulations. This relationship can be obtained by means of a 2D or 3D thermo-fluidynamic model of the system in order to take into account the effects of the phase change in the thermal storage unit and the effect of the buoyancy. Once the evolution is obtained, it is possible to consider that the maximum heat absorbed/released by the system changes depending on the state of charge of the thermal storage. In this work, a compact model for a modular shell-and-tube LHTS is integrated into the multi-energy system. For more details on the employed 0D model refer to Ref. [24].
The relation between the chemical/thermal/electrical power entering and exiting eac technology is expressed by the performance curve of each technology. One of the mos critical aspects in finding the optimal operation is the deterioration of the performance o system components operating at partial load. This deterioration of the nominal efficienc at partial loads is of particular importance in the residential sector, where load profiles ar characterized by wide variability that requires careful modulation to minimize efficienc losses. So, since the efficiencies of the production and conversion technologies depend o the operating condition, the correlation between the source and the energy vector pro duced is not linear. This makes the optimization problem non-linear. Among the ap proaches that can be used to solve these kinds of problems, there are Mixed Integer Linea Programming (MILP), Non-Linear Programming (NLP), and Mixed Integer Non-Linea Programming (MINLP). The first approach requires a linearization, a method accordin to which any equation curve is divided into multiple linear regions in each of which effi ciency is constant. This method can provide sub-optimal solution if the efficiency curve i not divided into an adequate number of regions. However, if there are more regions, th variables of the problem increase, and, consequently, the calculation time also increases The second approach cannot handle the discrete working range of the energy system sinc a binary variable cannot be defined. The third approach can theoretically be used for ever kind of problem, but the convergence can be more difficult.
When analyzing scheduling optimization problems, the minimum power and the in clusion of maintenance costs are the constraints, which mainly need integer variables. I the case of small-scale systems, the devices can often operate in a larger domain with re spect to large-scale systems. Furthermore, the maintenance cost for various technologie can be neglected. For this reason, the constraints related to these characteristics are les impactful and often can be neglected. Therefore, when considering the installation o small-scale technologies in buildings, it is possible to use Non-Linear Programming.
A further issue to be considered concerns the modeling of latent energy storage sys tems. In these cases, the heat release of the latent heat storage changes with the tempera ture of the system, and therefore with time ( Figure 1). The temperature of the system ca be easily related to the heat stored in the system, by means of numerical simulations. Thi relationship can be obtained by means of a 2D or 3D thermo-fluidynamic model of th system in order to take into account the effects of the phase change in the thermal storag unit and the effect of the buoyancy. Once the evolution is obtained, it is possible to con sider that the maximum heat absorbed/released by the system changes depending on th state of charge of the thermal storage. In this work, a compact model for a modular shell and-tube LHTS is integrated into the multi-energy system. For more details on the em ployed 0D model refer to Ref. [24].

Combined Design and Operation Optimization
If the aim is not the operation of a predefined system but also its synthesis and design, a different problem must be addressed. In this case, the best overall solution depends on the operational costs as well as on the investment costs. In this section, the optimization approach suitable to achieve the best size of the technologies, considering the investment cost and the expected operations, is fully described.
The optimization includes the cost for the energy supplied (both thermal and electrical) and the investment costs. These are both considered as a function of the installed power and, in case the technology is not installed, the corresponding investment cost is zero. The independent variables of the optimization are: (a) The fluxes of heat/electricity produced/consumed by each production/conversion energy system, which are 9 (photovoltaic, wind turbine, gas heat-only boiler, micro combined heat and power unit, heat pump, electric storage, thermal storage, electricity sold by the system, electricity purchased by the system); (b) The capacities of technologies to be installed, which are 7 (photovoltaic, wind turbine, gas heat-only boiler, micro combined heat and power unit, heat pump, electric storage, thermal storage).
The variables of the optimization problem can be divided into two categories: 1.
Optimization variables related to operations, which, as previously discussed in Section 2.1.1, are equal to the coefficient to be evaluated times the number of time frames considered for the simulation.

2.
Optimization variables consist in the investment contributions of the multi-energy system components.
The objective function to be minimized is the total cost, which is achieved by summing the cost of the resources entering the dwelling plus the investment cost of the technologies, taking into account the lifetime of each system component. Therefore, the total cost is expressed as shown in Equation (3).
where the electricity purchased (c e_in ), the electricity sold (c e_out ), the natural gas purchased (c gas_in ), the biogas purchased (c biogas_in ), and the investment cost (c inv ) are all expressed in €/day, as for the optimization described in Section 2.1.1. The parameters related to the cost for the energy supplied and to investment costs that appear in Equation (3) are detailed in Equations (4) and (5), respectively.
where y is the power absorbed/released by each technology i at time j, c is the cost of the energy vector in the input of the technology i, while s is the specific investment cost of the technology i expressed in €/kW or €/kWh (based on whether it is a generation/conversion technology or a storage technology). As previously mentioned, this problem is nonlinear because of the variation of the nominal efficiency at partial loads. Furthermore, optimization on the basis of operating costs, along with investment costs, requires the inclusion of binary variables in the model. If the technology is not selected in the design process, its investment costs should not be taken into account. As a result, the Mixed Integer Non-Linear Programming (MINLP) is the most suitable approach for the combined design and operation optimization because of the presence of the investment, which is considered with integer variables.
A summary diagram of the cases analyzed and the methodologies adopted both in terms of optimization techniques (NLP or MINLP) and as an optimization approach (Operation or Combined Optimization) is shown in Figure 2. A summary diagram of the cases analyzed and the methodologies adopted both in terms of optimization techniques (NLP or MINLP) and as an optimization approach (Operation or Combined Optimization) is shown in Figure 2.

The Project
The present work was developed within the European project RE-COGNITION [25]. It aims at focusing the attention of the polygeneration on a single building with specific small-scale technologies. More in detail, the RE-COGNITION project has a twofold goal. The first is the development of small-scale renewable technologies (schematized in Figure  3a) that can be installed in building environments with different characteristics. The technologies developed are conceived to produce, convert, and store energy. Among these are the ones reported in Table 1:

Technology
Acronym Description

VERTICAL AXIS WIND TURBINE VAWT
The technology is developed with a new aerodynamic design with the aim of guaranteeing high efficiency (typical of variable geometry when high wind velocity is reached) also in urban applications. This performance is reached using a passive system to dampen vibration suppression. The wind turbine is specifically design for the installation on the rooftop and in the ground (i.e., courtyards, garden) in order to guarantee safety for the building occupants.

BUILDING INTEGRATED PHOTOVOLTAIC BIPV
The innovative photovoltaic modules are designed to reduce the impact of the installation on buildings (especially already existing) and to guarantee an aesthetic appeal of the generation system. The technology and the approached adopted for the module coloration are such for keeping low the specific cost of the technology

MICRO COMBINED HEAT AND POWER SYSTEM FED BY BIOGAS mCHP
The technology requires a deep study for making mCHP suitable for a fuel characterized by a lower energy content per unit mass (and volume). Furthermore, changes in the design should be performed to allow stable combustion (and flexible).

LATENT HEAT THERMAL STORAGE LHTS
The latent heat storage consists in a tank filled with phase change material that absorbs heat through its melting and release heat through the solidification phase. This guarantee high energy density and therefore low space required for the installation. The main problem of the technology consists in the low thermal conductivity that makes the power

The Project
The present work was developed within the European project RE-COGNITION [25]. It aims at focusing the attention of the polygeneration on a single building with specific smallscale technologies. More in detail, the RE-COGNITION project has a twofold goal. The first is the development of small-scale renewable technologies (schematized in Figure 3a) that can be installed in building environments with different characteristics. The technologies developed are conceived to produce, convert, and store energy. Among these are the ones reported in Table 1: Table 1. RES considered in the RE-COGNITION project.

Technology
Acronym Description

VERTICAL AXIS WIND TURBINE VAWT
The technology is developed with a new aerodynamic design with the aim of guaranteeing high efficiency (typical of variable geometry when high wind velocity is reached) also in urban applications. This performance is reached using a passive system to dampen vibration suppression. The wind turbine is specifically design for the installation on the rooftop and in the ground (i.e., courtyards, garden) in order to guarantee safety for the building occupants.

BUILDING INTEGRATED PHOTOVOLTAIC BIPV
The innovative photovoltaic modules are designed to reduce the impact of the installation on buildings (especially already existing) and to guarantee an aesthetic appeal of the generation system. The technology and the approached adopted for the module coloration are such for keeping low the specific cost of the technology

MICRO COMBINED HEAT AND POWER SYSTEM FED BY BIOGAS mCHP
The technology requires a deep study for making mCHP suitable for a fuel characterized by a lower energy content per unit mass (and volume). Furthermore, changes in the design should be performed to allow stable combustion (and flexible).

LATENT HEAT THERMAL STORAGE LHTS
The latent heat storage consists in a tank filled with phase change material that absorbs heat through its melting and release heat through the solidification phase. This guarantee high energy density and therefore low space required for the installation. The main problem of the technology consists in the low thermal conductivity that makes the power available poor. The technology developed within the project is characterized by the adoption of fins that are properly designed such as they are tailored for the specific application, for enhancing the heat exchange between the material changing phase and the heat transfer fluid. The second aim of RE-COGNITION is the study and development of an ICT platfo to guarantee a proper integration of the developed renewable technologies (Figure 3 The platform is conceived to enable a wise combination of the technologies for fulfilment of the building consumption (electricity/heat and cold).

Case Study
In the present analysis an existing multi-family dwelling, that currently satisfies energy demand by using a gas heat-only boiler for heating and the electricity purchas by the grid for power, is considered. The building considered as a case study is a la existing building with twenty apartments. The building is 30/40-year-old construct and, considering the energy performance classification, it is an Energy Class E dwelli This kind of building is largely diffuse in several residential areas of European countri A typical mild European climate is considered, in particular an area characterized by 25 degree-days. The yearly thermal energy consumption is about 100 kWh/m 2 . The aim the case study is to analyze the potential of some technologies developed within R COGNITION, for the installation in the analyzed building ( Figure 4). The second aim of RE-COGNITION is the study and development of an ICT platform to guarantee a proper integration of the developed renewable technologies (Figure 3b). The platform is conceived to enable a wise combination of the technologies for the fulfilment of the building consumption (electricity/heat and cold).

Case Study
In the present analysis an existing multi-family dwelling, that currently satisfies its energy demand by using a gas heat-only boiler for heating and the electricity purchased by the grid for power, is considered. The building considered as a case study is a large existing building with twenty apartments. The building is 30/40-year-old construction and, considering the energy performance classification, it is an Energy Class E dwelling. This kind of building is largely diffuse in several residential areas of European countries. A typical mild European climate is considered, in particular an area characterized by 2500 degree-days. The yearly thermal energy consumption is about 100 kWh/m 2 . The aim of the case study is to analyze the potential of some technologies developed within RE-COGNITION, for the installation in the analyzed building ( Figure 4).
The calculation of the thermal consumption of the building is done through the adoption of the hourly method described in the standard UNI EN ISO 52016 [26]. The power consumption can be estimated by summing up the typical daily profiles of various apartments. This operation makes the consumption evolution of the entire building more regular than that obtained for a single apartment. The thermal and electricity consumption evolutions for a typical winter cold day are reported in Figure 5.
Since the electricity price varies during the day, time-of-use pricing is adopted for the study. This kind of pricing polities is becoming more and more popular with the aim of pushing users to avoid use energy when the demand is still high and to shift the consumption to hours with low consumption. According to this tariff, the highest price is in the peak demand hours (before 10 a.m. and around 8 p.m.) while the lowest price is in off-peak hours (in the night and in the middle of the afternoon).  The calculation of the thermal consumption of the building is done through the adoption of the hourly method described in the standard UNI EN ISO 52016 [26]. The power consumption can be estimated by summing up the typical daily profiles of various apartments. This operation makes the consumption evolution of the entire building more regular than that obtained for a single apartment. The thermal and electricity consumption evolutions for a typical winter cold day are reported in Figure 5.   The calculation of the thermal consumption of the building is done through the adoption of the hourly method described in the standard UNI EN ISO 52016 [26]. The power consumption can be estimated by summing up the typical daily profiles of various apartments. This operation makes the consumption evolution of the entire building more regular than that obtained for a single apartment. The thermal and electricity consumption evolutions for a typical winter cold day are reported in Figure 5.  Two groups of technologies are taken into account, as shown in Table 2. The two groups differ only in the type of storage used: in the first, there is thermal storage, while in the second, there is electrical storage. More in detail, the following technologies have been considered for each case: • CASE 1: a vertical axis wind turbine (VAWT), a photovoltaic system (PV), a biogas-fed micro combined heat and power unit (mCHP), an air heat pump (HP), a gas-fueled heat-only boiler, and a latent heat thermal storage (LHTS).
• CASE 2: a vertical axis wind turbine (VAWT), a photovoltaic system (PV), a biogas-fed micro combined heat and power unit (mCHP), an air heat pump (HP), a natural gas-fueled heat-only boiler and electric storage (BESS).    The characteristics of the technologies considered for the present work are reported in Table 2. The nominal power values are estimating by research that considers the data that are available for the various technologies, the common practice in the design of RES, and a preliminary simulation that allows the estimation of the device size. The characteristics of the technologies considered for the present work are reported in Table 2. The nominal power values are estimating by research that considers the data that are available for the various technologies, the common practice in the design of RES, and a preliminary simulation that allows the estimation of the device size.
The investment costs adopted and the lifetime considered for the various technologies in this paper, with the proper references are listed in Table 3. The technologies efficiency often depends on the load. For this reason, the correlation between the input energy vector (e.g., the solar radiation for PV) and the output energy vector (e.g., the electricity for PV) is not linear. The non-linearity increases the difficulty of the problem to be solved. As the biogas-fueled combined heat and power unit turns out to be a key technology in the fulfillment of both electrical and thermal load in a RES framework, it becomes necessary to analyze the behavior of the system as the cost of the energy carrier changes. The main challenge for biogas as a fuel solution is, in fact, the costs of the product, which may depend on several factors, such as the cost of the feedstock used. Therefore, as this value is not a fixed and well-known value, it can be assumed that the biogas price can vary in a fairly wide range (0.22 €/m 3 -0.39 €/m 3 ) [34]. For this reason, additional analyses are performed considering the entire variation range.

Operations Optimization
The present section reports the results of the operation optimization for the cases described in Table 1. Results for Case 1 are reported in Figure 8. energy carrier changes. The main challenge for biogas as a fuel solution is, in fact, the costs of the product, which may depend on several factors, such as the cost of the feedstock used. Therefore, as this value is not a fixed and well-known value, it can be assumed that the biogas price can vary in a fairly wide range (0.22 €/m 3 -0.39 €/m 3 ) [34]. For this reason, additional analyses are performed considering the entire variation range.

Operations Optimization
The present section reports the results of the operation optimization for the cases described in Table 1. Results for Case 1 are reported in Figure 8. The base electric load is supplied using the mCHP. Wind turbines and photovoltaic are always operated when available since these are free sources. The electricity produced is used to supply the electric demand, for the operation of the electric heat pump, and for selling to the grid. The electricity is sold when the electricity cost is higher. Concerning the heat demand, the presence of thermal energy storage allows a flexible selection of the technologies for heat production. The technology mostly used for heat production is the mCHP. When the electrical load is low, it is more convenient to use the mCHP and feed the electric heat pump to store thermal energy in the latent heat storage than to switch it off. The electric heat pump is used when the electricity cost is low. When the cost is high it is cheaper to sell the extra electricity to the grid and to use the heat-only boiler to provide the heat load. The heat-only boiler, when operating, works at its maximum thermal power; the excess heat produced is stored in the thermal energy storage. The heat-only-boiler operation results in a sort of on-off regulation that allows maximizing the performances when it operates.
Results for Case 2 are reported in Figure 9. As for Case 1, the base electric load is supplied using the mCHP while the wind turbine and photovoltaic modules are always operated when the resource is available. The electricity produced is used to supply the electric demand, the operation of the electric heat pump, and for selling to the grid (for a small extent). The presence of the electric storage allows one to store electricity during the night and to use it when the electricity cost is higher and/or when the most convenient technologies are not sufficient to cover the peak. Furthermore, at 10 a.m., part of the electricity produced is sold to the network since the electricity price at that time is high. electric demand, the operation of the electric heat pump, and for selling to the grid (for a small extent). The presence of the electric storage allows one to store electricity during the night and to use it when the electricity cost is higher and/or when the most convenient technologies are not sufficient to cover the peak. Furthermore, at 10 a.m., part of the electricity produced is sold to the network since the electricity price at that time is high.
Concerning the heat demand, the baseload is mainly covered by means of the mCHP. The electric heat pump is used when the electricity cost is low while, in the timeframes when the cost is high, it is more convenient to sell the extra electricity to the grid and use the heat-only boiler for supplying the thermal load, as in Case 1. The results obtained in this section have been compared with the results obtained (without the optimization tool) Figure 9. Daily consumption and production pattern for Case 2: thermal production (a-up) consumption (a-down); electricity production (b-up) consumption (b-down).
Concerning the heat demand, the baseload is mainly covered by means of the mCHP. The electric heat pump is used when the electricity cost is low while, in the timeframes when the cost is high, it is more convenient to sell the extra electricity to the grid and use the heat-only boiler for supplying the thermal load, as in Case 1. The results obtained in this section have been compared with the results obtained (without the optimization tool) by selecting the various sources consecutively, depending on the average production cost (Benchmark Case). The Benchmark Case does not include the thermal and electrical storage. Concerning the objective functions, if only operating costs are assessed, the values are 62.03 €/day for Case 1, 61.37 €/day for Case 2, and 74.78 €/day for the Benchmark Case. The results clearly show that the availability of the optimization tool here presented (Case 1 and Case 2) allows one to save about 22% of the cost with respect to a nonoptimized solution (Benchmark Case). Furthermore, the installation of the electric storage (Case 2), with respect to the thermal storage (Case 1), allows one to save about 1% of the operation cost.
In the case the investment costs of the devices are included, it is possible to estimate which is the total cost (operation plus installation) of the overall group of technologies. In this case, the overall cost for Case 1 is 110.62 €/day and 108.64 €/day for Case 2; this is due to the large size of the thermal storage selected. However, from both the investment and operation perspective, the solution proposed in Case 2 is more advantageous with respect to the solution proposed in Case 1. Concerning the Benchmark Case, the investment costs of Case 1 and Case 2 are higher since they also include the presence of the storage. The overall cost for the Benchmark Case is 127.90 €/day, therefore the savings on the sum of operation and investment are about 15%.

Combined Design and Operation Optimization
In this section, the results achieved with the optimization performed to estimate the system design considering the operations (detailed in Section 2.1.1) are reported. Figure 10 shows the results for Case 1.

Combined Design and Operation Optimization
In this section, the results achieved with the optimization performed to estimate the system design considering the operations (detailed in Section 2.1.1) are reported. Figure  10 shows the results for Case 1. The installed technologies in this case are selected by the optimization algorithm. These are the mCHP, wind turbine, PV, electric heat pump, heat only boiler, and thermal storage (i.e., all the technologies available). As for the operation optimization, the base electric load is supplied using the mCHP while wind turbine and photovoltaic when the corresponding resource is available. The electricity produced is used not only to supply the electric demand but also for the operation of the electric heat pump and sold to the grid when the electricity cost is high (in the late morning). The installed technologies in this case are selected by the optimization algorithm. These are the mCHP, wind turbine, PV, electric heat pump, heat only boiler, and thermal storage (i.e., all the technologies available). As for the operation optimization, the base electric load is supplied using the mCHP while wind turbine and photovoltaic when the corresponding resource is available. The electricity produced is used not only to supply the electric demand but also for the operation of the electric heat pump and sold to the grid when the electricity cost is high (in the late morning).
The heat demand is mainly supplied by the mCHP and the electric heat pump (exploiting the excess electricity produced by RES). The thermal energy storage makes the selection of the technologies for heat production much more flexible as can be noticed by the number of times it is switched on and off.
During the evening, the thermal and electricity loads are still high, but the availabilities of PV and wind energy are, respectively, null, and low. At this time, both the electricity and the thermal energy produced by the most convenient technologies are not sufficient to cover the loads. Therefore, the heat-only boiler is activated to cover the thermal load and the electricity is purchased by the grid.
Results obtained for Case 2 are reported in Figure 11. The technologies selected by the optimizer are the mCHP, wind turbine, PV, electric heat pump, heat-only boiler, and electric storage. Therefore, in this case, all the available technologies are installed. The heat load, in this case, is covered by the mCHP and electric heat pump. The heat-only boiler is used to cover the thermal demand in the evening, while the electricity demand is covered by discharging the electricity storage.
Results obtained for Case 2 are reported in Figure 11. The technologies selected by the optimizer are the mCHP, wind turbine, PV, electric heat pump, heat-only boiler, and electric storage. Therefore, in this case, all the available technologies are installed. The heat load, in this case, is covered by the mCHP and electric heat pump. The heat-only boiler is used to cover the thermal demand in the evening, while the electricity demand is covered by discharging the electricity storage.
(a) (b) Figure 11. Daily consumption and production pattern in case of investment cost inclusion for Case 2: thermal production (a-up) consumption (a-down); electricity production (b-up) consumption (b-down).

Impact of Biogas Cost on Optimization Results
As can be seen from the optimization results of Cases 1 and 2, both the Operation Optimization and the Combined Design and Operation Optimization suggest that the mCHP is installed at maximum power and meets a large part of the thermal and electrical load throughout the examined day. For this reason, given the wide range of variability in the price of biogas, a more in-depth analysis is done to assess the effects of the price variation on the optimization results. Figures 12 and 13 show the results of the operation optimization for Case 1 and Case 2 with a biogas price of 0.39 €/m 3 . Figure 11. Daily consumption and production pattern in case of investment cost inclusion for Case 2: thermal production (a-up) consumption (a-down); electricity production (b-up) consumption (b-down).

Impact of Biogas Cost on Optimization Results
As can be seen from the optimization results of Cases 1 and 2, both the Operation Optimization and the Combined Design and Operation Optimization suggest that the mCHP is installed at maximum power and meets a large part of the thermal and electrical load throughout the examined day. For this reason, given the wide range of variability in the price of biogas, a more in-depth analysis is done to assess the effects of the price variation on the optimization results. Figures 12 and 13 show the results of the operation optimization for Case 1 and Case 2 with a biogas price of 0.39 €/m 3 .   If a biogas price of 0.39 €/m 3 is considered, the optimal daily management of the system changes considerably. For both cases, the electric heat pump (along with the thermal storage if available) almost completely satisfies the heat demand. In particular, in Case 1, the heat pump operates with large fluctuation of thermal power (i.e., strongly alternate operations) exploiting the availability of the thermal storage. In some timeframes, the EHP is switched on at nominal power and the thermal storage is charged, in other timeframes, the storage is discharged and the heat pump operates at a lower If a biogas price of 0.39 €/m 3 is considered, the optimal daily management of the system changes considerably. For both cases, the electric heat pump (along with the thermal storage if available) almost completely satisfies the heat demand. In particular, in Case 1, the heat pump operates with large fluctuation of thermal power (i.e., strongly alternate operations) exploiting the availability of the thermal storage. In some timeframes, the EHP is switched on at nominal power and the thermal storage is charged, in other timeframes, the storage is discharged and the heat pump operates at a lower power level. In Case 2, as there is no possibility of using the thermal storage, the EHP is forced to follow the load. Only in the evening hours, when the peak of the electrical load occurs, the mCHP is used at nominal power for a few time steps. A considerable amount of electricity is purchased from the power grid to feed the electric heat pump and meet the daily electrical load. Finally, photovoltaic and wind power are always operated when respectively sun and wind are available, since, when the investment costs of the technologies are not considered, the energy produced is free. Also, the system design selected by the Combined Design and Operation Optimization deviates from the results obtained with a lower biogas price (0.22 €/m 3 ). Results for Case 1 and Case 2 with a biogas price of 0.39 €/m 3 are shown in Figures 14 and 15. The selected technologies are the same as in the results of the operation simulation with the exception of the mCHP, which is not installed in either Case 1 or Case 2. The advantage of using this component in the evening hours is not so profitable if, in addition to the operating costs, investment costs are also considered. Photovoltaic and wind power are installed for both cases. Finally, the strongly alternate operation of the heat pump in the presence of thermal storage also occurs for the Combined Design and Operations Optimization.
advantage of using this component in the evening hours is not so profitable if, in addition to the operating costs, investment costs are also considered. Photovoltaic and wind power are installed for both cases. Finally, the strongly alternate operation of the heat pump in the presence of thermal storage also occurs for the Combined Design and Operations Optimization.

Comparisons
Given the large number of cases presented, this section aims to compare the total cost obtained with the two optimization approaches. Figures 16 and 17 show the comparison among the total cost of the five cases presented:

Comparisons
Given the large number of cases presented, this section aims to compare the total cost obtained with the two optimization approaches. Figures 16 and 17 show the comparison among the total cost of the five cases presented:   As far the optimizations with a biogas price of 0.22 €/m 3 are concerned, the use of the optimization allows to reduce costs of 13-24% (depending on the case) with respect to the Benchmark. More in detail, the Combined Design and Operation Optimization provides a solution with an operational cost slightly higher than in the case of Operation Optimization; however, the investment cost (that is included in the optimization) is significantly lower. The total cost reduction obtained adopting the Combined Design and  As far the optimizations with a biogas price of 0.22 €/m 3 are concerned, the use of the optimization allows to reduce costs of 13-24% (depending on the case) with respect to the Benchmark. More in detail, the Combined Design and Operation Optimization provides a solution with an operational cost slightly higher than in the case of Operation Optimization; however, the investment cost (that is included in the optimization) is Results are presented for two different values of biogas prices. As far the optimizations with a biogas price of 0.22 €/m 3 are concerned, the use of the optimization allows to reduce costs of 13-24% (depending on the case) with respect to the Benchmark. More in detail, the Combined Design and Operation Optimization provides a solution with an operational cost slightly higher than in the case of Operation Optimization; however, the investment cost (that is included in the optimization) is significantly lower. The total cost reduction obtained adopting the Combined Design and Operation Optimization is 12% for Case 1 (with thermal storage installed) and 8% for Case 2 (with electric storage installed). Results achieved with Operation Optimization show that the installation of the electric storage is more convenient. Nevertheless, the Combined Design and Operation Optimization provides a better solution for Case 1 (with the thermal storage installed). This is because including the investment costs directly in the optimization process may significantly change the set of technologies that is more convenient to install. The total cost saving achieved by installing thermal storage instead of electrical storage is 2.5%. By contrast, if a biogas price equal to 0.39 €/m 3 is considered in the analysis, some additional considerations can be done. It should be noted that, as discussed above, if Operation Optimization is carried out with a biogas cost of 0.22 €/m 3 , it is more convenient to include electrical storage in the energy system rather than thermal storage, while, if the Combined Design and Operation Optimization is performed, the opposite occurs. On the contrary, with a higher biogas cost (0.39 €/m 3 ), this difference in terms of results between the two approaches no longer occurs since the installation of thermal storage is always preferred. In particular, if only operating costs are considered in the optimization, the reduction in terms of total cost reaches 6%, while, if investment costs are also assessed, the reduction is 4%. The results reported in Figures 14 and 15 clarify the importance of the design stage in the overall cost of RES systems. In particular, the adoption of a Combined Optimization, including design and operation, allows substantial cost reduction that significantly enhances the pathway of existing buildings towards low energy buildings.

Discussion
In this section, the results achieved using the two optimization approaches presented (Operation Optimization and Combined Design and Operation Optimization) are discussed.
From the results obtained, it is possible to state that, as already highlighted in several works present in the literature, CHP can be a key element for savings both in economic and environmental terms even in the residential sector. Despite the great variability of typical building loads, the dual production of heat and electricity can make the installation of CHP cost-effective.
The analysis performed varying the biogas cost proves that, for future works, the unit cost of biogas needs to be precisely defined, since this cost strongly influences the choice of whether or not to install the combined heat and power unit. Regarding the use of storage in the cases analyzed, thermal and electrical storage are always selected (regardless of the presence of CHP). This result differs from the results obtained by Comodi et al. [19] in which the installation of batteries does not result in profitable. In the case described in [19], the batteries considered have a higher cost than those considered in the present analysis; the battery price is clearly relevant in the selection of the storage installation. In agreement with the results obtained by Brahman et al. [23], the presence of storage leads to significant cost advantages As concern the two optimization methodologies, the results clearly prove that the adoption of the Combined Design and Operation Optimization provide relevant cost benefits (between 5-15% depending on the case) with respect to the Operation Optimization. This is an indication for future works that consider the installation of technologies having a non-negligible economic impact.
It is important to note that the type of building analyzed, the prices of energy carriers, and the building loads used in this study are typical of European countries. Clearly, in the case of lower prices for fossil fuel, as in the US, the adoption of traditional technologies and electricity-driven conversion technologies is more convenient (since a low cost of fossil fuel leads to a low cost of electricity from traditional technologies). However, in a framework of increasing reduction of fossil fuel adoption, these results can be considered worldwide representative for the not particularly harsh climates. Clearly in the case of a specific case study the methodology presented can be adopted to achieve more specific results.

Conclusions
This paper presents an optimization approach for integrating the building-scale technologies for energy production, conversion, and storage. The aim is to analyze the benefits of the installation of electrical or thermal storage and the impact of the primary energy cost variation for the micro-cogeneration units. Two optimization approaches are presented. The first, Operation Optimization allows finding the best schedule of the technologies (on/off and the operating power). The second, Combined Design and Operation Optimization aims at optimizing the capacity of the technologies installed along with the operation (since this is based on the expected building demands). The second approach provides an optimal solution from both the design and operation perspective that allows pushing the transition of existing dwellings towards low energy buildings by including the relevance of the economic aspects. The technologies taken into account are innovative devices for energy production (i.e., building integrated photovoltaic modules, vertical axis wind turbine, micro-cogeneration system fed by biogas), transformation devices (i.e., air heat pump), and storages (i.e., latent heat thermal storage, batteries). More in detail, the proposed optimization approaches are tested on two energy systems that differ in the type of storage used: one with thermal storage (Case 1) and the other with electrical storage (Case 2). The two cases are then compared to evaluate whether the installation of the thermal storage (characterized by low investment costs and higher lifetime) can be more or less cost-effective than the installation of electrical storage.
Non-linear programming algorithm has been adopted. A specific Non-Linear Programming approach is used for the Operation Optimization and a Mixed Integer Non-Linear Programming for the Combined Design and Operation Optimization. The optimization problem must be solved considering all the timeframes since the presence of the storage leads to a time-dependent problem. For this reason, the number of variables is significant because all the independent variables must be considered for all the timeframes. In order to analyze the impact of the biogas cost the analysis was carried out both with a biogas cost of 0.22 €/m 3 and 0.39 €/m 3 .
The results show that the Combined Design and Operation Optimization provide a cost reduction from 8 to 27% with respect to the benchmark case (where the more convenient technologies are consecutively selected). The adoption of the Combined Design and Operation Optimization provides cost reduction between 5-15% with respect to the Operation Optimization. If the price of biogas is equal to 0.39 €/m 3 and, consequently, higher than that initially assumed equal to 0.22 €/m 3 , it is no longer worthwhile to use the combined heat and power unit. Furthermore, when the Combined Optimization is performed, latent heat storage is more convenient to be used than the electric storage with a cost saving of about 2.5% with a biogas price of 0.22 €/m 3 and of 4.3% with a biogas price of 0.39 €/m 3 .