A network-aware market mechanism for decentralized district heating systems

District heating systems become more distributed with the integration of prosumers, including excess heat producers and active consumers. This calls for suitable heat market mechanisms that optimally integrate these actors, while minimizing and allocating operational costs. We argue for the inclusion of network constraints to ensure network feasibility and incentivize loss reductions. We propose a network-aware heat market as a Quadratic Program (QP), which determines the optimal dispatch and a set of nodal marginal prices. While heat network dynamics are generally represented by non-convex constraints, we convexify this formulation by fixing temperature variables and neglecting pumping power. The resulting variable flow heating network model leaves the sign and size of the nodal heat injections flexible, which is important for the integration of prosumers. The market is based on peer-to-peer trades to which we add explicit loss terms. This allows us to trace network losses back to the producer and consumer of these losses. Through a dual analysis we reveal loss components of nodal prices, as well as relations between nodal prices and between seller and buyer prices. A case study illustrates the advantages of the network-aware market by comparison to our proposed loss-agnostic benchmark. We show that the network-aware market mechanism effectively promotes local heat consumption and thereby reduces losses and total cost. We conclude that the proposed loss-aware market mechanism can help reduce operating costs in district heating networks while integrating prosumers.


Context
District heating is expected to play an important role in future carbon neutral energy systems, especially in urban areas [1].Through a district heating network, excess heat from industrial processes can be distributed to households, thereby facilitating the decarbonization of heat generation.Example sources of excess heat include supermarkets and data centers that produce heat as a by-product of their refrigeration or cooling system.Excess heat generation is usually less flexible than conventional generation, as only limited deviation from a reference production profile is possible.In order to compensate for a less flexible supply, flexibility on the demand side is needed.Studies show that households can provide such flexibility, among others using the virtual heat storage of buildings [2].The presence of excess heat producers and active consumers marks the rise of the prosumer in heating systems, a new market participant that has already gained interest in power systems.Prosumers are defined as proactive consumers that may possess assets for local energy generation, conversion and/or storage [3].Heat prosumer assets include, for instance, heat accumulators, heat pumps, and solar collectors.
The structure and operation of district heating systems will change significantly with the rise of distributed (excess) heat sources and heat prosumers.It remains an open question how heat markets should adapt to this new paradigm.Existing heat pricing methods do not succeed in providing consumers and generators with the right incentives to exploit their flexibility [4][5][6], nor do they deal with challenges related to the operation of a more distributed system.There is thus a need for the design of heat markets that exploit the benefits prosumers can bring to the heating system, while facilitating the integration of more distributed generation from a network operator's perspective.For the latter, markets should help ensuring network feasibility and minimizing operational costs, including the cost of heat loss.
To this end, we aim to design a network-aware market mechanism suitable for district heating systems with distributed generators and prosumers.In a more distributed system, it becomes more challenging to ensure network feasibility and operate the system efficiently.https://doi.org/10.1016/j.apenergy.2021 In this context, studies have pointed to the advantage of networkaware markets, which include explicit network constraints [7,8].Such markets guarantee network feasibility and economic efficiency of operation in a system with high penetration of distributed generators.If managed and integrated properly, it has been shown that prosumers can facilitate network operation and reduce system costs [9].In order to optimally coordinate prosumers while exploiting their value, the concept of consumer-centric markets has attracted attention.In the next Section, we review the literature on network-aware market design for heating as well as electricity systems, including works involving consumer-centric network-aware market design.

Status quo of network-aware operations and markets
The need for network-aware optimal dispatch has long been recognized for electrical power systems, in order to minimize operating costs while meeting system and security constraints [10,11].Optimal energy flow for the heating and gas sector has also been a topic of interest, see e.g. the literature review in [12].Possibly due to the liberalization of electricity markets, as well as increased decentralization, optimal flow problems for electricity have been researched most extensively.Solving Optimal Power Flow (OPF) problems in systems with many agents (e.g., producers and consumers) has become more complex [13].A standard OPF-based electricity market minimizes generation costs subject to power flow equations and operational constraints.The Alternating Current (AC) OPF considers the full non-linear power flow equations in its constraints, and thus represents the power flows most accurately.However, the non-convexity of this formulation has many drawbacks, such as a general lack of optimality guarantees on solver solutions and intractability of larger problems.Much research has therefore focused on approximation and convexification of the AC OPF.
A similar problem arises when designing network-aware heat market mechanisms, due to the highly complex, non-linear nature of district heating network dynamics.In the most general and most accurate variable-flow-variable-temperature (VFVT) formulation, the flow, pressure, and temperature of the heat carrier are variable.In the control literature, the resulting Mixed Integer Non-Linear Problem (MINLP) is solved using iterative methods, such as in [14][15][16].However, convex formulations are preferred in many applications, including market design.One may apply convex relaxations and retrieve a solution to the original problem after solving, as done in e.g.[17] and [18].However, there are no guarantees on the magnitude of the optimality gap, and the nonlinear problems can quickly become intractable for larger number of nodes.We therefore consider such methods unsuitable for our purpose.A second convexification method is to fix flow variables to arrive at the constant-flow-variable-temperature (CFVT) formulation, e.g.applied in [19][20][21][22].The fluid temperature is variable at injection points and throughout the network, so that the network can be used as a heat storage.As a drawback, due to fixed nodal flows, a node must be marked as a net producer or net consumer before market clearing.Nodal temperature constraints even enforce minimal injections and extractions of these pre-appointed producers and consumers, which limits the exploitation of prosumer flexibility considerably.Finally, the variable-flow-constant-temperature (VFCT) formulation convexifies the problem by fixing nodal temperatures, leaving the flow of the heat carrier variable.The heat loss in each pipeline is now a fixed share of the transported heat, i.e. loss is multiplicative.VFCT is applied in an optimal dispatch setting in [23].The authors of [24] apply the VFCT to prevent congestion in a distribution network with a single point of heat injection and several flexible consumers.
Over recent years, consumer-centric electricity markets have been proposed in order to accommodate prosumers.The authors of [7] review approaches for integration of distributed energy sources into power systems, and in this context discuss peer-to-peer mechanisms, as well as network considerations.Network-agnostic peer-to-peer markets based on bilateral trades are formulated in e.g.[25,26].More recently, several works have considered network effects within decentralized market frameworks.In [27], the cost for infrastructure usage is allocated to agents using several types of exogenous network charges, without considering explicit grid constraints.The authors of [28] propose a peer-centric market where distribution locational marginal prices reflect network usage charges that peers must pay to the utility.A peer-to-peer market with distribution and transmission grid constraints is formulated in [8], where the authors study the effect of different loss allocation policies as well.The prosumer has also gained interest in the context of district heating, not least because many types of excess heat providers classify as prosumers.The authors of e.g.[29] foresee the presence of prosumers in future heating systems, and highlight the importance of integrating them optimally.It has been shown that prosumers can be a cost-efficient solution to bottleneck problems in heating networks [30].The literature on consumer-centric heat markets is however limited.From a market perspective, the authors of [31] develop a community-based combined heat and electricity market for a group of prosumers, consisting of an optimal dispatch and different allocation mechanisms, while disregarding network constraints.The aforementioned work [24] proposes a mechanism for exploiting flexible prosumer demands while considering the network.In this work however, there is a single point of heat injection, and prosumers cannot export heat.

