Analysis of large-scale energy retrofit of residential buildings and their impact on the electricity grid using a validated UBEM

To evaluate the effects of different energy retrofit scenarios on the residential building sector, in this study, an urban building energy model (UBEM) was developed from open data, calibrated using energy performance certificates (EPCs), and validated against hourly electricity use measurement data. The calibrated and validated UBEM was used for implementing energy retrofit scenarios and improving the energy performance of the case study city of Varberg, Sweden. Additionally, possible consequences of the scenarios on the electricity grid were also evaluated in this study. The results showed that for a calibrated UBEM, the MAPE of the simulated versus delivered energy to the buildings was 26 %. Although the model was calibrated based on annual values from some of the buildings with EPCs, the validation ensured that it could produce reliable results for different spatial and temporal levels than calibrated for. Furthermore, the validation proved that the spatial aggregation over the city and temporal aggregation over the year could considerably improve the results. The implementation of the energy retrofit scenarios using the calibrated and validated UBEM resulted in a 43 % reduction of the energy use in residential buildings renovated based on the Passive House standard. If this was combined with the generation of on-site solar energy, except for the densely populated areas of the city, it was possible to reach near zero (and in some cases positive) energy districts. The results of grid simulation and power flow analysis for a chosen low-voltage distribution network indicated that energy retrofitting of buildings could lead to an increase in voltage by a maximum of 7 %. This particularly suggests that there is a possibility of occasional overvoltages when the generation and use of electricity are not in perfect balance.


Introduction
In Sweden, the building stock is responsible for more than 40% of the final energy use, which was equivalent to 140 TWh/y in the year 2020 [1], and associated greenhouse gas emissions.Of this, approximately 60% is supplied to the residential sector to cover mainly the demand for space heating and domestic hot water [1].On the other hand, to fulfill the international energy and climate plans and to make commitments to the Paris Agreement, Sweden aims to become carbon neutral by 2050 [2].Therefore, the residential building sector, as one of the main contributors to national energy, can play an important role in achieving the goals of a carbon-neutral society.
It is generally recognized that to improve energy efficiency, the key strategy is to renovate the energy-intensive buildings to meet the minimum requirements of the Passive House standard [3].This is not fulfilled unless the thermal properties of the building envelope are largely improved and the building is equipped with efficient heating, ventilation and air conditioning (HVAC) systems (such as heat pumps and heat recovery ventilation systems).Another well-known strategy for achieving low-energy buildings is to increase the share of building-level renewable energy solutions, in particular, solar energy systems [4].These energy efficiency measures can have a noticeable impact on the efficiency of individual buildings.However, to determine their overall potential, it is recommended to evaluate the energy efficiency scenarios on larger scales, when applied to a large number of buildings.
In the context of large-scale energy planning and/or energy retrofit of buildings, the previous research has been focused on the development of a set of analytical tools known as urban building energy models (UBEMs) [5].Reinhart and Cerezo Davila [6] define urban building energy modeling (UBEM) as a bottom-up engineering-based approach to modeling energy use in large sets of buildings.The UBEMs not only illustrate the current status of the energy use in the building sector but also foresee the results of any changes in the components of the buildings and their systems, e.g., HVAC or energy systems.These qualities of an UBEM make it an appealing decision-making tool for achieving lowenergy cities using different energy and carbon mitigation scenarios.https://doi.org/10.1016/j.apenergy.2024.122937Received 15 October 2023; Received in revised form 19 February 2024; Accepted 24 February 2024 In the field of UBEM, examples of the implementation of different models for evaluating stock-level intervention and retrofitting scenario are found in Refs.[7,8].
In [7], Hong et al. developed a web-based UBEM interface, referred to as CityBES, and incorporated more than 75 energy efficiency measures from different sources into the model.The model, which was primarily developed for American cities, was tested for energy retrofit of 540 non-residential buildings in San Francisco [9].Evaluation of the conducted measures, i.e., use of LED lamps, improvement of the efficiency of heating and cooling units, adding an economizer to the ventilation system and replacing windows, showed a 22%-48% reduction in the energy demand of each building.In [8], the UBEM of Boston which was developed around an UBEM interface known as ''UMI'' [10] is also another example for planning and evaluation of large-scale energy retrofits.In this study, the influence of photovoltaics (PV) power generation on peak shaving for the electricity load was the basis for the comparison of two retrofit scenarios, one suggesting the installation of PV panels on 50% of the roof area of all buildings and the other adjusting the room temperature of commercial buildings using a demand-response control that allowed for an increase of 2-4 • C in the indoor temperature during summer time.The results showed a similar outcome in the magnitude of peak shaving (approximately 48 MWh for an example day in Summer).
Additionally, Deng et al. [11] suggested a method for the development of an UBEM based on available data for the Chinese context.The model not only calculated the energy demand of buildings but also conducted energy retrofit analyses that were in line with the Chinese standard for nearly zero-energy buildings (nZEBs).Lin et al. [12] focused on evaluating the energy-saving potential of retrofitting a few historic buildings on a university campus in China.In this study, again, the authors proposed a method for the development of an UBEM that could also be used for implementation and testing the energy efficiency measures in buildings.Stanica et al. [13] proposed a methodology that combined the UBEM with a multi-criteria decision analysis (MCDA) approach, which took into account technical, economic, social, and environmental factors to prioritize retrofitting options in a group of university buildings in Germany.
In a colder climate region, such as Sweden, where the energy demand for space heating is relatively high, Pasichnyi et al. [14] made use of a data-driven UBEM to implement large-scale energy retrofit of buildings and improve the demand over the city.In this study, the authors focused on a group of multi-family buildings constructed around  to demonstrate the effectiveness of their model for the identification of optimal retrofit strategies from the three alternatives where either the ventilation system or windows or both were replaced by more energy-efficient ones.Johansson et al. [15] compiled an energy atlas for Sweden that not only mapped the energy performance of the multi-family building stock in Sweden but also determined the potential for renovation of buildings.Additionally, the authors suggested a renovation atlas in which the energy reduction potential and its associated costs were presented for selected geographical locations in Sweden.Although no UBEM was used in [15], their goal to determine large-scale energy efficiency potential was similar to UBEM.
Similarly, in all of these studies, the emphasis has been predominantly on buildings.There is no doubt that improving energy efficiency and reducing the energy use in the building stock is crucial.However, it is equally important to analyze the effect of these changes on the energy supply side and in particular the electrical distribution systems.
Previous studies show that, the use and generation of energy in buildings can significantly impact the electricity distribution systems.As more electricity is used on the distribution lines, the voltage decreases because of the higher resistance in the distribution lines [16].On the other hand, distributed power generated from buildings such as rooftop solar PV, can inject power back into the grid, causing voltage levels to rise, and potentially resulting in overvoltages [16].Baetens et al. [17], who implemented a net-zero energy neighborhood consisting of 33 detached residential buildings in Uccle, Belgium, found that due to the risk of overvoltage, up to 47% of the solar-generated power was wasted and not allowed to be exported to the grid.Earle et al. [18] studied the impact of energy efficiency measures and distributed energy resources, including PV panels, battery storage and electric vehicle charging, in a neighborhood located within Denever's central park community, USA.Their study focused on 30 single-family buildings in this area, where the findings showed that although periods of high PV production and export to the grid could potentially lead to overvoltages, they remained within permissible limits.
Consequently, renovating buildings can have both advantages and disadvantages for the electricity grid.Improving building efficiency and adding small-scale distributed power generation can help reduce the amount of energy required by the grid to meet the demand, which could mitigate undervoltages and lower energy losses [19].However, adding larger amounts of distributed generation in buildings could increase the risk of overvoltages.Thus, the value of the reduction in demand achieved through customer energy efficiency improvements depends on the quantity, temporal (mis-)match, and location of the energy savings [19].
Utilizing an UBEM to its potential allows for planning and implementation of energy upgrades, while also capturing changes in the spatio-temporal load patterns.Coupled with an electricity grid model (using different methods such as co-simulation or sub-system integration), an UBEM significantly deepens the understanding of the implications of large-scale energy retrofits, not only on the demand side but also on the distribution side.This combined UBEM-grid approach to evaluating large-scale energy efficiency and grid dynamics provides stakeholders and utility companies with valuable information which was not previously fully disclosed.

