Transforming a residential building cluster into electricity prosumers in Sweden_ Optimal design of a coupled PV-heat pump-thermal storage-electric vehicle system

Smart grid is triggering the transformation of traditional electricity consumers into electricity prosumers. This paper reports a case study of transforming an existing residential cluster in Sweden into electricity prosumers. The main energy concepts include (1) click-and-go photovoltaics (PV) panels for building integration, (2) centralized exhaust air heat pump, (3) thermal energy storage for storing excess PV electricity by using heat pump, and (4) PV electricity sharing within the building cluster for thermal/electrical demand (including electric vehicles load) on a direct-current micro grid. For the coupled PV-heat pump-thermal storage-electric vehicle system, a fitness function based on genetic algorithm is established to optimize the capacity and positions of PV modules at cluster level, with the purpose of maximizing the self-consumed electricity under a non-negative net present value during the economic lifetime. Different techno-economic key performance indicators, including the optimal PV capacity, self-sufficiency, self-consumption and levelized cost of electricity, are analysed under impacts of thermal storage integration, electric vehicle penetration and electricity sharing possibility. Results indicate that the coupled system can effectively improve the district-level PV electricity self-consumption rate to about 77% in the baseline case. The research results reveal how electric vehicle penetrations, thermal storage, and energy sharing affect PV system sizing/positions and the performance indicators, and thus help promote the PV deployment. This study also demonstrates the feasibility for transferring the existing Swedish building clusters into smart electricity prosumers with higher self-consumption and energy efficiency and more intelligence, which benefits achieving the ‘32% share of renewable energy source’ target in EU by 2030. https://doi.org/10.1016/j.apenergy.2019.113864 Received 5 July 2019; Received in revised form 23 August 2019; Accepted 4 September 2019 ⁎ Corresponding author. E-mail address: xza@du.se (X. Zhang). Applied Energy 255 (2019) 113864 Available online 10 September 2019 0306-2619/ © 2019 The Authors. Published by Elsevier Ltd. This is an open access article under the CC BY license (http://creativecommons.org/licenses/BY/4.0/). T


Introduction
Buildings as electricity prosumers are growing in energy space as they not only produce energy from distributed energy resources, but also consume the generated energy locally, through heating, ventilation and air conditioning (HVAC) systems, appliances and electric vehicles (EV) etc. These have profound impacts on the smart grid value chain. It is also a harbinger of another transformation -the shift of "power", from being concentrated in the hands of utilities as the sole owners/ distributors of electricity, to electricity prosumers on a vastly distributed and decentralized basis [1]. With the intensive growth in photovoltaic (PV) panels, EVs, home batteries, distributed heat pumps (HP), thermal energy storage (TES) and direct-current (DC) grid, buildings offer great potentials for consumers and building owners to re-evaluate their energy practices [2]. As the electricity prosumers are increasing at urban or district scale, the building integrated or added PV installations are boosting with very large capacity in recent years, which bring many unknowns about the integration of smart gird infrastructure that need to be optimized [2]. To develop strategies for the future, policymakers and planners need knowledge of how many and where PV systems could be integrated effectively and efficiently into local energy infrastructure and markets.
Up to date, many researchers have devoted to the techno-economic optimization of PV at building level [3]. For instance, Ning et al. [4] developed a genetic algorithm based optimization method to design the capacity, locations, tilt angles and azimuth of PV panels, with factors such as shapes and orientations of building exteriors and the surrounding obstacles considered. Their method is able to maximize the solar power output and thus reduces the capital investment per unit power output. Bingham et al. [5] developed a non-sorting genetic algorithm based optimization method to design the envelope, PV systems, and battery storage of a residential building in Bahamas. Their study indicates that application of PV systems and battery storage can significantly reduce the cost and consumption of grid energy. Koskela et al. [6] explored the optimal sizing of PV panels and batteries under different electricity pricing for an apartment building and detached houses in Finland. Their study shows that suitable electricity pricing can increase the profitability of applying PV panels and batteries. With the application of batteries and building load control technologies, O'Shaughnessy et al. [7] analysed the improvements in PV energy selfconsumption and net present value (NPV) using the renewable energy optimization (REopt) model. Oh et al. [8] developed an integrated model (i-FEM) based on finite element method for estimating the techno-economic performance of the distributed solar generation system on building façades. Liu et al. [9] investigated the design optimization of a PV-battery system combining heat pumps. Sensitivity analysis was also conducted by them under a range of PV capacities and battery prices to understand the impacts of heat pumps on PV-battery systems. Their study concludes that the use of heat pump can help increase the PV self-consumption and reduce the storage capacity. The abovementioned studies have considered solar resource and façade geometry, synergies with batteries and thermal envelope, electrical storage, electricity pricing, battery prices, and load controls. However, they didn't consider the synergies of energy sharing among neighbour buildings and the influence from local TES and EV penetration.
On district or above level, researches have also been conducted regarding the techno-economic analysis of PV and its related systems. For instance, Heijde et al. [10] developed a genetic algorithm based computation-efficient optimization tool, which uses the representative days to simplify the whole-year simulation, to determine the size of district solar energy systems and seasonal TES with the minimal operational costs. Shirazi et al. [11] proposed an integrated techno-economic evaluation tool to identify the most appropriate PV installation façades in urban areas in Tehran of Iran. Their study shows that proper selection of the angles and building façades for installing PV panels can significantly increase the solar power production (e.g. 19%) and internal rate of return (e.g. 6%). Roberts et al. [12] investigated the impacts of applying shared battery energy storage systems on the PV self-consumption and electricity bills of several apartment clusters in Australian. Their study indicates the shared batteries can effectively increase solar self-consumption and shave the peak demand of the building cluster. Zhang et al. [13] investigated the energy and environment impacts of integrating PV power into electricity systems in Kensai of Japan, under various scenarios with different EV penetrations and heat pump capacities. It is found that EV and heat pump are helpful for keeping more PV power in the smart electricity systems. Notably, Rodríguez et al. [14] proposed a PV-HP-thermal mass storage system for alleviating the energy poverty for a low-income housing district in Spain. In their study, the PV surplus electricity is used to power the heat pump to provide cooling/heating to improve thermal comfort of the occupants. However, the capacity of passive thermal storage (i.e. building thermal mass) is much smaller compared with active thermal storage, thus limiting the system flexibility and performance. Also, the energy sharing among different buildings and the EV penetrations is not considered. Regarding energy sharing among buildings, Shen et al. [15] compared the sizing of PV systems for a small building cluster with and without energy sharing enabled considering demand uncertainty. They study shows that enabling energy sharing can significantly reduce the required PV system capacity, since the surplus renewables of one building can compensate the renewable insufficiency of another. Huang et al. [16] investigated the operation of decentralized PV-battery system for a building cluster with energy sharing enabled. By comparing with the scenario that energy sharing is not allowed, their study indicates that energy sharing can significantly increase the cluster-level PV self-consumption and meanwhile reduce the electricity costs. These studies have conducted techno-economic analysis of district-scale PV from the aspects of the solar resources' maximization, seasonal TES, battery or heat pump integration, and power sharing integration. However, the integrated impacts of TES for excess PV electricity, EV as part of electrical load, and power sharing by DC grid are not fully studied on optimal design/operation of district/urban-level PV.
Regarding HPs and TES, many studies have been conducted for improving their performance and promoting their applications. For instance, Fischer and Madani [17] conducted a comprehensive overview of applications for HPs in a smart grid. They conclude that HPs can be seen as core technology to connect the heating and electricity sectors. Nolting and Praktiknjo [18] conducted validated simulations of realistic and flexible HP controls (i.e. time-of-use based controls and spot market price-based control), and assessed effects on energy efficiency and economic potentials compared to standard reference control algorithms. Sun et al. [19] conducted a comprehensive analysis of finegrained data collected from smart hybrid HPs (which perform smart switching between electricity and gas) and proposed a flexibility quantification framework to estimate the capability of HP demand shifting based on preheating. Their study results show that smart controls of hybrid HPs can deliver higher average COP values. By pairing HPs with TES, heat demand can be shifted to off peak periods or periods with surplus renewable electricity, and thus improved performance and increased flexibility can be achieved. Renaldi et al. [20] developed a design and operational optimization model to assess the performance of HP-TES system. Their study results show that the integration of TES and time-of-use tariffs can reduce the operational cost of the HP systems and make the HP systems cost competitive with conventional systems. Psimopoulos et al. [21] developed rule-based control algorithms for a HP system, which is integrated with TES and electrical storage, to minimize building energy usage and maximize self-consumption. Their developed method is able to reduce energy usage by 5-31% and the annual net cost by 3-26%. Baeten et al. [22] proposed a multi-objective model predictive control strategy for a HP-TES system, which takes into account users' energy cost and environmental impacts. Their study shows that applying TES is effective in reducing the required peak capacity of HPs. But, when demand response is applied by using TES, the costs for consumer always increase compared to the case without demand response or TES. The abovementioned studies have systematically investigated the application of HPs and TES in improving the building performance. However, the integration of HPs and TES with EV load as well as the energy sharing among buildings, are rarely considered.
In particular, the EVs are increasing their influence in PV deployment and smart grid, which should be considered as part of the electrical demand in the optimal design of renewable-energy based building renovations. The Swedish government has set a goal that the 100% of the national energy used in vehicle fleets should be independent of fossil fuel by 2030 [23]. EVs, which can use the grid power and the potential renewable energy, are promising solutions to achieving these energy targets. Many studies have been conducted to investigate the EV energy usage patterns and estimate the EV load profiles. For instance, using an availability model which generates driving profiles by statistical analysis, Geth et al. [24] analysed the impacts of both uncoordinated charging and coordinated charging on the load profiles in Belgium. Soares et al. [25] developed a discrete-state and discrete-time Markov chain model to simulate the EV motion and the energy usage. Shahidinejad et al. [26] adopted a fuzzy-logic inference system to emulate the EV battery charging based on a large field-recorded driving database. By combining EV usage with synthetic activity generation of occupants' electricity-dependent activities, Grahn et al. [27] used a Markov chain model to calculate the EV electricity consumption. They found that the EVs make up around 1/3 of the expected load during the peak hours and around 1/5 of the total daily electricity usage. Similarly, Munkhammar et al. [28] modelled the EV charging states with a Bernoulli distribution and generated the EV charging patterns by a Markov chain model. Their study shows that large mismatch exists between the PV power production and EV power consumption. Munkhammar et al.'s [29] study indicates that aggregating the multiple households' EV power usage and PV power generation will be more beneficial for increasing self-consumption of PV power than individual households. Fischer et al. [30] proposed a stochastic bottom-up model to describe the EV usage, charging behaviour and the resulting electrical load profiles. Their study reveals that load peaks strongly depend on the deployed charging infrastructure and can easily increase by up to 3.6 times, and EVs will lead to an intensification and an approximately 45 min earlier start of peak load hours during evenings for working households in Germany. EVs will represent large electricity end-users in building sector and have large impact on PV system performance. However, the interactions of EVs with other energy systems, such as heat pump and TES, are rarely studied at cluster or district level when EVs contribute as part of building electricity load.
Besides, there are many existing studies that have presented the energy modelling at building cluster level, but most of them didn't fully optimize the dynamic synergies of PV generation, heat pump, EVs, TES integration, and building load sharing among neighbour buildings, as well as the dynamic interactions of local building energy systems. A research gap thus lies in the absence of detailed techno-economic optimization of the coupled PV-heat pump-TES-EV at cluster level (thus involving neighbour buildings as aggregated electricity prosumers) related to demand coverage of heating, domestic hot water (DHW), and other general appliances. Research questions are therefore raised up, for instance, how the optimal configuration of PV's NPV changes as the EV penetration increases, and how do the different key performance indicators (KPI) are affected. What share of the electric demand for buildings and mobility can be realistically and economically covered by PVs with present technologies? A global optimization of PV in each scenario is urgently desired.
Therefore, this study aims to optimize the capacity of installed PV panels at each building in a small residential district, by considering thermal/electricity loads, power sharing among neighbor buildings, heat pump, TES and EVs, in order to maximize the self-consumed electricity (SCE) when the system is profitable (i.e. positive NPV) during its economic lifetime (of 15 years). Due to factors such as surrounding shadings and orientation, installing PV modules in different positions can produce different amount of power, since the amount of solar radiation can be significantly different in different positions on building roof or facades. To maximize the PV power output, this study also optimized the positions of PV modules to be installed on the building roof or facades. The research results will be useful in testing the effective strategies of PV deployment as connecting with different EV penetrations and heat pump/TES capacities in Swedish residential district. In the future, the same method could be replicated on different types of building clusters for achieving improved KPIs.
The structure can be depicted as followings: Section 2 describes the overall renovation concepts for the building cluster; Section 3 clarifies the research methodology and key performance indicators considered; in Section 4, the modelling of the coupled system is presented. Section 5 summarizes the boundary conditions and input parameters for the simulation case. A series of optimization and the related sensitivity analysis are subsequently performed in Section 6. Section 7 finally presents discussion and outlook; while the brief conclusions are disclosed in Section 8.

