Analysing municipal energy system transformations in line with national greenhouse gas reduction strategies

Climate change mitigation and transformation strategies with expansion targets for renewable energy sources are defined at the national level. Due to the decentralised character of these sources

Climate change mitigation and transformation strategies with expansion targets for renewable energy sources are defined at the national level.Due to the decentralised character of these sources, local energy system planning plays an important role.However, local communities often lack the capacity to develop energy concepts and thus exploit local renewable potentials consistently.This study develops a highly transferable methodology for deriving local energy system transformation scenarios in line with national greenhouse gas reduction strategies.Thus, an energy system optimisation model is substantially extended to collectively optimise the transformation of final energy demand in the residential, industry, tertiary and transport sectors, as well as established and niche greenhouse gas reduction technologies.Here, a focus is set on the building stock transformation, and a stochastic model is presented to better grasp and represent the dynamic developments and heterogeneity of the local building stock.Based on superordinate parameters such as retrofit rates and heating technology diffusion, the stochastic model generates informative building stock scenarios that are used as input for the developed energy system optimisation model.Exemplarily, the model is applied to the central European city of Karlsruhe.The results show that an increase of the retrofit rate to 2 %/a and strong electrification of the heat supply in the building sector is economically and environmentally beneficial.Furthermore, an accelerated expansion of

Introduction
At the United Nations Climate Change Conference of the Parties in Glasgow in 2021, the 197 participating countries reaffirmed the Paris Agreement temperature goal.They recognized that limiting global warming to 1.5 • C requires rapid, deep and sustained reductions in global greenhouse gas emissions [1].To achieve these goals most costeffectively, the participating countries are expected to develop longterm greenhouse gas emission reduction strategies, including an early and steady decarbonisation pathway [2].Accordingly, countries such as Germany have committed to ambitious targets to reduce greenhouse gas emissions by 65 % by 2030 and become climate-neutral by 2045 [3].
Necessary means to achieve these targets include the large-scale Waste to energy expansion of renewable energies, storage capacities and energy efficiency measures.However, the deployment of renewable energies happens mostly in local communities due to the decentralized character of these sources, and energy efficiency measures like building insulation require the decisions of individuals.Some local movements exist, such as the Covenant of Mayors [4,5], in which local authorities voluntarily commit to a high level of renewable energy deployment, but these local plans are not necessarily in line with national strategies.A direct transfer of national strategies to the local level would be impossible due to the heterogeneity of German municipalities in size, renewable energy potential and energy demand [6,7].All of this considered, achieving national targets requires a high degree of coordination with local communities [8,9,10], and transferable approaches are needed to determine local energy system transformations in line with national targets.
The majority of the municipal energy system studies in the literature (see Section 2) use an overnight system transformation approach [8,9,11,12,13], which may lack information to policy-makers and energy system planners in terms of how and when to transition to a greenhouse gas (GHG) neutral energy system [14].Consequently, there is a need for studies that, starting from the existing energy system, show a transformation path consisting of explicit energy system expansion and efficiency measures.While existing municipal energy system transformation studies [10,15,16,17] take into account temporal changes in, e.g., energy carrier and technology prices, they lack the consideration of temporal dynamics with regard to expansion rates of renewable energy technologies and efficiency measures like building retrofits.This can lead to an unrealistically fast spread of measures, compared to the national system transformation, as soon as the measures become economically viable (e.g.[17]).In the transformation studies mentioned, such unrealistically rapid dissemination of, e.g., retrofit measures in the residential building sector is particularly favored by a strongly aggregated depiction of the building stock to reduce computational complexity.To overcome the mentioned issues, the municipal energy system optimisation model RE 3 ASON [10,15,17,18] is extended in this work to answer the following research questions.
• What are the techno-economically optimal transformation paths of municipal energy systems in the context of national energy system transformations?
○ How can temporally dynamic developments in the residential building stock be appropriately captured in a transferable and open-data-based municipal energy system transformation model?
○ What are optimal local residential building stock transformations regarding key parameters such as retrofit rate, depth, and degree of electrification?
○ What influence do local limitations on expansion rates of renewable energy technologies have on local energy system transformations?
○ What influence does the exclusion/consideration of individual technology options such as biomass, deep geothermal energy, or wind power have on cost and emission developments?
Accordingly, the energy system optimisation model is substantially extended to collectively optimise the transformation of final energy demand in the industry, tertiary, transport sectors, and of the building stock, as well as established and niche greenhouse gas reduction technologies.In order to consider temporal dynamic changes and the heterogeneity in the municipal residential building stock within the energy system optimisation, a stochastic, spatially resolved building stock simulation is introduced in this study and integrated into the energy system optimisation model RE 3 ASON.To avoid unrealistically high expansion rates of renewable technologies, local maximum yearly expansion rates are defined in accordance with national developments.Furthermore, the overall portfolio of energy system supply technologies is expanded to include all relevant technology options considered in the respective national energy system transformation scenarios.In order to take into account developments of the energy demand transformation in all sectors, NUTS3-level specific final energy demand developments in the industry, transport and tertiary sectors are temperature corrected and integrated into RE 3 ASON.
The transferable model is demonstrated for the energy system transformation of the German city Karlsruhe.All methods rely on publicly available data and can be easily used to support local authorities like small scale energy supply system operators, distribution system operators, and public utilities.
In the following, a comparison of the developed approach with the existing literature is given in Section 2. Subsequently, the methodology for municipal energy system planning is presented in Section 3 and its applicability is demonstrated through a case study in Section 4. Section 5 discusses the methodology and results before the article is concluded in Section 6.