Research gaps and scientific contributions
Existing literature demonstrates that UBEMs have potential for supporting large-scale renovation strategies.However, in many studies, the UBEM approach is utilized for simplified archetype-based renovations, where specific renovation measures are applied to a chosen archetype and then scaled up to the whole city.Such approaches limit the possibility of identifying and adapting renovation measures only for those specific buildings in the city whose energy demands exceed the requirements and building codes.Besides, there are few studies exploring the potential for retrofit strategies to achieve passive and net-zero energy buildings at a large-scale and on the city level in cold climate regions such as Sweden.Finally, in existing literature, a limited attention is paid to analysis of the effects of large-scale building energy retrofits on the electricity grid.In fact, to date, no other UBEM has been properly integrated with a grid model [20].
To fill these research gaps, in this study, the overarching goal is to take full advantage of a validated UBEM to plan for large-scale energy upgrades of residential buildings and evaluate the subsequent effects on the local electricity grid.The method is conducted on a case study city in Sweden where the specifications of buildings and electricity grid is known to the authors.Additionally, considering the availability of hourly measurement data, this study also aims to address the question on validation of UBEM over different spatial and temporal levels.As discussed in [21] the accuracy of UBEMs has barely been evaluated in the previous research, and in the few existing cases, the validation was limited to lower spatial and/or temporal resolutions.
In line with these goals, the main objectives are to: • Utilize a building-by-building UBEM approach to determine the spatio-temporal power demand over the whole city.• Explore consequences of the suggested renovation scenarios on the electricity distribution grid in terms of peak demand periods and voltage levels.
Upon fulfilling the main objectives of this study, two central questions are answered; first, ''is it possible to accurately plan for deep energy renovation and energy reduction of the building stock using an UBEM?''; and second, ''how will deep energy renovations of the building stock affect the electricity distribution grid?''

Data
The input data for modeling and validation of the building stock and electricity grid were gathered from different sources for a case study city in Sweden.More details on these are presented as follows.

Case study
As detailed hourly electricity use and grid data were possible to obtain from the distribution system operator (DSO) Varberg Energi, the municipality of Varberg was chosen as a case study.With more than 22 530 residential buildings, Varberg is a mid-size municipality located on the West coast of Sweden.According to national statistics [22], the main source of energy in the housing stock in Varberg is electricity (60% of the annual use in 2021) followed by district heating (25% of the annual use in 2021).As of the year 2021, the rest of the demand is covered by renewable sources, such as solar, biomass.

Building data
Following the methodology suggested in a previous study conducted by the authors [23], the UBEM is developed using national open data for residential buildings in Sweden.These data are divided into two parts, namely GIS data and energy performance certificate (EPC) data.The GIS data in Sweden include the most important features of buildings, from geometry and geo-location to type, use, and year of construction.The EPC data, on the other hand, encompass the energy-related characteristics of buildings, in particular, the type and share of HVAC systems in buildings.Additionally, the EPC data is the only source of data with detailed building-level information on the measured energy use for heating, ventilation and air conditioning of buildings.In many cases, this dataset also includes the energy used for household and operational electricity, as well as PV power and solar thermal generation, etc.While the GIS data covers almost all 22 530 residential buildings of Varberg, the EPC dataset includes only 18% of them (approximately 15% of single-family buildings and 68% of multifamily buildings).After data pre-processing, some of the buildings were removed from the input data and around 10 590 buildings were deemed usable for further analysis, out of which only 2700 had EPCs.
The method for pre-processing of the Swedish GIS and EPC data was already developed and presented in [23].In summary, in the suggested method, five GIS data layers, including buildings' polygons and types, property polygons and property designations, buildings' construction year points and buildings' address points as well as light detection and ranging (LiDAR) point clouds, are combined with the EPC data to form a unique GIS-based dataset covering the most important features of buildings.This procedure involved several spatial and attribute join operations where defective or missing inputs were altered or excluded from the dataset.