Building cluster information
The studied building cluster is located in Sunnansjö, Ludvika, Dalarna region, Sweden. This demo site is a multifamily dwelling unit made of three buildings built in 1970/1973, as shown in Fig. 1. Table 1 lists the area of each building considered in this study. The cluster (three buildings) includes 48 apartments over three floors, and most of the apartment have one or two bedrooms. The total façade surface gross area of the complex is 2146 m 2 , the total roof surface gross area is 1750 m 2 , and the total heated area is 3861 m 2 . The energy consumption of the cluster is 165 kW⋅h/(m 2 ⋅year), including operational electricity but not including electricity used in the flats for appliances and lighting. These buildings will be improved by a series of renovation plans including installation of PV, thermal energy storage, DC micro grid, EVs and heat pump systems.

Energy concepts
With the purpose of improving the overall energy performance and reducing carbon emissions of the building cluster, the following  interventions are being applied in renovating this building cluster. First, a centralized heat pump using exhaust air and ground as heat sources will be used for supplying the heating and hot water for all the three buildings. All the exhaust air in each building will be ducted to a heat exchanger unit, in which the waste heat will be recovered and then delivered to the centralized heat pump via a brine loop. A back-up pellet boiler is utilized to accommodate the peak heating needs. The PV can be installed on the roof and façades of the buildings. The PV energy is first used to power the electrical facilities in the buildings (e.g. fans, pumps, lighting, EV demands). After this part of electrical load is met, the remaining PV energy is considered as excess PV energy. A hot water storage is planned to store the excess PV energy in the form of heat, where the excess PV electricity power is transmitted to the heat pump to produce heating energy, and the produced heat is stored as the hot water. All electricity in the buildings, including that in the flats, as well as that supplied to the EV's is managed by one Energy Hub in each building, connected together via a DC micro grid. The DC sources (i.e. PV) and sinks (i.e. EVs and variable speed heat pump compressor) as well as batteries, if present, are connected directly to the DC micro grid. The overall energy concepts (the advanced techniques used in the building cluster renovation for improving the overall energy performance) of the renovation plans are presented in Fig. 2. In this subsection, the details of the major energy concepts are presented.