Literature review
The relevance of the municipal energy system planning research field has increased significantly over the past decades resulting in a total of 1,235 studies in 2019 [5].Scheller et al. [19] provide an overview of energy system optimisation models with a high spatial, temporal and contextual resolution for the support of local decision makers at the municipal level and define challenges that should be addressed in the development of future models (e.g., integrated view, spatial planning, temporal resolution and uncertainty analysis).Kachirayil et al. [20] reviewed 116 case studies of local, integrated energy system models to identify best-practice approaches to model flexibility and address nontechnical constraints.Yazdanie and Orehounig [21] examined gaps in the field of urban energy system planning and showcased the need for more integrated modelling approaches and more comprehensive energy modelling scenarios to represent social factors and system imperfections.
Several studies exist that use overnight modelling approaches to determine energy system target states without analysing the transformation process to reach that state [8,9,11,12,13,22,23,24,25,26].In Østergaard et al. [11], a scenario for Aalborg (Denmark) entirely based on renewable energy in 2050 is studied.In simulations with the Ener-gyPLAN model, the scenario is evaluated in terms of the total annual energy balance and the hourly balance between electricity generation and demand.A similar study utilizes the EnergyPLAN model, in this case, to determine a 100 % renewable energy system using lowtemperature geothermal energy for district heating in Frederikshavn [12].Sveinbjörnsson et al. [13] optimize the energy system of the municipality Sønderberg, which aims to reach zero net CO 2 emissions in 2029.Several scenarios show that those with a high degree of electrification perform better than those with a high degree of biomass utilisation.Although these studies make assumptions about the cost development of technologies, the development of energy carrier prices, and emission factors, the municipalities are not explicitly considered in the context of a national energy system transformation scenario.Other municipal energy system analyses exist which analyse the interactions of local and national energy systems.However, these studies are mostly not dealing with the realisation of national scenarios or targets through action at the local level.For example, in Aunedi et al. [22], the interaction with the national level in the cost-efficient supply of local district heating systems is only captured by renewable penetration levels and electricity price volatility.Orehounig et al. [24] use the energy hub concept to manage the relations between energy flows at neighbourhood scale and further extend the concept by the integration of a building simulation tool to be able to evaluate and size urban energy systems according to their energy autonomy, economic and ecological performance.They show that the suggested method can lower peaks in energy demand of neighbourhoods, but no detailed interactions with transformation scenarios of the overarching system are considered.Two exceptions, which are particularly relevant to the present study, are Thellufsen and Lund [9] and Thellufsen et al. [8].In Thellufsen and Lund [9], a methodology is developed to show how well future local energy systems integrate with the surrounding national energy system by analysing system interactions in a sequential procedure.This methodology is applied in the context of a national scenario for 2030 for the Danish cities of Copenhagen and Sønderberg.In Thellufsen et al. [8], this methodology is extended to investigate a local energy system scenario of the municipality Aalborg in a 100 % renewable energy context of Denmark and Europe.In both articles, the EnergyPLAN model is applied, and thus, a simulation to analyse supply and demand for a specific target state is performed, in contrast to the methodology presented in this study, which analyses transformation paths.Murray et al. [25] present an approach for the comparison of storage systems in neighbourhood decentralized energy system applications from 2015 to 2050.This study is of particular importance, since the authors take into account potential future developments of the overarching energy system based on the Intergovernmental Panel of Climate Change's 'Special Report on Emissions Scenarios'.Based on these scenarios, they project energy demand and renewable potential for a rural and an urban neighbourhood in Switzerland till 2050 and calculate optimal energy system configurations for the years 2015, 2020, 2035 and 2050.In contrast to the approach presented in this study, Murray et al. [25] focus on neighbourhoods and conduct single optimisations for each respective year (myopic approach) and therefore do not consider the transformation of the energy system in closed form.
In addition to the overnight approaches presented, several studies have examined energy system transformations in municipalities from the point of view of a central municipal planner.McKenna et al. [10] developed a feasible energy concept for the German municipality of Ebhausen by 2030.The results of a mathematical energy system optimisation are evaluated in a multi-criteria decision approach with preferences derived from workshops with municipal decision-makers.The best performing alternatives that emerged showed similarities in installed technologies and measures and thus could be used as robust recommendations for future energy system design.In Weinand et al. [16] and Weinand et al. [17], the costs of energy system transformations by 2030 and 2050, respectively, are optimized for all 11,131 German municipalities.The former study focuses on complete energy autonomy in the municipalities, i.e., complete self-supply of energy demand by local renewable energies.The study shows that energy autonomy is feasible in 56 % of German municipalities and that the Levelised Costs of Electricity (LCOEs) increase on average by 0.41 €/kWh compared to the optimized energy system without autonomy.Weinand et al. [17] investigated the impact of the opposition towards onshore wind due to the influence of landscape beauty on the LCOEs.LCOEs can increase by up to 0.07 €/kWh when the onshore wind is excluded.
In the present article, a techno-economic optimisation of the municipal energy system transformation is presented with a particular focus on the residential building stock.In contrast to previous studies, which use an aggregated household sector energy demand [8,9,12] or a small number of representative archetype buildings to describe the household sector energy demand transformation [15,17], the present study introduces a spatially highly disaggregated stochastic building stock model and combines it with a municipal energy system optimisation approach.In Weinand et al. [15], already a small number of representative buildings (~10 buildings per municipality) lead to long runtimes of the energy system optimisation model (up to multiple days, depending on technologies considered).However, due to the small number of archetype buildings, no restrictions regarding maximum achievable retrofit and technology modernisation rates were imposed in the model.In this way, optimal investment decisions at the building level could be taken into account, but without considering relevant restrictions regarding the temporal dynamics of the building stock.Therefore, the inertia of the building stock transformation process was not considered in previous studies.This study aims to solve this shortcoming by presenting a stochastic building stock transformation model, upstream to the energy system optimisation (no. 1 in Table 1).This way, the high heterogeneity of the residential building stock is captured by considering each residential building.Furthermore, the building stock model can represent the temporal dynamics of the building stock transformation by taking into account core trends regarding future retrofit rates, retrofit depth, technology modernisation, and expansion rates.Through integrating informative and possible building stock transformation scenarios in the sector-coupled municipal energy system optimisation model, optimal transformation pathways of the local energy system can be determined in line with the national energy system.Besides the transformation of the household sector, local final energy demand developments in the industry, tertiary and transport sectors are integrated into RE 3 ASON to holistically capture the energy demand transformation (no.2).Additionally, the existing municipal energy system optimisation model is further expanded to include relevant established and novel innovative (niche) technologies for the reduction of greenhouse gas emissions (no.3).Finally, the optimisation model RE 3 ASON is extended by a two-stage approach to solving the optimisation problem, which enables the optimisation problem to be solved in hourly resolution (no.4).All extensions are summarised and contrasted with the former model implementations in Table 1.Roof structures, roof orientation Individual building [30] Retrofit state, energy carrier, heating technology, ventilation systems, solar-thermal National level [95] Solar-thermal installations Federal state level [34] New constructions Municipal level [32] Buildings under preservation order National level [35] Heating technology age National level [37] Scenarios for residential air conditioning dissemination National level [86] Information about energy-related household activities National level [85] Electricity consumption of household devices National level [57] Weather data (temperature, irradiation, wind speed) 30 km 2 grid

Methodology
A large amount of data is required to model municipal energy systems (see Table 2).A large part of the data, such as renewable potentials or information on the building stock, is municipality-specific.The base energy system optimisation model RE 3 ASON [18,15] minimizes the effort involved in data collection to be easily transferable to different German municipalities without additional effort.The only input required is the name of the municipality.Based on the location of the municipality, local weather data, spatially resolved population and building stock information and land use potentials for renewable energy sources are obtained and further processed to derive local energy demand and technology-specific renewable potentials.In a downstream optimisation model, total discounted system costs are calculated from a macroeconomic municipality planner perspective for the optimal energy system transformation.Thereby, the size and dispatch of the energy technologies and demand side measures are optimized.This modell is substantially extended in this study.
In Section 3.1, the objective function of the RE 3 ASON model is shown, and extensions made are introduced.Subsequently, the new and extended approaches for modelling the energy demand side transformation are presented in Section 3.2.Finally, Section 3.3 describes the energy supply side extensions and the new process for solving the municipal energy system optimisation model.

Objective function
Fig. 1 presents the objective function of the mixed-integer linear program (MILP) optimisation model for minimizing the total discounted system costs from the point of view of a public welfare-oriented municipality planner.The orange and grey connections to the national energy system describe the different energy carriers and CO 2 flows which are considered in the optimization by using long-term energy carrier c ei a,t,j and CO 2 emission c em a,j price developments from the superordinate national scenario.To adequately capture the high variability of the exchange electricity prices and the supply of fluctuating renewable energies, an hourly model resolution is used in contrast to previous studies (see e.g.Weinand et al. [16]).The blue and green highlighted area describes the costs connected to the expansion c inv i,j and operation and maintencance c op a,j of the local energy system.Investments in technologies x inv i,j take place in the intervals i ∈ Int in between the representative years of consideration a ∈ A. The algorithm used to solve the MILP optimization problem is presented in Section 3.3.
The consideration of multiple household transformation scenarios is represented by the area highlighted in red.In this study, investment decisions regarding the household sector transformation are made at the level of individual residential buildings outside the optimisation model in an upstream simulation model with a high spatial resolution.This way, the high heterogeneity of the residential building stock is considered without making the model intractable.Furthermore, the dynamics of the building stock can be examined in more detail, taking into account different retrofit rates, retrofit depth, modernisation rates for heating technologies and additional technologies like heat recovery units (HRU) and air conditioners (AC).No optimal decisions are made at the individual building level from the point of view of a central municipal planner.However, transformations at the individual building level are derived based on top-down predetermined national framework conditions.To account for the interaction during the transformation of the local energy system and the local residential building sector in the optimisation model, multiple household scenarios are calculated in the upstream simulation model, between which the optimiser can choose in the form of a discrete decision variable x scen h .In addition to the development of the final energy demand, the costs associated with the residential building sector transformation c scen h are calculated in the upstream model.

Energy demand transformation
A spatially highly resolved stochastic simulation model for the transformation of the local residential building stock is developed in Section 3.2.1, that while considering the framework conditions of the national building stock transformations, determines the change in the local building stock.Furthermore, a top-down approach for the development of the final energy demand in the sectors of industry, tertiary and transport is described in Section 3.2.2.

Bottom-up residential building and household sector transformation
Based on the municipal building stock, Fig. 2 presents the generation of different residential building transformation scenarios using publicly available data and information from national energy system Fig. 1.Visualisation of the objective function to minimise total discounted system cost of the municipal energy system transformation.transformation studies.Before the generation of the scenarios is presented, the derivation of the initial building stock is described.