Validation data
Measured electricity use data at the household level were used to validate the performance of the UBEM, which is formally introduced in Section 3.1.More specifically, hourly accumulated net load electricity (load minus renewable electricity generation) between 2020-07-12 to 2021-12-31 from 10 850 consumers were given by the grid company.Out of these 10 850 consumers, 4720 consisted of residential buildings.Since one of the aims is to analyze the performance of the UBEM at different temporal aggregation levels, a full year was deemed necessary and residential buildings with data for the complete year of were chosen.However, due to the replacement of electricity meters and server migration within the considered time period, 2326 of the residential buildings had complete data, i.e., 8760 h, which is why these buildings were used to validate the output from the UBEM model.Out of these buildings, 490 buildings had detailed buildinglevel information from EPC and the remaining 1836 buildings did not.The separation of buildings with and without EPC are used to analyze the effect of including detailed information on model performance and the number of buildings within each category can be seen in Table 1, including the spatial aggregation levels.

Grid data
Power flow analysis was conducted on an urban low-voltage (LV) distribution network situated in the city of Varberg, Sweden.The chosen LV network is a part of the city's distribution grid that consists of four 10 kV three-phase medium-voltage (MV) and 334 three-phase LV networks of 400 V with a total of 11 602 end-users point connections.The network has a three-phase connection to the end customers, a common feature in Swedish distribution networks.The network data is sourced from the DSO and it represents real data from an existing network.All cable characteristics, lengths, and configuration data are available from the network operator.
The chosen LV network consists of 80 connection points and buses connected to 155 residential buildings.The simplified network layout without geographical information data is shown in Fig. 1.The network has a very high share of residential buildings (more than 98%), compared to non-residential, which made it more relevant to this study where only changes to the residential buildings were of interest.In addition, due to the availability of the EPC data for more than 50% of the residential buildings in this district, the availability of information on the systems and energy use in this district was relatively high.
The general information about the chosen LV network compared to all LV networks in the city are given in Table 2.The chosen LV network is considered a long network relative to other networks in the city, with a total length of 6.47 km, which is higher than the 90th percentile of all LV networks.The total number of point connections is also significantly higher at 80, exceeding the average of 36.46.However, the reactance (X) to resistance (R) value of 0.14 is relatively close to the average value of 0.21.

Method
Referring to the goals of this study, the methodology was divided into four steps.First, an UBEM of the residential building stock in  Varberg was developed and calibrated.The calibrated model reproduced the current energy demand of buildings.Second, to increase confidence in the calibrated UBEM and its results, it was validated against electricity use data at various spatio-temporal resolutions.With the model being calibrated and validated, and in an attempt to increase energy efficiency and reach net-zero-energy districts, third, a set of deep energy retrofit scenarios were suggested and applied to the city of Varberg.Finally, with respect to these energy retrofit scenarios, the impacts of the different energy renovation scenarios on the stability of the grid and in particular the voltage profile and total losses were analyzed.An overview of the paper is illustrated in Fig. 2.

Urban building energy modeling and simulation
In this paper, the approach to UBEM proposed by the authors [23] was used, with slight differences as described below.

3D city model
To form a 3D representation of buildings of the city, referred to as a 3D city model, the method developed by Lingfors et al. [24] was adopted.Accordingly, using available low-resolution LiDAR (light detection and ranging) point clouds, the elevation of buildings was calculated and used to extrude the building footprints.One of the main advantages of their suggested method over certain alternatives, such as in [25], is their approach to co-classification of buildings and roof type selection.This resulted in a higher level of detail (LoD), equivalent to LoD2 [26].With a 3D city model of LoD2, not only the roof type but also the azimuth and tilt of the roof become known.Although from the urban building energy modeling perspective, the roof shape is given a lower priority [27], this information is crucial for the analysis of rooftop PV systems in buildings.
Using the exact shape of the roof and the x, y, and z coordinates, the equivalent shoebox volume for the roof was calculated and added to the main body of the building.In this way, a simplified yet more accurate shoebox model of the building was used for the energy simulations.However, as proven in Ref. [23], in the case of the availability of EPC data, the building box is determined from the given number of floors (above and below ground), and the heated floor area of the building.

Archetype development
The classification of the building stock and identification of building archetypes were fulfilled similarly to the method suggested in [23].Therefore, only the construction period and type of use of buildings were considered for finding the common characteristics, i.e., construction, and material, of buildings in Varberg.
Additionally, in this study, the heating system of buildings was also attributed to the archetypes.This means that if the heating system of a building was unknown, the representative heating system of the archetype was used in the model.The estimation of heating systems for archetypes was achieved by calculating the share of heating systems for each building (obtained from EPC data) and averaging it across all the buildings of each archetype class.All the heating systems were summarized into four main types including district heating, boiler (regardless of their energy carrier), direct electric (radiators, heat exchangers, etc.) and heat pump (different types).
Although for some of the buildings, this assumption may deviate from reality, in the absence of EPCs, it is probably the best solution that can be and should be adopted in particular on the aggregated levels.However, for buildings with EPCs, the heating system was still modeled as in the given.A summary of the chosen archetype classes, with estimated U-values and shares of systems, is found in Table 3.

Occupancy
The occupancy and related energy including the use of electrical appliances and lighting were extracted from a 10-state stochastic model developed by Widén et al. [28].The extension of the model to 12state, presented in [29], was also used for the estimation of the hot Table 3 Identified building archetypes and their main properties after calibrating the model.SFB and MFB refer to single-family and multi-family buildings respectively.The abbreviations for the share of heating systems, namely, DH, B, DE, and HP refer to district heating, boiler (regardless of their energy carrier), direct electric, and heat pump systems, respectively.

Archetype
Building water use.The stochastic model which originally generated minutebased profiles for each household and each occupant was later averaged over 100 households and the associated number of occupants to make 24-h weekday and weekend profiles for occupancy, use of electrical appliances and use of hot water.The exception to this was the lighting which was shown to have a great dependency on seasons, in Sweden.Therefore, for the lighting, 24-h weekday and weekend profiles were made for each month of the year.To estimate the internal heat gain from the occupancy profile, the occupant-related activity levels and relative heat were incorporated into the model.The details on the applied method are found in [23].