Click-and-go PV panels
Click-and-go is a concept that aims at making the installation/removal of the PV modules easier while improving the aesthetical quality.
The mounting systems have been carefully designed so that they can be easily, conveniently, and flexibly installed/removed. The PV modules can be installed on either building roofs or façades. The roof mounting system has overlapping panels and has been certified by KIWA (IEC 61215) and meets building standard 'NEN 7250, Solar energy systemsintegration in roofs and façades -building aspects' [31]. The mounting system for the façades is based on an equivalent click-and-go system, which can be easily mounted and demounted. In contrary to the pitched roof version with overlapping panels, the façade mounting system has flat mounted panels with a surrounding gap between the panels. Beside the easy mounting, the system has a high aesthetic value, as at the front side only the glass of the PV modules is visible and the mounting construction is invisible. Accumulation of dirt/stripes on glass is prevented simultaneously.
The PV panels are developed on basis of a portfolio of lightweight, aesthetic and click-and-go solutions. There are two lightweight PV module technologies developed in the Energy-Matching project: glass/ glass and composite-based modules. The difference between them relies on the encapsulation material. This study uses the glass/glass-based modules. The manufacturing process of glass/glass PV modules is based on traditional manufacturing processes, adapted accordingly to allow the effective integration of PV cells, leading to a lightweight concept (range of weight between 10-15 kg/m 2 ).

Centralized exhaust air heat pump (EAHP) system
A centralized heating plant is proposed, which comprises a brinewater heat pump using exhaust air as heat source as well as a back-up boiler. The heat pump covers all the DHW load using a hot water storage tank. The heat pump also provides the space heating until its maximum capacity is reached. At peak heating loads, the back-up boiler is used to supply the remaining heating load. Each building has one heat recovery unit in the attic, to which the exhaust air in each room, including kitchens and bathrooms, is ducted by fans. The recovered heat from the ventilation air is then supplied to the heat pump as the heat source via a brine loop. An anti-freeze mixture is used in this loop so that the heat pump can operate with supply temperatures below zero. The amount that can be extracted from the exhaust air is dependent on the ventilation rate, which is generally fixed at the national requirements for hygienic air. In Sweden, the required air flow rate is normally 0.35 l/m 2 ·s, which results in roughly 0.5 ACH for normal ceiling heights [32]. The design supply and return temperatures of water in ventilation radiators for space heating are 55°C and 45°C, respectively. The actual supply temperature is varied depending on the ambient temperature using a heating curve. The speed of the heat pump compressor (or pellet fed into the boiler) is controlled to maintain the desired supply temperature. When the required heating is below the minimum load of the heat pump, the heat pump goes into cycling mode to provide the desired load. The charging of the DHW storage is controlled using two temperature sensors in the storage. The control ensures that there is enough heat in the store to meet the expected load. The hot water circulation is supplied at about 55-57°C with a return temperature around 52°C, consistent with the Swedish requirement that the temperature at tapping points should be over 50°C. During charging of the DHW, the heat pump is running at high power.
The heat pump has a variable speed compressor, which can adjust the heating capacity by changing the frequency of the compressor. For variable speed heat pumps, an inverter is typically used to convert DC power to variable frequency alternating current (AC) power. In the conventional heat pumps, this DC power is first created with a rectifier. With the application of DC micro grid technology, in this study the heat pump is connected directly to the DC micro grid, which eliminates the needs for extra rectifiers and thus reduces unnecessary conversion losses. At present, the available heat capacity is in the range of 6-60 kW. Up to eight such units can be cascaded and controlled by one controller, so the available capacity range can reach up to 480 kW. It is also possible to have additional heat sources in the same centralized system, such ambient air or the ground.

Micro direct current grid -Energy Hub concept
To use the DC power produced by PV panels, inverters are usually needed to convert the DC power into AC power that can be delivered by the conventional AC power distribution system. On the other hand, modern large loads, such as pumps, compressors, fans and EVs, are often operating with DC power with built-in AC-to-DC converters [33]. The DC/AC converting at both the supply side and demand side not only causes dramatic electricity losses, but also reduces the system reliability due to increased complexity. To address these issues, the Energy Hub based on DC micro grid is recommended to replace the traditional AC distribution systems [34]. Fig. 3 presents the schematics of the Energy Hub DC micro grid. The Energy Hub closely integrates multiple energy systems of different energy carriers through convertors, energy distribution and storing components in an optimal manner for various energy use [35]. Please note that Energy Hub is different from the Heat Pump. The Energy Hub consists of DC/AC inverters or AC/DC convertors and power optimization module, which connects the power generating and consuming facilities to form DC a micro grid. It converts and controls the energy flow in both directions between the DC grid and the facility AC grid. By using the Energy Hubs, the whole DC micro grid becomes an easy-to-use and energy-efficient power management system that can be applied in wide scales. The different nodes in the grid, such as PVs, EVs and loads, can exchange power efficiently and reliably by autonomous distributed control systems based on the DC voltage. The Energy Hub automatically controls all system components, such as heat pump, EVs, and other electrical appliance, to ensure optimized energy utilization within the DC grid.
The Energy Hub based DC micro grid is able to maximize the use of locally produced PV electricity by sharing with different end-users that have consumption at any given time. The system also supports peak load shifting to reduce power tariffs. For instance, load peaks of one user (e.g. EV charging) can be distributed to other users to reduce power drawn from the public AC grid. Meanwhile, by keeping as much of the electricity production and consumption on the DC grid, the converting losses can be significantly reduced (by up to 50%) and thus producing higher efficiency. The Energy Hub techniques used for constructing DC microgrid were developed by Ferroamp [36]. The operating voltage of the DC microgrid is 760 V. Loads that support a nominal DC voltage of 760 V can be powered directly from the DC grid. A minibus DC/DC converter has also been developed by Ferroamp to step down the 760 V DC grid voltage to the output voltage required by other DC loads (120-400 V), thus enabling more flexible applications. For details of the microgrid operation and control, please refer to [37].

Thermal energy storage for excess PV electricity by heat pump
As most of the buildings' energy is for thermal loads, this study uses hot water storage to store the excess PV power (after supplying other electricity loads) instead of electrical batteries. When there is excess PV power, the excess electricity will be used to power the heat pump for producing heat, which is stored in separate hot water tank. The stored heat can only be used for DHW purposes in the chosen system design. The algorithm varies the speed (and thus the heating capacity) of the heat pump in order to match the total electricity load with the PV supply. If there is a battery in the system, the utilization of thermal storage is prioritized. The battery is only used when the thermal storage is fully charged.