Initial building stock.
To determine the local building stock in 2020, building stock information about size, age, and type of buildings, as well as the number and size of households in 2011 is derived based on 1 km 2 spatially resolved census data [27], Open Street Map building information [28] and the German residential building typology [29] by using the procedure presented in Mainzer [18].A comparison of our approach with current urban building energy modelling developments in literature can be found in the Appendix (see Urban building energy modelling).In order to determine the initial retrofit state of the residential buildings, empirically collected building age class-specific retrofit shares rs ac of the German residential building stock are taken from Cischinsky and Diefenbach [30].Based on these shares, the retrofit state for all buildings bldg of the local residential building stock BS in the year 2016 are sampled by using a Bernoulli distribution according to eq. ( 1). )) Buildings under preservation order are excluded when sampling the retrofit state.Analogously to [31], 20 % of the Multi-Family Houses (MFH) before 1950, 10 % of the Single-Family Houses (SFH) before 1950 and 5 % of all buildings between 1950 and 1994 are excluded from retrofit measures [32].The year of retrofit is estimated by assuming that retrofit cycles have been carried out uniformly since 1990 [33].A piecewise linear dependency between the retrofit probability and the building age is assumed for the probability that a building is renovated in a given year.The relationship is shown in eq. ( 2), where cy bldg describes the construction year of the building.
Depending on the time of the retrofit, different retrofit depths are assumed.Buildings that were refurbished before 2009 are refurbished to the respective new construction standard of the year of retrofit.From 2009 onwards, the U-values of the refurbished buildings are based on the usual retrofit standard of the IWU building typology for Germany [29].A retrofit rate of 1 %/a (full retrofit equivalents) between 2016 and 2020 is used to derive the initial building stock state in 2020.Spatially resolved information at the municipality level is used to include new buildings and building demolitions [34].For the geographic placement of future newly constructed buildings within the municipality, new construction shares of the districts after the year 2000 are used [27].In this way, unrealistically high growth rates in inner-city areas are avoided.No new locations are set for the exact placement of the buildings, but duplicates of existing buildings are created.
For the allocation of the heating technologies, the spatially resolved information from the census survey on the centralisation type of heating 1 is combined with the Germany-wide information on energy carrier and heating technology distributions depending on the building type and building age [27,30].In the first step, each building is assigned an energy carrier ec bldg using a multinomial distribution based on the building's construction year cy bldg , building type type bldg and centralisation type of heating ctoh bldg eq. ( 3).
Based on the energy carrier, the specific heating technology ht bldg is assigned to the respective building in a second step eq.( 4).
The age of the heating technology is estimated based on the building age and the nationally available information on the age distribution of the different heating technologies [35].
Based on the parameterized building stock, the demand for useful energy of household electricity devices, domestic hot water, and space heating is calculated in an hourly resolution based on a combined occupancy and thermal building model described in the Appendix (see Residential energy demand simulation).

Residential building stock transformation.
The transformation of the local building stock is visualized in Fig. 2. In the first step, the buildings to be retrofitted are identified for each simulation year, Fig. 2. Generation of different residential building transformation scenarios using transferrable data and information from national energy system transformation studies.
starting from 2020 until the target year.An annual retrofit rate rr in the form of full retrofit equivalents as well as information on the percentage of deep retrofits rr deep is required as input.For the selection of the buildings to be renovated, the space heating demand after a standard and deep retrofit, as well as the energy-related cost of the retrofit measures c rm are calculated for all buildings of the building stock based on the component-specific surface areas sa bldg comp , U-values u bldg comp , prices c comp and an assumed heat conductivity λ of 0.035 W/(mK) according to Hinz [36] eq. ( 5).
Using the Levelised Cost Of Saved Heat (LCOSH), calculated according to eq. ( 6), and the amount of saved heat per m 2 ΔSH of the respective retrofit measures, retrofit weightings are calculated.In addition, the age of the building is considered in selecting the buildings to be renovated, analogous to determining the initial residential building stock.Based on these weightings, a multinomial distribution is used to identify the buildings that go through a retrofit cycle in the respective simulation year and to determine the retrofit depth of the measure undertaken eq.(7).
Subsequently, based on the simulated distribution and age of the HRUs in 2020, the future distribution of HRUs is calculated using target shares from selected national scenarios for the future representative years of consideration.For the dissemination of the HRU systems, it is assumed that they are only installed in newly built or well-insulated buildings with a maximum wall U-value of 0.3 W/(m 2 ⋅K).
The iterative process for simulating the dissemination of heating technologies in the future local building stock is described in Fig. 3.
Information about the local building stock, future heat generation technology shares from national scenarios, historical heating technology transition rates, and assumptions regarding local modernisation rates are required as input parameters.Historical heating technology transition rates are derived from BDEW [35].The probabilities for a heating technology transition are calculated based on the heating technology type and age (w age ) as well as historical transition rates (w htr ).In addition, information on the time of retrofit from previous calculation steps (w tor ) and technology-specific requirements (w tsr ) (e.g.heat pumps can only be installed in buildings with a space heating demand < 120 kWh/ m 2 /a) are taken into account.Furthermore, in areas where many buildings already have a district heating connection, the probability of a connection to the district heating network increases in proportion to the number of already installed connections (w dh ).Consequently, the probability of a heating technology change P bldg ht old/new is calculated according to eq. ( 8) for all buildings and all possible new heating technologies.Based on these transition probabilities and the assumed annual modernisation rate, the multinomial distribution described in eq. ( 9) is parameterized for each building of the local building stock.

P bldg
Starting from the initial heating technology transition distribution parameterized in eq. ( 9), the iterative process described in Fig. 3 occurs.The heating technologies in the existing building stock and the newly added heating technologies in the newly constructed buildings are calculated in annual steps up to the following reference year (e.g., 2030/ 40/50 in Fig. 3).The dissemination of the heating technologies in newly constructed buildings follows the trends in the existing building stock.Further, it considers optional higher requirements, e.g., installation bans (e.g., no new heating systems based on fossil fuels).The calculated shares of heating technologies in the reference year are compared with the target distributions of heating technologies in the reference years derived from the national scenarios considering the local initial state.An error in the form of a mean absolute error (MAE) is calculated based on the deviations of the distributions.Based on the heating technology- specific deviations, the historical transition rates w htr are adjusted and the heating technology transition is calculated in an iterative way till the MAE reaches a pre-defined threshold.If, due to the local characteristics of the building stock, the MAE does not fall below the specified threshold, the algorithm stops after a certain number of iterations without improvement.
The dissemination of cooling devices in the form of air conditioners in the local residential building stock is implemented in the model based on the scenarios defined by Kenkmann et al. [37].Two scenarios for the penetration of air conditioning systems in the household sector are analysed (low: ~ 14 %, high: ~25 % of households use ACs).As in Kenkmann et al. [37], the severity of the scenarios depends negatively on the assumed retrofit rate (range of retrofit rate: 1 %/a -2.5 %/a).Furthermore, it is assumed that ACs are mainly installed in wellrenovated buildings and that, on average, 50 % of the living area is cooled [37].

Residential building technology design and operation.
For the appropriate dimensioning of the heating technologies, the design heat load is calculated based on DIN EN 12831 [38], taking into account the thermal standards of the building envelope.The design heat load ensures the required heat demand can be provided even at the lowest winter temperatures without solar and internal gains.Combined heat and power plants (CHP) and solar thermal plants (ST) are not designed to cover 100 % of the heating demand.The size of the CHP is determined by using a target number of full load hours (5000 h/a) according to BKWK [39], assuming that the CHP is operated in a heat-driven way.The solar thermal systems are designed depending on the available roof area and type of use (combined plant or only for DHW).
Technical parameters from the technical reports of the Danish Energy Agency are used for the simulation of the technology operation [40].The coefficient of performance of the heat pumps is calculated in hourly resolution depending on the heat source temperature (outside air or geothermal heat) and the heat sink temperature.The heat sink temperature depends on the outside temperature and the feed temperature of the heat distribution system, with the feed temperature being estimated depending on the age of the building [31,41].The energy efficiency ratio (EER) of the air conditioner is determined in hourly resolution depending on the outside temperature and is calculated according to the procedure presented by Meissner et al. [42] and Cherem-Pereira and Mendes [43], with the future development of the EER being assumed analogous to Kenkmann et al. [37].For the simulation of the thermal energy supply of the solar thermal systems, the irradiation is calculated for all roof areas of the local building stock.Therefore, based on satellite data, all useable roof areas are identified using the method presented in Mainzer et al. [98].Representative area orientations are determined using the k-means method based on azimuth and inclination.Radiation simulations are then carried out for the representative areas with the PV-Lib [97].The heat supply for all solar thermal systems is calculated based on the method presented by Lindberg et al. [44].