Contributions
The state-of-the-art literature lacks a convex, network-aware heat market that integrates distributed generators and prosumers, while minimizing operational costs.In this work, we propose a VFCT based network-aware market mechanism to fill this gap.The market is network-and loss-aware, minimizing total production cost including the cost of generated losses.The choice for VFCT representation of the heating network is motivated by the need for a convex model as well as variable sign of nodal injections.This comes at the cost of fixing nodal temperatures, so that the storage capacity of the heating network itself is not exploited, and market participants must inject at a fixed temperature.We furthermore neglect pressure and pumping power constraints, so that we can include distributed heat injections.The market mechanism is suitable for any radial network with unidirectional pipeline flows.Nodal flows may be bidirectional, so that prosumer flexibility can be harnessed.Our choice for unidirectional network flow matches current practice in the operation of district heating networks.Bidirectional network flow is envisioned to be realized in fifth generation district heating, but this concept is in an early stages of research and development [32].Due to the unidirectionality in the pipelines, prosumers cannot sell heat to agents located upstream.In other words, prosumers can only sell heat to agents at their own node, or downstream nodes.For prosumers at the end node, this implies that they can only sell heat to other prosumers at the same node.
We explore several questions related to network heat losses.Who causes them?Which generator compensates for the losses?And finally, who pays for losses?The answers to these questions help use to account for heat loss in both dispatch and pricing.Our market formulation includes peer-to-peer trades.In this work, the main purpose of introducing peer-to-peer trades is to reveal the agents that cause a certain network loss.We link network losses to a particular trade, which allows us to identify which seller and buyer caused a certain amount of heat loss in certain parts of the network.We present two variations of the dispatch mechanism, in which either the distributed generators or the grid connection compensate for heat losses.Furthermore, we propose two allocation mechanisms for the costs of energy and losses.We provide insights in our proposed formulation through detailed analysis, including a derivation of the loss components of nodal prices, and a dual analysis revealing relations between nodal prices and between seller and buyer prices.For fair evaluation of the proposed market mechanism we formulate a network-aware but loss-agnostic benchmark.By comparison to this benchmark, we can show the effects of loss-aware dispatch in our case study.The comparison shows that the proposed network-and loss-aware mechanism effectively promotes a more local heat consumption and thereby reduces losses and total costs.Finally, we compare the effect of individual and socialized loss allocation on consumer payments.
To the best of our knowledge, we are the first to engage in a detailed analysis of VFCT-based heat markets, and thereby to provide deeper insights in this formulation.In fact, explicit market considerations apart from optimal dispatch are rarely addressed in the literature.In addition, we consider explicit allocation of loss generation costs, which has not been done for the heat case.Our network and peer-to-peer formulations are partly inspired by the work in [24], but differ from it in several ways.Firstly, we add constraints to prevent arbitrage, ensuring a unique solution.We furthermore allow for multiple points of heat injection.As a result we need to omit the pumping power constraint.
The remainder of this article is organized as follows.We describe the components of the system under consideration in Section 2, including the district heating network model and agent representation.Section 3 presents the proposed market mechanisms, as well as the benchmark.The price of energy and loss are discussed in Section 4, including two different loss allocation policies.Next, the properties of the proposed market are illustrated in a case study in Section 5. We draw conclusions and discuss future work in Section 6.

System description
This Section describes the dynamics of the considered heating system, as well as the representation of agents present in this system.First, the general district heating system setup is introduced in Section 2.1.Sections 2.2 and 2.3 respectively present the heating system model and the agent model that are used in our market formulation.Temporal coupling is introduced through the load flexibility model in the latter Section.Therefore, we need to use a time index  ∈  .

District heating system representation
Fig. 1 provides a graphical representation of the district heating system setup.The district heating network consists of a supply and a return side.Heat generators extract cold fluid from the return side and inject hot fluid on the supply side.Supply-side pipelines then transport the hot fluid to heat consumers, which extract the hot fluid from the supply side and inject cold fluid in the return side.The network is a directed graph ( , ), where  is a set of nodes connected by pipes  ⊆  ×  .Each node and pipe consists of a supply and a return side, which are indicated by superscripts S and R. Any pipe  ∈  is defined by its supply-side start and end node, i.e., if  = ( 1 ,  2 ), then the flow in the supply side of pipe  goes from node  1 to node  2 .The system state is described by nodal supply  S  and return temperatures  R  , nodal mass flow rates ṁN  (here positive towards the return side), and unidirectional pipeline mass flow rates ṁS  .Due to mass conservation, the mass flow rates in the supply and return side of a pipe are equal, so that it suffices to consider only the supply-side flow.
We consider a unidirectional district heating network on the distribution level.More specifically, pipeline flow is unidirectional, while nodal flow may be from the supply to the return side or vice versa, so that nodes are free to be net generators or net loads.This allows for prosumer nodes, which do not have to fix the sign of their injection before market clearing.The local system is connected to a larger grid, that may supply heat energy at import price  H  .Due to the unidirectionality, no heat export to the larger network is possible.As this work focuses on the heating system, we simplify the connection to the electricity system.It is assumed that all agents are subject to the same known electricity import price  E  for each period.The imported heat and electricity from the grid are denoted  H g and  E g .These quantities are not upper bounded, so that the grid agent can in principle supply unlimited amounts of heat and electricity.However, due to grid constraints introduced in the next Section, these quantities are limited indirectly.

