### Model overview

The target of the presented model is to identify the cost-optimized design of a municipal energy supply system. The model is formulated as a linear optimization problem (van Beeck 1999) minimizing the overall system costs, including costs for investment into grids and conversion units as well as costs for energy consumption during operation. It takes the perspective of a central planner, who has control of all investment and operational decisions within the municipal energy system. The optimization variables therefore comprise installed capacities for central and decentral conversion units, electric cables and transformers, gas pipes and pressure regulators, and heat pipes. Furthermore, the system operation, described by the input and output of conversion units as well as flows on grid elements, is optimized. This approach enables the identification of optimized system designs from a holistic perspective neglecting the barriers of split ownership and the influence of frequently changing energy regulations.

The investments and operation are subject to various constraints as further introduced in “Constraints” section. The model allows for a brown field approach by considering existing grid capacities in the optimization, or a green field approach by neglecting those.

The input comprises the geo-referenced grid structure, the supply task, weather data, as well as technical and economic parameters. The *grid structure*, defined as a graph with nodes and edges, describes possible infrastructure connections for each energy carrier. In case of a brown field optimization, existing capacities for each edge are defined. The grid structure also contains nodes for all buildings to be supplied. The *supply task* defines demand time series for electricity, space heat, and warm water to each building. The *weather data* contains time series for the global radiation and ambient air temperature. The *technical and economic parameters* include electric and thermal efficiencies and investment costs of energy conversion units as well as investment costs for grid elements such as cables, pipes, transformers, and pressure regulators. Furthermore, specific emission factors and price time series for each energy carrier are included. All aforementioned input time series are full-year data sets with a time resolution of 15 minutes per time step.

### Grid model

Municipal energy supply systems contain grids for different energy carriers as well as conversion units such as heating technologies. These are either located in central locations to feed into the grid, or in buildings, where the demand occurs. The grid of each energy carrier comprises different grid levels. The electricity grid relies on the low voltage level to connect buildings with distribution stations, and the medium voltage level for linking those with substations (Sillaber 2016). Similarly, the gas system comprises a low pressure and the overlaid high pressure level (Cerbe 2016). Heating grids can be split into main and final distribution levels (Nussbaumer et al.). These two grid levels, in the following referred to as ‘upper’ and ‘lower’ level, are connected using transformers (electricity), pressure regulators (gas), and heat pipes (heat). Within the optimization model, the grid information for each energy carrier is described by a graph with nodes and edges, as visualized in Fig. 1. The nodes are classified as building nodes, central conversion nodes, grid nodes, connection nodes, and exchange nodes.

*Building nodes* are present in the lower grid level of each energy carrier and have a demand for electricity and heat, which must be fulfilled by the overall system. In a building node, conversion units can be installed to directly serve the demand, such as heat pumps, electric or gas heaters, pellet heaters, small cogeneration units, solar thermal units, and photovoltaic systems.

*Central conversion nodes*, linking the different energy carrier grids, are present in the upper grid level. They can convert energy from one carrier to another using similar technologies as used in building nodes, but in large scale, and with the difference that generated heat is fed into the heat grid.

*Grid nodes* and the edges between them exist on both grid levels and for each energy carrier individually. They perform the task of transporting their respective energy carrier between import nodes, central conversion nodes, and building nodes.

*Connection nodes* connect the upper and lower grid level of each energy carrier and represent electric transformers, gas pressure regulators, and heat connections.

The *exchange nodes* for the energy carriers electricity and gas are located in the upper grid level and allow the energy exchange between the modeled system and the outside. There is no exchange node for heat, as the heat grid is considered as being entirely local within this model.

The part of a grid on the lower level located under one connection node is referred to as ‘grid group’, as shown in Fig. 1. A building node belongs to the same grid group for all energy carrier grids.

### Objective function

The objective function describes the minimization of annualized overall system costs with investment into grid and conversion units as well as operation, as stated by

$$\begin{array}{@{}rcl@{}} Z &=& C\sp{\prime inv}_{grid, total} + C\sp{\prime inv}_{conversion\_units, total} + C^{operation} \end{array} $$

(1)

$$\begin{array}{@{}rcl@{}} &=& \sum_{c}\sum_{k}C\sp{\prime inv}_{c,k} + \sum_{j}\sum_{n}C\sp{\prime inv}_{j,n} + \sum_{c}\sum_{t}P_{c}^{exchange}p_{t,c} \end{array} $$

(2)

The first term \(\sum _{c}\sum _{k}C\sp {\prime inv}_{c,k}\) describes the annualized grid investment costs as sum across all energy carriers *c* and all grid edges *k* of the annualized investment costs per edge. These are derived based on the installed edge capacity, edge length, and annualized specific investment costs for the respective edge type. The second term \(\sum _{j}\sum _{n}C\sp {\prime inv}_{j,n}\) describes the annualized investment costs for conversion units as sum across all units *j* in all nodes *n* of the annualized investment costs per unit. These result from the installed unit capacity and annualized specific investment costs for the respective technology. The third term \(\sum _{c}\sum _{t}P_{c,0}^{exchange}p_{c,t}\) describes the operational costs for energy carrier consumption.These are defined as the sum across all time steps *t* and energy carriers *c* of the energy exchange at the exchange node multiplied by the price of the respective energy carrier. As the model takes the perspective of a central system planner, no charges related to energy regulations, such as network charges and energy taxes, are considered. The prices for the energy carriers therefore represent wholesale market prices, which in addition in the case of electricity inherently imply scarcity or abundance in the overall national system.