Modeling and simulation
With the collected geometrical and non-geometrical information on each building using the UBEM interface developed by the authors [23,30] and following the evidence on model complexity presented in Ref. [31], single-zone building models were automatically generated in Python and simulated by EnergyPlus.The automated process of modeling and simulation was conducted for each building of the city and continued until the results for all the buildings were appended to the output.The simulation was completed for the entire year and with the hourly time scale.The choice of simulation year and weather data were made based on the requirements for the subsequent calibration and validation steps, which are discussed in Sections 3.1.5and 3.2.
The whole UBEM process in this study was run on a desktop workstation with 32 cores (64 threads) and 194 GB RAM.Accordingly, the computation time for each building was estimated to be approximately 9 s.This excludes the later presented retrofitting steps (Section 3.3).

Calibration
Finally, to make sure the model represented the case study properly, in an iterative process, it was calibrated based on the EPCs and reported annual energy delivered to the buildings.This means that the calibration was done on 26% of the available buildings.
Similar to [23], the construction assemblies and thermal properties of the building archetypes were calibrated to reach the least mean absolute percentage error (MAPE) of the simulations from the EPCs.Unlike in [23], the infiltration rate, which was previously an archetype-related parameter, was excluded from the study.The effect of infiltration rate on the energy demand of buildings, on the archetype level, was observed to be marginal and therefore factored out.The other geometrical-related parameters, such as heated floor area, height and complexity of the building construction, in this study, were already included in the procedure for 3D city modeling (Section 3.1.1).

Validation with measured data
Based on the validation data presented in Section 2.3 and the output from the UBEM model explained in Section 3.1, validation was conducted in order to assess the performance of the calibrated model for independent data (other than calibrated for) and higher time resolution than calibrated for.The metrics used in this study were MAPE and the Pearson linear correlation coefficient.The MAPE gives the average error between the observed and modeled output and is formulated as follows: where ŷ and   are the observed and modeled net load at time step , respectively. is the number of time steps in the data (8760 h).The MAPE should be as low as possible, where 0% defines a perfect model.Pearson's linear correlation coefficient measures the strength of the relationship between two variables and is defined as: where (,  ) is the covariance between the variables  and  and  () is the variance of variable .The correlation coefficient is 1 when the observed and modeled data are perfectly positively correlated, and −1 in the case of perfectly negatively correlated.A complete lack of correlation corresponds to zero.In order to analyze the effect of spatial and temporal aggregation, the data were divided into different spatial domains and temporal resolutions, respectively.Regarding the spatial domains, the previously defined performance metrics were calculated on the building level as well as aggregated for properties, zip codes, areas and the whole city.The temporal resolution was analyzed by summing the hourly time series on daily, monthly and yearly basis for the different spatial levels.

Energy retrofit scenarios
The study of large-scale energy renovation of buildings was carried out based on three deep renovation scenarios, aligned with the latest guidelines for energy-efficient low-energy buildings.To implement the scenarios, instead of the entire municipality, the city of Varberg was chosen.This decision on limiting the boundary of the study was simply made to focus on the more populated areas of the municipality.The three scenarios and their criteria are presented in the following subsections.

BBR codes
The Swedish National Board of Housing, Building and Planning, Boverket [32] introduces general regulations and guidelines for the planning and construction of buildings that follow the national energy and climate plans.In the latest version of the building code [33], referred to as ''BBR29'', the calculated primary energy use of a building, was suggested as a base for the construction of low-energy buildings or carrying out energy renovations on the existing building.In BBR29, the primary energy is described as where   is the energy used for space heating,   is the energy for comfort cooling,   is the energy for domestic hot water, and finally   is the operational electricity used for running pumps, fans, etc.In this equation, the geographical adjustment factor   and the conversion factors for the energy carriers   were also proposed for the proper transformation of the energy use to the primary energy.
The exact values for each of these parameters are found in [33].As for presenting the primary energy in kWh/m 2 y, the heated floor area   is also another parameter that was used in the equation for the calculation of the primary energy.
In this study, the first strategy for energy retrofit of buildings was formulated based on the BBR guidelines.If the primary energy of a building was higher than 95 kWh/m 2 y for single-family buildings and 75 kWh/m 2 y for multi-family buildings, the building underwent changes on its envelope.By adding an extra layer of insulation, e.g., VIP insulation, to the walls, roof and floor and by replacing the windows with low-energy windows, the thermal properties of the building envelope were improved at once.The aim of this renovation strategy was to get as close as possible to the BBR29 recommendations for thermal transmittance of wall, roof, floor and window to be respectively lower than 0.18, 0.13, 0.15 and 1.2 W/m 2 K.

Passive house
The Swedish Forum for Energy-Efficient Building (FEBY) [34] suggests that for a district-heated building, implementation of the Passive House standards results in 0%-35% lower energy demand as compared to a BBR-regulated building.This value for an electrically heated building increases to 32%-54%.This is a confirmation of the influence of the Passive House standard on improving the energy efficiency of buildings.The previous studies [3,35] also proved the effect of the Passive House renovations in large-scale energy retrofits.Therefore, the second chosen energy retrofit scenario was unfolded based on the Passive House standards.
In the Swedish Passive House definition, the annual heat losses from the building, i.e., the sum of transmission losses from the building envelope, ventilation losses and infiltration losses, is the primary measure for labeling a building as Passive House.This is accompanied by an additional measure for primary energy use, if the building is the heating system of the building is purely driven by electricity [34].The standard is divided into three levels, namely, gold, silver and bronze, ranked based on the annual heat losses, from 14 to 22 kWh/m 2 y.The given numbers are used for buildings with a heated area (A  ) of greater than 600 m 2 .If the heated area of the building is less than 600 m 2 , a correction to the numbers versus the area is suggested [34].
The second energy retrofit scenario followed the Swedish Passive House standards.For this reason, the building envelope was deeply renovated at once to reach the minimum thermal transmittance of 0.1 W/m 2 K for walls, roof and floor and 0.8 W/m 2 K for windows.To improve the thermal properties of the building, similar to the BBR scenario, a layer of insulation was added to the inner part of the surface, i.e., wall, floor, or roof.The window was also replaced by energy-efficient windows and the ventilation system was replaced by mechanical heat recovery systems with an efficiency of at least 75%.