Model of district heating network dynamics
We will now continue to present our VFCT heating network model.The network-related variables are the nodal flows ṁN  and the pipeline flows ṁS  .The temperature at the supply and return side of each node are model parameters, and they are constant over time.This way, time delays can be neglected.The temperature loss in each pipeline is determined by those fixed values.The supply-side temperature at a node must necessarily be greater than its return-side temperature for the node to be able to extract heat from the system.In addition, temperatures must be non-increasing along pipelines in the direction of the flow.It is important to emphasize that losses are multiplicative in this formulation.That is, a fixed share of the heat injected in a certain pipeline is lost while the heat carrier flows to the next node.This share does not depend on flow or temperatures.However, total system losses are not fixed, as the amount of heat injected in each pipeline is variable.For the VFCT model, fixed nodal temperature values are needed.These may be obtained from measurements, as in [24].Another option is to estimate temperature losses as in [33] (Eqs.( 7) and ( 8)), or using an average mass flow and temperature loss equations as in [14] (Eq.( 6)).
The set of heating system variables is given by  DHN = { ṁN  , ṁS  }.Mass is preserved at each node, which means that the difference between incoming and outflowing mass at a node must equal the nodal flow.This translates to Each node contains a heat exchanger that ensures locally produced heat is injected into the network.The nodal power injection and nodal flow are related as where  f is the heat capacity of water.The nodal flow ṁN  is considered positive when the direction is from supply to return side.Note that the temperature of the injected fluid on the supply and return side of node  must equal the fixed temperatures  S  and  R  , respectively.Finally, the flow variables are subject to limits.The flow in pipelines is unidirectional, and upper bounded: The nodal flows are bidirectional, but bounded in size:

Consumption model
A set of agents  is present in the system.Agent  is located at a node   in the district heating network.The set of agents at node  is denoted   ; multiple agents may thus be located at a single node.The agents have an hourly heat load  H  and generation  H  , resulting in a total heat injection  H  given by The heat load consists of an inflexible domestic hot water load LDHW and a partially flexible space heating load  SH , It is assumed that the heat is generated using heat pumps (HPs), which have an electric load  E,hp  .The electric load and heat production are related by the heat pump Coefficient of Performance (COP) as The COP can in principle vary in time, but is considered fixed in this work.All agent variables are collected in the set  agent = { H ,  H ,  SH ,  H ,  E,hp }.The generation is upper and lower bounded as follows Flexibility in prosumer consumption is represented as follows.First, the space heating profile of agent  may at most deviate from this agent's reference profile LSH  by a maximum flexibility   at each time: Note that if LSH  −   < 0, the lower bound on the space heating consumption is zero.In addition, the total heat consumption for space heating has to equal the total in the profile, i.e.
which means that space heating load may be shifted but has to be consumed eventually.
The utility is inversely proportional to the squared deviation from this profile.This relation is scaled by a time and agent dependent factor ũ representing the importance of following the space heating profile.The resulting utility as a function of the space heating demand is Heat generation costs for agent  are given by

Optimal dispatch strategies
We will now define the three different dispatch strategies we consider in our market designs.An overview of the proposed dispatch strategies is first provided in Section 3.1.Next, we present our formulation of peer-to-peer trades in Section 3.2.This formulation allows us to derive the losses each agent is causing, which we do in the following Section 3.3.The objective functions used for loss-aware and for lossagnostic dispatch are provided in Section 3.4.Finally, we summarize the full optimization problem in Section 3.5.

Overview
We design three optimal dispatch strategies, that differ from each other in one or two aspects.The first option that can be switched is loss-awareness versus loss-agnosticism.This setting is discussed in Section 3.4.Our aim in this work is to show the benefits of loss-aware dispatch compared to the status quo in heat markets.We use the lossagnostic dispatch as our benchmark for showing these benefits.This benchmark is intended to resemble current practices in heat markets, which usually do not consider the network nor operational costs.However, for a fair comparison to our network-aware and loss-aware market, the benchmark needs to respect network constraints.
The second setting is centralized loss generation (CLG) versus decentralized loss generation (DLG), which determines the generator that compensates for losses, as we will discuss in Section 3.2.Combining these options gives four different dispatch strategies, illustrated in Table 1.However, as indicated, we exclude the loss-agnostic DLG variant, as it is unlikely to be applicable in reality, nor does it mimic any existing market setups.Moreover, it results in counter-intuitive dispatch and prices, as the loss generation is competing with energy generation for the limited capacity local generators.In all cases, we assume non-strategic and regulation-agnostic agents.By the latter we mean that agents are not able to anticipate hindsight payments, which implies they do not change behavior in the dispatch because of the hindsight payments.
Reasons for including network constraints in the optimal dispatch are twofold.Firstly, for all three proposed dispatch strategies, the resulting dispatch will be feasible.This means that the physical limitations posed by the network are respected by any resulting dispatch.Second, the network model implicitly models heat loss, so that the cost of loss related to a certain unit of consumed energy is directly included in the market.This cost will influence the choices of heat consumers when buying heat: it may happen that a generator close to a certain consumer is preferred over a cheaper but far away generator, when the latter trade becomes more expensive due to loss costs.This effect can be observed in our loss-aware dispatch.In the loss-agnostic dispatch, we artificially remove the loss costs from the objective function, as we will formalize in Section 3.4.The loss-agnostic dispatch is agnostic to the cost of loss only: the losses are still produced and transported, and the dispatch remains feasible in the network.
In our proposed markets, generator bids are of price-quantity format.That is, they bid a maximum quantity  H  for each time step, as well as their generation costs per unit for each time.The consumer bids are more complex: they bid a fixed load LDHW , a minimum and maximum quantity for flexible load  SH , and the total to consume flexible load over the entire day.In addition, the price component of the consumer bid comes as a quadratic utility function   ( LSH , LDHW ).If the market were to be decomposed, and agents would engage in bilateral trades in a decentralized system, the consumers would not need to hand all this information to the market operator.Instead, the information would be used in their local optimization problem.