Industry, tertiary and transport sector transformation
For the design of the municipal energy system, the transformation of the final energy demand in the sectors of industry, tertiary and transport needs to be considered.Due to the greater heterogeneity of demand in contrast to the household sector, publicly available data from the Sol-idEU scenario of the ExtremOS project is used [45].In contrast to the presented household model in Section 3.2.1 the ExtremOS data are provided by a top-down approach that disaggregates national energy demand to all European NUTS3 regions.The data are available in hourly resolution differentiated by the final energy source and the individual sectors.Furthermore, the demand transformation from the initial state in 2020 to 2050 is provided in five-year steps.The final energy demand is available for the weather year 2012.In order to analyze the energy system transition for different weather years, the final energy demand is adapted to different years based on the daily temperature temp d and day categories dc of the target year eq.(10,11)

Energy supply transformation
The base model RE 3 ASON [18] is further extended to include all relevant technologies considered in the national energy system transformation studies discussed in Section 7.1 in the Appendix (see National energy system transformation).Integrated technologies in the base model are wind turbines, rooftop photovoltaic (PV) systems, biomass technologies, natural gas CHPs, lithium-ion batteries, and deep geothermal power plants.The procedure for the transferrable determination of the local renewable potentials for wind turbines, rooftop PV, and biomass systems is based on local land use potentials based on Open Street Map and satellite data and is described in detail in Mainzer [18].The transferrable methodology for determining the geothermal potential and implementing the simultaneous heat and power generation from geothermal plants is described in Weinand et al. [15,46].
The energy system model is expanded as part of this study to include all technology options and energy carrier flows shown in Fig. 4. Based on the potential for freestanding PV determined at the NUTS3 level in Ebner et al. [47] the available area potential A f in the respective NUTS3 region is deduced.Thereby, the land use competition is considered for the expansion of freestanding PV and solar thermal plants according to eq. ( 12).Optimisation variables are presented in bold.P fPV i,a describes the capacity of freestanding PV installed in year a, from investment interval i with a specific area consumption of A fPV i .A fST i,a describes the installed solar thermal area in year a from the investment interval i.
To cover the future demand for hydrogen in the industrial, transport and energy sectors, the model includes the possibility of importing or generating hydrogen in an electrolyser using locally generated electricity and storing it in pressure storage tanks.Furthermore, investing in a methanation plant to convert hydrogen and CO 2 into synthetic natural gas is possible.The required CO 2 can be captured by investing in carbon capture (CC) systems to upgrade CHPs or directly from the atmosphere by investing in direct air capture systems (DAC).In addition to electricity, heat at a temperature level of ~ 100 • C is required to operate a low-temperature DAC system [48].Three sources can provide hightemperature heat (>100 • C).The engine exhaust of a CHP can be recovered, which has a higher specific heat content than the engine jacket water, intercooler and lubricating oil [49].The extraction of heat at high and low-temperature levels (Q ) and the provision of electricity P CHP el t,a taking into account the respective efficiencies η of the CHP is shown in eq. ( 13) for every timestep t in every year a.
A heat pump can be used to upgrade heat from low-temperature heat sources.If available, the local district heating network can be used so that the inlet temperature temp in of the heat pump would be set equal to the temperature of the district heating network temp dh .If there is no district heating network, ambient heat can be used as a heat source (temp in = temp amb ).According to eq. ( 14), together with the exergetic efficiency η exergy of the heat pump, the ratio between the electrical power P HP t,a and the thermal output Q HP t,a of the heat pump is defined.
Furthermore, a geothermal power plant can be built in municipalities with geothermal potential.For achievable hydrothermal temperature levels above 100 • C, the implementation of the geothermal power plant presented in Weinand et al. [15] is expanded to include the possibility of extracting high-temperature heat according to eq. ( 15) and eq.( 16).: geothermal injection temperature).The energy balance for heat extraction for the district heating network (eq.( 17)) is identical to Weinand et al. [15].
The maximum volumetric flow rate VB of the geothermal plant, the specific heat capacity of the geothermal water c p,w as well as the water density ρ w are assumed analogously to Weinand et al. [15].
Due to the large number of technology options in which the optimiser can invest in the representative years and the associated large number of (structural) binary decision variables that are required, for example, for the operation of the geothermal plant (see Weinand et al. [15]), the MILP optimisation model cannot be solved in a reasonable time in closed form over several years in hourly time resolution.To reduce the complexity of the optimisation problem, the time series aggregation method presented in Kotzur et al. [50,51] is integrated into RE 3 ASON and used in this study, which was specially developed for energy system optimisation problems with time-coupling restrictions.The optimal choice of structure variables is determined in the first optimisation step based on the aggregated time series structure.In a second optimisation step, the operation for the structural design from the first optimisation step is then optimized based on the disaggregated time series structure (similar procedure to Bahl et al. [52] and Kotzur [31]).By integrating the time series aggregation into the workflow of the transferable methodology presented, the complexity of the optimisation model can be adapted to the available computing resources with little effort, taking into account a slightly reduced computational accuracy (depending on the considered system components [50]).The MILP optimisation problems in this study are solved using the Gurobi solver and a relative MIP gap of 0.5 %.All underlying basic constraints of the RE 3 ASON optimisation model, such as hourly energy balances, capacity expansion constraints through, e.g., space restriction or state of charge equations of storage technologies can be found in Weinand et al. [17] and Mainzer [18].

Case study
To illustrate the methodology presented, an exemplary case study for the Central European city of Karlsruhe in Germany is carried out.Karlsruhe is a city of approximately 308,000 inhabitants whose final energy demand can be divided nearly equally between the household (24 %), industry (26 %), tertiary (24 %) and transport (26 %) sectors [53,54].A district heating network utilizes waste heat from industrial processes (61 %), CHP (18 %) and a gas-fired heating plant (21 %) to supply 25 % of the dwellings in Karlsruhe with district heating in 2020 [55,56].The energy supply side is characterized by relatively high solar irradiation (1187 kWh/m 2 /a; German average 1122 kWh/m 2 /a) and a high potential for geothermal plants due to high achievable hydrothermal temperatures (130-160 • C) [15,57].Karlsruhe is used as a convenience sample, and further validation of the results of this case study is planned in follow-up work in cooperation with local energy utility companies and infrastructure analysts as part of the research project mentioned in the acknowledgment.
The framework conditions for the case study are presented in Section 4.1.Subsequently, the transformation of the local household sector, a significant model input for the municipal energy system optimisation, is discussed in Section 4.2.Finally, Section 4.3 analyzes the municipal energy system, considering the transformation of sector-specific demand and local renewable potential.

Economic, environmental and technological framework conditions
The exogenous parameters specified in this study concerning energy carrier import/export price and emission development, CO 2 price development and assumptions regarding grid usage fees for transmission networks have a major impact on the decentralisation or centralisation of future local energy supply.Based on the studies described in the Appendix (see National energy system transformation), the framework conditions from Sensfuß et al. [58] are taken for the development of energy carrier prices and emissions as well as for CO 2 emission certificate prices.The reason for choosing the framework parameters of Sensfuß et al. [58] is the high transparency and temporal resolution of, e. g., electricity prices compared to the studies with the target of achieving climate neutrality in 2045.In addition to importing CO 2 -emitting energy carriers before achieving climate neutrality in 2050, the local energy planner is provided with the possibility of importing emission-free carbon-based energy carriers in the form of synthetic methane and Fischer-Tropsch Fuel at import prices according to Hampp et al. [59].Future developments of technology parameters and price developments are assumed according to the technical reports of the Danish Energy Agency [60].Size-independent and size-dependent prices for investments in heating technologies are assumed analogous to Kotzur [31].