Net zero energy buildings
A net zero energy building (NZEB) is generally defined as a building that over a specified period, typically a year, demands as much energy as is generated on-site [36].In other words, a NZEB has a zero energy balance, where the total energy produced by renewable sources within the building, such as solar PV or geothermal systems, is equal to the energy used in the building.This definition specifies the two important aspects of a NZEB; firstly, the optimal use of energy and, secondly, the integration of renewable energy technologies.
To comply with the main aspects of the NZEBs, in this study, the buildings were equipped with solar PV systems where it was possible.This was done for buildings in their existing condition and after conducting energy scenarios based on BBR and Passive House standards.The possibility of having a PV system was defined based on the estimation of solar energy potential on the rooftop where the annual solar radiation was higher than 900 kWh/m 2 .Referring to [37], the tilt and orientation of the roof, shading obstacles and the surrounding environment, are all determining the solar energy availability.Using the method developed in [37], the available area on the roof with high solar radiation was obtained and covered with PV panels, each having an area of 1.9 m 2 and maximum power output of 400 W at standard test condition.The tilt and orientation of the panels were set to be similar to those of the roof.

Electricity grid simulations
To study the effect of the energy retrofit scenarios on the electricity grid, time series simulations of power flow were performed.Previous studies show that there are variations between voltages, already before the addition of solar PV systems [38].Voltage variations experienced in the low-voltage network before the local production are referred to as background voltage, and these variations originated from the MV networks [39].To obtain the background voltage, simulations were done for the MV networks.In MV network grid simulations, slack bus voltages needed to be defined.In this study, slack bus voltages in MV networks were assumed to be 103% of the rated voltage, i.e., 1.03 p.u.
The simulations show that the background voltage for the chosen LV network remains relatively constant within the range of 1.027-1.029p.u.These background voltage profiles were used as the supplied voltages to the chosen LV network for all grid simulations, including the scenarios with PV systems.The inclusion of PV systems in other LV networks connected to the same MV network, in theory, could affect the voltage supplied to the chosen network.However, for simplicity, these impacts were excluded.
The validation of grid simulations was initially carried out by comparing UBEM base case data with the available load measurement data.However, since the load measurement data was only accessible for the last few months of 2020, the validation of electricity grid simulations was specifically performed for the UBEM model of that period.It is important to note that this validation is distinct from the validation of the entire UBEM, as explained in Section 3.2, due to the availability of more building measurements for the year 2021 across the entire city.The actual grid simulations, however, used the UBEM model for the year 2021.
For the actual grid simulations, the measured load data were replaced by the UBEM scenarios explained in Section 3.3.Initially, the status of the grid for the base case scenario, i.e., buildings at their existing conditions, was presented.Then, after the implementation of the large-scale energy retrofit scenarios, according to what is suggested in Section 3.3, the changes to the grid were evaluated in detail.
Power flow simulations were done over one year on an hourly basis.In this study, the electricity grid model and time-series simulations were performed using the open-source software Pandapower [40].The simulations were based on the Newton-Raphson load flow method, and the detailed equations for this method can be found in [41].Based on the literature review presented in Section 1, the simulation results will primarily focus on voltage profiles and total losses.

Results
This section presents the results from the calibration and validation of the UBEM for residential buildings in the case study of Varberg.Moreover, it also includes the results of energy retrofit scenarios and their effect on the electricity grid.

UBEM calibration and performance
The urban building energy modeling and simulation of the residential buildings in Varberg were performed based on the method suggested in Section 3.1.Table 4 summarizes the deviations between the simulated versus delivered energy for space heating and hot water in buildings, for the uncalibrated and calibrated model.The iterative calibration of the thermal properties of the building archetypes using EPC data improved the MAPE of the model considerably.While the MAPE for the model before calibration was 40%, it reduced to 26% when calibrated.
As presented in Table 4, for the calibrated model the average error, i.e., MAPE, stayed below 30% for almost all the archetype classes.This is also an improvement from an uncalibrated model in which the MAPE of some of the archetypes reached 40% and higher.In the calibrated model, the archetype class 10, multi-family buildings built in the 00s, was the only class that resulted in a MAPE of higher than 35%.For older multi-family buildings (archetype classes 12-15), however, the MAPE was considerably lower.In general, the performance of the model was better for multi-family buildings.As compared to single-family buildings (archetype classes 1-8), the simulation results for multi-family buildings showed a higher correlation to the EPC data.Unlike multi-family buildings, single-family buildings have more diversity in their construction and material.These variations make it more difficult to model a single-family building based on generalized construction and material of the corresponding archetype class.
A graphical representation of the distribution of the percentage error (PE) of the annual simulation results of the calibrated model from the EPC data for buildings of the archetype class is displayed in Fig. 3.For most archetypes, the PE was distributed around ±100% with the mean percentage error (illustrated as a solid black line) located very close to zero.The illustration of the standard deviation of the PE (dashed line) also proved that for some of the archetype classes, such as archetypes 5, 7, 8, and 15, the variability was higher.However, comparing the overall performance of the model over the city, it could be seen that only 10% of the buildings were affected by the higher degree of variability.The other 90%, on the other hand, had a PE of After confirming the accuracy of the calibrated UBEM using the annual delivered energy to individual buildings, found in the EPC, it is necessary to validate the model based on an independent source of data.The results from the validation of the calibrated UBEM using measurement data at different aggregation levels are presented in the following section.

Validation and spatio-temporal analysis
As part of the validation, the error between the simulated and measured electricity in residential buildings can be assessed using MAPE as described in Section 3.2.Table 5 shows the MAPE between measured data and simulated results for different temporal and spatial aggregation levels.The general trend is that the error decreased with lowering temporal and spatial resolutions to the extent that for the aggregated results over the city and year, the error is as low as 12%.
However, contrary to the general trend, it was observed that the temporal aggregation, from hour to month, led to a noticeable increase in the MAPE.This observation was specific to higher spatial resolutions, i.e., building and property levels, and for the cases where the majority of buildings did not have an EPC (cf.Table 5(a) and (c)).The reason behind this trend can probably be explained by the incorrect assignment of heating systems.This mainly impacts the seasonal variations, due to an incorrectly modeled heating demand, which should be most visible on the monthly time scale.
The other interesting trend was that, when spatially aggregating the results over the city, the unavailability of EPC data for the majority of buildings did not considerably impact the performance of the model.The averaging effect became more influential over the higher spatial aggregation levels, meaning the quality of the input data became less influential.
The correlation coefficient can be analyzed to assess the linear relationship between the observations and the modeled data as explained in Section 3.2.Recall that the correlation coefficient should be as close to one as possible since that explains perfectly correlated signals.Table 6 shows the correlation coefficient between measured data and modeled output for different temporal and spatial aggregation levels.Note that correlation cannot be calculated for the city level on a yearly basis since it only consists of one number for the measured data and one number for the simulated data.
In order to more clearly show the underlying reason for the resulting metric results in Tables 5 and 6, Fig. 4 a scatter plot for the different spatial and temporal aggregation levels, is presented.

