Photovoltaics Enabling Sustainable Energy Communities: Technological Drivers and Emerging Markets

: In this paper, we investigate the economic beneﬁts of an energy community investing in small-scale photovoltaics (PVs) when local energy trading is operated amongst the community members. The motivation stems from the open research question on whether a community-operated local energy market can enhance the investment feasibility of behind-the-meter small-scale PVs installed by energy community members. Firstly, a review of the models, mechanisms and concepts required for framing the relevant concepts is conducted, while a clariﬁcation of nuances at important terms is attempted. Next, a tool for the investigation of the economic beneﬁts of operating a local energy market in the context of an energy community is developed. We design the local energy market using state-of-the-art formulations, modiﬁed according to the requirements of the case study. The model is applied to an energy community that is currently under formation in a Greek municipality. From the various simulations that were conducted, a series of generalizable conclusions are extracted.


Introduction
Energy communities are emerging as a significant enabling factor for the transition towards a more sustainable, efficient and democratic energy system. They provide the opportunity for citizens to collectively shape the energy production mix by fostering investments in renewable energy systems (RESs), such as rooftop photovoltaics (PVs) and other small-scale renewable energy infrastructure. Recently, several studies have investigated the possible technical characteristics of community-owned microgrids and Virtual Power Plants (VPPs), which can assist in efficient power system operation while providing benefits for their members [1,2]. More specifically, the efficiency and security of the distribution system can be supported by providing additional services to the system operator [3,4].
In addition, recent studies have investigated the social aspect of the impact of energy communities [5], such as raising environmental awareness and providing a way to act upon it. Nevertheless, there is still a long road towards tackling the various challenges that occur, mostly regarding the integration of the different energy vectors into local energy systems but also the identification of different business models that will favor a large number of collective RES investments.
The techno-economic paradigm of an energy community does not differ much from that of a VPP, or in some cases a microgrid. They are all characterized by the aggregation of (small) distributed energy resources (DERs), including energy storage systems and in several cases flexible loads. Energy communities in practice have the potential to coordinate However, realistic business models that could be implemented within the current regulatory frameworks for energy communities have not been yet adequately investigated. The profitability of investing in small-scale RES and the benefits from the aggregation of prosumer-owned assets into energy communities needs to be explored in detail. A special focus should be put on the actual implementations, the available incentives and the overall benefits arising from forming energy communities. Within this scope, the existing and emerging frameworks that enable the coordination of a growing number of individually-owned, small-scale RESs and the roles that energy communities can adopt in the energy system should be studied. The aforementioned issues are addressed in this paper as follows: • We perform a focused literature review on the market models, trading mechanisms and applications of local energy systems and energy communities, while clarifying the nuances of important terms, and propose respective definitions; • We design a practical tool for studying the enhancement in the feasibility of small-scale PV investments by energy communities through the approximation of the annual energy cost reductions, simulating an actual local energy marketplace for the community members; • The implemented tool departs from state-of-the-art formulations for the operation of a local energy markets, which we significantly enhance in order to accommodate the requirements of our case study-e.g., accounting for load flexibility and prioritizing self sufficiency; • We present a highly realistic case study, using historical electricity production and consumption data, with the aim of estimating the economic benefits of an energy community that is currently under formation in a Greek municipality; • We identify crucial factors through economic indices that impact the benefits occurring from the operation of the local energy market.
The rest of the article is organized as follows; Section 2 presents the literature review along with the term definitions and the current status of energy communities in Greece; Section 3 describes the proposed modeling tool and formulations for the market mechanism of the energy community; the case study for the energy community is presented in Section 4; Section 5 discusses the results of the simulation and explains how the proposed modeling tool improves the feasibility of the investments. Finally, Section 6 concludes the paper.

Definitions
Reviewing the large and diverse relevant literature reveals the necessity to explore the nuances of some important terms which have not yet converged to a common definition, due to the fact that energy communities are still characterized as a relatively new topic, at least from the perspective of this work, which focuses on PV-dominated decentralized energy trading and the collective coordination of investment schemes.

Transactive Energy
The concept of transactive energy (TE) has emerged as a means of coordinating the growing number of individually owned and operated DERs within active distribution systems [7,8]. The increasing adoption of ICT-based smart grid technologies has given birth to the architecture of transactive energy systems (TESs) as a way to directly trade energy between grid users (e.g., prosumers, microgrids). Within TESs, energy becomes a commodity as users can trade their surplus in the real-time domain, or store it for later use [9]. TESs can support the system's reliability and the optimal integration of DERs, while accommodating flexible demand. The aim of such solutions is to provide scalable, adaptable and extensible and highly automated platforms across a number of diverse devices and participants, even within different geographic regions. They can coordinate the optimization of decentralized energy trading among the participants [9].
Different works have attempted to give a rigorous definition for transactive energy, yet most of them-e.g., [8][9][10][11][12]-adopt the definition provided by the GridWise Architecture Council (GWAC), which defines TE as "a system of economic and control mechanisms that allows the dynamic balance of supply and demand across the entire electrical infrastructure using value as a key operational parameter" [13]. Thus, GWAC considers TE to comprise the economic and control methodologies for managing the rate of consumption and generation resources and the energy trading within a distribution grid based on market mechanisms [10].
Chen and Liu [14] have highlighted several features which they associate with TE. The TE concept enables real-time control of dispersed devices, based on economic incentives, rather than centralized dispatch commands, and their participation in the balancing of the supply and the demand of the system is voluntary. The flexible devices exchange information and make transactions in a decentralized way to ensure the scalability of the control system. Transactive energy provides joint market and control functionality, while both supply-side resources and demand-side resources are coordinated.