Household sector transformation
To illustrate the interactions between the local building sector and the national energy system, 192 transformation scenarios for the local residential building sector of the municipality Karlsruhe in Germany are calculated according to Fig. 2. The scenarios differ in terms of the retrofit rate (8x), the level of the target U-values of retrofit measures (3x), the dissemination of heat recovery units (2x), and the dissemination of the heating system technologies (4x).The definition of the range of the parameters in Table 3 is inspired by the national scenarios "Climateneutral (CN)-gas" and "CN-electricity" by Sensfuß et al. [58].In comparison to the "CN-gas" scenario, the "CN-electricity" scenario has a more ambitious yearly retrofit rate and retrofit depth (lower U-values) as well as higher heat pump shares in the future building stock.The future achievable retrofit rate is one of the most frequently discussed parameters in building stock studies, as discussed in the Appendix (see National energy system transformation).Consequently, the influence of the retrofit rate is particularly examined by considering a wide range of possible future developments between the investigated representative years.Intermediate heating technology dissemination scenarios are determined by interpolation between the two extreme scenarios.When determining the future retrofit depths (U-values), a distinction is made between three scenarios in which achievable U-values for new  constructions (nc) as well as conventional (cr) and ambitious retrofit (ar) measures are defined (cf.Table 3).Fig. 5 shows the results of the calculation of the final residential energy demand development for space heating (SH) and domestic hot water (DHW) in Karlsruhe for the "CN-electricity" scenario, one of the 192 different scenarios.Based on the superordinate national transformation of the heating system technology stock, the transformation of the heating technologies in the local building stock is derived.The case study presented here shows a future modernisation rate of 3 %/year between 2020 and 2030, based on empirically derived historical modernisation rates [30], and an increase of 4 %/year between 2030 and 2050 is assumed in all scenarios.The "CN-electricity" scenario shown in Fig. 5 is based on a strong increase in the share of heat pumps in the national building stock, especially between 2030 and 2040, which cannot be fully achieved in the local building stock due to the local conditions and the assumed maximum achievable modernisation rate.Therefore, an increased local expansion of heat pumps is seen between 2040 and 2050.In the described scenario, the final energy demand for space heating and hot water is reduced by 48 % between 2020 and 2050.While oil and gas provided around 69 % of the final energy in the initial state in 2020, in 2050 there is only a small share of gas boilers left in the local building stock and the majority of the buildings are supplied by heat pumps and district heating systems, which cover for 88 % of final energy demand (environmental heat for heat pumps included).
In contrast to the "CN-electricity" scenario, Fig. A10 describes the developments of the local building stock for the "CN-gas" scenario.The share of heat pumps in 2050 is significantly lower in the "CN-gas" scenario compared to the "CN-electricity" scenario.Due to the lower retrofit rate of 1.33 % per year, the lower requirements for the retrofit measures in the form of less ambitious U-values and an assumed weaker dissemination of heat recovery units in contrast to the "CN-electricity" scenario, a reduction in final energy demand of 36 % is reached in the period from 2020 to 2050.While the share of synthetically produced natural gas in the "CN-electricity" scenario falls to around 3 %, the gas share in the "CN-gas" scenario is significantly higher at 40 % in 2050.
In the following, the scenarios "CN-gas" and "CN-electricity" are compared with the other 190 scenarios.Fig. 6 a.) shows the levelised cost of saved heat (LCOSH) through wall, roof, floor and window retrofit measures against the respective saved heat for space heating over the entire period of consideration (2020 till 2050).The LCOSH is calculated according to eq. ( 5) and ( 6) assuming an interest rate of 5 %/a and a retrofit measure lifetime of 40 years for all components.Only energy-Fig.6.Comparison of the 192 residential building stock transformation scenarios for the municipality of Karlsruhe regarding a.) the Levelised cost of saved heat, b.) total discounted system cost and CO 2 emission as well as their temporal occurrence c.), d.).related additional costs are considered, according to Hinz [36].Due to the low retrofit rate of 1.33 %/a in the "CN-gas" scenario and the less ambitious retrofit depth compared to the "CN-electricity" scenario, the total saved heat is 20 % lower in the "CN-gas" scenario.The energyweighted average LCOSH in the "CN-gas" scenario (0.039 €/kWh) is 0.014 €/kWh lower in comparison to the LCOSH in "CN-electricity" scenario (LCOSH 0.053 €/kWh).On the one hand, the lower LCOSH can be explained by the selection of the buildings that go through a retrofit cycle (selection according to eq. ( 7)).Buildings with low LCOSH and high specific heat savings are given preference for retrofit.Therefore, the 0.33 % of the additional buildings retrofitted in the "CN-electricity" scenario tend to have higher LCOSH than the first 1.33 %.On the other hand, the more ambitious U-values in the "CN-electricity" scenario mean that more heat is saved per retrofit.However, the marginal utility of a retrofit decreases with increasing retrofit depth.
Fig. 6 b.) compares the total discounted system cost (TDSC) and the energy-related CO 2 emissions of the local building sector transformation for the "CN-electricity" and "CN-gas" scenarios and the scenario with the lowest TDSC "CN-opt".The TDSC consists of capital expenditures (CAPEX) in retrofit measures (wall, roof, …) as well as heating/cooling systems (heat pump, boiler, …), expenses for the maintenance of the technologies (O&M) and expenses for the procurement of energy carriers and the purchase of CO 2 emission certificates.The prices for the procurement of energy carriers are composed of the market prices and the network charges for transmission and distribution (see Table A6).Further levies and taxes are not taken into account due to the perspective of a central municipal planner.In contrast to the network charges for gas and electricity grids shown in Table 4, which represent average grid charges across all sectors (industry, tertiary, household), household sector-specific network charges are used here according to BEE [61].The household-specific charges are further differentiated and reduced network charges for power-to-heat applications are assumed for the heat pump electricity demand [61].Under the defined framework conditions, the TDSC of the "CN-gas" scenario is 0.6 % lower than the TDSC of the "CN-electricity" scenario, whereas the cumulated CO 2 emissions in the observation period in the "CN-electricity" are over 14 % lower.The composition of the TDSC shows that the capex in the "CN-electricity" scenario is 20 % higher than the capex of the "CN-Gas" scenario due to the higher retrofit activities, the increased expansion of heat pumps and HRU, whereby the costs for the procurement of energy carriers are 7 % higher in the "CN-gas" scenario.The "CN-opt" scenario shows a substantial heat pump expansion as in the "CN-electricity" scenario.In contrast to the "CN-electricity" scenario the retrofit rate is increased from 1.66 %/a to 2 %/a, and the retrofit depth is reduced to the level of the "CN-gas" scenario.
Fig. 6 c.) shows the temporal development of the total annual system costs and the energy-related CO 2 emissions caused by the residential building sector.The color of the background scenarios is chosen depending on the heating technology dissemination (four degrees of differentiation), whereby red is chosen for scenarios with a high proportion of gas boilers (analogous to "CN-gas") and blue for scenarios with a high proportion of heat pumps (analogous to "CN-electricity").Fig. 6 d.) presents the development of the annual total costs of the residential building sector, differentiated according to cost type.The three  exemplary scenarios are highlighted in the foreground, while the spread of the 192 scenarios is shown in the background.All scenarios show an increase in costs between 2020 and 2040.The main reasons for the increase are: On the one hand, the increase in procurement prices for energy sources (including CO 2 emission price) (see operation in Fig. 6  d.)) and on the other hand, the increase in costs associated with investments in the building envelope and heating technology modernisation.While the increase in procurement prices is mainly reflected in the scenarios with a high proportion of gas boilers and a lower retrofit rate, the increase in the scenarios with a high proportion of heat pumps and higher retrofit rates is more driven by the capital expenditures, especially between 2030 and 2040.The difference in the course of the total system costs between the "CN-opt" scenario and the "CNelectricity" scenario can be explained by the lower renovation depth and the less extensive expansion of HRUs and the energy carrier costs saved due to the higher retrofit rate.The delta in saved CO 2 emissions is particularly evident in the year 2040 between the scenarios and can be explained by the faster reduction of the CO 2 emission factor of the electricity mix (30 g/kWh CO 2 emission) compared to the gas mix (150 g/kWh CO 2 emission) of the national energy system in 2040.