Energy retrofit scenarios
Fig. 5 presents the annual energy demand, electricity and district heating, over the residential buildings in Varberg in the base case and after conducting large-scale energy retrofit scenarios based on BBR and Passive House standards.The UBEM estimated that the aggregated annual energy demand for the share of residential buildings evaluated in this study is approximately 193 GWh/y.More than 46% of this amount is covered by the electricity grid and the rest by the district heating unit.According to the model, a small share of the energy demand in the city is supplied by wood boilers (less than 5%).This is however excluded from the illustrations in this section as is not supplied by energy systems, e.g., the district heating and electricity grid.The large-scale energy renovation buildings based on the BBR scenario decreased the annual demand to 182 GWh/y.This is equivalent to 6% reduction in the demand annually.Using the BBR's baseline for primary energy use in buildings, it was estimated that 30% of the buildings at their current condition, have a higher contribution to the primary energy use of the city.Renovation of these buildings based on the BBR standards, which only target the building envelope and not systems, resulted in 14% reduction in the average primary energy use (from 76 to 65 kWh/m 2 y).However, as seen the overall energy use of the city did not affected considerably.
Unlike the BBR scenario, the influence of the Passive House scenario on the energy demand of the city is significant.As seen in the figure, there is a considerable drop from 193 to 110 GWh/y, meaning that the annual demand is 43% lower when both the building envelope and the ventilation system of buildings have gone under renovation.
In the last scenario, the installation of solar PV systems on the rooftop and increasing the contribution of renewable energy to the annual energy demand of the city was evaluated.The dashed line in Fig. 5 represents the annual generation of electricity from the maximal use of PV systems in buildings.If it is assumed that the surplus electricity can be fed into the grid and bought back when needed, the aggregated annual generated electricity can balance out the demand in the base case, i.e., buildings in the existing condition.However, the effect of Passive House renovated buildings combined with PV systems considerably improves the energy performance of the city.The annual electricity demand for energy-retrofitted buildings based on the Passive House scenario is in total 59 GWh/y, meaning that the generated PV (91 GWh/y) is 35% oversupplied.Fig. 6 is another representation of the changes to the energy demand, both electricity and district heating, before and after the energy retrofits.This figure displays the hourly energy demand aggregated on the city level and arranged in descending order where the largest energy peaks appear first.In this figure, the imports of energy from the grid are represented by positive values and exports of energy from buildings to the grid by negative values.Due to the fact that PV generation does not have a direct effect on the use of district heating, the district heating use profiles remain unchanged.
In Fig. 6(a) and (b), it is seen that the peaks of hourly electricity and district heating demand are mainly affected by the Passive House scenario.Clearly, the Passive House scenario has a significant impact on the heat losses from the building.As a result, the space heating demand during cold hours of the year decreases considerably.In warmer periods, when the load is primarily influenced by occupantrelated usage, the differences between the base case and the renovated buildings become smaller.However, similar to previous observations, the BBR scenario brings no significant benefit to the city.Fig. 7 illustrates the energy demand of the city, i.e., electricity and district heating, before and after implementing the renovation scenarios using the UBEM.The heat maps for electricity and district heating demand highlight the hotspots of energy use over the city which are more accumulated in the city center where the population density is high.In certain areas of the city, i.e., suburbs, the district heating system is less likely to be present.Therefore, the electricity demand in such areas is dominant.After implementing and testing the energy renovation scenarios using the UBEM, it was noticed that the energy intensity in the city center became considerably lower, particularly for the Passive house scenarios, with or without PV systems.The increased share of renewable and PV electricity reduced the annual demand even more.The electricity bought from the grid was considerably lower when the PV electricity covered a share of the hourly load.Fig. 8 presents the path to net zero energy districts (NZEDs) through the retrofit scenarios.The maximum use of distributed solar power combined with the Passive House renovation scenario could reduce the annual import of energy to buildings considerably.By analysis of the results on the aggregated level, it can be realized that, except for the densely populated areas of the city, it is possible to achieve the goals of not only NZED but also the positive energy district (PED) where the power generation is higher than the demand.

Effects of energy retrofit on grid performance
This section is divided into two parts.In the first part, the load profiles obtained from UBEM simulations are compared against actual measurements to validate their accuracy using MAPE and correlation coefficient.Additionally, the grid simulations are evaluated to ensure the validity of the results.The second part of the section focuses on presenting the grid simulation results for different energy retrofit scenarios.These findings provide insights into the performance of various retrofit approaches within the electrical grid systems.

Validation of grid simulations
The validation process consists of two aspects: load profiles and simulated grid voltages.Fig. 9 illustrates the comparison between the load profiles derived from the measured data and the simulated model.For these load profiles, MAPE and correlation coefficients were calculated following the methodology described in Section 3.2.By comparing the measured data with the simulated results for buildings within the selected LV network utilized for the grid simulations, the MAPE and correlation coefficients were estimated as 125% and 0.7, respectively.
The MAPE was calculated on both the hourly and building levels.The resulting value of 125.29 is lower than the error observed for the same aggregation levels as shown in Table 5(a).Furthermore, the correlation coefficient obtained is 0.70, surpassing the values observed for the same aggregation levels as presented in Table 6(a).These findings indicate the validity of the load profiles for the selected low-voltage (LV) network.
These load profiles are subsequently employed in the grid simulations to verify the accuracy of the resulting voltage profiles.Fig. 10 displays scatter plots depicting the voltage values derived from simulated and measured electricity demands.The results indicate that during the summer period, the simulated electricity demand can result in both higher and lower voltages compared to the measured electricity demand.Conversely, in winter, the simulated one tends to yield lower voltages in comparison to the measured demand.This disparity can be attributed to the higher simulated electricity demand observed in the winter period, as demonstrated in Fig. 9. Consequently, it can be inferred that the voltage outputs from the grid simulations in the following subsection may have a tendency to underestimate values during winter.