Optimization algorithm and fitness functions
The aim of the modelling is to understand which features the system should have to perform well over its lifetime, rather than to estimate the exact energy or economic output of a pre-designed system. For this reason, a set of features should be optimized according to a specific measure of performance. The features of the system are expressed in the optimization problem as parameters and the measure of performance is expressed as a fitness function based on genetic algorithm. The parameters are the quantity of PV capacity installed on each façade of the building and the quantity of electric storage. Focussing on the capacity of PV on a building, in which there are two façades (roof and south façade) the set of parameters [0,0] represents a building without PV, [1,1] is a building where all the area available is covered by PV, [0,0.5] is a building where half of the area available on the south façade is occupied by PV while the roof is empty. The quantity of electric storage simply constitutes a parameter as it is. The aim of the fitness function used in this study is to maximize self-consumed electricity (SCE) during the lifetime of the system. Eq. (1) expresses the lifetime cumulative electricity self-consumed weighted by electricity price for the consumer.
where, -SCE is the lifetime self-consumed electricity; -t is the year of operation of the PV system where N is the planned lifetime of the system; -c is the cumulative electricity produced by the PV system and consumed on site (contemporaneously or through electric storage); -P t hoy ( , ) c is the "point in time" price of the electricity for the consumer depending on the year t and the hour of the year (hoy) (in case of day/night or summer/winter variations). This value was added to privilege, at the same level of self-sufficiency, the solutions that generate a higher economic output: this may seem a monetary consideration, but because of how the fitness function is designed, any profit would indeed constitute a sort of buffer that the algorithm trades in exchanges for an improvement in self-production until any profit is dissipated.
The fitness function in Eq. (1) presents a problem because it is monotonic relatively to the capacity, so it cannot decrease amid an increase in capacity and it will indeed increase as long as there is a gain in self-consumption. This feature of the fitness function would obviously cause the optimal set of parameters to converge on the largest possible capacity (i.e. [1,1,…,1]), hence causing a grossly over-dimensioned system and defeating the very purpose of an optimization process. To avoid the excess generated by the fitness function in Eq. (1) while still maximizing it and to avoid economically unprofitable solutions, the function is described as following Eq. (2), where the fitness function is described according to two domains. The algorithm will thus maximize the lifetime SCE at the condition that the system cannot be unprofitable.
In this way, the monotony of the function with respect to the capacity is used to guide the algorithm towards solutions that are not unprofitable, in fact once the NPV becomes negative, an increased capacity would increase the absolute value of the fitness function, rendering it more negative. In practice, the fitness function will maximize the self-sufficiency while guaranteeing that the system does not become a net cost during its lifetime.
The formula of NPV calculation is expressed as: where, -The quantity c P · c , represents the costs avoided for the electricity that was not purchased from the grid because of the self-sufficiency; P c is the price for the electricity paid by the consumer: c P · c is treated in the formula like an economic gain. An avoided cost and an earning are not different for any practical purpose in this optimization; -Similarly s P · s represents the revenues generated by the fraction of the electricity that is sold s multiplied by its price P s : notice that the price for the valorization of the electricity sold is usually lower than the price paid by the consumer (P c ). indicates the discount rate applied for the investment as defined in [38].
The result of the optimization process strongly depends on the demand but, as Section 4.3 shows, the demand itself is influenced by the excess PV electricity (the excess PV power will be used by the heat pump), which is in turn influenced by the result of the optimization. The optimal PV system is generally characterized by some hours of over-production along the year: if this over-production is used to heat a thermal storage, the energy transfer to the local grid is reduced. The reduction of over-production would cause an increase in the optimal dimension of the PV system because it will effectively be an increase in electric demand, this causes a positive feedback loop (see Fig. 4) until convergence (i.e. when the average temperature of the extra storage is high enough to send electricity to the grid anyway).

Key performance indicators considered
This study mainly considers four KPIs, self-consumption (SC), selfsufficiency (SS), expected levelized cost of electricity (LCOE), and expected self-consumed-LCOE (LCOE self ). These four KPIs are introduced in this section. The SC is the annual average of the rate (expressed as a %) at which the electricity produced by the PV system is consumed onsite. It is calculated by Eq. (4).
where E pv onsite , [kWh] is the aggregated PV power that is consumed onsite during one year period, and E pv offsite , [kWh] is the aggregated PV power that is consumed off-site (i.e. exported to the power grid). A larger SC indicates a better performance in terms of load matching.
The SS (expressed as a %) represents the annual average of the rate at which the electricity used by the building is provided by the PV systems. It Is defined by Eq. (5).
where, E d pv , [kWh] is the aggregated electricity demand that is supplied by the PV system during one year period, and it is equal to E pv onsite , [kWh] is the aggregated electricity demand that is supplied by the power grid. The sum of these two terms equals E d whole , [kWh] (i.e. whole electricity demand) of the building regardless of which source is providing it, a larger SS indicates a better performance as it refers to a building that is less reliant on the grid.
The LCOE [€ cent /kWh] is calculated through dividing all the costs (i.e. initial investment, maintenance and substitutions) by all the electricity produced over 15 years, as expressed by Eq.
where [kWh] is the aggregated PV power produced over the 15 years. The expected self-consumed LCOE [€ cent /kWh] refers to the LCOE for the electricity that is self-consumed, it is therefore obtained as the total costs of installation and maintenance divided by only the electricity self-consumed, as shown by Eq. (7), where E pv onsite total , , [kWh] is the aggregated self-consumed PV power over the 15 years. Since the amount of self-consumed PV power is usually smaller than the total PV generations, the expected self-consumed LCOE is usually larger than the expected LCOE. In other words, this KPI considers the cost of electricity as if only the "onsite" share has been produced. This was made because the cost of production of a resource should refer to the share of this resource that is usable, and the over production from PV cannot be considered usable by the district. The excess PV electricity is in theory usable by someone else in the larger grid, but it cannot be guaranteed that all of the electricity will be utilized (especially in a future with a high penetration scenario for PV). In this sense this KPI can be interpreted as an extremely conservative value for the real cost of electricity by urban PV. Notice that if the electricity sold to the grid has value (i.e. P S ≠ 0) the LCOE self will be higher than the average price for the consumer (i.e. LCOE self > P c average), this is consequence that there are some revenues that can be used to purchase a larger system and so increase the SCE.

PV system modelling and the related assumptions
The PV systems are modelled to ensure not only accurate operation, but also reducing the effort for collecting model inputs in the early design stage. In a complex context such as PV, the biggest losses are due to the partial shading of modules and arrays. In this paper, the power profile of the PV system is estimated as proportional to the irradiation falling on the module, but corrected according to the cell temperature [39] and a temperature coefficient as shown by Eq. (8) [40].
represents the power output of a PV system in a specific hour of the year (HOY); -PR (performance ratio) is static performance ratio of 0.8 [40] that takes into account losses such as soiling or reflection. PR is defined as the ratio between the system yield (energy produced in time period over the nominal power) and a reference yield (the incident solar energy in time period t over the reference irradiance 1000 W/ m 2 ); -Mod is the latest module in the system characterized by its efficiency T is a temperature correction coefficient calculated as in [41] and dependant on the module temperature which is in turn determined by MOD and HOY. The temperature is found by the simplified relation T Mod = T ambient + k·H MOd,HOY where T ambient [°C] is the ambient temperature retrieved from the weather file and k [m 2 /kW] is the Ross coefficient described in [39] and [42].
Aside from the modelling of the power production curve, the cost of the system is modelled as well: the initial costs are composed by total system costs (including modules, inverters, cables, structure installation and taxes), which are assumed to be directly proportional to the capacity installed following a linear relation. In reality, the unitary cost is probably bound to decrease for larger capacities, but due to the difficult estimation of the phenomena in an urban context (where large homogeneous production plants cannot be built), the price is assumed independent from the capacity. This approximation can be considered conservative as it will advantage smaller capacities during the optimization process. Likewise, the operational costs are also considered linearly correlated with the capacity of the system: these costs consist of maintenance costs and costs for the substitution of the inverter. The maintenance costs are an annual expense that should be paid proportionally to the capacity installed (expressed therefore in unit of €/kWp year), the inverter cost is an expense that comes once every 10 years and corresponds to the amount of 250 €/kWp. As for the calculation of the power, the exact number of inverters and the strings they serve is unknown, because of this the cost of inverters is included in the unitary price of the PV system at installation and amounts to 250 €/kWp in the years when it is substituted. The electric storage system is not interested by maintenance costs, but it generates initial and substitution costs every 10 years as well: these costs are proportional to the storage capacity, the initial cost of the electric storage is selected as an input while the substitution costs are averaged from the learning curve taken from three independent studies on the matter [43][44][45]. It should be noted that given the current economics, the electric demand and the location, the electric storage suggested by the algorithm has an exceptionally low capacity.

