PV sharing in local communities: Peer-to-peer trading under consideration of the prosumers ’ willingness-to-pay

Distributed on-site PV generation enables traditional consumers to become active participants in a decentralized energy system. In this work, a linear program optimizing peer-to-peer trading between prosumers of a local energy community with PV systems and battery energy storage systems (BESSs) is developed. The community members are characterized by their individual willingness-to-pay for purchasing PV electricity generated by the community, which reflects their ambitions to reduce marginal emissions from the grid. By adding the willingness-to-pay, prosumers do not prefer their own PV generation over the community ’ s generation. The objective function of the optimization model maximizes the social welfare, which means maximizing the self-consumption of the entire community and optimally allocating generation between prosumers. The method is applied to community set-ups including households and small businesses. Results of an arbitrary case-study show improvements in the overall profitability of the PV systems and BESSs. BESSs further decrease imports from the grid by 15% due to flexibilities. The willingness-to-pay is a promising tool to save marginal emissions from the grid, and the case-study shows annual savings of up to 38%. The results show that the community set-up is able to sustain without any subsidies and it can compete in the electricity market.


Introduction
Anthropogenic climate change is detrimental to humanity, wildlife, and ecosystems.The Intergovernmental Panel on Climate Change (IPCC) has advised that to combat the impacts of global warming, greenhouse gas (GHG) emissions must be substantially reduced (Masson-Delmotte et al. (2018)).Globally, most of the energy used for electricity, heating and cooling, transport, and in the industry sector is generated by the combustion of fossil fuels.Switching to renewable energy is a major part of the solution toward sustainability.In addition to the generation of hydro power, it is anticipated that a large share will be provided by wind and photovoltaic generation (see International Energy Agency (2018)).
Photovoltaic (PV) electricity generation on a ground-mounted utility scale and via building attached/-integrated PV systems has become increasingly prevalent in recent years.Notably, on-site PV electricity generation in the building environment accelerates the transition from a centralized energy system to a sustainable, decentralized, and local one.The importance of sustainable energy communities is growing, and the European Union's Clean Energy Package explicitly mentions energy communities, and acknowledges their great potential (Directorate-General for Energy (European Commission), 2019).Participants in energy communities are referred to as prosumers.Prosumers are the simultaneous local producers and consumers of renewable energy; they share the renewable energy within the community and are active participants in the energy system.This paper focuses on energy communities that go beyond the meter and are not limited to a closed system boundary, such as a multi-apartment building or microgrid.Instead, the participants are located in different buildings, and they match and trade their PV generation and demand profiles via a local public distribution grid.However, it is necessary for the matching and trading algorithm to be governed by certain specifications and detailed rules.Most European countries currently lack a legal framework for this type of energy community, unlike for tenant electricity sharing models in multi-apartment buildings that are implemented in certain European countries such as Austria and Germany.
In the sense of "energy democratization," participation in an energy community occurs on a voluntary basis, and different incentives are offered to prosumers to entice them to join.In this respect, such incentives are reflected in the individual willingness-to-pay of each prosumer: the stronger the preference to buy local PV generation, the higher the willingness-to-pay.A model is developed in this study that optimizes peer-to-peer (PtP) trading in an energy community while respecting the willingness-to-pay for local PV generation of individual prosumers.The aim of the energy community is not self-sufficiency, as the members of the community are connected to the public grid and they purchase part of their electricity from the retailer.Instead, the aim of the energy community is to optimally use the resources and thus sustain without requiring any governmental financial support or subsidies.
The paper is structured as follows: Section 2 reviews the state-of-theart types of PV sharing, energy communities, and PtP trading and the contribution beyond state-of-the-art of the study is outlined.Section 3 describes the methodology and the optimization model developed and applied in this work.Sections 4 and 5 present the results of different use cases and sensitivity analyses, respectively, and Section 6 presents the conclusions and future outlook.

State of the art
This section reviews and discusses the current state-of-the-art energy communities and PtP trading reported in scientific literature.Section 2.1 provides an overview of prosumers and sustainable communities/districts.The differences between energy communities and microgrids are defined in Section 2.2, and the legal framework of energy communities is explained.Section 2.3 presents the current state-of-the-art of PV sharing in buildings and beyond single buildings, and Section 2.4 provides examples of real-life peer-to-peer trading implementations.Finally, Section 2.5 concludes this chapter by presenting the own contribution beyond state-of-the-art.

Prosumers and sustainable communities
The push for a transition to a renewable-based, decentralized, energy system has mainly been made by the increasing number of prosumers with PV systems, raising new challenges and opportunities at the same time.For example, the study of Marzband, Fouladfar, Akorede, Lightbody, and Pouresmaeil (2018) shows how prosumers can participate in the electricity market by using home-microgrids.Golmohamadi, Keypour, Bak-Jensen, and Pillai (2019) provide an optimization of the household energy demand of prosumers toward the day-ahead market price, and the challenges of the low voltage network of future smart communities with a high share of prosumers are analyzed in Marszal--Pomianowska, de Cerio Mendaza, Bak-Jensen, and Heiselberg (2019).
Furthermore, the study of Reynolds, Rezgui, and Hippolyte (2017) presents upscaling from the prosumer level to the active participation of buildings within a wider district-level context, and Petersen (2016) analyzes a city in northern Germany to determine how existing districts or communities could become more sustainable and meet climate targets at a local level.Walnum et al. (2019) present a case study of smart communities in Norway, and the study of Leal and Azevedo (2016) is based on districts in Porto, Portugal.Furthermore, a review of the different modeling approaches applied in urban areas (so-called "urban-scale energy modeling (USEM) tools") can be found in Sola, Corchero, Salom, and Sanmarti (2020).
The concept of local energy communities is essential for meeting climate targets at a community level.The next few sections therefore investigate state-of-the-art concepts in relation to local energy communities.