Peer-to-peer trades
The market includes peer-to-peer trades, which enable agents to negotiate directly with one another and agree on bilateral heat trades.Our formulation is an extension of a common peer-to-peer setup, as described in for example [34].The extension consists of constraints that prevent arbitrage, as well as an explicit loss representation.We define a trade   between agent  and , which is positive if  sells and negative if  buys heat.The grid agent is denoted using the index g.Trades define an amount of energy that is received by the buyer, not including any losses on the way.This means that, besides the traded heat   , the losses   associated with the trade need to be generated by some agent.We introduce a binary parameter   ∈ {0, 1} to indicate whether the seller of trade   will be responsible for producing the losses caused by this trade (  = 1) or whether grid import will be used to compensate for losses (  = 0).We will refer to these respective cases as distributed loss generation (DLG) and centralized loss generation (CLG).An illustration of peer-to-peer trading variables is given in Fig. 2.
A trade   can be decomposed into sales   ≥ 0 and buys   ≥ 0 as Trade reciprocity is ensured by the constraint The variable   =   represents energy bought from own production, used for self-consumption.This self-consumption variable   is used to prevent arbitrage and ensure a unique solution, using the following constraints.Agents can buy no more and no less than the energy they need for consumption, which prevents reselling of bought energy and thus prevents arbitrage.Note that the sum in this Equation includes the self-consumption   .Among others, this constraint ensures that for any , , no agent is both buying from and selling to a single other agent, i.e.   = 0 ∨   = 0.An agent must generate an amount equal to the total sale of heat plus the associated loss generation allocated to this agent, The losses   will be quantified in the next Section.The grid agent must produce where  g  is the amount the grid agent must inject to compensate for the losses in the trade   , which is quantified in the next Section.
The primal variables related to the peer-to-peer trading are  p2p = {, , , ,  g }.

Explicit loss formulation
Pipeline losses occur both on the supply and return side in the network.These losses are implicit in (1) and (5).In order to provide more insight in the losses, and to be able to allocate losses to market participants, we turn to a more explicit loss formulation.
Suppose without loss of generality that trade   > 0, so agent  is the seller of the nonzero trade with agent .In the VFCT formulation, the loss associated to trade   is a fixed share of this trade, depending on the nodal temperatures at   and   .To derive this share, suppose   =   > 0. Then the change in power injection (and thus flow) at the receiving node   equals by (2).By continuity of flow,  ṁ  = − ṁ  .Assuming the losses are supplied by the seller , the change in power injection at node   is The lost energy is equal to the difference between generated and consumed energy in this trade, as given by ( 19) and ( 18) respectively.The total loss associated to the trade   thus equals Thus, we derive the constant relationship w between   and   as An important observation is that, as a result of assuming constant nodal temperatures, the losses become multiplicative, i.e. a fixed share of the energy transported through a pipeline.Note furthermore that the factor w is only non-negative if the temperature gradient between supply and return side at   is at least as large as the gradient at   .This is the case as long as   is downstream of   , or   =   .

Loss component for decentralized loss generation (𝛼 𝑖𝑗 = 1)
We define   as the loss associated with the trade   in case that the seller of this trade is also producing the loss, i.e.   = 1.If   < 0, so  is the buyer of this trade, then   = 0 while now   ≥ 0 represents the loss associated with this trade.In other words,   ≥ 0 ⟹   ≥ 0,   = 0, whereas   ≥ 0 ⟹   = 0,   ≥ 0. The explicit computation of the losses caused by a certain trade is where it is important to note this holds under the assumption that the seller produces these losses.Furthermore, losses must be positive, i.e.   ≥ 0. Combining this with the nonnegativity of , we enforce that   = 0 if w < 0. The interpretation of this is that  cannot buy from  if  is upstream of , so these constraints exclude physically impossible trades.

Loss component for decentralized loss generation (𝛼 𝑖𝑗 = 0)
In this case, the grid agent has to inject an amount of energy that results in an amount of   arriving at the node of the seller of trade   .If   > 0,  is the seller of the trade   .Therefore, an amount of   must arrive at node .This means that the grid agent must produce Again, the loss must be positive, i.e.  g  ≥ 0.

Loss-aware and loss-agnostic objective functions
The difference between our loss-aware and loss-agnostic dispatch lies in the objective function  obj of the respective optimization problems.The objective of both markets is to maximize some form of social welfare (or equivalently, minimize negative social welfare).In the lossaware dispatch, total production cost is included, which consists of the costs of energy sold to a consumer and the cost of producing losses: In the loss-agnostic benchmark, the objective function of the market is adapted to minimize only the production cost of consumed load, while disregarding the cost of losses: After a loss-agnostic dispatch, the cost of losses may be computed and allocated a posteriori as discussed in Section 4.2.The total cost of losses is therefore in general different when using these two objective functions.Note that without appointment of an agent responsible for loss generation, there will in general not be a unique solution in the loss-agnostic case.

Resulting overall market optimization problem
To arrive at a complete market formulation, we combine the constraints defined over Sections 2 and 3 in a single optimization problem in (24).Dual variables are indicated for each constraint, where we use  for equality constraints and  for lower and upper bounds.These dual variables are used in our derivation of energy and loss prices in Section 4.1 and Appendices A.1-A. 4.
The objective function  obj is either  awa for loss-aware dispatch, or  agn for loss-agnostic dispatch.The optimization variables are  = { H g ,  H g } ∪  DHN ∪  agents ∪  p2p .We list network constraints in (24b)-(24e), and the agents' own constraints in (24g)-(24l).To synchronize notations between the grid agent and prosumers, we add a power injection constraint for the grid agent in (24f).Trade related constraints are in (24m)-(24q), and loss related constraints in (24r)-(24u).In the absence of preferences with respect to trading partners, as in this work, the same dispatch as the one resulting from our peer-to-peer market can be obtained from an equivalent pool formulation as well.

Pricing and loss allocation mechanisms
After the optimal schedule is determined using one of the three dispatch strategies presented in Section 3.1, payments and revenues have to be determined for all market participants using an allocation mechanism.In this Section we propose different allocation mechanisms.First, the allocation of energy and loss cost is discussed in Section 4.1.Then, Section 4.2 presents different loss allocation mechanisms.