Thermal and electrical loads of buildings
TRNSYS 18 [46] is used to simulate the building and energy systems in a two stage process where an hourly space heating load file is generated by a building model in the first stage that is then used as input in the second stage to the HVAC system model. This in turn generates an hourly electricity load profile that is used as input by the PV optimisation tool (see Section 3.1).
In the first stage, all three buildings are modelled in one Type 56. A 3-D model built in the tool SketchUp is used to generate the geometry of the buildings. For building C, four zones are used, one for each of the floors plus one for the attic. For the other two buildings, where the ground floor has parts that contain flats and other parts that are not kept at normal room temperature, two zones are modelled for the ground floor in addition to the zones for the other floors and the attic, making five in total. The model is then converted into the non-geometric mode in order to have a faster simulation time, and material properties based on the real building were added. Ground coupling is done using a simplified approach with Type77 providing the ground temperature to which heat losses are calculated. The occupancy, electricity and DHW load profiles for the flats are derived by a stochastic model developed by Widén and Wäckelgård [47] and the annual electricity usage has been calibrated to the measured data. The internal gains due to operational electricity are based on the measured values and assume 100% is converted to heat. The simulation model is then calibrated with the available measured data in order to achieve acceptable accuracy.
The HVAC system model is a simplified model of the proposed HVAC system, as shown by the TRNSYS model in Fig. 5. The space heating and DHW loads are input as load files ("SH Load" and "DHW Load" respectively in Fig. 5), with one load file for the whole district. Similarly, only one exhaust air heat exchanger is modelled using Type508b as brine source to the heat pump, using the total ventilation flow rate for the district of 1460 l/s as input. The heat pump is modelled using Type1927, which uses a performance map with source and load inlet temperatures, source flow rate as well as compressor frequency as independent variables. A detailed performance map covering the range of operating conditions is provided by the manufacturer of the heat pump that is used in the system. The heat pump has a nominal heating capacity of 45 kW with a COP of 3.82 at B0W35 and 102 Hz compressor frequency. The space heat is controlled using a heating curve (a curve describing how supply water temperature should be set based on the outdoor air temperature) for a heating system with design temperatures of 55/45°C at a design ambient temperature of -23°C. "SH Load Equ" removes the heating rate specified in the load file "SH Load" from the space heating flow, while the two distribution pipes are for all the three buildings and based on the sizes, lengths and insulation standard in the buildings.
The heat pump frequency is controlled using a PID controller to supply the current flow temperature according to the space heating curve. If the maximum frequency does not give enough heat, a Type 6 auxiliary heater with 200 kW maximum heating rate adds heat in order to generate the required flow temperature. This auxiliary heater, representing the pellet boiler of the real systems, is thus only used for space heating, and supplies only as much heat as required to match the space heating load. A small buffer store of 370 L, modelled using Type 4, is located in series between the heat pump and the auxiliary heater.
The DHW of 2.5 m 3 and the extra store for excess PV in the form of heat ("PVxs store") are modelled with one Type 534 each, using five zones and connections at the top and bottom. The volume of the PVxs store is 3.5 m 3 for the case study. The U-value for the store heat losses is calibrated to give the measured heat loss from a typical DHW store at rated conditions. "DHW Load" and "DHW" provide the load mass flow rate at a time resolution of one minute together with the cold water temperature that varies with the seasons. The cold water is preheated in the extra hot water store ("PVxs store") in series with the DHW store. DHW circulation is connected to the DHW store and has pipes calibrated to give losses of 0.57 W/m 2 of living area, 2.2 kW in total for the three buildings. The DHW store is charged from the HP at full power using an on/off controller designed to maintain the store at the height of the sensor to between 51 and 56°C. During charging the three-way valves "HP split", "HP Tp", "SHbypass1" and "SHbypass2" are switched so as to send the flow from the heat pump to the stores and for the space heating loop to bypass the heat pump.

Storage of excess PV production as thermal energy in an extra thermal energy storage
The HVAC model also reads in the electricity use profiles for the building (flats and operational electricity) and the EVs as well as the production of the PV array, all with a time resolution of one hour, which is also the time resolution of the PV optimisation tool. The model then calculates the excess PV power available for running the heat pump, after use in the flats and for operational needs. If the heat pump is already running to supply space heat or to charge the DHW, no action is taken and the system operates as normal. If the heat pump is not in operation, the heat pump is turned on and the flow is switched to charge the PVxs store using the three-way valves "HP split", "HP Tp", "PVxssplit" and "PVxs Tp". The compressor frequency is then controlled so that its electricity load matches the available PV excess, using a function with excess PV power and condenser inlet temperature as independent variables. This is limited to the maximum compressor frequency and continues until the PVxs store is fully charged, 56°C. The excess PV that is stored in the form of heat, is thus only used for supplying heat for DHW and can only be stored when there is no "normal" need for space heating or for charging the normal DHW store, and thus represents a conservative capability. The temperature in the store is varying from close to that of the mains cold water supply to 56°C at the temperature sensor when fully charged. Thus, the preheating of hot water has to be achieved with a heat exchanger to avoid legionella problems, the preheated water being then heated to above 50°C in the main DHW stores.

Electric vehicle load generator
The EV load is generated by using the Grahn-Munkhammar model [27]. It simulates the EV home-charging based on standard settings of 0.2 kWh/km electricity use (including losses) and 24 kWh battery capacity available for trips, and a total distance driven per year of about 12,200 km as a Swedish average scenario. The used model considers the EV battery charging process is related to household activities (i.e. away, sleeping, etc.). For example, the EV owners usually charge the EVs after returning home from work, and thus charging process is usually activated in this period. The household activities are first computed by a discrete Markov-chain model. Then, based on the obtained household activities, the usage of EVs and the charging load profiles are calculated. The state of charge (SOC i+1,j ) of the j th EV battery in the (i + 1) th time interval is calculated by Eq. (9).
When the EV is being used, the electricity consumption v C ( , ) i s is calculated based on the EV velocity (v) and the season (represented by a seasonal coefficient C i s ). When the EV is being charged, the SOC of the battery will increase at a constant charging rate of C p (i.e. 2 kW used in this study). t is the time step for calculating the EV battery SOC. To prolong the service life of battery, full charging/discharging cycles should be avoided when using the battery, and thus a minimal SOC value should be considered. As depicted by Eq. (10), the lower limit of SOC is determined by a fraction p dod , which defines the minimal depth of discharge (DoD).
The EV load imposed on the building is then calculated based on the charging power of EV battery, as shown by Eq. (11). Fig. 6 shows the hourly EV charging load in a typical day. The charging load is small during daytime and reaches the minimum during 9:00~11:00, while it reaches the maximum at night during 22:00~24:00. Note that in peak demand time (i.e. between 22:00 and 24:00) the EV demand is still lower than the charging power of the EV plug (i.e. 2 kW), this is due to the fact that the EV are not always charging contemporaneously.