Grid simulations results
The cumulative distribution functions of voltage profiles for all scenarios, both with and without PV, are shown in Fig. 11.The red dashed lines show the 1.05 pu overvoltage limit and the 93th percentile values.The green dashed lines show the less strict limit of 1.1 pu and the 99th percentile values.
In the absence of PVs, the voltages in the base case range from 0.962 to 1.028 p.u.With energy retrofitting, the maximum voltages remain unchanged.However, the minimum increases to 0.981 pu for the BBR scenario and 1.007 pu for the Passive House scenario.This is because peak loads were reduced in both the BBR and Passive House scenarios, but the reduction was greater in the Passive House scenario.
When the energy retrofit scenario includes PV systems, the minimum voltage remains the same for all scenarios, but the maximum voltage increases significantly to 1.153 pu for all cases with PV.Whether this violates the hosting capacity or not depends on the chosen limit and risk.The black dashed lines in Fig. 11 demonstrate that 99% of the values are lower than 1.1 pu, indicating that the risk of overvoltages is approximately 1%, and it is possible to address these overvoltages risks on an individual basis.However, with a stricter limit of 1.05, 7% of cases exceed the limit as shown in the gray dashed lines.
The presence of similar overvoltage risks in all scenarios involving PV indicates that energy retrofitting does not offer direct benefits for accommodating more PV systems in buildings.Energy retrofitting does not enhance the self-consumption of PV systems since its primary focus is on load reduction rather than load shifting.However, the increased minimum voltages resulting from the energy retrofit reduce the risk of undervoltages, and at the same time enable adjustments to the slack bus voltage in the MV grids.By decreasing the slack bus voltages in MV grids, the risk of overvoltages caused by PV systems might be mitigated.
The initial energy losses in the grid were estimated to be 14.96MWh/y.However, these losses were reduced through the implementation of energy retrofits which is due to the reduced amount of electricity being distributed to the buildings.The BBR scenario can save up to 4.89 MWh/y, while the Passive House scenario cut energy losses more, up to 10.61 MWh/y.The integration of large-scale PV systems has resulted in a significant increase in total losses, with excess power being sent back to the grid, resulting in a yearly loss of up to 45.95 MWh/y.Energy retrofits resulted in reducing these energy losses, with the BBR scenario resulting in savings of up to 4.28 MWh/y, and the Passive House scenario resulting in greater savings of up to 9.17 MWh annually.The results indicate that the energy savings (in terms of losses in the grid) through the implementation of energy retrofits are almost the same in the case with PV systems and without PV systems.The red lines represent the stricter limit of 1.05 pu and 93% percentile line.The green lines represent the limit 1.1 pu and 99% percentile line.Subfigure (b) is a zoomedin version of (a), which displays the probability distribution (cumulative distribution function) at different levels of magnification for enhanced clarity of the differences between the energy scenarios.

Discussion
The field of building energy modeling (BEM) has been important for energy benchmarking and the implementation of energy efficiency measures in buildings.With the introduction of the EU's new renovation policies and the growing interest in the concept of NZED, there is a demand for more sophisticated approaches that can handle large numbers of buildings more efficiently.This opens for the emergence of large-scale energy models of buildings and in particular UBEMs.The UBEMs, as presented in this paper, serve as virtual representations of buildings and their energy systems.If integrated with models representing other elements of the urban energy systems, such as the electricity grid, UBEMs become capable of capturing the interactions between buildings and grid which leads to better understanding the dynamics of the urban energy system.
In the existing literature, applications of UBEM can be categorized under three domains of stock-level energy analysis [23], energy retrofit scenario planning [7], and renewable energy integration [8].The realworld implications of UBEM are for example found in the latest action plans towards a carbon free Boston [42].However, the applications of UBEM integrated with power distribution models, not only incorporate those of UBEMs, but are also extended to building-to-grid, demand response control, grid resilience and reliability, and optimization and planning for infrastructure [20].
Data availability can be a major barrier to the modeling and analysis of urban energy systems [5].In this study, however, the collected data on the two studied elements of the urban energy system, namely, the building stock and electricity grid, was sufficiently detailed.This is in particular relevant for the electricity and grid data.Nonetheless, the coverage of the building-related data, i.e., EPC data, was relatively low.This left a knowledge gap about the HVAC systems of the buildings and therefore, increased the uncertainty of the model in properly capturing the temporal patterns of the electricity use for the buildings without EPCs.Lower accuracy of the developed UBEM model was a downside of the limited EPC data.The archetype-based heating systems, while an acceptable alternative solution, solved only part of the problem.There is still a need for information on the HVAC systems of all the buildings.This is also the case for the other building information that was only available from the EPCs, such as heated floor area versus building floor area, number of floors, etc.A higher EPC coverage would therefore greatly improve the accuracy of urban-scale analyses.
In this study, all the simulations were hourly based.Despite the fact that the developed models could technically run for sub-hourly time steps, the one-hour time step was selected.Increased computation time, lack of sub-hourly historical climate data and most importantly, availability of hourly electricity use data were the reasons for not using the study on the higher time resolution.However, a slight overestimation of the PV self-consumption for the NZEB/NZED scenarios could be expected, as discussed in [43].
Finally, to address some of the limitations, the future outlook for this work is to develop a refined calibration method aimed at reducing the uncertainty of the model and improving the accuracy of the results at higher spatio-temporal resolutions.This can be an efficient way to reconsider the share or type of heating systems of buildings based on available electricity use profiles.However, for better capturing dynamics between buildings and the electricity grid, there is still a need for the availability of sub-hourly measurements, for both electricity and climate.