Municipal energy system transformation
The transformation of the local energy system is based on the sectorspecific final energy carrier demand developments and the local potential for the expansion of renewable energies.The energy demand development of the four demand sectors in Karlsruhe up to the year 2050 can be found in Fig. A11.While the optimisation model for the Fig. 8. a.) Illustration of the differences in TDSC and CO 2 emissions without local energy system expansion (a) and with local energy system expansion (b,c,d,e).b.) Visualisation of the differences in TDSC and CO 2 emissions of the measures presented in Table 4.When balancing indirect CO 2 emissions, the emissions from the upstream chain are taken into account, while direct emissions describe emissions caused by local combustion of carbon-based energy carriers.

Table A5
Comparison of studies from 2021 to achieve climate neutrality at the German and European level (GHG: greenhouse gas, CN: climate neutrality).transformation of the household sector is given a choice between one of the 192 transformation scenarios, the demand developments in the industrial, tertiary and transport sectors are fixed.
To cover the final energy demand, energy carriers can be imported from the higher-level national energy system, or locally self-generated electricity, heat and renewable gases can be used.The local potentials for biomass plants and rooftop photovoltaic systems can be found in Fig. A12 and Fig. A13 in the Appendix.Besides the fully transferable  methods, one manual specification is made to consider the local waste heat supply.Local sources of waste heat can be integrated into the model by specifying the heat output and the temporal availability of the waste heat sources.Karlsruhe's primary sources of waste heat are a refinery with a waste heat potential of 90 MW and the waste heat from a coalfired power plant with a waste heat potential of 220 MW [55,56].In this study, it is assumed that both waste heat sources will be available until 2035.From 2022, the waste heat from a paper factory is also considered in the model with an assumed heat output of 30 MW and availability over the entire observation period of the study [55,56].Furthermore, Karlsruhe is located in the Upper Rhine Graben and has a high geothermal potential.Hydrothermal temperatures between 130 and 160 • C can be reached at a drilling depth below 5000 m [15].Furthermore, a technical potential for the installation of one wind turbine exists.
Five different transformation scenarios a)-e) are discussed in detail in the following (Fig. 7).In scenarios b), c) and d) the yearly expansion capacity of photovoltaics is restricted to avoid unrealistic high expansion rates compared to nationwide photovoltaic expansion.Therefore, local expansion rates for rooftop and freestanding photovoltaics are derived from the PV expansion rates calculated in the national scenarios exp nat PV,i from Section 7.1 in the Appendix (rooftop (rt) PV: 6 GW/a, freestanding (fs) PV: 10 GW/a).The locally required expansion rate exp loc PV,i is derived as a function of the share of the technical photovoltaic potential pot loc PV,i of the municipality to be examined in comparison to the national potential pot nat PV,i according to eq. ( 18).
In scenario e) the upper boundary for the rooftop and freestanding photovoltaic expansion is removed.
Starting from 2020, Fig. 7 presents five transformation scenarios (ae).In scenario a) the local renewable expansion of the energy system is permitted.In scenarios b), c) and d) the local energy system is expanded in a cost-optimal way, but the household scenarios are predetermined (b) "CN-opt", c) "CN-electricity", d) "CN-gas" (regarding Section 4.2)).While in scenarios b), c) and d) the yearly expansion capacity of photovoltaic plants is restricted, this restriction is removed in scenario e) in comparison to scenario b).All transformation scenarios shown in Fig. 7 reach zero or negative CO 2 emissions in 2050.Even in scenario a) without local energy system expansion, zero CO 2 emissions are achieved since energy carrier imports are CO 2 neutral in 2050 (see Table A6).The TDSC associated with scenario a) are higher than scenarios b) to e) with local energy system expansion.By expanding the local energy system, the TDSC and CO 2 emissions can be reduced by 222 M€ and 1.14 kt over the observation period (see Δ ab in Fig. A10 a.).While the energy imports and CO 2 emissions differ in scenarios b) to d) due to the different Fig. A12.Spatial representation of the biomass plant locations and the potentials for electricity and heat generation, as well as the LCOE and LCOH associated with the generation for the municipality of Karlsruhe.The calculation of the LCOE and LCOH is based on an interest rate of 5 %/a and an assumed system lifetime of 20 years.The potentials are calculated based on the procedure presented in [18].household transformation scenarios, local electricity and district heating generation expansion is comparable.In all three scenarios, the potential for wind power and photovoltaics is fully exploited considering the maximum yearly expansion rates explained above (PV (rt): 16.7 MW p /a, PV (fs): 1.8 MW p /a).
Furthermore, investments in biomass plants for the energetic use of waste and wood residues are undertaken in the first investment period between 2020 and 2030 and are further equipped with carbon capture devices from 2040 on.On the other hand, biogas upgrade plants are only built in the last investment period between 2040 and 2050.While the generated biogas is used directly to cover the gas demand in scenario d), in scenarios b) and c) a Solid Oxygen Fuel Cell (SOFC) CHP plant is built to provide heat to the district heating network and electricity to the local grid.After discontinuing the two primary waste heat sources, from 2035 scenarios b) to e) rely on geothermal energy, waste heat from biomass plants and local waste heat from the paper factory to cover the base load of the district heating network.A heat pump in combination with a gas boiler is used to cover the heat peaks (see Fig. A14).By removing the annual maximum expansion capacity in scenario e), the optimal local average expansion rate between 2020 and 2050 is 3.3 times faster than the photovoltaic expansion rate of the national system.To increase selfconsumption, Lithium-ion batteries are installed from 2040 on.Through the extreme expansion of photovoltaics, TDSC and indirect CO 2 emissions can be further reduced by reducing external electricity purchases in 2030 and 2040 (see Fig. 8 a.)).
In other scenarios, the effects of individual measures on the TDSC and CO 2 emissions of the local energy system transformation are quantified in Table 4 and visualized in Fig. 8b.).Scenario b) is taken as the initial scenario (see Fig. 8) and additional measures are defined or excluded based on this scenario.The ratio between ΔTDSC and ΔCO 2 describes the economic and ecological efficiency of the individual measures.If the ratio is positive, the measure has a clear positive or negative impact on TDSC and CO 2 emissions.If the ratio is negative, no clear statement can be made about both factors.The impacts of measures b1) to b6) are unambiguous.Increasing the local expansion rate of photovoltaics by 10 % compared to the national expansion rate lowers costs and CO 2 emissions.The photovoltaic expansion has high economic efficiency when comparing the efficiency ratio of measure b1) with the other measures.On the other hand, measure b6) which describes the change from a heat supply in the household sector with high proportions of heat pumps (see Fig. 5) to a scenario with higher proportions of gas boilers (see Fig. A10) is particularly ecologically efficient, but does not make a big difference when considering the TDSC.When biomass plants are excluded, these are partly replaced by heat pumps and gas-fired CHPs, while large-scale heat pumps exclusively replace the geothermal plant.If, in comparison to scenario b), additional 1 Mt CO 2 emissions have to be reduced, this is done as in measure b7) by a low-temperature direct air capture (DAC) plant.The DAC plant is installed in 2050 and captures CO 2 out of the atmosphere by using hightemperature heat (100 • C) from the geothermal plant and electricity as input.Subsequently, the captured CO 2 is liquefied, transported and stored long-term.The basis for the economic evaluation is a CO 2 price of 150 €/t and costs of 40 €/t for the transport and final storage of CO 2 in 2050 [62].If DAC is excluded as an investment option (measure b8)), synthetic carbon-neutral gas imports achieve the reduction in CO 2 emissions in 2040 and increased carbon capture of exhaust gases from the SOFC plant in 2050.