Boundary conditions, input parameters and regulation for PV electricity sharing
The simulation tool requests a series of input parameters summarized in three categories in Fig. 7. The main input is a 3D model describing the building geometry and being used to calculate the irradiation matrix. This is expressed in W/m 2 for every hour of the year, and for each building unit surface. Every point represents a solar collector with a given area and is associated with an hourly irradiation. Hourly weather data for Borlänge regional airport, from the extended weather data set in TRNSYS, is used for all stages of the process: building simulation, PV optimisation tool and HVAC system simulation. The site of the weather station is roughly 45 km north-east of the building cluster in Sunnansjö, and has a similar climate. The average ambient temperature and annual global radiation are given in Table 2 together with key figures for the energy demands in the case study.
The PV module efficiency data is provided by LudvikaHem (i.e. the building owner) based on field measurements. The values of parameters related to economic analysis, including the electricity price, PV system price and electric storage price, are also provided by LudvikaHem. The price of the electricity for the consumer is assumed to be 0.16 €/kWh year round according to a long-term contract stipulated by the building owner. This arrangement is more profitable in terms of PV profitability compared to a monthly variable plan as, in the latter, the largest possible earnings are in periods when the radiation is unavailable. In a monthly variable plan the months where most earnings are possible for a PV system are only March and October. The electricity that is not contemporaneously self-consumed is assumed to be sent to the grid for 0.05 €/kWh. Nevertheless, it is assumed that the price paid by the energy provider for the excess PV electricity is going to decrease alongside the lifetime of the system or at best stay the same. For what concerns the EVs, the possibility to charge two EVs will be guaranteed immediately after the restoration project, nevertheless the long-term level of penetration of the EVs is unknown to this day. It is assumed that the maximum penetration possible for the electric vehicle would be of one EV per family for a total of 48 EVs. Different optimization is therefore performed: with two EVs, with 25 EVs and with 48 EVs. Aside from these inputs, Tables 3 and 4 report the set of techno-economic parameters required for PV and other components. Fig. 8 represents the variation of electric demand due to the EVs on an annual basis and for the average day. The EV charging load is not much affected by the season in terms of cumulative demand, shown in Fig. 8 (a). This is because of two reasons: (1) The low operation temperature in winter will reduce the battery capacity, which can lead to reduced ranges. However, by increasing the charging frequency (i.e. how often the battery is charged) or the average depth of discharge, the overall cumulative charging loads (which can be considered approximately proportional to the product of ranges and charging frequency) are still likely to be stable. (2) For the EVs used in cold regions, large amount of electricity is needed for heating the interior of the car, leading to reduced available amount of battery-stored electricity for EV motion. However, in Sweden such amount of electricity is partly provided by the buildings (i.e. the heating process occurs in the car park before the EV usage), and the battery in the car does not need to supply heat to heat up the car before a journey. Since most of the electricity stored in the EV battery is still used for motion in winter seasons, the EV ranges will not be greatly reduced because of the increasing heating needs in Sweden. Please also note that even with assumptions that lead to a significant amount of heating by the car battery (greater winter EV charge demand), the results of the study would not change as this increased demand occurs only during the months with very little PV production, and when all PV can be used for other loads. In annual cumulative terms, each EV absorbs little over 1MWh so that the aggregated demand of 23 EVs requires an amount of energy that is almost equal to 30% of the baseload. In the hourly average load over the year, displayed in Fig. 8 (b), it is visible that the EVs are adding their demand mostly at night, and the additional load thins out during the daytime (especially during the late morning). In general, the annual behaviour of the EV demand can be considered advantageous for the PV installation, because the PV produces proportionally more during the summer months when the rest of the load demand is the least. Nevertheless, the prevalence of the load at night risk to render the PV less useful unless electric storage is installed. On the other hand, an electric storage is extremely unlikely to be profitable as there is probably no over-production of PV electricity during the winter months (thus forcing the storage to have idle time and therefore reducing its profitability). The construction of DC microgrid and the sharing of PV power among different buildings should obey the local regulation and policy and additionally needs approval from the grid operator. Until now, although many countries permit the feed-in of PV power to the power grid and clearly established regulations, renewable energy sharing among different electricity prosumers is still not allowed and the     [48]. While when the local micro grid consists of lines connecting buildings that are not equipped with PVs, the situation is a bit unclear for sharing the produced solar energy among buildings. A preliminary ruling from the Swedish Energy Markets Inspectorate is then needed by the grid owner for considering approving an exception from the grid concession. In this study, all the three buildings are planned with PVs, so an exemption is achieved according to the regulation, which means it is possible to share the produced PV electricity by micro grid among these three buildings. Unfortunately, in many other European countries, due to the concern of system reliability and safety, such micro grid application and energy trading among different small electricity prosumers are still not allowed.
To estimate the impact of the possibility of sharing electricity, the private consumption of the flats in the cluster is assigned differently to the three buildings. At first, the power demand is assigned proportionally to the area (obtaining ca. 21 MWh/m 2 year), then three different occupancy schedules have been assigned to the three buildings. It is assumed that the building A is a retirement home and has therefore a similar occupancy to an hospital, while the other two buildings are regular households with most of the occupancy during the morning, evening and night. To estimate the occupancy profile of the three buildings, the schedules from [49] are used, and the resulting occupancy profile of the whole cluster is shown in Fig. 9. By assigning shares of the total demand proportionally to the contemporary inhabitants, the demand profile in Fig. 10 is obtained. Building B and C have a slight peak before 8:00 and a sustained demand between 18:00 and 21:00. On the contrary, the A building features a strong and sustained demand between 10:00 and 16:00.

Optimization and sensitivity analysis results
In the following section, the optimal configuration of the PV system is shown in terms of capacity on the different roofs and façades in the building cluster, and different optimal PV configuration will be shown following an increasing order in terms of demand covered (see Fig. 11 and Table 5).
The first run of optimization (i.e. Scenario 1) is performed using as electric demand: public and private lights and appliances, electricity for the operation of the condominium devices, heat pump, heating of the DHW and two EVs. After that, an iterative optimization (i.e. Scenario 2) is performed following the procedures described in the Section 3.1 in order to add an extra thermal storage for hot water. The iterative process is useful because it enables the control strategy of the heat pump to use the excess PV electricity when this is available. Once the demand is increased with the special additional thermal storage, progressively more EVs will be added (i.e. Scenarios 3 and 4) and the impact on the KPIs is assessed. All the optimization process explained in this section refers to an aggregated electrical demand for the whole cluster, this takes for granted that some form of electricity sharing exists among the three buildings. The last optimization (i.e. Scenario 5) explores the situation in which there is no possibility to exchange flat electricity among the buildings (except operational electricity). The positive impact of the energy sharing technology on the performance of the PV system is measured through the difference in optimal capacity and in performance KPIs.

Design results of the coupled system for the base load scenario
The first run of optimization is the one that includes the smallest possible electric demand, in this scenario no extra thermal storage for the excess PV electricity is included and the number of EV is only the minimum of two in the whole cluster of buildings. Fig. 12 (a) shows the optimal configuration of PV modules over the roof and façade of the cluster. The screenshot on Fig. 12 (b) shows in color-coded disks the

Cumulative demand [MWh]
Average demand [kWh] (b) Hourly average demand (a) Monthly cumulative demand Hour of the day Month   Fig. 9. Occupancy assigned to the three buildings in the cluster along 24 h (Building A is assumed in this simulation to be a retirement home). annual cumulative irradiation over the different façades. The southern slope of the roof is clearly more irradiated than the rest of the surfaces made available for a PV system averaging just below 1200 kWh/ m 2 year. The east and west slopes are a bit better irradiated than the south façades, despite this, a significant portion of the system is installed on the southern façade while much of the roof is still available.
The southern façade turns out interesting for the optimization algorithm as it enjoys a more homogeneous irradiation throughout the year, during the winter season the solar angle is closer to the horizontal than the vertical and irradiates the southern façade more than the roof. In Fig. 12 (a) the modules on the east and west slopes of the roof have a dispersed pattern, because the placement of the modules is chosen randomly depending on areas with essentially equal radiation. Thus, the PV modules placed randomly by tool, which can be placed together in practice. In the case shown in Fig. 12 (b), the result of the tool is interpreted as follows: the southern slope is the most profitable surface and should be exploited as much as possible (ca. 45 kWp out of 65 kWp); the south façade should be used (ca. 6 kWp) even if large portions of the roof are still available, but the lower parts of the two façades should be avoided because of shading, while the east and west slopes of the roof should be used (ca. 14 kWp) and the exact position of the modules is not important from an optimization point of view. Table 6 shows the main KPIs reached by the optimal system for the baseload scenario.
Overall, the collection of KPIs can be considered satisfying, in fact it shows that it is possible to cover (contemporaneously to the production) ca. 20% of the electric demand of the cluster while retaining an excellent level of self-consumption of ca. 77%. Despite being at high latitude, the system reaches better results compared to other studies such as Ref. [50]. The reason for this might be the aggregation of the demand. A single-family house has a demand profile that is really hard to match for a PV system lacking storage (or with minor storage), this is due to the strong variability of the load that is characterized by an extremely low baseline and huge "spikes" or "peaks". The positive effect of the aggregation of the load is quantitatively discussed in Section 6.4.
It can be noticed that the optimal system often includes very small capacities of electric storage (see Tables 6-9), these capacities are trivial compared to the generation and loads, so cannot be making any meaningful contribution to the system. The result should be interpreted Fig. 11. Steps to produce the five optimal configurations analyzed in the study: the baseload consists of public and private lights and appliances, common operational loads, heat pump demand, domestic hot water and two EVs. The tone of color used in the chart is reported also in the 3D representation of the different configurations.  Fig. 12. (a) The optimal configuration for the baseline case, most of the system is installed in the southern slope of the roof and on the southern façade; (b) Colorcoded depiction of the annual cumulative irradiation, despite the higher area installed the façade is less irradiated overall. in general as the fact that the electric storage is unprofitable under these techno-economic conditions, nevertheless are reported for the sake of completeness. To avoid this aspect, it suffices to increase the capacity step for the optimization of the electric storage, in this study the capacity step used was 0.1 kWh. It should be noted that some external users might consume the electricity that is not self-consumed, this is out of the scope of the system. Furthermore, in a future where PV will become more pervasive, it is unrealistic to expect some demand by neighbouring clusters in over-production times. Compared to the present price of the electricity, the LCOE of the self-consumed fraction would be 12% higher (at almost 0.18 € against the present 0.16 €) while the whole electricity LCOE would be about 10% lower. Given the present costs and the economic modelling performed in this study, the tool suggests to install a very minor electrical energy storage quantity.