Peer-to-Peer Energy Trading
Peer-to-peer energy trading is an emerging TE market paradigm. Several references have proposed P2P energy trading mechanisms as a way to enable consumers and producers to trade directly with each other. To date, to the best of our knowledge, there is no clearly articulated definition of P2P energy trading, rather only several common characteristics usually attributed to P2P. In the field of computer science, peer-to-peer (P2P) networks are widely used models for resource sharing, where resources are located in and provided by geographically dispersed computers (i.e., the peers) at the edge of the network [15].
Within the energy trading context, however, P2P mechanisms can enable producers and consumers to trade their excess energy with each other in a decentralized manner [4,[16][17][18][19]. A survey in [20] classifies the applications of P2P energy trading into three models: distributed energy trading, demand response optimization and power routing. Some authors consider P2P energy marketplaces to be under the responsibility of a centralized entity for validating the transactions or clearing the local market [1,6,[21][22][23]. The centralized entity is usually a market operator associated with the distribution system operator (DSO) in order to satisfy the grid constraints and avoid congestion and imbalances [22].
In [4], Guerrero et al. state that, in P2P trading, the information flows between peers in a decentralized manner and every peer can interact through financial flows (i.e., monetary payments and transactions). In [17], Tushar et al. attempt to define P2P energy trading as a distributed network architecture where participants share a part of their own resources with each other directly, without the requirement of an intermediate entity. Thus, any participant can be removed or added without the network suffering from a loss of network service.
Another definition of P2P energy trading is given in the context of energy communities. Community-based schemes define various objectives for the trading mechanism, as those are posed by community governance. In P2P schemes, the users actively participate considering their own selfish objectives as opposed to the community-based schemes, in which members share common objectives and try to maximize total social welfare [9].
The European Commission (EC) defines peer-to-peer energy trading in the (recast) Electricity Market Directive known as EMDII [24], which is equally adopted in the Renewable Energy Directive of the European Union (EU) 2018/2011, also known as REDII [25], stating that the peer-to-peer trading of renewable energy means the sale of renewable energy between market participants by means of a contract with pre-determined conditions governing the automated execution and settlement of the transaction, either directly between market participants or indirectly through a certified third-party market participant, such as an aggregator. The right to conduct peer-to-peer trading shall be without prejudice to the rights and obligations of the parties involved as final customers, producers, suppliers or aggregators.
We define "P2P energy networks" as bottom-up, prosumer-based energy networks which are decentralized, autonomous and flexible [16], where all peers are at the same hierarchical level in the market value chain, and no entity has market power over the others. The information flows are decentralized as proposed in [4] and the decisions are formulated by the peers though a horizontal governance scheme.

Energy Community
Under the directives of the Clean Energy Package [26], the European Commission has set the grounds for Energy Communities by recognizing the right of citizens to participate in the energy system. This can be realized by forming energy communities, which are defined in the two directives. The Renewable Energy Directive 2018/2011 (RED) [25] directive sets the framework for "Renewable Energy Communities" (REC) while the Electricity Market Directive 2019/944 [24] describes new roles and responsibilities for "Citizen Energy Communities" (CEC).
Energy communities are described as a possible type of organization for collective citizen actions in the energy system [27]. Both directives allow different forms of organizational structure around specific criteria and activities that ensure equal participation in the market without discrimination [28]. They describe entities characterized by common elements: participation must be open and voluntary, the effective control shall remain in the hands of the citizens, local authorities and smaller businesses and their purpose is to generate social and environmental benefits rather than profits [29].
In the reviewed literature, energy communities are briefly described according to the specificities of the implementation or case study. In [1], the energy community model is considered as a set of heterogeneous households owning rooftop PV systems and battery storage and their interactions with each other. A local energy coalition of prosumers is considered in [2]. Paudel et al. [22] discuss how a group of prosumers can be integrated in an energy community. According to [6], an energy community can be a group of prosumers, under a single electricity procurement contract, based on which they trade energy with each other and optimize their assets to minimize their cost.
While these works describe and model the energy communities of prosumers, there is not a definitive reference to the governance model and the effective control of flexible resources. In [10], the cooperative role of the community is stressed. It describes a prosumer cooperative, which is a large coalition of prosumers trading energy as a unique entity. The term "cooperative" refers to conglomerations of prosumers that organize and operate largely in a democratic manner.
Besides the organizational structure, energy communities also have technical aspects, particularly considering the generation and consumption of energy. In this sense, community members can be identified as prosumers or consumers, and if the energy assets are community-owned or operated for the maximization of the overall welfare, the energy community can be realized by a community microgrid. At the center of the community, the microgrid is the prosumer.
We regard a Citizen Energy Community (CEC), or alternatively an energy community, as a type of an organization of citizens for collective or cooperative actions in the energy system, where, as a cooperative, the operation is characterized by the seven cooperative principles as defined by the International Cooperative Alliance (ICA) [33]:
Member economic participation;
Concern for community.

Prosumer
The concept of the prosumer emerged in the literature during the 1980s, as proposed by Alvin Toffler [34] and contemporary writers who suggested that the new global economy is moving away from the binary model of producers and consumers, as two separate economic entities, which was a prevailing economic model since the Industrial Revolution. According to these researchers, mainly thanks to the rise of the information technology, the new global economy allows the massive re-formation/re-emergence of an economic entity capable of producing the products that it consumes, as before the industrialization of modern economies. Various information and other technological developments, such as open source software, 3D printing, Do It Yourself (D.I.Y) toolkits and platforms (e.g., Arduino) etc., have allowed for the concept of the prosumer to be used in various fields; e.g., web and software users who generate content have been regarded as prosumers [35].
The technological advances and the transformation of the electricity grid have led to the emergence of the energy prosumer concept in the energy field. According to [36], the energy prosumer is an economically motivated entity that (i) consumes, produces and stores energy (ii) optimizes decisions (economical, environmental etc.) regarding energy utilization and (iii) becomes actively involved in the value-creating effort of an electricity or energy service of some kind. In [35], Jacobs identifies two distinctive features of energy prosumption: autonomy and market participation. The former feature refers to a behavior by which consumers become more proactive by regulating consumption or engaging in self-supply. These behaviors are coordinated to an extent by the energy market, in which the prosumers participate as actors.
It should be noted that the economic aspect of the prosumer entity-that is, the value creation through some kind of service (which implies the existence of an adopted business model)-distinguishes it from a mere demand response or other consumer engagement program. Actually, as [37] states, prosumers are changing the way revenue is owned in the energy value chain, changing the value chain itself. In [38], Baez-Gonzalez et al. see energy as a commodity for the prosumers, expressing the current trend of perceiving the abstract notion of energy as a tradeable good.
The European Union has not yet identified officially the prosumer as an energy actor, but in the recast Renewable Energy Directive 2018/2011 (REDII), the RES self-consumer is described as "a final customer operating within its premises located within confined boundaries or where allowed by Member States, on other premises, who generates renewable electricity for its own consumption and may store and sell self-generated renewable electricity, provided that, for non-household renewable self-consumers, those activities do not constitute their primary commercial or professional activity". The last condition of the EU definition highlights an important aspect of self-consumers that is also important for the prosumer and refers to its goals, which are not seen as merely economic. As an economic entity, the prosumer has primarily an economic motive, but the importance of environmental, ideological and social reasons is also significant [35].
Inspired by [36], we understand the prosumer as an entity that is motivated by economical, ideological, environmental and other factors. It refers to residential and commercial customers for which prosumerism is not their primary economic activity.

Local Energy Market
Local electricity markets (LEMs) have been studied for the past two decades, but only recently (after 2011) have they gained increased attention [39]. Due to this, as Mengelkamp et al. [39] observe, there is a lack of a unified definition that allows for a differing in understanding, possibly leading to a confusion with the similar concepts of P2P trading, energy sharing and energy communities.
In most of the reviewed literature, LEMs are posed as a solution for the market and technical integration of the continuously increasing DER penetration in the distribution system. This is primarily formed within the context of electricity sector deregulation, the commodification of energy and the advancements in Information and Communication Technology (ICT). The concept of LEM develops in parallel with the emergence of the economic entity of the energy prosumer as its structural component that is required to encompass all the necessary attributes of an electricity market player.
In [16], Parag and Sovacool investigate three potential market structures for prosumers, pointing out that local markets "are key for managing DERs and for coordinating decision models that satisfy large numbers of self-interested autonomous agents". Similarly, Ref. [40] supports the idea that the market and technical integration of DERs can be achieved by the application of market-based control (MBC), realized by the establishment of LEMs at a district level. In [41], Bremdal et al. consider the LEM rooted in a residential area based on a "micro-market" concept. They support the suggestion that negative and positive externalities with a local impact can be better incorporated by means of local markets. According to that view, the tradeable assets of a local market are energy, end-user flexibility and other associated services/products. Zia et al. [9] understand LEMs through the concept of the TES, which they see as the necessary conceptual and design context in order to make energy a commodity available for customers. LEMs are seen as an integral part of a decentralized TES. According to that definition, an LEM of an MG is a platform that helps residential and commercial prosumers to participate and trade their energy for monetary benefits. In this system, power producers and LEMs trade energy based on the price signals determined by the wholesale energy markets.
We identify LEMs, as a vehicle for the realization of a decentralized TES, to be fundamental players including a large number of small residential and commercial prosumers and consumers of a specific geographical area connected at the same distribution network subregion. These actors participate either as self-interested players, aiming to maximize their economic benefits, or as coalitions who aim to fulfill their collective goals (economic, energy or environmental related) and satisfy common needs.
LEMs are realized as platforms (or virtual market places) that nevertheless have some geospatial proximity and are associated with a specific part of the distribution network. The technical and operational constraints of the grid are in the responsibility of the grid owner and operator (i.e., a DSO, or a microgrid operator) and can be incorporated in the market operation. In the case of a grid-connected system, LEMs interact with wholesale markets through appropriate market signals. The tradeable commodities in a LEM are electricity, flexibility and possibly ancillary services (e.g., voltage and frequency support, reserves, etc.).

Trading Methods and Pricing Schemes
In the reviewed literature, authors design LEMs and energy trading mechanisms to match demand and supply while minimizing costs or maximizing profits. The problems are mostly in the market clearing framework and are formulated as optimization problems. The optimization either directly clears the market or defines the bidding strategy of the players, which then creates an auction mechanism (most often a double-auction). In several works, the strategy of each player has been formulated as a game theoretic model based on which the trading decisions are taken. Both cooperative and non-cooperative games are identified in the reviewed literature.
The optimization objectives can be targeted towards individuals' costs minimization (or profit maximization) or may refer to the overall welfare of a community or a coalition. In both cases, but most often in the latter, non-monetary parameters may be included, such as social or environmental factors. Moreover, an especially important concept introduced in several works is the concept of "fairness", which is encountered in different forms such as "market efficiency" [42], "Pareto condition" [43], "imputation" and the "stabilizing core of a game" [44]. The idea behind this concept is that the trading decisions must ensure that no entity is penalized and no player will be better off without the coalition. This ensures that all players are incentivized to stay within the specific market framework.
Considering the community-based works, several formulations and methodologies have been adopted. In [1], a P2P trading framework is developed which aims at optimizing rooftop PV generation and battery storage to maximize the household savings. The problem is formulated as a mixed integer linear programming (MILP) model with a pricing mechanism. The objective is to minimize the total energy cost by finding the optimal trading and operational decisions.
In [2], a nonlinear bi-level optimization problem is formulated based on the marginal pricing framework and shows that the cost savings for a prosumer are maximized within the specific community compared to trading individually. The lower-level problem is a market clearing problem for the microgrid which aims to maximize the social welfare, while the upper level is a profit allocation mechanism to ensure that no entity is penalized when trading within the microgrid (Pareto superior condition). A central entity is introduced that is responsible for solving the problem, which is defined as a benevolent planner that manages the microgrid. Another P2P mechanism is defined in [21]. The excess energy of the prosumers is traded locally while the total reserve is sold to the market and the profits are allocated among the members. Three different pricing (allocation) methods are investigated.
According to [21], the bill sharing (BS) mechanism is a simple scheme that splits the single electricity bill of the community microgrid between the members based on their individual total energy consumption and exports. In the case that a mid-market rate (MMR) is used, the energy exchange price (P2P trading price) is taken as a value between the electricity selling and the buying price. In this case, based on the demand and supply ratio, a different price is assumed that can be either the P2P price (MMR) or the grid buying price, while when there is excess of energy, it is sold to the grid at a lower price. Under an auction-based pricing strategy (APS), each household plays an active role in providing bids for their demand and generation. These bids are then managed using pre-defined methods to clear the market and find the trading price.
In [31], a community microgrid is considered where the optimization problem respects network constraints so that the microgrid can assist the grid operator in managing local grid congestions. To handle privacy issues, the centralized problem is decomposed to be solved by each prosumer in a distributed and parallel way. The Jacobi-ADMM method is proposed to decompose the problem while utilizing the reinforcement learning modelfitted Q-iteration to solve the local optimization sub-problems at the household level. The analysis showed that with the combination of distributed optimization and data driven techniques, such as the fitted Q-iteration, the microgrid is able to provide the requested flexibility.
A distributed double auction blockchain-based mechanism is proposed in [45]; due to blockchain, it eliminates the need for a central trusted entity, demonstrating quick convergence and computational efficiency.

Game Theoretic Models
Another category of the reviewed works corresponds to game theoretic models. In [46], a P2P framework with a pricing algorithm is developed based on cooperative game theory. Li et al. show that their method has superior computational performance, especially when handling the "curse of dimensionality". The proposed benefit distribution mechanism is shown to be an imputation. A payoff allocation is called an imputation if it satisfies individual rationality (the payoff of each player in the grand coalition is greater or equal to the welfare of the player acting alone) and a balanced budget, which ensures that the total payoffs are equal to the maximized social welfare.
The P2P mechanism of [23], is also defined based on a canonical coalition game (CCG), where the MMR benefit allocation is shown to be within the core of the problem, confirming the stability of the coalition, meaning that no players are incentivized to leave the coalition and form sub-coalitions. The set of feasible allocations is defined as the core of the game.
Thomas et al. [47] propose a two-stage auction-based market-clearing setup to design a platform to trade physical storage rights, which results in a Nash equilibrium problem consisting of interconnected optimization problems where each participant tries to maximize their expected profit. They reformulate the equilibrium problem in a more computationally tractable optimization problem by extracting the KKT optimality conditions, preserving the desirable economic market properties of the initial problem, such as market efficiency and revenue adequacy.
A constrained problem with the objective of minimizing the time-average cost in the whole community, including purchasing electricity and the cost of charging and discharging energy storage systems, is considered in [48]. Ye at al. formulate the optimization problem based on the Lyapunov theory in order to achieve a low computational complexity. Based on the Nash bargaining theory, they design a revenue distribution algorithm to share the benefits fairly among the community members, and they prove that the algorithm results in an up to 12% reduction for the community costs compared with the non-cooperative approach while maintaining fairness.

The Legal Framework for Energy Communities in Greece
Since the introduction of Energy Communities in the directives of the Clean Energy for All European package, several countries have adopted this concept in their national legislation, adjusted on a national level. In Greece, the legislation for Energy Communities first appeared in 2018 with the Greek law 4513/2018 [49] which enables, proposes and fosters the creation of energy cooperatives. A variety of business models can be adopted by the communities, ranging from performing collective investments in small-scale distributed generation (DG) units to taking on the role of retailers or even regional distribution system operators (DSOs).
Several social and environmental aspects are also considered in the Greek legislation, addressing also the issue of energy poverty mitigation. Energy communities can assist in tackling energy poverty using various means. Currently, there is legal framework for including vulnerable households under virtual net metering schemes, drastically reducing or eliminating the costs of their energy needs.
Small-scale RESs-i.e., with an installed capacity less than 500 kW, which is usually the case for energy communities-are subject to three pricing schemes in Greece. First, there is the support scheme for the Feed-In Tariff, described in the Greek law 4414/2016 [50] and updated in Greek law 4602/2019 [51], which states that all generated energy is compensated at a fixed reference price calculated according to the technology, contract, etc. Currently, for private-owned PVs, the reference value is 65.73 €/MWh, while for energy-community owned PVs, this is 68.86 €/MWh (as of 21 February 2020). The second scheme is the so-called net metering, applicable to small RESs, where the produced energy is subtracted from the energy consumption and the prosumer pays the difference at the retailer's price (e.g., 0.11936 €/kWh). Surplus electricity is not compensated, yet the balance is netted (cleared) in a period of 3 years, allowing significant time to benefit from excess production. Note that energy communities, formed under the Law 4513/2018, are eligible to participate in a virtual net metering scheme, which is net metering but with the production and generation at different points of connection. The third scheme, which is rarely used, is self-consumption and was introduced in the Greek law 3468/2006 [52] and updated in 4414/2016, which considers RES installations that are sized to satisfy demand and allows up to 20% of the excess energy that is injected into the grid to be compensated annually at a price equal to the reference price in the first scheme.

Valorization
Energy communities create value for their members, sometimes as side benefits of their participation in an energy community. Financial value is the most straightforward benefit, and it refers mostly to reduced electricity bills and grid charges and, in some cases, to income from power injection to the grid. The distribution of the value to its members in a fair and transparent way is a challenging problem, which is analyzed in [53]. However, the value of participating in an energy community is not only financial, but includes, as already mentioned, environmental and social aspects, which are far more difficult to measure.
In practice, the drivers behind the creation of an energy community and its respective value are often more related to environmental and social concerns. For example, the reduction of carbon footprint (e.g., via the production of cleaner energy) and the possibility to become energetically independent create important value that also applies to single consumers who become prosumers. Belonging to a community, including feelings of trust and solidarity, democratic control, community ownership, the reduction of energy poverty and the general feeling of contributing to the common good create important value for the members of energy communities.

Community Modeling Tool
In this section, we simulate the daily operation of a local energy market of an energy community as a way to assess the economic impact that the formation of an energy community has on the benefits/cost savings of its members. To this end, the optimal operational (and local trading) actions are sought for the community members that support the given community goals. Inspired by the state-of-the-art formulations, as in [23,54,55], we employ a generalized optimization model for the calculation of the optimal operational set-points and energy exchanges, which we extend in order to take into account the community flexible load scheduling, as well as the guidelines of the Greek regulatory framework for the energy communities and the historical electricity data from the region, obtained from the EU research project WiseGRID [56].

Problem Formulation
The operational objective set by the community is the minimization of the total energy costs of the members and the community as a total. For this study, we assume that the coordination actions needed to achieve the community goals are calculated and communicated via a fictitious entity we refer to as the "community manager". They are the interface between community members and the wholesale market. The community manager coordinates the sharing of energy within the community but also validates the trades between the members and the central market. The objective function considers both the individual community member's behavior ( f j refers to the cost function of each community member), but also the collective behavior of the community (modeled with g, which affects the trading behavior of the members favoring either local trading, or the procurement of their energy from a standard retailer). The optimization problem for calculating the optimal daily operational behavior of the community is formulated as j = 1, ..., n, t ∈ T By using different formulations for g(q imp,t , q exp,t ) (convex combinations in order to ensure that the overall optimization problem remains convex), different behaviors are modeled for the community as an aggregation, affecting in turn the total revenues and electricity costs of the members.
The optimization considers the technical constraints of each prosumer expressed in (1f), where P j,t is the feasible set for the energy production of prosumer j. The power balance constraint (1b) ensures that the net energy production of prosumer j is equal to the total energy traded. The total imported energy of the community from the central market is expressed by q imp,t , while the total exported is represented by q exp,t respectively. Figure 1 depicts the energy market model.
Each prosumer (indexed with j = 1, 2, ..., n) seeks the optimal operational set-points for the assets they own with respect to the total cost minimization expressed by the objective function (1a). The prosumers are modeled by their individual cost function f j , which allows different levels of detail for each prosumer's behavior. For the purposes of this study, we assume the cost function to be a quadratic expression of the decision variables: • p j,t represents the net energy production of each prosumer for a single time step; • q j,t expresses the energy that is exchanged between prosumer j and the community at the time step t; and • α j,t , β j,t the total energy that the prosumer j imports from and exports to their retailer, respectively. To include more information for each community member considering both their assets and their behavior, we appropriately extend the cost function. The total net energy production expressed by p j,t is decomposed into the assets the member owns (indexed by i), p j,t = ∑ i s i,j,t so that the optimal operational set-points can be found. The resulting quadratic cost function for each asset is expressed as

Energy Community
The coefficients c i,j,t and d i,j,t represent the preferences of the community members, and they depend on the price the members are willing to pay as well as the maximum and minimum accepted values for the set-points of their individual assets. They were calculated based on the model proposed in [54]. Moreover, we model the transaction costs previously agreed within the community and the individual objectives using the function h. In our case, each member seeks to maximize their autonomy and thus import and export less energy. To enforce this objective, a penalty is introduced for the imported and exported energy.
The community also aims to increase the levels of collective autonomy, and this is depicted in the formulation of function g, where we introduce a penalty for the imported energy. The penalty is imposed by the community manager and based on the selection of the coefficient the manager can affect the members operational decisions. In the simulation, we assume a coefficient equal to the rate of the imported energy: Flexibility is also considered in the model by introducing a lower and an upper bound for the loads. We assume that some prosumers are equipped with flexible loads and they can shift their consumption towards times during the day when their production is higher, which results in increased autonomy and revenues. The utility function of each prosumer for consumption assets is then bounded between the minimum load and a maximum load, while the total daily amount is not affected. That means that we assume each day to be independent and no flexibility can be transferred within days. Let L j be the set of load assets for prosumer j; the flexibility is formulated as follows: where l j,t refers to the total daily load that should be consumed, while the flexibility of each asset is modeled with upper and lower bounds expressed in (5). We avoid using a mixed-integer formulation and a detailed representation of the shiftable appliances of each household, as that would significantly increase the complexity of the optimization problem, while we are interested in assessing the total operational costs on a long-term horizon (i.e., on a yearly basis). The revenues from each production asset of the prosumers are introduced in the model as the product of the export price and the utility of the production assets. The revenues are maximized in the model to ensure that the excess energy will be traded within the community, since the intra-community trading price is higher that the export price. With G j,t being the set of production assets of prosumer j, we model the revenues as The final cost function of each community member is formulated as follows and aims at minimizing the overall costs, while also maximizing the revenues to ensure that the excess produced energy is sold within the community:

Case Study
Driven by the recent on-going discussions on forming an actual energy community in the area of Rafina-Pikermi, Attica, Greece, we investigate the benefits for local citizens participating in an energy community that operates a local electricity market. The municipality of Rafina-Pikermi serves as a pilot site for the EU research project COMPILE [57], which aims at developing road maps for forming energy communities. So far, two community models have been identified [58] and they are being studied in terms of their feasibility and impact.
The first model considers the cooperation of the local municipality with interested organizations and citizens to invest in rooftop RESs, utilizing available infrastructure such as public rooftops. This model aims at reducing municipal electricity bills and thus leading to the reduction of municipal taxes, while including vulnerable households in the scheme, tackling energy poverty. In the second model, the municipality serves as a facilitator, providing available public rooftops to local energy communities to develop PV installations and participate in net metering schemes. The municipality is compensated through a portion of the produced electricity, agreed bilaterally, to cover the needs of the specific building or to be provided to vulnerable households.
Inspired by this public discourse, we assume a number of households (apartment blocks and dwellings) and commercial buildings located in this area, the owners of which are willing to invest collectively or individually on rooftop PVs with the primary goal of covering a large part (around 80%) of their annual electricity needs. We assume that these prosumers form an energy community and participate in the local electricity market operated by the community. In addition, a number of consumers are also part of the energy community and the local market without having invested in DGs. These consumers can be residential-e.g., of the same apartment blocks-or commercial.
Another interesting aspect is that the vulnerable households of the region-that is, households that suffer from energy poverty-can also be assumed to participate and benefit from the community. This is in line with Greek Law 4513/2018, which has specific provisions for energy communities to support and assist households that have difficulty in covering their basic energy needs. By participating in the local market, as shown below, they have access to lower prices and thus economic benefits. In the local energy market, the Rafina-Pikermi Municipality with the Town Hall building and a PV installed at the Town Hall rooftop is also eligible to participate (according to the relevant law).
Furthermore, some members of the community are assumed to have flexible loads, such as an electric boiler, an electric vehicle (EV) charger or in the case of the Town Hall, a building management system (BMS) controlling the heating, ventilation, and air conditioning (HVAC) system. This flexibility provides the means to increase the energy efficiency of the local market, as allowing more generated energy to be utilized by the members of the energy community. Flexibility is modeled as a portion of the total daily energy of the member that can be moved and is bounded by an upper and a lower limit at each time step of the optimization, as discussed in Section 3.
Following the discussions which have taken place in the Rafina-Pikermi and the huge interest shown by the citizens in a number of workshops and focus meetings, we assume an energy community consisting of 60 members, as well as the Mayor's office. Each member is categorized by its annual electricity needs, which also defines the consumption profile (see Table 1). For the derivation of the electricity consumption data of each candidate member, we employed personalized interviews and questionnaires. Additionally, 50 out of the 60 members were assumed to own a rooftop PV, while the other 10 participated only with flexible loads. It is important to note that, in this case study, we have not considered grid tariffs or any type of taxes, which could impact the results. For example, if grid tariffs are added for the consumed energy (not the injected energy), the least benefit would occur for a consumer without local generation. This means that the higher the self-consumption, the higher the benefit for the consumer. However, if taxes are added for the local trades or for owning an RES or storage unit, then the overall benefits are expected to decrease. The assessment of these factors is out of the scope of this work.

Data Gathering
Data spanning an entire year starting from 1 January 2019 were obtained in order to create the generation and consumption profiles. Concerning the consumption, annual data of hourly active power time series from three regional MV/LV substations were used, which were then scaled down so that the annual energy corresponded to the typical annual consumption of each specified category. Then, the three different profiles of each category were assigned randomly among the members of the category. For the case of the Town Hall building, actual historic data of the building were obtained. For the generation, the annual data of three 99 kW PVs, located in Rafina-Pikermi, were used and scaled down based on the installed power of each prosumer.  For the prices used in the simulation, recent electricity prices in Greece were employed. Regarding the energy import rate, this was set at γ imp = 0.119 €/kWh corresponding to the actual retail price of one of the largest Greek energy providers. For the export rate, this was set to γ exp = 0.069 €/kWh. This price corresponds to the compensation price (reference price) of the feed-in scheme for PV projects below 500 kW implemented by an energy community in Greece for the first half of 2021.
Currently, there are two schemes in Greece for PV installations below 500 kW: the net metering scheme, in which the export price equals the retail price, and the feed-in scheme, in which the compensation is at a defined reference price. Both schemes are planned to change in the short term. The export price of the net metering scheme is expected to be reduced and probably to be linked to the market price, while the reference price of the feed-in scheme may be defined by competitive auctions. Finally, for the intracommunity trading, the mid-market rate (MMR) method was used, and the price was set at γ ec buy = γ ec sell = 0.094 €/kWh.

Simulation Results
In order to study and comprehend the benefits of the local energy market and the flexibility for the participants, a number of scenarios were examined. The various scenarios aimed to clarify which factors are more important when establishing such a local market. In the scenarios, the number of the members with PVs, which was 50 (plus the Town Hall), the installed power of the household rooftop PVs, which equalled 96 kW in total, and the total number of participants, which was 60 plus the municipality, were considered constant. As parameters, we considered the upper and lower bounds of the members' and Town Hall's flexible load (i.e., the flexibility as a percentage of the total consumption), the number of members that could employ a flexible load (apart from the 10 members that were consumers without generation but with flexible load) and the installed PV at the Town Hall building. For the Town Hall PV, the initial scenarios assumed a 99 kW PV which corresponded approximately to 75% coverage of the annual electricity needs of the building and was comparable to the aggregated installed capacity of the prosumers. In order to examine the impact of this PV in the market, a second set of scenarios assumed a Town Hall PV of 50 kW. A scenario with the Town Hall not participating in the energy community was also considered. The scenarios are presented in Table 2. As we can see, scenarios S1-S3 assumed a rooftop PV for the Town Hall with an installed capacity of 99 kW, while S4-S6 assumed 50 kW for the PV. For both scenario groups, the flexibility limits and the number of members with a flexible load varied in a similar manner; that is, from 20% to 30% for the former and from 50 members in total (10 without PV and 40 with PV) to 60 (10 without PV and 50 with PV). In S7, we considered a 50 kW Town Hall PV and 30% limit for the Town Hall flexibility percentage. However, the main difference was that the flexibility limits of PV-owners and consumers varied from 15% to 30%, but their average was maintained at 20%. Finally, in the last scenario, S8, the operation of the market without the Town Hall was examined, which was the largest participant with regards to both consumption and generation.
Each scenario was simulated for a complete year, and for each day, the optimization algorithm gave the optimal operational schedule for the participants. Then, using rolling horizon optimization, we extracted results for the whole year. The optimization problem and the processing were developed using the Julia language and the optimization package JuMP. Figure 4 shows the aggregated results (power profiles) for one day in July in scenario S1. It shows how the energy was traded during a day. Until 08.00 in the morning, where no generation was available, the energy was imported solely from the grid. Then, until 13.00, the generated energy that was not self-consumed was sold to the community. The figure shows also the load that was shifted from the early morning and evening hours to the morning and afternoon hours (the difference between the historic load curve and final consumption curve). Apparently, this load was not enough to absorb the complete generation, and for that reason, the excess energy was exported to the grid.  The impact and the benefits of the community operation were evaluated using a number of metrics. The first one was the trading benefit; i.e., the benefit that each participant gained by participating in the local market compared to not participating at all. Not participating in the market would mean that all the energy was imported from and exported to the grid. Table 3 summarizes the results with respect to the trading benefit for the participants of the market. Note that the values are average values for all the participants with and without PV. We investigated the changes in the locally traded energy by calculating the ratio of the total energy traded inside the local market, compared to the total energy traded both within the local market and with the central market ( Table 4). Note that for the members with PV generation, the largest part of the locally traded energy refers to the excess generated energy that was sold to the members. For the members that owned a PV, all the traded energy inside the community refers exclusively to the energy that was purchased. Finally, the self-consumption rate-that is, the total generated energy that was consumed by the owner of the asset (PV)-was calculated. Obviously, this refers only to members who owned a PV. The following table (Table 5) summarizes the results with respect to the self-consumption rate for the participants that owned a rooftop PV. Note that the values of the households are average values for all the household participants with PVs.

Discussion
The participation in the local market has tangible economic benefits for all participants. However, the extent of this benefit for each member category depends highly on the relative size of the installed capacity of the DG and the annual consumption of the members. We observe, for example, that by halving the installed PV of the municipality, the benefit of the PV owners and the Town Hall increases substantially, since a greater percentage of their generated energy is traded inside the community. For the consumers, on the other hand, it decreases because less energy is available in the community in total at the time they require it. On the contrary, when the municipality, which represents the biggest load, is not participating in the market, the benefit of the members with PV decreases significantly, as their excess energy is not absorbed inside the community, while for the consumers, the benefit is high. It is therefore shown that the mix and the size of the participants in such a type of market, in which self-consumption is prioritized, is important for the maximization of benefits.
The impact of flexibility is also very important. Comparing scenarios S1 and S3 with S2 and S4, respectively, we observe that an increase in the number of the PV owners with flexible load (total number of flexible loads from 50 to 60) leads to a slight decrease in the overall benefit for the participants. This is because less energy is available for trading inside the community while more is self-consumed (see Table 5). On the contrary, when increasing the flexibility margins, the benefits tend to increase. However, for scenarios S1-S3, the mentioned increase for the consumers is much higher compared to scenarios S4-S6. This is because, in the second case, the increase in the flexibility of the Town Hall, and therefore its self-consumption, allowed for less available energy to be consumed by the consumers despite the capability of the latter to absorb more energy (thanks to the higher flexibility limits). It is apparent, therefore, that flexibility benefits PV owners, both because it increases self-consumption and because it gives the consumers an increased capability to absorb locally-produced energy (provided that it is available).
Admittedly, the flexibility is modeled in a simplified but generic way in our case study. It is usual for energy communities to invest in energy storage systems (both individually and community-owned), or other potential sources of flexibility such as EVs in order to improve the overall operational performance. In future work, we intend to include specific modeling formulations for the different flexibility sources and investigate their impact on the LEM.
We must mention that the extracted results are average values, meaning that the trading benefits differ based on the category and the power profile of each member. For example, let us consider scenario S7; in this scenario, the maximum benefit occurs for the PV owners of the first energy category (see Table 1-the category with the smallest annual consumption). As explained previously, each category consists of groups with different power profiles. So, while a group of members has a trading benefit equal to 14.8%, another group in the same category has a trading benefit equal to 6.0%. On the contrary, the self-consumption of the first group is 50.9% while for the second it is 67.1%. Apparently, this is due to the fact that the consumption profile of the former part does not coincide sufficiently with the generation peaks, despite the flexibility, and thus it benefits from the local market by selling at the local prices instead of exporting to the grid.

Investment Feasibility Improvement
A crucial advantage of the rooftop PVs is that they enhance and promote self-consumption; that is, the consumption of power where it is generated. However, these small-scale PVs have very small profit margins. As already mentioned, in Greece, the currently existing pricing schemes for PV projects below 500 kW comprise the net metering and the feed-in-tariff, the tariffs of which are planned to be reduced in the forthcoming period, which will reduce even further the feasibility of such projects.
In this context and based on the results of the simulations, we observe that the energy community, consisting of PV owners who have invested in small-scale PVs and local consumers, has substantial benefits with regard to PV investment when a local electricity market is operated and uses the presented optimization scheme. The results show that this market, especially when the size, the mix and the flexibility of the participants is appropriate, can result in a more than 10% annual benefit on average for the PV owners. This provides an important improvement of the feasibility of the investment of the PV owners, which is translated to an increased annual cash flow and thus less payback time and a higher IRR index. This project feasibility enhancement comes, at the same time, with the promotion of the self-consumption, first in the location of the PV asset and then in the region of the energy community, which is significantly differentiated from a typical wholesale market.

Role of Energy Community
As mentioned in Section 2.1.3, energy communities are collaborative types of organizations focused on collective energy initiatives, pursuing a common goal of benefitting the community members. The energy community structure organizes a number of citizens and possibly local businesses, along with the municipal agency, aggregating them into a market layer. Thus, a common coordination of the operational decisions and the electricity trading behavior can be achieved. The practical implementation of such a local energy market via an energy community requires effective organization and coordination among the local citizens in the first place, entailing various public procedures.
The requirement for such a social consensus is the manifestation of the social dimension of these structures. The actual day-to-day operation of the proposed model certainly requires an advanced technical infrastructure for implementing the administrative goals, while these goals are created from the social interactions of the members which define the governance body of the community. In that context, energy communities should be seen not as static structures but instead as living organisms. Furthermore, the Greek Law allows for a wide range of activities, from RES generation and energy retailing to education and consulting. This means that the local energy market can be only a part of the overall activities of the community.
Even though the focus of this work was to study a local market mechanism that fosters community trading (aiming at improving the feasibility of individually owned PV systems), we highlight that energy communities are not limited to trading. The community aspect refers to the sharing of resources among the members, including investments (individually or collaboratively), infrastructure, knowledge, time and expertise. The value creation of such collaborative schemes is substantial, with the financial value being the most straightforward and easy to quantify of the benefits. However, the acceptance of energy community schemes strongly depends on the social and environmental culture of the citizens.

Conclusions
We have investigated the economic benefits for the members of an energy community when a local energy market is operated. Reviewing a large number of relevant literature revealed a lack of a consensus on certain important terms; therefore, improved definitions were proposed. The developed tool, which simulates the local energy trading taking place in the context of an energy community, was applied to a realistic case study, using data from an actual energy community in Greece that is under formation. The community consists of members (residential or commercial) with and without rooftop PVs and the Town Hall; some of these members have flexible loads. The case study results were used to assess the economic benefits derived from the local energy market and the factors that impact these benefits. Assuming the current situation in the regulatory framework and disregarding grid tariffs and local trading taxation, we show that, in our specific case, for the members that own a PV, the economic benefit for participating in the community local energy market can be up to 10.3%, enhancing the feasibility of PV investment. At the same time, the self-consumption can reach the value of 59.7%, if load flexibility can be employed, increasing the overall efficiency of the community.