Discussion and outlook
To adequately account for temporal dynamic developments in municipal energy system transformation scenarios, the present study extends an existing municipal energy system optimization approach by a stochastic bottom-up residential building stock model.In contrast to the adopted approach from [18,15,16,17], in which investment decisions in retrofit and other efficiency measures for individual representative buildings are determined within the energy system optimisation model, the investment decisions in the present study are determined outside of the municipal optimisation in a stochastic simulation for every residential building of the municipality.While the approach presented in [18,15,16,17] allows to make optimised investment decisions for individual representative buildings, it is not possible to adequately consider the dynamic changes in the residential building stock, as already a small number of representative buildings leads to long model runtimes.Due to the simplified representation of only a few representative buildings, the model does not consider upper limits for maximum practicable retrofit and technology modernization rates, which means that the entire building stock can be modernized from one year to the next.In our approach, dynamic processes are considered in an upstream simulation model in the form of annually feasible retrofit and technology modernization rates.Furthermore, future heating technology transformations are implemented, taking into account the characteristics of the local residential building stock and future target states from national scenarios.By shifting the optimization decision away from representative buildings to choosing between different residential building stock transformation scenarios, temporal dynamic transformation processes are now considered in the optimization model.As a result of the simulation, the building retrofit status and the technological equipment are available for each building and each simulation year so that infrastructure simulations for electricity, gas or district heating networks can be carried out based on the results of this study.
The simulation decision as to whether a building undergoes a retrofit cycle in a specific year is based on technical parameters such as building age and potentially saved heat and economic parameters such as the

Table A6
Overview of the framework conditions for energy carrier procurement prices, grid charges and emission factors based on [58,61,59,96].A cost increase of 2 %/a is assumed for the grid charges of the gas network.LCOSH of the retrofit measure.Thereby, the aim is to assist local decision-makers in identifying buildings in need of retrofit from a techno-economic point of view to develop support measures depending on the building owner structures.Another approach would be to consider the ownership structure when selecting the buildings that go through a retrofit cycle [63].Similar factors could also be considered in future work when deciding to modernize heating technologies.However, this would require further spatially high-resolution information on ownership structures and empirical information about owner dependent investment preferences.The residential building stock scenarios presented in this study are derived based on four core trends regarding the retrofit rate, depth, technology dissemination and HRU uptake.Other potentially relevant trends, such as changes in behavior, e.g., in the form of increased work from home, such as in the COVID-19 pandemic, or the impact of climate change on future heating and cooling demand are not considered in this work.While short-term changes in behaviour during the COVID-19 pandemic led to shifts in energy demand [64,65], long-term behavioural changes are uncertain.Therefore, the simulation of the occupant behavior of the individual households, which is the basis for the simulation of the household appliances and the thermal building demand, is based on historical time-use survey data (see Residential energy demand simulation in the Appendix).In future analyses, the potential influence of behavioral changes on the structure of the energy demand profile could be examined by adjusting the underlying time-use survey data based on projected socio-demographic scenarios.In contrast to long-term behavioral changes, the influence of climate change on energy demand, energy generation and energy infrastructure is undisputed [66,67,68].However, in this study we decided to analyze the effects of the four core trends mentioned above independently of climate change based on an average historical weather year (2017).In follow-up studies, the impact of climate change could be integrated by using high resolution climate projection datasets from, e.g., the EURO-CORDEX project [69].Especially, high-probability, low-impact conditions should be considered in future energy system design studies since they can significantly impact renewable energy integration levels and system cost [67].
The results of the household sector transformation of the case study for the municipality of Karlsruhe show that under the assumed economic framework conditions, a substantial electrification of the heat supply with a high proportion of heat pumps and an annual retrofit rate of 2 %/a together with less ambitious U-value requirements lead to the lowest TDSC and CO 2 emissions.Scenarios with high U-value requirements and high proportions of HRU lead to higher TDSC.This means that the marginal cost of saving the last few kWhs is higher than the cost per kWh of heat supplied.It must be considered here that only energy-related additional costs are used for the economic evaluation of the efficiency measures (full cost considerations would increase the effects described) and only the costs for generation, transport and CO 2 certificates are included for the purchase of energy carriers.Microeconomic assessments of the efficiency measures from a building owner perspective can come to different conclusions if household procurement costs for energy carriers are considered.A real interest rate of 5 %/a is used for all investment decisions in this study.Investments in retrofit measures with high initial costs and long lifetimes would be valued even more favourably if interest rates were assumed to be lower.Furthermore, when interpreting the results, it must be considered that they are subject to many uncertainties with regard to assumptions about the development of energy carrier prices, technology efficiency and price developments.
The results of the municipal energy system optimisation show that, from the point of view of a central social planner, the expansion of local renewable energies is advantageous for reducing overall system costs and minimizing local emissions: a significantly faster expansion of local photovoltaic potentials compared to national expansion scenarios leads to reductions in TDSC.This could be partly explained due to the optimistic assumptions regarding the development of the technological efficiency of photovoltaics (see Fig. A13), which is based on the [60].Furthermore, it should be considered that this study does not examine any effects of the local energy system transformation on the national energy system and that, therefore, the local feed-in has no influence on market pricing.If many municipalities would increase variable renewable expansion, the market value of renewable feed-in could be reduced, which could have a feedback on investment decisions.Since network restrictions in the energy distribution networks are not considered in this study, further analysis should be conducted to determine whether the energy system expansion determined in this work can be implemented, taking local infrastructures into account.
While most of the analysed technologies are already established on the market, technologies such as direct air capture are still in the development stage and should therefore be viewed critically when planning future energy systems.The model presented in this work optimizes the local energy system transformation under perfect foresight.Thus, anticipated certain future developments by the optimizer, which are based on assumptions with a high degree of uncertainty, can lead to misleading decisions.Technologies that are still under development, such as direct air capture technologies, should not be used as an excuse to emit more emissions today to offset these emissions in the future.
In Karlsruhe, after the waste heat from the local refinery and the coal-fired power plant is taken out of the system in 2035, a geothermal power plant is built, which, together with the waste heat from the paper factory and the biomass plants, covers the base load of the district heating demand.While the local waste heat sources still have to be provided manually, methods for the automated identification of waste heat potentials should be integrated in the future.While waste heat potentials are currently only considered in the form of available power, in the future, different temperature levels should also be included in the model for more efficient heat integration.A useful database for this is the district heating atlas [70], which tries to collect scarce public information on district heating systems to provide it on a central platform.While scenario independent district heating transmission costs are assumed in the current study, the existing model could also be expanded to include various district heating expansion scenarios with different grid fees.For this, however, approaches for the industrial and tertiary sectors would first have to be developed that assign the processdependent useful heat demand of the sectors to the respective locations of the non-residential buildings, as is the case in the residential building sector.Furthermore, future studies could analyse the impact of low temperature district heating networks in combination with booster heat pumps in order to use heat sources more efficiently and to minimize heat transfer losses in the district heating network [71,72].
In addition, for the industrial, tertiary and transport sectors, only developments with a high degree of electrification based on the solidEU scenario from Guminski et al. [45] are taken into account in this study.Scenarios with higher shares of hydrogen or synthetic hydrocarbons in the future final energy demand of the respective sectors could lead to different expansion strategies of the local energy system and should be analysed in the future.
While a holistic validation of energy system optimizations for future developments is challenging, we have performed plausibility checks and validations of interim results.For example, the amount of residential buildings in the single districts from OpenStreetMap deviates by about 10 % from empirical data.Furthermore, the final energy demand of this study's household sector simulation of 2.1 TWh/a in 2020 is comparable to results from other studies, with 2.0 TWh/a [54] and 2.5 TWh/a [45].The difference to the higher value of Guminski et al. [45] can be explained by the different balancing approach, which also incorporates environmental heat.In addition, as presented in Fig. 7, the initial calculated CO 2 emissions in 2020 are in line with historical data [55,56].The future development of the total final energy demand across all sectors deviates from the local climate protection concept by only about 5 % in the reference years considered [54].In order to further improve the accuracy of the initial state of the spatial heating system distributions in future studies, updated data from the 2021 census should be used as soon as it is published.The restriction to purely publicly available input data can lead to buildings being assigned to grid-dependent energy carriers without having a connection to the respective grid infrastructure since detailed information about the energy supply networks is not publicly accessible.Additional location specific information about the energy carriers used for heating in the upcoming census [73] will help reduce incorrect assignments.When further using the results of this study in downstream analysis, the accuracy of the publicly available data basis should be considered with regard to the question to be examined.If necessary, the underlying data should be enriched with expert data, e.g., in the case of detailed power flow calculations.