Impact of thermal storage capacity on the PV design and overall performance
The role of TES is to increase the self-consumption by enabling some part of the electricity to be used in a non-contemporaneous way. In Section 3.1, an iterative series of optimizations was described to be able to use the excess PV electricity. The ability of transforming the excess PV electricity in thermal energy generates an increase of the electric demand during the times of over-production. This encourages the next optimization process to install a higher capacity restoring the situation of overproduction in some hour of the year (HOY). The process is then repeated with the aim to exploit the over-production, nevertheless the average temperature of the storage is higher this time as the thermal need is limited, so the increase in electric demand is minor. The following optimization did not yield any increase of capacity and the process could be then considered converged. Table 7 shows the main KPI's for the first, second and third optimization. A volume of 3.5 m 3 was used in this case study for the PV excess thermal store.
The second iteration generates a large increase in the optimal PV capacity compared to the baseload scenario (+21%): this is not due to the increase in electric demand (the overall demand is basically unaltered as the increase during the central hours is compensated by a reduction in the evening), but due to the improved matching of the demand with PV production. The electric demand resulting from the use of excess PV electricity presents a bump during the central hours of the day. This feature makes it easier for the PV to match the electric demand and allows the optimization algorithm to install a larger capacity of PV. The two values for the LCOE shows how the iterations leave the LCOE almost unaltered. Nevertheless, it is possible to notice that the LCOE associated with the self-consumed quota is reducing while the overall one is increasing. This is not surprising since the selfconsumption grows along the iterations boosting the cumulative electricity self-consumed and a larger system forces the algorithm to use position that are slightly less irradiated and therefore reduces the overall yield. The main result is the reduction in residual electric demand (i.e. the part that cannot be covered by the PV system + thermal storage) that achieves a −6.8% reduction over the whole process of roughly 11.6 MWh/year. Most of the reduction in demand is accomplished in the 2nd iteration when the PV capacity increases, but some reduction happens in the 3rd iteration and therefore is due solely to a better contemporaneity between production and consumption.

Impact of electric vehicle variation on the PV design and overall performance
PV optimization with the impact of variations of EV is shown in Fig. 13. The southern portion of the roof is the first one to be occupied by the PV system because it is the mostly irradiated part. With increasing presence of EVs, it is visible how the PV system grows in size. Despite having slightly higher irradiation compared to the façades, the east and west portions of the roof are not entirely utilized for the application of PV by the algorithm, the southern façades are used instead. The reason for this noticeable behaviour lies probably in it having a better performance during winter months, when the sun angles are closer to the horizontal and the electric demand is more prominent, the façade integration results therefore to be more profitable, thus prioritized by the algorithm. Table 8 shows various KPIs at the three levels of EV presence. Despite a noticeable growth in the installed capacity, the larger growth of the demand forces the share of PV electricity to go down. There is a slight increase in self-consumption (not surprising considering that the whole system shifts towards larger load and larger capacity), thus a small reduction in the LCOE of the self-consumed electricity.
The results from this study are consistent with other similar analysis in Sweden. For instance, in [29] under different scenarios of PV capacities and EV penetrations, the self-sufficiency values vary within 20% 30%, which is close to the values calculated in this study.

Impact of electricity sharing on the PV design and system performance
Using the optimization technique, the difference in performance between the optimal configuration for each building and the one for the whole cluster are addressed. The optimization for each building separately is the condition that would apply in the case in which there is no means of exchange of flat electricity among the different buildings within the cluster. In the case of the same heating demand and operational electrical load, Table 9 shows a selection of KPIs for two cases where the possibility to exchange flat electricity is extremely favourable for the PV market: (1) aggregated electricity sharing as a cluster, and (2) disaggregated cluster: no electricity sharing among neighbour buildings. In this example the aggregated cluster shows in fact an optimal installed capacity of a whopping 27.5% higher compared to the disaggregated one. This is because energy sharing makes the PV system more versatile (the whole cluster is more efficient at consuming the electricity produced on-site), hence improving its economic value. Because of the fitness function, where the self-sufficiency should be maximized, an increased value translates into a larger investment with the aim of increasing self-sufficiency, thus producing a larger overall PV capacity. This phenomena does not disagree with other studies such as Ref. [15], where is shown that a smaller system can achieve the same level of performance of a larger one if sharing is taken into account. Also, in this case energy sharing would have allowed a smaller system to achieve the same performance of a larger one in a disaggregated scenario: but the aim is not to maintain the performance, but rather to out-perform it at the same price. In the disaggregated case, Building A has a better matching (better contemporaneity) because of the shape of the load matches the PV generations better (see Fig. 10). Building B has better yield thanks to the south slope and can afford to put some storage and highest capacity. Building C does not have a good yield nor contemporaneity. The higher capacity does generate more hours of overproduction (self-consumption is reduced of ca. 7%), but the increase in capacity is more than enough to offset this effect causing an increase of the self-sufficiency of ca. 24%. These KPIs aside, also the LCOE has a benefit (in both ways it can be calculated) and the residual demand is reduced of about 6%.
Looking at the geometric patterns of installation (as shown in Fig. 14), it is visible that the south slope of the roof is not completely occupied by the PV system in the disaggregated case, this is an obvious source of inefficiency as that slope is the most irradiated part of the building and even if completely covered with PV does not cause significant over-production if applied to the whole cluster. In the disaggregated case, the possibility of installation on the southern slope is obviously limited by the lack of sufficient demand in the underlying building.