Marginal price of energy and loss
Different choices of consumed energy and loss prices are possible.In this work, we consider nodal marginal pricing.In the Appendix, we derive dual relations for the different markets, and determine the nodal prices.It is derived that the price per unit of loss and price per unit of energy are equal.However, the amount of loss per unit of consumed energy depends on where the energy is imported from, and therefore the loss cost per unit of energy consumed increases with distance from the generator.We denote nodal marginal prices as  N  , and seller  and buyer  marginal price as  s  and  b  respectively.In Appendix A.2, we show that the unit price received by seller  is given by  S  +  inj  , whereas the price per unit consumed for buyer  is − B  +  inj  .We further derive that for loss-aware DLG, these prices relate as As a result, the cost of loss connected to energy sale   on the DLG loss-aware market is given by In the loss-aware CLG market the prices relate as as derived in Appendix A.3.So, losses are paid for at the nodal price of the node of grid connection.Therefore, in the CLG loss-aware market the cost of loss connected to sale   is given by Finally, for the loss-agnostic CLG, we show in Appendix A.4 that the buyer and seller marginal price are always equal, i.e.  s  =  b  , regardless of whether the agents are at different nodes (as long as there is no congestion).This implies that the losses are not paid by the buyer directly, which is what was intended with this formulation.The costs of losses are not optimized and therefore the cost of loss cannot be obtained from any dual variable.Instead, the cost of loss has to be computed in hindsight.As in the loss-aware markets, we choose to price the loss in hindsight at the nodal price of the generator of the loss, in this case the grid node.Thus, the cost of loss connected to sale   is computed in hindsight in the same way as in CLG loss-aware market as given in (28).
Note that we price the loss   at the nodal price of generator  in all three market formulations.

Allocation mechanisms for loss costs
Once the generation cost of losses are known, these costs have to be allocated to market participants.A loss allocation policy is a system for distributing loss costs over generators and loads.It is desirable that such a policy is budget balanced, i.e. the loss payments add up to the cost of loss, so that the network operator does not suffer a loss or earn a profit.
In this work, two budget balanced loss allocation policies are investigated: 1. individual: the buyer of heat pays for the generation of the losses associated with this trade.2. socialized: losses are paid for collectively a posteriori.Each consumed unit is charged the average cost of loss per unit consumed, so that the loss costs are distributed proportionally to prosumer total consumption.
In the individual loss allocation policy, losses are paid by the individual that is causing them, while the cost of losses are shared evenly using the socialized loss allocation policy.In particular, the socialized loss cost per unit consumed is taken as an average over the entire time period considered, so that the unit price of loss is equal for any time .This is intended to mimic current network and loss charges, which are usually a fixed price per unit, where the network and loss costs for the whole year are socialized in a grid tariff.The socialized loss allocation is a pro rata method, as described in [35] for the allocation of electrical loss costs.In our case, we allocate 100% of the loss costs to the consumers.Pro rata procedures are network-agnostic, i.e. loads near generating nodes pay the same loss price per unit consumed as loads far away from generating nodes [35].
It should be noted that the individual loss allocation policy suits our loss-aware markets naturally.In other words, in the loss-aware markets the agents are dispatched optimally, given that the losses are allocated according to the individual loss allocation policy.For these loss-aware markets, the dispatch would be different if the agents would be able to anticipate the socialized loss allocation.For the loss-agnostic market, this is the case for both the individual and the socialized loss allocation.In this work, we however assume that the agents are not able to anticipate the loss allocation post-processing, i.e. they are regulationagnostic.To summarize, the socialized loss allocation is an ex post step for all market types, while the individual loss allocation is integrated in the market clearing for the loss-aware markets.
For the loss-aware DLG, the revenue   of generator  at time  is computed as (29) so that every generated unit costs the nodal price at   .In the rightmost expression the cost is split into cost of consumed energy and cost of loss.When using the individual loss allocation policy, consumer  is paying    N    to make up for the cost of loss.In the socialized loss allocation policy, the costs of loss are shared over all consumed units, so that the cost of loss per unit consumed  L in DLG becomes and in CLG becomes

Numerical results
Through an illustrative case study we show the benefits of lossaware dispatch, and the drawbacks of not considering the cost of loss.We look at total scheduled generation volumes, total amount of losses, total cost and cost of loss, and agent payments and revenues.In addition, we visualize the effect of loss-and network-awareness on nodal (locational) marginal prices.The aim of this case study is to illustrate the properties of the proposed market mechanisms, rather than to mimic a specific real system as closely as possible.All case study inputs, as well as an implementation of the three market variations in Julia, and example analysis of the outcomes can be found in our GitHub repository. 1

Case study setup
We simulate an hourly day-ahead market for 24 h.We consider a simple network topology without branches, see Fig. 3, even though the market mechanisms are also suitable for other types of radial systems.The system consists of 11 nodes.The supply temperature at the most upstream node  1 is 90 • C, and the return side temperature of the most downstream node  11 is set to 40 • C. Precise ways of determining constant nodal temperatures are beyond the scope of this work.For illustrative purposes, we will assume a temperature loss of 0.1 K m −1 on the supply side, and a loss of 0.05 K m −1 in return side pipelines.A total of 28 prosumers are present in the system, of which 6 generate excess using heat pumps, while the remaining 22 cannot generate heat.The used reference DHW and space heating load profiles are measurements from the Nordhavn neighborhood in Copenhagen, collected in the EnergyLab Nordhavn project [36].The excess heat generators are located at all even nodes and node 1, i.e. node 1, 2, 4, 6, 8, 10, which are marked as HP in Fig. 3.The remaining agents without production are distributed over the remaining nodes, so that nodes 3, 5, and 7 contain 4 agents each, and node 9 and 11 contain 5 agents each.The excess heat generators have identical maximum generation capacity, while their heat pump COPs differ.The six heat pump COP values range linearly from 3.27 to 3.46.
The agents are subject to a variable electricity price, whereas the heat import price is constant.This is a situation that currently can be the case for consumers in for example Denmark: consumers can opt-in on variable electricity prices, whereas heat prices are always constant (apart from possible seasonal differences).The price curves used in this case study are plotted in Fig. 4. The electricity price profile is a series of day-ahead prices from Nord Pool Elspot on January 8th 2021.This price only includes the energy price, so the real price paid by consumer is higher, especially in Denmark where the price of energy is around 20% of the total price. 2To be more realistic, we multiply the price signal by 2.5.The constant heat import price signal is set to 524 DKK/MWh or 69.87 EUR/MWh, which equals the consumer heat price set by the Danish heat provider HOFOR.We consider two variants of this case study: case I and case II.The cases differ only in the marginal costs of the local heat pumps, which allows us to illustrate different properties of our mechanism, and to distinguish between general outcomes and case-dependent outcomes.In case I, the heat pumps are placed so that marginal production costs decrease (i.e.COPs increase) with distance from the heating grid connection.This means that the excess heat producer at node 1 will have the highest marginal cost, followed by the producer at node 2, then node 4, etc.In case II, the heat pump order is reversed, so that the marginal production cost increases and COP decreases with distance from the grid connection.Now the marginal costs of the producer at node 1 will be lowest.In the next Section, we use case studies I and II to compare the different market mechanisms, and illustrate relevant properties.