Conclusion
Given the constantly changing political framework conditions for achieving increasingly ambitious climate protection goals, decision support tools are needed that can easily identify local conditions and support local decision-makers in the formulation of energy system transformation strategies.
This study extends the highly transferable energy system optimisation model RE 3 ASON to consider temporally dynamic transformation processes of the local energy system supply and demand side in line with national greenhouse gas mitigation strategies.To capture dynamic temporal developments and the high heterogeneity of the local residential building stock, an existing energy system model is extended by an upstream dynamic building stock transformation model.By considering higher-level framework parameters from national scenarios and local initial building stock conditions, multiple household transformation scenarios can be calculated and further used as input in an energy system optimisation.To comprehensively consider the transformation of local energy demand and supply transformation, RE 3 ASON is further extended to include the final energy demand transformation of the industry, tertiary, and transport sectors and a variety of additional greenhouse gas reduction technologies in combination with maximum yearly expansion rates.By the integration of a two-step optimisation approach we demonstrated that the formulated optimisation problem can be solved in hourly resolution.
192 building stock transformation scenarios are calculated for an exemplary case study of the German city of Karlsruhe.The results show that for the cost-minimal transformation of the local building sector, the retrofit rate should be increased to 2 %/a and that, in addition to significantly lower CO 2 emissions, scenarios with high shares of heat pumps can be economically advantageous compared to scenarios with high shares of gas boilers, despite higher capital expenditures.The municipal energy system transformation results show that an accelerated expansion of photovoltaics compared to the national reference system can be economically advantageous and leads to lower CO 2 emissions.By considering anticipated transformations, e.g., the discontinuation of local waste heat sources, it is shown that local biomass and geothermal potentials are used to cover the base load of district heating demand, while large-scale heat pumps and gas boilers are used during peak times.
In future work, the integration of the process-specific useful energy demand in the industry, tertiary and transport sectors is planned to better take into account local flexibility and waste heat potentials.Furthermore, transferable infrastructure models for the electricity, gas and district heating networks are developed to verify the feasibility of the calculated scenarios.

Urban building energy modelling
Urban building energy models (UBEM) can be categorized into top-down and bottom-up approaches, while bottom-up models can be further classified into physics-based, data-driven, and reduced-order methods [78,79].Bottom-up models, are needed to assess the impact of certain retrofit measures among groups of (archetype) buildings [78].Reduced-order models contain a physical representation of the building while being computationally efficient and easy to parameterise based on archetype information [80].Therefore, this study uses a reduced-order bottom-up approach, since it fits best the requirements of a highly transferable approach, which is operating in a low data environment.The use of more advanced physics-based models, which require more advanced input data and more computational power, would only lead to a higher pseudo-accuracy due to the initial data situation.In comparison to physics-and reduced-order based approaches, data-driven bottom-up approaches do not contain a physical representation of the building to estimate the energy consumption, but learn a function for the prediction of energy consumption based on information such as available building stock data, billing data or socio-economic indicators [80].Data-driven methods therefore require a training data set, on the basis of which they can learn the connection between building properties, local weather conditions and energy demand.Since such a dataset is not available, data-driven methods are not suitable for the approach presented in this study.

Residential energy demand simulation
Based on the parameterized building stock, the demand for useful energy for household electricity devices, domestic hot water and space heating is calculated in an hourly resolution based on a similar approach to Kotzur et al. [81].Therefore, the CREST model developed for the UK for simulating residential electricity demand based on occupant behavior is parameterized with data on the behavior of German residents and German household device information [82,83,84,85,86].Considering the local weather conditions based on ERA5 reanalysis data [57], occupancy profiles, domestic hot water and electrical appliance demand profiles are generated for 1000 households of different household sizes in the municipality under consideration.The marginal utility of each additional profile decreases as the average profile of the individual households comes very close to the H0 standard load profile (representative electricity demand profile for German households) between 100 and 1,000 households [87,31,88].The 1,000 households are then assigned to the households in the municipality by stochastic sampling, taking into account the household size.
The thermal demand for space heating is calculated based on a 5R1C model from DIN EN ISO 13790 [89], using the internal gains from the household simulation and the thermal building parameters of the TABULA residential building typology [29].Since municipalities can be composed of a large number of residential buildings and the simulation of each individual building can take a lot of time and computational resources, it is possible to identify representative buildings based on the k-means cluster method before performing the thermal simulation of each individual building.For this purpose, the residential buildings are divided into clusters based on the features of building type, building age, living space, number of apartments, number of occupants and state of retrofit.Thermal simulations are only carried out for the buildings closest to the respective cluster centers.

Spatiotemporal household energy demand development
The bottom-up structure of the simulation of the energy demand development in the residential building sector enables spatiotemporal analysis within the municipality.To calculate the results shown in Fig. A9, the final energy demand of the geo-allocated residential buildings is aggregated at the district level.Fig. A9 a.) shows the peak to mean ratio (r p/m ) of the daily electricity demand d el for the individual districts, which is calculated according to eq. (19).It can be seen that the electrical demand increases in winter due to the increased dissemination of heat pumps, especially in parts of the municipality where a small proportion of the buildings can be supplied with district heating (see Fig. 7 b.)).On average, across all districts, the r p/m increases from 1.4 in 2020 to 2.3 in 2050 in the "CN-electrcity" scenario.In the "CN-gas" scenario, an r p/m of 1.9 is reached in 2050.

•
Local energy system transformation in line with national GHG reduction strategies.• Consideration of temporal building stock dynamic and heterogeneity.• Case study for central European city Karlsruhe.• 192 stochastic building stock transformation scenarios.A R T I C L E I N F O windowvar + c windowfix ⎞ ⎠ ⋅sa bldg window comp ∈ {wall, roof , f loor}, ∀ bldg ∈ BS, ∀ rm ∈ RM (5)

Fig. 3 .
Fig. 3. Visualisation of the iterative process to calculate the dissemination of heating technologies in the local building stock based on overarching changes at the national level.

Fig. 4 .
Fig. 4. Visualisation of the technology options and energy carrier flows considered in the municipal energy system optimisation and representation of the exchange flows with the national energy system.

Fig. 5 .
Fig. 5. Visualisation of the calculation steps for simulating the local final energy demand development of the residential building sector for the municipality of Karlsruhe (KA).

Fig. 7 .
Fig. 7. Visualisation of the development of energy carrier imports, local generation of electricity and district heating, and the development of CO 2 emission for Karlsruhe.Historical CO 2 emissions are shown until 2019 [55,56].

Fig. A9 .
Fig. A9.Exemplary visualisation of the spatial and temporal resolution of the residential demand for electricity and district heating in the "CN-electricity" scenario in 2050.

Fig. A10 .
Fig. A10.Visualization of the calculation steps for the simulation of the local final energy demand development of the residential building sector for the municipality of Karlsruhe.

Fig. A11 .
Fig. A11.Sector-specific final energy demand development for the municipality of Karlsruhe.The developments for the industrial, tertiary and transport sectors are based on[90][91][92] and were adapted to the weather conditions of the weather year (2017) on which this study is based, by using the procedure presented in Section 3.2.2.As an example for the 192 transformation scenarios of the household sector, the development of the final energy demand of the "CN-electricity" scenario is presented.

Fig. A13 .
Fig. A13.Development of the potential for rooftop photovoltaic systems in the municipality of Karlsruhe, calculated based on the procedure described in Section 3.2.1.

Table 1
Description of the model extensions of the energy system optimisation model RE3ASON.

Table 2
Overview of publicly available sources used in this study to simulate the local residential building stock energy demand.
. The days are divided into the categories Monday to Thursday, Friday, Saturday, and Sunday/holiday.

Table 4
Quantification of the effects of individual energy system transformation measures on TDSC and CO2 emissions.The changes are made exclusively for the individual scenarios and therefore do not affect each other.