Discussion and outlook
For the demonstration building in Sweden, the most profitable surface for installing PV panels is the southern slope, since it is more irradiated (~1200 kWh/m 2 year) compared with the other surfaces that are available for PV panel installation. The upper parts of the two south façades are the second most profitable locations for installing PV panels. This is because the south façades are irradiated more homogeneously throughout the year. The east and west slopes are the third most profitable surface for installing PV panels since they are not shaded and have relatively large solar irradiation.
The application of Energy Hub DC micro grid in buildings enables an easier, more convenient and more energy-efficient way for utilizing on-site produced renewable energy. This will help promote the deployment of renewable energy systems in the building sector. More importantly, the Energy Hub DC micro grid provides a platform for flexible energy sharing between different buildings. By enabling energy sharing among buildings, the buildings with surplus renewable energy generations can send their renewables to buildings with insufficient supply, thus achieving an improved match between the district-level renewable supply and electrical demand. The improved match helps boost the SC. Note that the significant increase in SC is contributed by the sharing mechanism at almost no extra cost, and thus should be possible to implement profitably in many cases, if national regulations allow this. Thus, the Energy Hub DC grid has huge potential to be applied in large scales for improving the SC of buildings. This is in line with Luthander et al. [51], who investigated the impact of placement of meter and battery storage for a group of buildings and showed that centrally placed battery and metering for the buildings as a cluster resulted in increased self-consumption of the cluster compared to the case with buildings individually. It also showed that much less curtailment would be required if large amounts of PV were to be installed, and power input to the grid were to be limited. In this study, the  considered three buildings all belong to residential buildings, which have similar occupancy schedules and load patterns. Such similarity limits the benefits from energy sharing, since the buildings may have surplus renewable generations or insufficient supply in the same period. When different types of buildings with different demand patterns are connected in one Energy Hub DC grid, more performance improvements in SCE are expected to be achieved. For instance, putting an office building and a residential building in one cluster, the potential renewable energy shortage of the office building during the daytime can be compensated by the surplus renewables from the residential building [52].
Thermal energy storage is an efficient solution to improving the renewable energy self-consumption rate of buildings. The integration of thermal energy storage, together with appropriate control, will lead to increase in the optimal capacity of PV systems that maximizes the SC, as the charging of thermal energy storage is treated as extra electrical demand. By changing the shape of the electrical demand to match the renewable energy generations, an increased SC can be achieved (i.e. the self-consumption increased from 77% to 79.4%) at the same time as the total installed capacity increased. Fig. 15 presents the KPIs of the three iterations (refer to Section 6.2) using the scheme proposed in [50], as the authors points out the iteration 2 and 3 are aligned respect to the origin of the axes and the increase in self-production is therefore proportional to the increase in self-consumption.
It should be noted that this study is a single-objective optimization by the basic genetic algorithm, and previous research has shown that significant improvements can be achieved with more advanced algorithms [21], meaning that the results shown here are conservative compared to what can be achieved in practice. However, if thermal storage of excess PV in the form of heat is to be included in the PV optimisation tool, only basic algorithms will be feasible, together with a simplified model of the heat pump system. The energy sharing is likely to help reduce the capacity of TES to some extent. When energy sharing is enabled in the building cluster, the required optimal capacity of TES can be reduced, compared with the scenario in which energy sharing is not allowed. This is because the district-level electric demand can match the district-level renewable supply better as discussed previously and shown by Luthander et al. [53], and thus a smaller sized TES is needed to compensate the energy mismatch. The integration of TES does not affect LCOE too much, as both the renewable energy generations and the costs increase. Another potential application of the thermal energy storage is to conduct demand management in response to the varying electricity prices. By storing the grid power in lowelectricity-price period in advance, economic savings can be achieved for the building cluster [21].
With increased EV penetration, the cost-optimal PV capacity will also increase due to the increased electrical demand. Increasing the number of EVs will lead to a slight increase in the SC, as the whole system shifts towards larger load and larger capacity. The EV profiles used have only a small seasonal variation. This is not always correct for the cold Swedish winter climate, when a significant amount of heating is required for the interior of the car, which increases the amount of electricity used for a given journey. How large this heating demand is depends on the duration of the journey and not its distance. The electricity demand of the buildings used includes electrical heating for cars in the car park before use, as is common practice in Sweden, so the battery in the car does not need to supply heat to heat up the car before a journey. For the location of the cluster, there is no traffic congestion for normal journeys and thus the energy use for motion will be much higher than that for heating, even in winter. Additionally, in the winter the electric load is far greater than the PV production, so any differences of EV load at this time of year would have very little impact on the results. In each hour of a day, the charging demand varies dramatically, reaching peaks at night and valleys during daytime. Such daily EV demand profiles have an opposite trend as the PV power generation, which reaches peak in the daytime and becomes zero at night. Thus, the increase of EV numbers will not promote a higher contemporary selfconsumption rate for PV electricity. Similar to the application of Energy Hub DC micro grid, in the residential area of Sweden the particularly negative interaction between PV and EVs suggests to replicate the optimization process in other building clusters, instead of only residential buildings. The relation between PV and EVs could be more synergic in offices and commercial activities due to the better contemporaneity of production and demand, as EV's used for commuting are logically charged when people are at work. This study did not consider the scenario that EV batteries are allowed to charging the power grid and thus can help alleviate the grid stress in the peak-demand periods [54]. In such scenario, EVs are used as mobile electrical energy storage which is charged in buildings with surplus renewable production and discharges in the buildings with insufficient renewable supplies [55]. From this aspect, the deployment of EVs can help further increase the renewable energy self-consumption at the building cluster level.
According to 2030 Framework for climate and energy [56], the European commission bids to achieve a 32% share of renewable energy source (RES) by 2030. Increasing the capacity of renewable energy systems can help achieve this goal. However, the increased capacity will cause issues such as high investments and over-production. The energy concepts introduced in this study, such as energy sharing and TES integration, represent good solutions for the buildings in Sweden to achieving this '32% share of renewable energy source' target. They should also be easy to implement in many other countries on a technical level, but regulations would need to be revised in order to allow power sharing among buildings with or without PVs.

Conclusions
This paper has presented a case study about transforming existing building cluster into electricity prosumers in Sweden. The core energy concepts, including click-and-go PV, centralized variable-speed heat pump, Energy Hub direct current microgrid that can share power between buildings and hot water thermal storage, have been introduced and applied for retrofitting an existing building cluster. An optimization method has been developed to design the capacity and positions of PV modules on each building, which aims at maximizing the self-consumed electricity under the constraint that the system has a positive lifetime net present value (and thus it is profitable). Based on the developed method, the impacts of thermal energy storage, electric vehicle penetrations, and energy sharing on the optimal capacity and positions of PV panels have been investigated. The results have revealed how those factors influence the design of PV systems and the system techno-economic performance, and thus help promote the PV deployment. More importantly, this study has demonstrated the feasibility for transferring the existing Swedish building cluster into smart electricity prosumers with higher self-consumption rates and energy efficiency and more Self-consumption and self-sufficiency scheme as proposed in [53], the diameters of the bubbles represents the capacity of the PV system. intelligence, which offers good solutions for EU to achieving the '32% share of renewable energy source' target. The major findings are summarized as follows.
• The annual cumulative solar irradiation and homogeneity of irradiation are two significant factors affecting the PV power self-consumption, and thus they should be considered in the selection of locations for PV panel installation.
• The energy sharing can significantly improve the renewable energy self-consumption. The self-consumption could reach as high as 77% while maintaining a self-sufficiency above 20% in the baseline case, which is much higher than other studies at similar high latitude. This is because the aggregated electrical demand of multiple buildings eliminates the huge peaks featured by single building's demand, and thus can better match the PV power generations.
• The integration of thermal energy storage, together with suitable control for storing heat using PV excess production, will lead to increase in the optimal capacity of PV systems, as charging of thermal energy storage will increase electrical load. Due to an increased match between the electrical demand and power generation, the integration of thermal energy storage is beneficial for increasing renewable energy self-consumption, i.e. self-consumption increased from 77% to 79.4%. The integration of thermal energy storage does not affect levelized cost of electricity too much, as both the power generation and the costs increase.
• The integration of electric vehicles will lead to increase in the optimal capacity of PV systems that maximizes the self-consumption, in this case study the self-consumption rate increased from 79.4% to 80.9% when EV number increased from 2 to 48. Meanwhile, due to the increased self-consumption, the levelized cost for the self-consumed electricity will be reduced slightly.
• Aggregating the building demand and supply by enable energy sharing will lead to increase in the optimal capacity of PV systems that maximizes the self-consumption rate, since energy sharing makes the PV system more versatile, and thus the whole cluster is more efficient at consuming the electricity produced on-site. The self-consumption will be reduced (i.e. 7.8% decrease), but this will be compensated by a dramatic increase in the self-sufficiency (i.e. 23.8% increase). The levelized cost of electricity is not affected by aggregating the building demand and supply.
In this study, the considered system is one centralized heat pumpthermal storage system for the three building. The energy sharing control is relatively easy as just one set of system needs to be controlled. When buildings have their own heating and storage systems, the district-level collaborative controls will become difficult. Future work is needed to develop advanced collaborative control strategies for building clusters, which can globally coordinate multiple systems and demands. One limitation of this study is that the thermal storage cost is not considered in the optimization. Future work will take into account storage costs for a more comprehensive optimization. Furthermore, the effect of the technologies analysed in this study could be as well investigated in terms of specific CO 2 emissions [kg CO 2 -eq/MWh].