Results
First, it should be noted that a network-agnostic dispatch in a unidirectional network with multiple producers may be infeasible.The main reason for this is the lack of directional awareness, i.e. downstream producers can be scheduled for an amount greater than the loads they are able to reach.An important benefit of the considered market mechanisms (including the loss-agnostic benchmark) is that the resulting dispatch is guaranteed to be feasible, as opposed to network-agnostic markets.In addition, the loss-aware dispatch is optimal under the assumption that grid temperature cannot be varied.When projecting network-agnostic market outcomes in the feasible space, as is common practice in current district heat dispatch, such optimality guarantees do not exist.

Scheduled generators
We compare the dispatch of local generators in the loss-aware markets, both DLG and CLG, to our loss-agnostic CLG benchmark.In the loss-aware markets, the cost of loss is taken into account in the dispatch, while the loss-agnostic benchmark minimizes production cost of consumed heat only.It is expected that distant generators have an advantage in the loss-aware markets, as their loss costs are lower.This effect is indeed seen in the dispatch shown for case study I in Fig. 5a and case study II in Fig. 5b, where the generation over the entire time horizon is shown per node.In both loss-aware markets (blue and orange bars), distant heat producers are scheduled to generate a greater amount of energy than in the loss-agnostic benchmark (green bars).This shows that loss-aware dispatch promotes more local heat consumption.We note that for case II, the DLG has a far more widely varying generation between nodes 6-10.This observation is most certainly case-study specific, and would not be there if focusing on a different case-study application.In case I, the loss-aware markets' generation schedules are equal except for the loss generation, which is shifted from the local generators to the grid agent in the CLG dispatch.This similarity of schedules is not a general result, as we see for case II in Fig. 5b.In case II, the loss-aware DLG and CLG dispatches are not equal for node 6, 8, and 10.Compared to DLG, loss-aware CLG increases the generated heat at the most distant generation nodes 8 and 10, while reducing the generated heat at node 6.This is due to the higher cost of loss for these generators in the CLG market compared to the DLG market, as the losses have to be imported from the grid node that is far from node − 10.In other words, distant nodes have a greater incentive to minimize losses in loss-aware CLG than in loss-aware DLG.

Total heat loss and total generation costs
Table 2 gives an overview of the total heat loss over 24 h for each market mechanism and each case.Note that the heat loss in all three markets is considerably higher in case II than in case I, because in case II the cheaper generators are located far from the distant consumers.As expected, the loss-agnostic market results in the largest heat loss in both case I and II.The table also shows the percentage decrease in heat loss relative to the loss-agnostic case for the other two markets.In case II, this decrease is most dramatic: the heat loss is almost halved in the two loss-aware markets, compared to the loss-agnostic case.These results show that loss-aware dispatch leads to a decrease in network heat loss.
One may expect that the losses of loss-aware DLG must always be lower than loss-aware CLG.Interestingly however, the results of case II in Table 2 show loss-aware CLG may lead to lower total losses than lossaware DLG.The explanation for this is that in loss-aware CLG, losses are more expensive as they have to be imported from the grid, so that local production is stimulated even more than in loss-aware DLG.This may result in more frequent scheduling of the distant generators, and thereby a reduction in total heat loss.
Table 3 summarizes total generation costs for all three market mechanisms, for both case I and II.In addition, the cost reductions in percentages compared to loss-agnostic CLG are given.Loss-agnostic dispatch is expected to increase the cost of loss, and thereby the total cost.Furthermore, it is expected that CLG leads to higher generation costs than DLG, because the feasible space is restricted by forcing the grid agent to produce all losses, rather than leaving it to the cheapest generator.These effects are indeed observed for both case I and case II, as seen in Table 3.In case II, the total costs are lower for loss-aware DLG than loss-aware CLG, despite the observed higher heat loss.The cost differences between the different market types are largest in case II, whereas they are minimal in case I.The reason for this is that in case I, the different market mechanisms lead to rather similar generator schedules.In all, we show here that loss-aware dispatch decreases operational costs resulting from heat loss.

Locational marginal prices
The Locational Marginal Prices (LMPs) as a function of time for case I are shown in Fig. 6, and for case II in Fig. 7.These prices depend on the choice of loss allocation policy as well.For the loss-aware markets, we use the individual loss allocation that suits these markets naturally.For the loss-agnostic benchmark, we use the socialized loss allocation that is most suitable to this market.Two effects on the nodal prices can be distinguished: the effect of losses and the effect of (unidirectional) flow constraints.The effect of losses is only present in the loss-aware markets, most clearly in case II in Figs.7a and 7b, but also in, for example, hour 10 of the loss-aware markets in case I.The LMP at node 1 equals the import price, and as one moves away from the grid node the LMP increases by a (known) factor.The effect of unidirectional flow can be seen in both loss-aware and loss-agnostic markets of case I in hour 14 to 17.It occurs when a cheap marginal generator is located downstream, so that it cannot supply some upstream nodes.As a result, marginal prices may be lower at distant nodes.The effect is not seen in case II, as the cheaper marginal generator is always upstream.Concluding, in the loss-aware markets the LMPs may differ per node for two reasons, namely due to losses and/or due to heat flow restrictions.In the loss-agnostic case, the LMPs only differ between nodes due to heat flow restrictions, and downstream LMPs will always be lower than or equal to upstream LMPs.
On the shape of the LMP curves, it is also visible at which hours nodal heat is generated and when heat is imported from the grid.The latter is the case in those hours where the LMP curve is at high level, and horizontal.Here, we see the effect of having a constant heat   import price while having a variable electricity price.Local generators are selling heat at times of low electricity price, i.e until 9 AM and after 9 PM, no matter if grid heat is actually cheap at that time.Heat is imported between 10 AM and 20 PM, which includes the evening demand peak.This puts a pressure on the heat transmission grid, which may be prevented if a variable cost of importing heat is communicated to the consumer.This illustrates the need for variable heat import prices, or even combined heat and electricity markets.