### Constraints

#### Technology constraints

For each conversion unit *j* in each node *n* at each time step *t*, the energy carrier input and output are linked via the efficiency \(\eta _{t,n,j}^{c}\) with

$$ P_{t,n,j}^{c, out} = P_{t,n,j}^{c, in} \cdot \eta_{t,n,j}^{c} \quad \forall t,n,j $$

(3)

The output of the unit *j* in node *n* is further limited by its installed capacity with

$$ P_{t,n,j}^{c, out} \leq \hat P_{n,j}^{c, out} \quad \forall t,n,j $$

(4)

For heat pumps, the time-varying coefficient of performance (COP) replaces *η*_{t,n,j}. It is calculated based on time series for the flow temperature and evaporation temperature. For decentral air to water heat pumps, estimated building-specific flow temperatures and the outside air temperature are used in combination with the COP curve of a definable heat pump. For central water to water heat pumps, the flow temperature of the heating grid is regulated based on the outside temperature. The evaporation temperature, describing the temperature of the heat source such as ground water, waste water, or river water, is set at a constant value. A large-scale heat pump available on the market is used as basis for the COP curve.

#### Node constraints

Similar to the transport model described in Saad Hussein (2018), each grid node *n* of each energy carrier *c* must be in balance regarding incoming and outgoing edge flows \(F_{t,mn}^{c}\), infeed \(P_{t,n}^{c, infeed}\), and withdrawal \( P_{t,n}^{c, withdrawal}\) in each time step *t*:

$$ \sum_{(m,n)}F_{t,mn}^{c} - \sum_{(n,m)}F_{t,nm}^{c}+ P_{t,n}^{c, infeed} - P_{t,n}^{c, withdrawal} = 0 \quad \forall t,n,c $$

(5)

In a building or central conversion node, multiple conversion, renewable energy, and storage units can be installed. Some units can feed their output into the grid, others can only supply within the same node. Therefore, a multi-layer node model is chosen, as shown in Fig. 2. Each building or central conversion node in each energy carrier grid is made up of three layers, whereby each layer has its own energy balance constraint.

Layer I represents the connection with the grid and is subject to Eq. 5. The balance equation of layer II considers the output from the subset *J*_{n,gc} of conversion units in node *n*, which can feed their output back into the grid:

$$ \sum_{j \in J_{n,gc}} P_{t,n,j}^{c, out} + P_{t,n}^{c, withdrawal} - P_{t,n}^{c, infeed} - P_{t,n}^{c, remain} = 0 \quad \forall t,n,c $$

(6)

The term \(P_{t,n}^{c, remain}\) describes the energy transferred from layer II to layer III. The balance equation of layer III considers the output from the subset *J*_{n,ngc} of conversion units in node *n*, which cannot feed their output into the grid.

$$ \sum_{j \in J_{n,ngc}} P_{t,n,j}^{c, out} + P_{t,n}^{c, remain} - \sum_{j \in J_{n}} P_{t,n,j}^{c, in} - P_{t,n}^{c,demand}= 0 \quad \forall t,n,c $$

(7)

This layer balances the energy demand of the building \(P_{t,n}^{c,demand}\) and the fuel input into conversion units within the same node \(P_{t,n,j}^{c, in}\) on the one side with the energy transferred from layer II and the output of conversion units in layer III on the other side. The restriction of energy transfer between layer II and layer III to positive values hinders units installed in layer III from feeding their output into the grid.

$$ P_{t,n}^{c, remain} \geq 0 \quad \forall t,n,c $$

(8)

#### Grid constraints

The flow \(F_{t,mn}^{c}\) on each edge of energy carrier *c* connecting nodes *m* and *n* and on each transformer (electricity) and pressure regulator (gas) is modeled as power flow neglecting parameters such as voltage, pressure, and temperature level, as well as losses. It is limited by its installed capacity:

$$ F_{t,mn}^{c} \leq \hat F_{mn}^{c} \quad \forall m,n,c,t $$

(9)

#### CO_{2} emission limit

The overall system operation in all time steps is constrained by a CO_{2} emission limit, considering the emissions resulting from the consumption of energy carriers. For electricity and gas, the exchange across the system boundary at the exchange nodes is taken into account. A reverse electricity flow out of the system results in a CO_{2} credit. For pellets, the consumption at all nodes is considered. The specific emission factors for these energy carriers depend on the overall scenario parametrization.

### Aggregation of lower grid levels

The “Grid model” section introduced the grid model of municipal energy supply systems with an upper and lower grid level. Results on the lower level allow for a detailed analysis of the optimal design for individual buildings and streets. Results for the upper level support assessments of the optimal overall cross-sectoral system design and are therefore in focus. The mere neglection of the lower level in the optimization, however, is not possible, as both levels interact with each other. At the same time, the full consideration of the lower level increases problem complexity significantly. The aggregation of information and thereby reduction of resolution on the lower level can help to bridge this conflict. The aggregation chosen in this work selects one representative building node for each grid group on the lower level and assigns the aggregated characteristics of all buildings within this grid group to it. For additive values such as the demand time series, the sum is calculated. For non-additive values such as the COP time series, the weighted average is calculated, with the heat demand time series used as weighting factors. The length of the new edge between the representative building and the connection node is calculated as the weighted average of all individual distances between the buildings and the connection node, with the annual energy demand as weighting factor.