Energy communities versus microgrids
The concept of an energy community is fundamentally different to the concept of a microgrid.A microgrid is a physical distribution grid, or a defined part of a distribution grid, and all connected consumers and producers are part of the microgrid.A microgrid is part of the distribution grid, and it can still be "disconnected and independently operated" (see Rakos, Stumpf, and Nagy (2012)).Ali et al. (2017) investigate the policies, incentives, and barriers associated with microgrids in the EU, US, and China, and further definitions, state-of-the-art, and case studies are found in Hossain, Kabalci, Bayindir, and Perez (2014), Hirsch, Parag, and Guerrero (2018), and Mohseni and Moghaddas-Tafreshi (2018).
In contrast, an energy community is not necessarily physically constrained to a certain area, and participation is on a voluntary basis.Literature provides different definitions of energy communities.For example, Gui and MacGill (2018) provide a very broad definition of an energy community as a social structure that has the primary goal of ensuring a cleaner energy supply, and the context may also be extended to water, transportation, and waste management.They also introduce several concepts and typologies relating to energy communities, such as community-scale energy projects, virtual power plants (VPPs), PtP trading, community microgrids, and integrated community energy systems (ICES).
In Europe, a legal framework has recently been set by the European Commission that promotes active consumer and prosumer participation, self-consumption, and energy communities (see Clean Both RECs and CECs should offer environmental, economic, or social benefits for the community, and they do not primarily promote financial profits.For the main differences between RECs and CECs, please refer to Urbantschitsch (2020) and COMPILE (2019).

PV sharing and peer-to-peer trading
With a reduction in (or phasing out of) subsidized feed-in tariffs in

Nomenclature
PV generation of prosumer i kWh Purchase of prosumer i from the grid kWh Sales from prosumer i to the grid kWh Purchase of prosumer j from prosumer i kWh Charging of prosumer i's battery kWh many countries, it is necessary to increase the self-consumption of PV generated electricity, to ensure that PV systems are profitable.The load aggregation of multiple prosumers could therefore further increase profitability, and tenant electricity models play a key role in this respect.
The study of Fina, Fleischhacker, Auer, and Lettner (2018) analyzes sharing generated PV in multi-apartment buildings, and that of Roberts et al., 2019a compares different arrangements, with the aim of maximizing the value of PV in apartment buildings.The subsequent study of Roberts et al., 2019b evaluates the impact of using a shared battery energy storage system (BESS) in apartment buildings.Both a welfare maximization and a game-theoretic model for PV sharing in a multi-apartment building are developed in Fleischhacker, Auer, Lettner, and Botterud (2019), and multi-objective optimization for retrofitting an apartment (building including rooftop PV systems) is modeled in Fan and Xia (2017).
To go beyond a single building (and therefore beyond the meter), energy communities and PtP trading play a major role in managing the assets of distributed energy resources (DERs).Lüth, Zepter, del Granado, and Egging (2018) analyze battery flexibility in communities of prosumers and consumers, and Tas ¸cikaraoglu (2018) analyzes shared energy storage in neighborhood networks.Furthermore, the study of Zepter, Lüth, del Granado, and Egging (2019) develops an interface to integrate communities of small prosumers into the day-ahead and intraday markets.Multiple home energy hubs in neighborhood grids are analyzed in Gholinejad, Loni, Adabi, and Marzband (2020), and virtual energy hubs within local markets (including thermal energy) are presented in Jadidbonab, Mohammadi-Ivatloo, Marzband, and Siano (2020).Energy communities are very diverse, and their sizes, the number of actors involved, and the rules of sharing electricity are not standardized.The potential of energy communities for different settlement patterns is examined in Fina, Auer, and Friedl (2019).In Abada, Ehrenmann, and Lambin (2020), the viability of energy communities is shown to strongly depend on the rules for sharing electricity among the members.Sharing electricity within a community has a higher potential to reduce GHG emissions than prosumers who act individually, as shown in Schram, Louwen, Lampropoulos, and van Sark (2020), and PtP trading concepts with product differentiation are presented in Sorin, Bobo, and Pinson (2019) and Orlandini, Soares, Sousa, and Pinson (2019).
The incentives for German households to participate in PtP trading, as well as PtP pricing schemes, are studied in Hackbarth and Löbbe (2020), and the trading preferences and decision strategies in PtP trading are evaluated in Hahnel, Herberz, Pena-Bello, Parra, and Brosch (2020).To provide maximum profits, the study of An, Lee, Yeom, and Hong (2020) examines the optimal pricing strategies for the prosumer and consumer and their PtP trading partners, and a simulation of a PtP bidding system is conducted in Zhang, Wu, Zhou, Cheng, and Long (2018).Furthermore, Sousa et al. (2019) suggest that PtP trading currently means either: (i) sharing of the excess renewable generation within a community, or (ii) buying electricity directly from a local renewable generator.

Practical peer-to-peer trading implementations
Park and Yong (2017) introduce PtP trading concepts and provide a comparative review.Zhang, Wu, Long, and Cheng (2017) also review different PtP trading concepts, for example that of Piclo in the UK (see Piclo.(2020)), the Brooklyn Microgrid (Mengelkamp et al. (2018) and Microgrid (2020)), and Vandebron in the Netherlands (see Vandebron. (2020)).Customers using Piclo buy local renewable electricity and generators have full transparency on a half-hourly basis.The Exergy platform of the Brooklyn Microgrid allows the prosumer to conduct autonomous electricity transactions almost in real time.Vandebron allows producers of renewables to set their own prices, and consumers then select a supplier.OurPower is a platform for producers and consumers of renewable, decentralized electricity that is implemented by an Austrian energy cooperative (see OurPower.( 2020)), and the project P2PQ optimizes PV self-consumption and tests PtP trading concepts via blockchain (see open4innovation.( 2018)).The sonnenCommunity (see sonnenGroup (2020)) in Germany, Austria, Switzerland, and Italy allows prosumers to share their electricity with other members of the sonnen-Community, and members of this community do not need to also use a conventional electricity provider.In addition, people who join efriends can invest in PV projects of SMEs and subsequently buy renewable PV generation from there (see eFriends Energy GmbH (2020)).Other recent projects are presented by BestRES (see BestRES ( 2018)).

Progress beyond state-of-the-art
This work presents a method for distributing generated PV power within energy communities that involves voluntary participation.The allocation mechanism uses a PtP trading concept that considers each member's individual willingness-to-pay.The contribution of this paper beyond state-of-the-art is outlined as follows: • The prosumers not only share their PV surplus with the community, but the total amount of PV electricity generation is PtP traded within the community to optimally allocate resources while respecting each of the member's willingness-to-pay.In this respect, prosumers can create a greater profit margin by selling their PV electricity generation to community members who have a higher willingness-to-pay.
In addition, prosumers who are interested in minimizing their environmental footprint can purchase greater amounts of clean PV electricity generation.Many different nuances between profit maximization and emission minimization are also possible.• Ultimately, this concept means that prosumers do not prefer their own PV electricity generation over other prosumers' PV generation and it paves the way for energy communities to attain a sharing economy.
• The individual willingness-to-pay of each community member is a very comprehensible function that is derived directly from GHG emissions having an equivalent CO 2 price in EUR/tCO 2 .It is a price that prosumers are willing to pay on top of the electricity price and is their individual and voluntary contribution to emission reduction targets.
• Prosumers are therefore able to calculate the reduction in direct emissions (in tons of CO 2 ) that is a result of them sharing PV generated electricity.The willingness-to-pay is derived considering marginal emissions which in turn reflect the actual hourly emission savings.With the proposed method, prosumers can individually account for their environmental impact and footprint.

Methodology
This section explains the methodology and the optimization model used to obtain the results presented in this paper.The section starts with an introduction and overview of the model in Section 3.1, followed by a detailed mathematical description in Section 3.2.Model implementation parameters and data are presented in Section 3.3, and model validation is shown in Section 3.4.

Introducing the optimization model FRESH:COM
The linear optimization model developed in this work1 is described in detail in this section.In general, local energy communities with the following properties are considered: • Members of the community are either consumers, producers, or both (prosumers).For simplicity, all members are referred to as prosumers throughout the paper.• The members are regular households, or small-to-medium-sized enterprises (SMEs).• The incentives for participants to join the energy community vary between (i) consuming local PV electricity, (ii) contributing to increasing the community's self-consumption, (iii) improving the PV system's profitability, (iv) avoiding emissions, and (v) others.• The community is based on fully democratic participation.Joining or leaving the energy community is on a voluntary basis, and the willingness-to-pay for the community's generated PV electricity is individually set (the minimum price is equal to the retail electricity price).• The technology portfolio includes PV and BESS.
• Each household is connected to the public distribution grid, which is used to conduct PtP trading.The case presented in this paper is a setup in which all the prosumers are located in the same section of the local distribution system.• The objective function of the model maximizes the community's social welfare, and this is expressed in monetary terms.
Fig. 1 shows a flow chart of the methodology.The sequence used in the modeling approach is as follows: • Members joining the energy community are defined and the following prosumer input data are collected for the model: an electricity demand profile, a PV generation profile, and the battery parameters.It is important to note that size of the PV system is not optimized for the community. 2It is assumed that prosumers, who join the community, already have a PV system designed according to their roof top area and orientation as well as their annual demand.• The willingness-to-pay of each prosumer is calculated as explained in Section 3.2.2.
• A linear optimization problem (LP) is set-up, and the objective function and constraints are defined according to Eqs. (3a)-(3g).• The linear optimization problem is solved.
• The results for the community set-up are analyzed with respect to the amount of electricity traded and the revenues and emission savings of the prosumer.

Mathematical formulation of the optimization model
This section explains the optimization model in detail.First, social welfare is defined in this context.Then, an individual's willingness-topay is explained.Finally, the mathematical formulation of the objective function and constraints of the model are presented.

Definition of social welfare
The objective of the model is to maximize the social welfare of the community.To make the abstract term social welfare more tangible, the individual members of the energy community are considered on the one hand, and the energy community as a whole is considered on the other hand.In economics, social welfare maximizes the welfare of both parts. 3 Part I of social welfare measures the optimal resource allocation on the level of the community as a whole, and overall self-consumption is maximized by PtP trading among all members.In other words, the community minimizes its electricity bill from the retailer.Part II of social welfare is maximized when the share of PV generation is optimally assigned to each member of the community under consideration of the willingness-to-pay of each individual.Social welfare, SW, is defined as With this approach, prosumers not only negotiate the PV surplus, but 3 Social welfare comprises two parts: producer and consumer welfare.Producer welfare corresponds to part Ithe community as a whole acting as a producer to maximize profits.Consumer welfare corresponds to part II and considers the demand function (here: willingness-to-pay).
T. Perger et al. the entire amount of PV electricity generated is traded within the community, without preference for self-consumption, and solely according to each individual's willingness-to-pay.As willingness-to-pay also depends on avoiding GHG emission, social welfare indirectly includes emission preferences.

Defining willingness-to-pay
As explained above, the willingness-to-pay of an individual determines how much PV generated electricity is shared between the community members and how it is distributed.The main idea behind the willingness-to-pay above the retail electricity price for purchases from the grid relates to an individual's preference for reducing marginal emissions from the grid.Similar to marginal costs, marginal emissions are emitted when another unit of electricity (kWh or MWh) is produced in the wider electricity system, and the time variant vector e t (in t CO 2 / kWh) represents the marginal emissions.This means that the GHG emissions from a marginal power plant are considered instead of the average emission factor.Each prosumer, j, can choose an individual weighting factor, w j , (in EUR/t CO 2 ), which represents the amount they are willing to pay on top of the retailer's price, because marginal emissions will be avoided by buying the locally produced PV generated electricity.
The willingness-to-pay can thus be determined in relation to the retailer's electricity price, p Gin t , plus the premium for avoiding emissions as a product of the individual weighting factor, w j , and the marginal emissions, e t , as q share i,j,t is therefore distributed according to the emission factor w j of each prosumer.Ultimately, this means that prosumers do not prefer their own PV generation over other prosumers' PV generation.

Mathematical formulation of the objective function and constraints
Fig. 2 shows a sketch of a small, energy-trading community.The figure helps to illustrate the following mathematical representation and formulation of the optimization model, FRESH:COM.Including BESSs and PV systems in the technological portfolio of the community, the optimization problem can be formulated as follows.

max {
q Gin i,t , q Gout i,t , q share i,j,t , subjectto q load i,t = q Gin i,t + q Bout i,t + ∑ j∈ℐ q share j,i,t (3b) q Gin i,t , q Gout i,t , q share i,j,t , q Bin i,t , q Bout i,t , SoC i,t ≥ 0 (3g) for all i, j ∈ ℐ and t ∈  .The objective expressed in Eq. (3a) to maximize the social welfare described in Section 3.2.1.Equations ( 3b) and (3c) are constraints for covering the demand and PV generation of each prosumer at each time, and Eq.(3d) determines the state of charge (SoC i,t ) of the batteries.4Equations (3e) and (3f) limit the state of charge and the (dis-)charging power to their physical boundaries.Finally, the nonnegativity constraints are represented by Eq. (3g).

Model implementation and data
The model is implemented in MATLAB (version R2019b MATLAB (R2019b) (2019)) using the optimization toolbox YALMIP Löfberg (2004) and the solver Gurobi Gurobi Optimization (2019).In this study, the model is applied to different arbitrary energy community set-ups.T. Perger et al.

PV generation data
The PV generation data were obtained from the open source tool Renewables.ninjaRenewables.ninja (2019), see also Pfenninger Pfenninger and Staffell (2016) and Staffell and Pfenninger (2016), where relevant data can be obtained for any location and for different PV system parameters, such as peak production, azimuth, and tilt.The community set-up used to obtain the results in this paper is situated in the city of Vienna, Austria (latitude 48.2084 • N and longitude 16.3725 • E).The reference year employed was 2019, and a tilt of 35 • was set equally for all PV systems used in these analyses.

Prosumer data and willingness-to-pay
The sample community used to test the proposed optimization model, FRESH:COM, comprises a set of (arbitrary) prosumers consisting of ten private households and five small businesses.The electricity demands of the households are generated by using real measured anonymized demand profiles EEG (2020), while the electricity demands of the different types of businesses are derived from so-called Synthetic Load Profiles APCS-Austrian Power Clearing and Settlement (2019), which are also used as a reference in daily electricity market operations, scheduling, clearing, and financial settlements.Table 1 shows the parameters of PV orientation and peak output, the BESS capacity, the individual emissions' preference, w i , and the annual electricity demand of each prosumer, and Figs. 3 and 4 are graphical displays of prosumer household data and those of the five small businesses, respectively.Further information about the demand and generation profiles is provided in A and B.
The charging and discharging efficiencies of the batteries is assumed to be η B = 0.9, and the maximum (dis)charging power is The state of charge should not fall below SoC min i = 0 kWh.

Marginal emissions and prices
The study of Schram et al. presents a time series of marginal emissions from certain European countries in 2017 Schram, Louwen, Lampropoulos, and van Sark (2019).The hourly values of the German-Austrian price zone are used in this study to remain geographically consistent.Further information about marginal emissions can be found in C.
The optimization model also requires the retail electricity price, p Gin t , that prosumers pay when buying electricity from the grid, and the remuneration, p Gout t , for feeding PV generation to the grid.In addition, the average value of the 2019 Austrian retail electricity price (0.20 EUR/ kWh 5 ) is assumed for p Gin (see European Commission -Eurostat ( 2019)).
In this work, all the settings are designed for PV generated electricity without consideration of any subsidies and/or feed-in tariffs.It is assumed that excess PV generation is sold at a spot market price.To retain consistency with data available for marginal emissions6 , the reference used here is the average value of the base product of the (then) German-Austrian spot market in 2017 EXAA Energy Exchange Austria (2020).Therefore, p Gout is set to 0.0345 EUR/kWh.

Model validation
In this section, the model is validated by testing its basic functionalities.Section 3.4.1 presents the model validation with respect to sharing excess PV electricity generation only, but not considering the willingness-to-pay.The functionality of the willingness-to-pay is then verified in Section 3.4.2.

Model validation by sharing excess PV electricity generation only
The first model validation verifies the model when considering that only the prosumers' excess PV electricity generation is shared with the other community members, and that the willingness-to-pay for PV generation by the community is equal to the retailer's electricity price.To model this case, the willingness-to-pay, wtp i,j,t , is adapted compared to Eq. (2): By adding a small term, ε i , to p Gin t for self-consumption, it can be noticed that self-consumption is preferred before buying from other members.No further changes are added to the model.The prosumers in this set-up are the same ten households those presented in Table 1.The diagonal line in the 3D bar plot in Fig. 5 indicates the self-consumption of each prosumer.Prosumers owning a PV system have very high selfconsumption, and the amount of excess PV generated electricity is shared mostly with members who have no PV systems of their own.Luthander, Widen, Nilsson, and Palm (2015) summarize different studies that have researched typical values for prosumer self-consumption and the effects of BESSs on self-consumption.As shown in Fig. 6, the values for self-consumption in this scenario lie between 25% and 40%, which is in agreement with the values presented in Luthander et al. (2015).Prosumer 3 has over 50% self-consumption and is an outlier because of their small PV system.When including batteries (prosumers 2, 4, 7, and 9), the self-consumption of those prosumers operating BESSs increases by 20-25% (see Fig. 7).

Validating the functionality of the willingness-to-pay
The next step is to validate the functionality of the willingness-topay.The community set-up consists of ten households with the parameters shown in Table 1, except that only prosumer 10 has a PV system (and all BESSs are neglected).The 3D bar plot in Fig. 8 shows that the PV generated electricity of prosumer 10 is traded within the community according to the willingnesses-to-pay of the prosumers (i.e. who pays most, buys most), and prosumer 3, 8, and 9 are the most willing to pay.Fig. 5 shows the results relating mostly to self-consumption, where only excess PV generation is distributed within the community.However, compared with the scenario shown in Fig. 8, it is highly evident how the willingness-to-pay enables and determines PtP trading.

Results
This section presents the results for two different energy community set-ups.Section 4.1 presents the results for the ten households, and the five small businesses are then added in Section 4.   results including businesses on an annual basis.

Electricity balance on annual level Energy community without BESS
In the set-up of prosumers selected (10 households without BESSs), 26% of the electricity is traded within the community, while the share of self-consumption is only 3%, see the pie chart in Fig. 9. Furthermore, 43% of the electricity is purchased from the retailer and the surplus fed into the grid equals 28%.The objective function of the linear optimization model ensures that the electricity purchased from the retailer is minimized.Furthermore, sharing within the community and selfconsumption are preferred compared to selling to the grid.
PtP trading is then discussed in detail.The 3D bar plot in Fig. 10  T. Perger et al.
shows the results of the optimization variable q share j,i,t over one year ( ∑ t∈ q share i,j,t ,  = 1,…,8760), and the amount of PV generated electricity that each prosumer trades with other prosumers is evident.Following the matrix logic of q share j,i,t , the diagonal line indicates the self-consumption of each prosumer and their willingness-to-pay decides how the generation is shared.
As each member of the energy community has their own characteristic electricity demand and the dimensions of the PV system vary, the distribution of q share j,i,t not only depends on the willingness-to-pay, but also strongly on the size of each prosumer's PV system.A different perspective is shown in Fig. 11, where the focus is on the relation between the self-consumption of each prosumer (yellow) and the electricity purchased from the community (green) and from the grid (blue).The PV consumption to demand ratio (the percentage of the annual demand that is covered by PV generation from self-consumption and buying from other community members) is presented on the right axis (in %).
Fig. 12 shows the correlation between the willingness-to-pay (left axis, blue) and the ratio between the amount of PV electricity consumed and the demand for electricity (right axis, red).The figure indicates that a high willingness-to-pay generally leads to a higher share of PV electricity from the community and vice versa.Therefore, the introduction of a willingness-to-pay is a promising tool for allocating the PV electricity generated, especially within an energy community where all of the PV generation is shared, and not just each prosumer's surplus.
The revenues and emissions' savings of each prosumer change when they join the energy community and engage in PtP trading.To analyze this effect, the revenues and CO 2 -emissions are calculated and compared to the revenues and the emissions that the members would generate if they were stand-alone prosumers only, who do not share their PV electricity generation.Participants with a high willingness-to-pay pay more for electricity in the PtP trading scenario and end up with a negative financial balance compared to being a stand-alone prosumer.On the other hand, participants with a relatively low willingness-to-pay generate profits because they sell most of their renewable energy to members who are willing to pay more.The red bars in Fig. 13 show the financial savings generated by engaging in PtP trading.The four prosumers with the highest willingness-to-pay (prosumers 3, 6, 8, and 9) have a negative balance.Prosumers 1 and 7 have the lowest willingnessto-pay and the highest savings, with savings of approximately 38% for prosumer 1.
A similar but opposite tendency can be seen with emissions' savings.The green bars in Fig. 13 indicate whether a member can save marginal emissions by purchasing from their peers.A high willingness-to-pay leads to emissions' savings because of the implicit preference to purchase emission-free PV generated electricity over that from the retailer.It should be noted that most prosumers in Fig. 13 follow the same pattern: a positive financial balance but no emissions' savings, or emissions' savings but a negative financial balance.

Energy community with BESSs
This section describes the effects of including BESSs to the technology portfolio.By using BESSs, it is possible to increase the community's shared self-consumption and decrease the amount purchased from the retailer.BESSs are added to the set-up of ten households from the previous section.The pie chart in Fig. 14 shows the distribution of  electricity on an annual level with BESSs operating: 28% of the electricity is shared within the community, 9% is provided by BESSs within the community, and 3% is self-consumption.Purchases from the grid have decreased to 39% due to BESSs, and the amount sold to the grid has reduced to 21%.
Fig. 15 compares the results of community set-ups with and without BESSs showing the differences between the two scenarios, and the following conclusions can be drawn: • Batteries are charged only when the amount of PV electricity generated exceeds the demand of the whole community; therefore, the amount of electricity used for charging is equal to the difference in the amount sold to the grid.• Prosumers are not buying from the retailer to charge their batteries; therefore, the difference in the amount bought from the grid equals the amount discharged by batteries.• When excess PV electricity is generated, prosumers with BESSs can charge their batteries with the PV electricity they generate, and they can then buy from the community, if required.When there is not enough available PV generation, they can use their batteries to cover their demand, instead of buying from the retailer.With BESSs, the whole community buys approximately 15% less electricity from the retailer than without BESSs.• BESSs do no compete with the community's generated PV electricity because only excess electricity generated is stored, and the batteries are discharged only when the amount of PV generation is insufficient for covering the demand.There is only a slight shift between selfconsumption and trading with other members.
In addition, Fig. 16 shows that the financial savings of prosumers with BESSs (prosumers 2, 4, 7, and 9) are higher than in Fig. 13 (without BESSs).Furthermore, prosumers 2, 4, 7, and 9 achieve greater emissions' saving in this new scenario.These positive financial and emissions' balances could thus be incentives to invest in BESS.

Focusing on a detailed 1 h time slot
Following the results obtained on an annual level, one specific hour is analyzed in detail in this section to gain a better insight into the PtP trading mechanism.The set-up is the same as that in Section 4.1.1.1 without BESSs.April 1st between 16:00 and 17:00 is chosen as the timeframe.7Production from the PV systems is relatively high within this hour, and the total amount of PV electricity produced exceeds the total demand of the prosumers (see Fig. 17).The marginal emissions in this hour are 578gCO 2 /kWh and the willingness-to-pay (wtp i,j,t ) is between 0.20 and 0.26 EUR/kWh (see right axis Fig. 17).
Fig. 18 shows the PtP trading results, again as a 3D bar plot.Prosumers 6 and 8 have no PV systems of their own, and they cover their demand by purchasing PV electricity from the community.Prosumer 7 generates high amounts of PV electricity compared to their demand, and is thus selling to prosumer 1 and 8.Other prosumers are also selling proportions of their generated PV electricity to the community.As there is a PV generation surplus, the community does not need to purchase electricity from the retailer during this specific hour.

Energy community including businesses
Energy communities should not only be an option for private households, but also for small and medium-sized enterprises (SMEs).The original community set-up is extended by five prosumers that have typical commercial load profiles.Each new prosumer has a 10kWpeak PV system, and their w j is 0EUR/t CO 2 (the willingness-to-pay therefore corresponds to the retailer's electricity price).First, pie charts compare the annual share of electricity consumed and the PV electricity generated with and without BESSs, see Fig. 19.As there are no BESSs assigned to the businesses (only to the households), the effects of the BESSs are relatively small in this extended community set-up.The remaining results in this section exclude BESSs.The annual demand and amount of PV electricity generated is much higher for the businesses than for the households; therefore, q share j,i,t is particularly high for the businesses (prosumers 11-15, see Fig. 20).
Fig. 21 shows the amount of electricity demanded by each prosumer that is covered by the following: self-consumption, purchases from other community members, and purchases from the grid.The PV electricity consumption to demand ratio (right axis in Figs.21 and 22) shows that the household prosumers can increase their share of locally generated PV electricity compared to the previous set-up (with only households), because of the higher amount of available PV generation.The businesses show different characteristics.Prosumer 13 is a business open from 08:00 until 18:00, and it has a high PV electricity consumption to demand ratio.Its demand profile is high during the day, especially around noon, which is a perfect time to consume PV generated electricity.The demands of prosumers 11 and 14 are highest during the day, but they are not as distinctive as prosumer 13; their PV electricity consumption to demand ratios are lower than that of prosumer 13.In contrast, prosumers 12 and 15 have low PV electricity consumption to demand ratios.Prosumer 12 is a business operating 24 h a day, and the peak demand of the bakery (prosumer 15) is in the early morning hours.Both of their demand profiles do not correlate well with the PV electricity generation profiles.
Finally, the financial balances and emissions' savings of the five businesses are shown in Fig. 23.Interestingly, four out of the five businesses have a negative financial balance.Only prosumer 13 has a positive balance, because their demand profile correlates with PV electricity generation times.Due to the overall dimension of the community's PV systems, the other businesses sell to the grid instead of selling to the community during times of high PV electricity generation, which leads to lower profits.
Therefore, the community set-up is not ideal for most of the five businesses, because sufficient amounts of PV electricity are already generated.A preferential set-up would thus comprise mostly consumers  to whom businesses can sell their PV generated electricity.However, from the perspective of the community, businesses add value because they become the consumers of the PV electricity generated.
Based on the results of this study, it is necessary to determine what type of community is the best fit for new potential members and which prosumer characteristics add value to communities.Future studies can be conducted in this respect, by analyzing energy communities in which members drop in and out over several years, or in which their willingness-to-pay alters over time.In the future, it will be important to determine criteria that members need to meet prior to joining a community, so that the added value is optimal for the existing community as well as for the new member.By applying pareto-optimization principles and net present value (NPV) analyses over a period of time, a joint optimum solution can be found.

Sensitivity analysis
In this section, the input parameters and the default set-up of ten households without BESSs (Section 4.1.1.1)are modified in different sensitivity analyses.The default set-up is located in Vienna, Austria, and some of the parameters (for example the retail electricity price, the average spot market price, and the marginal emissions) are specific to the region.The model presented in this paper is designed to be applied in different regions and countries, and only the location specific input data thus need to be adapted accordingly.In the following sensitivity analyses, some of the input parameters are varied and the prosumer set-up is modified.In this section, the following four scenarios are modeled and evaluated: 1. Varying the Retail Electricity Price The average Austrian retail electricity price is just slightly below that of the 2019 EU-28 average value (see European Commission-Eurostat ( 2019)).As it would be interesting to determine whether adapting the retail electricity price in the model to that of another European country would change the results of the energy community, the retail electricity price, p Gin t , is adapted here to the average German value of 0.3088EUR/kWh.This is a retail electricity price at the upper end of Europe (due to the high renewable levy share, surcharges, and taxes).2. Varying the Remuneration for Excess PV Generation In the default scenario, it is assumed that excess PV generation is sold to the grid at an average spot market price.In this scenario, the results are evaluated when the renumeration is neglectable, i.e. when p Gout t is set to 0. This could occur if excess renewable generation in the current electricity market design is treated rather as a burden than a benefit.

Varying the Marginal Emissions of the External Reference Electricity
Market Compared to the Austrian/German electricity system, other electricity systems have different power plant portfolios (for example, they have a high share of nuclear power plants, which are classified as low-emission or emission free in terms of GHG).As an example, the marginal emissions in the French electricity system are a fraction of the marginal emissions in the Austrian/German electricity market (see Schram et al. (2019)).In this sensitivity analysis, the vector of the marginal emissions, e t , represents the French electricity system instead of the Austrian/German system.4. Structural Diversification of the Community In this final sensitivity analysis, one member drops out of the community.To best demonstrate the possible impacts of changes in the community set-up, it is considered that a prosumer with a relatively high PV electricity generation and electricity demand leaves (prosumer 7 with a 5kWpeak South West PV system).
The following Fig. 24 shows the percentage deviation of the different sensitivity analyses from the default scenario.The output values of social welfare, self-consumption, sharing within the community, and the purchases and sales from/to the grid are compared and the results are as follows: • Social welfare (in EUR) decreases in all four sensitivity analyses.As per Eq. ( 1), the retail price, p Gin t , and remuneration, p Gout t , influence social welfare.Varying marginal emissions does not alter the weights of the willingness-to-pay, but the prosumers pay proportionally less (or more if marginal emissions increase), and therefore the social welfare result changes.The drop-out of the member decreases welfare because there are only 9 prosumers left to buy and sell the PV electricity generated.
• The amount of electricity (in kWh) available for self-consumption and sharing within the community shifts slightly in scenario 2-4.The only distinctive deviation is noticeable in sensitivity 1, where self-consumption increases and sharing with the community decreases.It is important to note that self-consumption in the default scenario is only a few percent, and thus the relative shift seems high.• The purchases and sales from/to the grid (in kWh) in sensitivity analyses 1-3 are not different from those in the default scenario, because the prosumer set-up is the same and the social welfare maximization minimizes the purchases/sales from the grid.However, these change in sensitivity analysis 4, when one member leaves the community.The total amount of electricity decreases, because there is a lower electricity demand as well as lower PV electricity generation.

Conclusion and outlook
By using the linear optimization model developed in this work, sustainable energy communities can share PV electricity generation under the consideration of each prosumer's willingness-to-pay.The conclusions of this study are summarized below: • The results show that the implementation of the willingness-to-pay, as proposed in this work, promotes the desired outcomes for the prosumers.Individual added values are created from participating in the energy community, depending on the needs of the prosumer: financial savings (equivalent to higher profits) for profit-orientated prosumers with a low willingness-to-pay, and high emissions' savings for environmentally concerned prosumers with a high willingness-to-pay.• The algorithm ensures that generated PV electricity is perfectly allocated, not only to prosumers according to their willingness-topay, but it is also optimized for the entire community by minimizing purchases and sales from/to the retailer.• Battery energy storage systems (BESSs) increase the flexibility and are therefore able to reduce the community's purchases from the grid.In addition, profitability increases for prosumers with BESSs.• The set-up of the community (with respect to the installed PV capacities, the number of prosumers vs. consumers, and the demand profiles) has a strong impact on the performance of the entire community and of each prosumer.As shown in the sensitivity analysis, members leaving the community may decrease the social welfare and amount of PV electricity generation that is shared in the community.While this may not be significant when only one prosumer leaves, the effects are likely to increase when there is greater variation in the community set-up.• The findings of the sensitivity analyses show that the retail electricity price has a great influence of the overall results.A higher retail price, for example in Germany, decreases social welfare because the community members generally have to pay more for electricity; however, local self-consumption becomes more valuable and therefore the profitability of sharing PV increases.• The concept presented here endorses the concept of energy communities contributing to a sharing economy.Interested participants without their own PV systems can consume locally generated PV electricity, while other prosumers can sell their PV generation to others, who see the value in consuming locally generated PV electricity.There is a potential for new business models to be created and the promotion of investments in PV systems.
The prosumers of energy communities thus become active participants within the energy system and contribute to achieving climate targets.This concept agrees completely with the policy goals of decentralization, decarbonization, and democratization of the energy system.It is therefore possible for individual members of the community to make tailor-made and measurable contributions to ameliorating global climate change.If technological resources and preferences are optimally allocated, the concept presented in this paper can sustain requirements without the need for any government subsidies or financial support.Moreover, this type of energy community concept can be competitive within the current electricity market.
However, this study has a few limitations that require further consideration and investigation.Future studies should therefore address the following aspects: There is a decrease in the revenue of the distribution system operator (DSO) due to local PV self-consumption.Naturally, DSOs are in favor of increasing the fixed component of the grid tariff in case of an increase in the variable/volumetric self-consumption of PV electricity generation by prosumers and communities.A reduction in the variable grid tariff component also negatively influences the profitability of the energy community balances, as this fraction of the grid tariff directly relates to the retail electricity price.Therefore, future studies should focus on different compositions of fixed versus variable charges of grid tariffs and their corresponding influences on energy community results.
It is also necessary to consider dynamic participation in energy communities, where prosumers can join or leave the community on a yearly basis.However, it will be necessary to define the criteria based on a common optimum for old and new community members, which will determine if a potential new prosumer is allowed to join the community.
Furthermore, when considering a community with members who are more dispersely located than those in a small geographic area or distribution grid branch, the addition of a distance-related factor is proposed (in addition to the willingness-to-pay.)This distance-related factor considers that the matching of widely dispersed PV generation and load is disadvantageous compared to a closer matching, which is preferred.
And finally, different settlement patterns (urban, suburban, small town, and rural areas) and their potentials should be analyzed in detail, as they usually differ considerably with respect to rooftop area availability for PV systems, the diversification of demand profiles, and demographics.

Fig. 2 .
Fig. 2. Sketch of electricity trading in a small energy community comprising three members.

Fig. 3 .Fig. 4 .
Fig. 3. (Left axis) Energy consumption and PV generation for one year and (right axis) battery capacity of the test community (households only).

Fig. 9 .
Fig. 9. Percentage of annual share of electricity consumed and PV electricity generated (without BESSs).

Fig. 10 .
Fig. 10.PV generation traded within the community in a year (without batteries).

Fig. 11 .
Fig. 11.(Left axis) Prosumer electricity demand is covered by PV self-consumption (yellow), PV generated by the community (green), and electricity from the grid (blue); (right axis) PV consumption to demand ratio -(without BESSs).(For interpretation of the references to color in this figure legend, the reader is referred to the web version of this article.)

Fig.
Fig. Comparison of community set-ups with and without the inclusion of BESSs.

Fig. 14 .
Fig. 14.Percentages of annual share of electricity consumed and PV electricity generated (with BESSs).

Fig. 18 .
Fig. 18.PV generated electricity traded within the community during one specific hour (without BESSs).

Fig. 19 .
Fig. 19.Percentages of annual share of electricity consumed and PV electricity generated within the community (including five small businesses); left: without BESSs; right: with BESSs.

Fig. 20 .
Fig. 20.The amount of generated PV electricity traded within the community (including five small businesses) in one year (without BESSs).

Fig. 22 .
Fig. 22. (Left axis) Willingness-to-pay; (right axis) ratio between the amount of PV generation consumed and amount of electricity demanded (without BESSs, including five small businesses).

Fig. 21 .
Fig. 21.(Left axis) Prosumer electricity demand (including that of five small businesses) is covered by PV self-consumption (yellow), PV generated by the community (green), and electricity from the grid (blue); (right axis) PV consumption to demand ratio (without BESSs).(For interpretation of the references to color in this figure legend, the reader is referred to the web version of this article.)

Fig. 26 .
Fig. 26.Business demand profiles, average hourly value, normalized to an annual consumption of 1000 kWh.

Fig. 27 .
Fig. 27.PV generation profiles for different PV system sizes and orientationsaverage hourly value.
Energy Package Directorate-General for Energy (European Commission) (2019)), and the regulatory frameworks of different EU countries are presented in Campos et al. (2020).The European Commission introduced the legal terms Renewable Energy Community (REC) and Citizen Energy Community (CEC) in the 2018 Recast Renewable Energy Directive (REDII, see European Commission (2018)) and the 2019 Electricity Directive (ED, see European Commission (2019)), respectively.Both REC and CEC are legal entities, where members are private persons, small businesses, or local institutions, and participation is on an open and voluntary basis.

Table 1
Relevant data relating to different prosumers.