Payments: individual vs. socialized loss allocation
In this Section we illustrate how consumers may be affected by loss-aware dispatch under different loss allocation policies, by looking at the average consumer price per unit consumed.This average price includes the costs of consumed energy and of loss, where the latter is either socialized or individual, while the former is individual in all cases.The proposed loss allocation policies affect the payments made by consumers of heat, whereas the revenues received by generators are equal for the different loss allocation policies.
The socialized loss allocation policy redistributes the cost of loss, so that an equal loss price is paid for all consumed units.As a result, nodes with an above average loss costs per unit consumed will pay a lower price in the socialized case than in the individual case, and vice versa for nodes with below average loss costs.The redistribution of loss costs is most intuitive in case II, as illustrated in Fig. 8b for the loss-aware DLG market.In case II, where marginal generation costs increase with distance from the grid node, the cost of loss increases with distance from the grid node.As a result, it can be seen that the socialized loss allocation generally reduces the unit price for distant nodes, whereas it increases the price for nodes closer to the grid connection.The socialization of loss cost also pulls most nodal prices towards the average price, for all nodes except node 6 and 8.This is not a general result, but it is a result of the fact that most nodes with higher loss costs also have higher energy costs.For case I in Fig. 8a, there is also a trend that the socialized loss allocation redistributes loss costs from distant nodes to proximal nodes, but it does not hold for all nodes.For instance, node 10 pays a higher unit price under the socialized loss allocation.For case I, as opposed to case II, most nodes experience an average unit price further from the average under the socialized loss allocation.In other words, if energy costs are individualized, the socialization of loss costs may lead to larger differences in unit prices, which is the opposite of what may be expected from socialization.
Finally, we compare the average unit price of loss-aware DLG market with individual loss allocation policy, and of loss-agnostic CLG market with socialized loss allocation policy.The loss-aware DLG market with individual loss allocation is the one giving optimal incentives to market participants for reducing losses, but leads to the highest loss price differentiation between them.The loss-agnostic CLG market with socialized loss allocation is closest to existing practices.The comparison is shown in Fig. 9, which shows both the average unit price as a function of node, and the overall average.In both case I and II, the overall average unit price is higher for the loss-agnostic market.As a result, most nodes pay a lower unit price in loss-aware DLG with individual loss allocation, even though the loss is paid by the individual.Only those nodes with the very highest loss costs benefit in the loss-agnostic CLG with socialized loss costs.

Conclusion
District heating systems become more distributed with the integration of prosumers, including excess heat producers and active consumers.This calls for suitable heat market mechanisms that optimally integrate these actors while ensuring network feasibility and considering operational costs.To this end, we have proposed two variants of a network-and loss-aware heat market mechanism, as well as a networkaware but loss-agnostic benchmark.The markets are formulated as Quadratic Programs.In our distributed loss generation (DLG) market variant, losses caused by a certain trade are produced by the seller of that trade, while in the centralized loss generation (CLG) formulation this is done by a grid agent.In the benchmark, the loss costs are excluded from the objective function.We used peer-to-peer trades to explicitly link losses to certain market participants.The mechanisms are suitable for radial, unidirectional district heating systems with bidirectional nodal flow, , and allow for multiple heat injection points.We have derived dual relations for the proposed markets and the benchmark, and determined the nodal marginal prices.Based on these nodal prices we formulated allocation mechanisms for energy and   loss production costs.We considered two allocation mechanisms for the cost of loss: an individual and a socialized policy.In the former, loss costs are allocated to the buyer of the trade causing the losses, whereas in the latter they are socialized.Through a case study we have illustrated several properties of the proposed market mechanisms by comparing to our benchmark.Most importantly, we have shown that the loss-aware dispatch may schedule distant generators despite their higher production costs, in case this reduces the total cost including cost of loss.We have shown that the total heat loss and cost of heat loss are reduced in a loss-aware dispatch compared to our loss-agnostic benchmark.In conclusion, we have shown that the lossaware market mechanisms can help promote local consumption and reduce operating costs in district heating networks, while integrating distributed generators and prosumers.

Discussion
Compared to network-aware mechanisms in the literature, our formulation has the advantage that it can include multiple distributed generators and flexible loads, while leaving the size and sign of nodal power injection variable.The latter means that no unit commitment decisions are fixed before dispatch, and prosumer nodes are free to either consumer or produce, as opposed to constant-flow variabletemperature (CFVT) formulations.These advantages come at the price of other desirable properties.First of all, generators (consumers) must inject water at the respective nodal supply (return) temperature, while CFVT or full variable-flow variable-temperature (VFVT) formulations allow for variable injection temperatures.This may be a problem for some agents in practice.A way to deal with this would be to have punish deviations from the set temperature.For example, generators would not be paid for the additional energy in case they inject at a too high temperature, and would pay a fee in case they inject at a lower temperature than expected.Another challenge is that the fixed nodal temperatures in our formulation have a large impact on dispatch and prices, and should therefore be selected carefully.New, fair methods of determining these temperatures are needed.
The main purpose of adding peer-to-peer trades in this work was to trace losses back to certain producers and consumers.There are other reasons these peer-to-peer trades may appeal in practice.For one, the formulation allows for including consumer preferences, both based on the source of the heat as well as on the amount of loss.This would be done by adding weighting factors to the objective function, as for example in [26].Moreover, for implementation of a consumer-centric heat market in practice, the peer-to-peer formulation is appealing because it forms the basis for deriving a decentralized negotiation mechanism, in which all market participants solve a local optimization problem.The peer-to-peer market is then cleared using a distributed optimization method, such as the Alternating Direction Method of Multipliers (ADMM), in which agents would negotiate directly with one another.ADMM is an iterative method.In every iteration, the market participants all solve a local optimization problem, and sends trade proposals to each trading partner.For more details on reformulation to distributed setup, as well as a discussion of the implications of a decentralized peer-to-peer market in practice, refer to for example [27].Our individual peer-to-peer dispatch satisfies conditions to be solved by ADMM as summarized in [37].Therefore it is possible to solve the dispatch in a distributed, fully decentralized manner.Note that the socialized loss allocation policy is not readily suitable for use in a distributed setup.