Conclusion
The overarching aim of this paper was to develop a calibrated and validated urban building energy model (UBEM) for the residential building stock that can be used for large-scale energy retrofit scenarios and analysis of their impact on the electricity grid.The UBEM was developed from geo-referenced energy performance certificate (EPC) data for the municipality of Varberg, Sweden.The calibration of the model was carried out also using the open EPC data.The calibration of the model through tailoring the thermal properties of the archetypes improved the accuracy of the results.The MAPE of the simulated annual energy demand from the delivered energy reached 26%, which became 14% less than that of the uncalibrated model.However, the calibration was done based on available EPCs for some of the buildings.In addition, it was done on the annual level and with the aim to decrease the average error of the archetype class.
Therefore, to ensure the accuracy and reliability of the model at different spatial and temporal levels, it was validated.The validation of the calibrated UBEM against hourly measurements for electricity use approved that the model has the highest performance at the aggregated levels.The MAPE of the results from measurements, at all the temporal resolutions, fell below 30% when aggregated over the city.This shows that the effect of spatial aggregation on the improvement of the results is greater.This agreed with the goals of UBEM for estimating the demand over large-scale areas.Another conclusion made from the validation was that on the aggregated levels, the calibrated model worked properly for all the buildings and not just those with EPCs.This is probably due to the averaging effect and balancing out the error in the big datasets.
After assuring the validity of the calibrated model, it was used for the implementation of three energy retrofit scenarios based on the Swedish building codes (BBR), the Passive House standards and net zero energy buildings.The large-scale energy renovation was done on the building level and where the building did not follow the minimum requirements of the BBR or Passive House.The assumption of the installation of rooftop PV systems was also made from the solar potential.Therefore, not all the buildings and all the roofs were covered with PV.The finding from these scenarios showed that the Passive House renovation of buildings considerably reduced the peak loads of district heating and electricity demand during cold days.The most influential factor in the Passive House renovation as compared to BBR was the criterion for the heat recovery ventilation system.
To achieve net zero energy buildings the contribution of renewable energy systems, i.e., solar PV, was increased considerably.Through the maximal use of solar energy, it could be seen that the net zero electricity demand for residential buildings was already achieved on an annual basis.However, on an hourly basis, it was realized that the excess PV generation during summer, which was sent back to the grid, was almost three times larger than the peak demand in winter.This excess generation balanced out the demand that mainly happened during winter time.In the case of Passive House buildings, the incorporation of PV electricity transforms many areas of the city near zero and positive energy.
The results of grid simulation and power flow analysis for a lowvoltage network suggested that the background voltage remained relatively unchanged when peak loads were eliminated.The elimination of the peaks was a result of implementing BBR and Passive House scenarios.However, incorporating PV generation into the system increased the risk of over-voltage problems in the grid.In this case, the maximum voltage increased to 1.153 p.u. Depending on the hosting capacity and the limits in the grid, the risk of overvoltage could range from 1% to 7%.Furthermore, feeding in excess PV electricity to the grid led to an increase in energy losses.
In conclusion, this study proves the applicability of a calibrated and validated UBEM for accurate scenario planning and analysis of the energy efficiency measures impacts on the electricity grid.An UBEM that is combined with a grid model could help identify the potential problems or possibilities arising from changes in the demand and supply of electricity.

Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Fig. 1 .
Fig. 1.A simplified low-voltage distribution network layout showing the 10 kV grid supply (yellow square) and 154 buses (blue dots).

Fig. 2 .
Fig. 2.An illustration of the overview of the methodology and data used in this study.

F
.Johari et al.

Fig. 3 .
Fig. 3. Calculated percentage error of the simulated energy demand of the calibrated model from the measured delivered energy found in the EPCs for (a) each archetype class and (b) for the whole city.In subfigure (a), the mean and the first standard deviation of the mean are presented as solid and dashed lines, respectively.

Fig. 4 .
Fig. 4. Correlation between the measured and simulated electricity demand in residential buildings in Varberg.The measurements are illustrated on the -axis and the simulations from the UBEM on the -axis.

Fig. 5 .
Fig. 5. Annual energy demand, district heating and electricity, in the residential buildings at their existing condition and after renovation based on BBR and Passive House (PH) standards.Moreover, the dashed line illustrates the annual PV electricity generation.

Fig. 6 .
Fig. 6.Hourly electricity (subfigure (a)) and district heating (subfigure (b)) demand, in descending order, for the city of Varberg before and after large-scale energy retrofit, based on BBR standards and based on Passive House (PH) standards, and with and without PV systems.In this figure, the negative values represent the excess PV power generation.

Fig. 7 .
Fig. 7. Spatial distribution of the hourly aggregated annual energy demand over the residential buildings in the city of Varberg, before and after energy retrofitting scenarios.The illustrations belong to electricity demand with and without the contribution of PV, as well as district heating for the year 2021.The  and  axes represent the coordinates of the map.

Fig. 8 .
Fig. 8. Reaching NZED in the city of Varberg with large-scale energy retrofit of buildings and increased share of PV electricity for (a) buildings at their existing condition, (b) after renovation based on BBR, and (c) after renovation based on Passive House (PH) standards.The light green areas are labeled as near zero energy districts (nZED) meaning that the annual energy demand is very close to zero.The  and  axes represent the coordinates of the map.

Fig. 9 .
Fig. 9. Validation of the simulated electricity demand against the measurements for the residential buildings within the selected LV network and for the year 2020.

Fig. 10 .
Fig. 10.Validation of the simulated voltage against the measurements for the residential buildings within the selected LV network and for the year 2020.

Fig. 11 .
Fig. 11.Subfigure (a) compares the probability distribution (cumulative distribution function) of three different energy retrofit scenarios both with and without a PV system.The red lines represent the stricter limit of 1.05 pu and 93% percentile line.The green lines represent the limit 1.1 pu and 99% percentile line.Subfigure (b) is a zoomedin version of (a), which displays the probability distribution (cumulative distribution function) at different levels of magnification for enhanced clarity of the differences between the energy scenarios.

Table 1
Number of units within each spatial aggregation level used for validation of the UBEM.

Table 2
Parameters of all LV systems.

Table 4
Analysis of the simulation results as compared to the EPC data before and after calibration of the model.

Table 5
MAPE of the simulated electricity demand from the measurements data at different spatial and temporal aggregation levels.

Table 6
Correlation coefficient of the simulated electricity demand with the measurements data at different spatial and temporal aggregation levels.