Future perspectives
Future research could investigate the inclusion of operating costs and constraints related to water pumping in the network.This is done in [24] for a system with a single point of heat injection, using a first order approximation of bilinear expression for pumping energy.This approximation cannot be used in the presence of multiple injection points, but can perhaps be generalized to the multiple injection setting.Otherwise, one could respond to approximate pumping costs as a recourse action, after market clearing.In such a setup, the output of the simplified market clearing without pumping equations may be seen as the operating point for the system.Then, by adding McCormick relaxations of pumping equations to the simplified setup, one could see how much it would be beneficial to deviate from these operating points.Those deviations may eventually be seen as potential recourse actions.
The proposed market design is only suitable for systems with unidirectional pipeline flow.It could be adapted to accommodate systems with bidirectional flow.For instance, pipelines losses could remain a fixed share of transported energy, i.e. the losses would still be multiplicative.A loss factor would have to be determined for each pipeline.It is however not trivial how nodal temperatures and pipeline flows could remain part of such model, and this should be investigated further.
In this work, we have focused on the heat market, and therefore simplified connections to the electricity system.Already in this simplified case, it became clear that consumers that are subject to variable electricity prices but fixed heat import prices may shift their load in a way unfavorable for the heating system.This highlights the need for variable heat prices in the presence of variable electricity prices.In future work, the proposed heat market mechanisms can be extended to a combined heat and electricity market.

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

Appendix
In this Appendix we derive dual variable relations for the three market setups considered in this work.

A.1. Dual variable relations between nodes
The relations derived in this Section hold for all market formulations in this work.To determine the relations between the nodal dual variables  HE  , we derive the first order conditions for flow in node  and pipe  = ( where the equality on the third line comes from (41).This relation shows that the buyer price is a fixed factor greater than the seller price, which implies that the buyer pays more per unit of consumed heat than the seller is paid per unit of produced heat.This way, the buyer is experiencing the cost of loss.The price of energy and loss is equal.Case 2:  and  are at the same node, so   =   .Then by (34d) it holds that  inj  =  inj  .The loss must be zero, i.e.   = 0 which implies  w  ≥ 0. From (39) and the fact that w = 0 if   =   , we derive This relation is as expected, as there are no losses when  and  are at the same node.

A.3. Loss-aware CLG market
So in this case,   = 0 for all agents.This results in several changes in the first order conditions.First of all, in the derivative with respect to   , now we have The price of loss for the trade between agents  and  is a fixed share of the nodal price at the grid node.We can see that for any time , it holds that

Fig. 1 .
Fig. 1.Representation of district heating network with prosumers and connection to greater heating grid.The supply side is colored red, the return side blue.Nodal temperatures and flows, as well as pipeline flows are indicated.

Fig. 2 .
Fig. 2. Visualization of peer-to-peer variables related to the trade   =   =   = −  .If  = 1, the seller generates the losses, while this is done by the grid in case  = 0.

Fig. 3 .
Fig. 3. Overview of case study district heating system.Each of the nodes 1, 2, 4, 6, 8, 10 contains a single prosumer with a heat pump (marked with HP).Nodes 3, 5, 7 each contain 4 flexible consumers, while nodes 9, 11 contain 5 each.The grid agent injects heat at node 1.The flow is unidirectional from the supply side of node 1 to 11.The return side is equal to the displayed supply network, with reversed flow directions.

Fig. 4 .
Fig. 4. Heat and electricity import prices used in case study.

Fig. 5 .
Fig.5.Total scheduled nodal generation.The shaded part represents the generated heat that is lost on the way to the consumer.

Fig. 6 .
Fig.6.Locational marginal prices as a function of time in Case I. We consider individual loss allocation for the loss-aware markets, and socialized loss allocation for the loss-agnostic benchmark.

Fig. 7 .
Fig. 7.Locational marginal prices as a function of time in Case II.We consider individual loss allocation for the loss-aware markets, and socialized loss allocation for the loss-agnostic benchmark.

Fig. 8 .
Fig. 8. Loss-aware DLG: average consumer price per unit consumed as a function of node for the different loss allocation policies.

Fig. 9 .
Fig. 9. Average price per unit consumed as a function of node.Comparison between loss-aware DLG with individual loss allocation policy and loss-agnostic CLG with socialized loss allocation policy.
.117956 Received 12 July 2021; Received in revised form 14 September 2021; Accepted 26 September 2021 f Specific heat capacity [J kg −1 K −1 ]  Space heating flexibility factor [-] ũ Utility function scaling factor [-] w Loss factor from  to  [-] COP Heat pump Coefficient of Performance [-] L Forecasted load [W]   Temperature at node  [ • C]

Table 1
Overview of dispatch strategies considered.

Table 2
Total heat loss for the three different market mechanisms in case I and II.Percentage decrease with respect to the loss-agnostic CLG market is provided for the other two market mechanisms.

Table 3
Total generation costs for the three different market mechanisms in case I and II.Percentage decrease with respect to the loss-agnostic CLG market is provided for the other two market mechanisms.
Now consider two nodes  1 and  2 connected by pipe  = ( 1 ,  2 ).If none of the pipeline flow bounds are active, it holds that  mp = 0 =  mp , so that  mc  1  =  mc  2  .Combined with (32b) and assuming that none of the nodal flow bounds are active, the following relation between  HE  1  and  HE  2  can be derived f ( SIn this Section we derive the dual relations for the DLG loss-aware peer-to-peer market.Consider the following first order conditions for this case.Those are We can identify that the price each agent perceives for generation is  S  +  inj  .For the perceived price for loads, we combine (34b) and (34c) to Note that  eb  is seen as a bound on the load.Next, we derive relations between seller and buyer price of a nonzero trade   .Assume the sale from agent  to  is nonzero, i.e.   =   > 0. For a marginal generator ,  and  are at different nodes, so   ≠   .Still assuming   > 0, the loss must be positive, so   > 0 and  w (33) 2 ) ṁN  ∶ − mc  +  f ( S  −  R  ) HE  −  mn +  mn = 0 (32a) ṁS  ∶  mc  2  −  mc  1  −  mp +  mp = 0 .(32b)inj.(1+w ) S  = − B  .(41)Combining this with nodal price relations in(33), we derive that buyer price = − B  +  inj  = − B  −  HE    L. Frölke et al.
S g instead of  S .This yields