Agent-based modeling of a rule-based community energy sharing concept

. In an energy community, the prosumers' interactions are critical to ensure efficient use of renewable resources. Local energy sharing concepts where a coordinating agent typically regulates the energy transactions between prosumers intend to achieve such a sharing economy. The coordinating agent, known as the market agent or energy sharing agent, acts according to a set of rules to match the prosumers' renewable energy surpluses and deficits. This paper describes an agent-based modeling strategy and a case study to demonstrate the interactions in an energy sharing community where each agent individually and collectively attempts to maximize renewable energy self-consumption. The prosumers attempt to achieve their individual and collective objectives by following a two-step rule-based strategy. In the first step, a building-integrated battery storage operation strategy based on a schedule improves the prosumer-level self-consumption while providing grid-friendly behavior. The next step involves an energy sharing strategy and an operating strategy for community-scale battery storage that maximizes the collective self-consumption. Throughout the transactions, prosumers have no visibility of other prosumers; therefore, the energy sharing coordinator has the sole responsibility of orchestrating the energy exchanges between prosumers. Finally, we discuss the significance and future research outlook for energy interaction modeling at a community scale.


Introduction
Currently, self-consumption is the trend that drives the expansion of renewable energy sources in communities. As a result of low feed-in tariffs and high utility electricity prices, self-consumption provides an economically attractive energy sourcing option. Several European countries already have mechanisms to encourage energy communities and collective self-consumption, e.g., Switzerland, France, and Spain, while countries like Germany (Mieterstrommodell) and Austria recognize collective self-consumption in multioccupancy buildings [1]. The EU directive 2018/2001 on "the promotion of the use of energy from renewable sources" (recast) provides an enabling regulatory framework to promote energy communities that give entitlement to household prosumers to be part of a renewable energy community [2].
There are several important arguments for collective self-consumption. Firstly, it unveils opportunities to optimize the use of available physical resources, e.g., better-located roof-tops. Collective self-consumption also enables asset sharing at the local level, facilitating collective investments on renewable assets. Energy and asset sharing achieve higher self-consumption levels in the community than what each prosumer can reach individually, especially if they are heterogeneous [3]. Energy sharing platforms or market platforms is an essential enabling concept to maximize an energy community's collective self-consumption. Contrary to centralized or direct control, market platforms are a place where the prosumers can, by their own will, choose to trade their surplus resources for an economic benefit. In Table 1, we highlight some key characteristics of such platforms based on a subset of recent studies that we examined. Bill-sharing, midmarket rate, and auction-based. [7] Control architecture of the multi-agent system to maximize self-consumption Rule-based P2P Bilateral negotiations [8] Economic dispatch in a microgrid Optimization + rule-based Uniform-price clearance [9] Maximize benefits to energy-users and ensure an envy-free energy trading market Optimization Pool-based, singlesided auction [10] Blockchain-based energy trading with double-sided auction Rule-based Pool-based, doublesided auction Decision algorithms based on decentralized rules provide simplicity without massive computational power; although, it does not necessarily lead to the optimal strategy [11]. However, in a multi-agent environment, the agents' continuous interactions can lead to a near-optimal emergent behaviour in the energy community to maximize the collective selfconsumption [7]. All of the examples listed in Table 1 have implemented rule-based strategies while [8] has also implemented an agent-level optimization algorithm that evaluates each prosumer's economic dispatch strategy.
Peer-to-peer (bilateral contracts) local energy market designs, often based on blockchain technology [12], have attracted interest from the research community in recent years [e.g., 4,7]. In a P2P setting, agents can trade among each other in a randomized order and payas-bid basis. At each timestep, the sellers and buyers are iteratively matched in random order until either the buyer procures his/ her demand or is unable to procure enough energy due to no more potential sellers in the market [5]. The prosumer must import the demand that is not procured locally from the public utility network.
By contrast, the pool-based (order-book) market is a more centralized approach where the market participants do not interact with each other directly. The orders are submitted to a central entity (clearing house) [12], where they are ranked and matched either continuously or at discrete market closing times [5]. There is a single price for electricity in a pool-based market [12], called the clearing price. In single-sided auctions, there is only demand-side or supply-side bidding but not both simultaneously [12]. The merit-order of the bids received determines the market-clearing price of a single-sided market [13]. A double auction market allows both demand and supply sides to participate in market activities simultaneously [12]. [14] discusses the main operating strategies of battery storage systems to improve renewable energy self-consumption. Direct loading maximizes the self-consumption by charging battery storage as soon as there is surplus renewable energy. However, this strategy may result in excessive feed-in during peak irradiation times. The schedule-based strategy is more favorable from the grid's perspective but may lead to lower selfconsumption rates and lower battery storage utilization. The peak-shaving strategy's main objective is to avoid critical voltages by avoiding high renewable energy feed-in; therefore, the amount of self-consumption depends on the feed-in set points. Forecast-based strategies can achieve high self-consumption rates while being grid-supportive at the same time. However, the success of forecast-based strategies depends on the accuracy of the forecast.

Objective
This paper aims to present an agent-based framework to maximize renewable energy self-consumption in an energy community with PV and battery storage systems.
The strategy proposed in this paper is a combination of building-level storage, community aggregated storage, and energy sharing between prosumers. With this setup, we intend to reduce extreme PV feed-in at the building connection point, reduce the storage capacity required by single buildings, and create additional value streams for battery storages through the community storage.

Concept and methodology
The prosumers presented in this paper are agents who have their PV electricity generation and battery storage capacity. They have a personal objective to increase their renewable energy self-consumption and, at the same time, as a community, maximize the collective self-consumption.
As shown in Figure 1, prosumers are connected to the utility energy supply and, at the same time, linked with the local energy market through a communication link. The energy market enables the prosumers to share their surplus renewable energy generation with other prosumers who has a residual demand.
The local energy market design is a discrete, merit-order based, single-sided auction. The prosumers with surplus renewable generation may submit a sell-offer based on an hourly forecast at each trading period. The sell-offers are ranked according to the price and dispatched until either all the sell-offers are exhausted or the community's residual demand in that trading period is entirely satisfied. Each buyer gets served based on the first-come basis, and each sell-order gets compensated based on the pay-as-bid pricing. The sell-offer price should lie between the feed-in tariff (EUR 0.10) and the utility electricity price (EUR 0.30) to attract local energy sharing to be attractive to market participants. Consequently, we model the sell-offer price as a uniform distribution (mean = 0.20, standard deviation = 0.033), where 99.7% of the price offers fall between EUR 0.10 and 0.30. There are two storage levels. The building-level storages owned by the prosumers are controlled based on a grid-friendly schedule. They support the prosumers' self-consumption behavior, but their primary role is to control excessive PV feed-in through the building connection point. Each prosumer who has storage commits a small share (up to 10%) of their storage capacity to a community storage aggregator for a fixed rental. The aggregated community-level storage operates based on the direct-loading strategy and has the purpose of maximizing collective self-consumption. The prosumers can sell their surplus PV generation to the aggregator at a fixed price of EUR 0.125/ kW or request PV electricity from the aggregator when there is a deficit at a fixed price of EUR 0.25/ kW. The difference between these two prices is the gross economic benefit earned by the aggregator.

Agent-based model setup
The simulation framework presented in this article is an agent-based approach where multiple agents interact with each other. The agent-based model is built using the templates provided in Mesa, an open-source python package for creating agent-based models [15].
The neighborhood model, a Mesa model, serves as a container for all model-level parameters, the agents in the simulation, a scheduler that defines the agents' activation regime, methods to progress the time during the simulation, and a data collector to store the simulation results. We derive two types of agents in the simulation environment, i.e., building agents (prosumers) and an energy sharing coordinator agent. The neighborhood model may have many agents corresponding to each building in the neighborhood and one energy sharing coordinator. The energy sharing coordinator's tasks are to coordinate energy sharing between the buildings provide community-scale storage by aggregating the portions of smaller storage units. Note that, for modeling convenience, we assign the responsibility of storage aggregation to the energy sharing coordinator; however, the model can report the results of energy sharing and storage separately. The schedule attribute of the neighborhood model defines the activation regime of the simulation agents. In our model, we choose the simultaneous activation regime, where all agents act simultaneously.

Performance metrics
The two most important indicators that we use to measure our method's performance are the self-consumption rate and the collective self-consumption rate that describe the share of PV generation consumed locally by each prosumer individually and collectively by the energy community.
Self-consumption rate = Share of prosumer's RE production that is consumed by the prosumer itself. Collective self-consumption rate = Share of RE generation in the energy community that is consumed by the prosumers of that energy community.
The self-sufficiency rate measures the energy community's dependence on the utility energy supply.

Self-sufficiency rate = Percentage of the total electricity demand of the energy community supplied by locally produced RE.
The economic benefits of energy sharing can be evaluated by the total energy cost reduction and new economic value creation metrics. In the use-case presented in this paper, 'new economic values' are created when a prosumer sells its surplus energy and when a prosumer commits a fraction of its local storage to join the community storage aggregation.

Energy cost reduction = Reduction of energy purchasing costs as a result of local energy
sharing.
New economic value creation = Economic value newly created by energy sharing and community storage aggregation.

Case-study
The case-study presented in this study is the planning area B (Rosensteinviertel) of the "Rosenstein-Quartier" new neighbourhood development project in the North of Stuttgart. The planned "Rosenstein-Quartier" spans over 85 hectares that will be redeveloped as a new residential and commercial district. The project developers envision the energy supply of the neighbourhood to be entirely of electricity, with a significant emphasis on building integrated photovoltaic systems. The area consists of 95 buildings with commercial and residential purposes.
In this case study, we assume two scenarios. In the first scenario, the PV modules cover 50% of the building roof, and each prosumer agent is equipped with a 1.5-hour battery storage capacity. The second scenario considers some of the uncertainties associated with renewable energy technology adoption; therefore, for each prosumer agent, the PV modules cover 20 -50% of the roof area. The bottom 20% of the prosumers with the lowest PV installed capacities do not have any storage capacities, while the other prosumers have 1.5hour battery storage similar to the first scenario.
We use the hourly TMY3 solar irradiance data for Stuttgart to calculate the PV potential. SimStadt, an urban energy simulation platform developed at the University of Applied Sciences -Stuttgart [16], is used to estimate the electricity and heat demand of each building in the neighborhood. The entire model is written in Python and executed over one summer month in an Intel Core i7 CPU@2.80GHz laptop with 12GB RAM. Each scenario is calculated 100 times to generalize the uncertainties incorporated in the model.

Self-consumption rate
As shown in Table 2, the prosumers' average self-consumption improves when the local energy sharing is allowed, and the increase is more significant (about 6%) in scenario 2. This result is related to the contribution of aggregated storage to increase self-consumption. We also observe that the average self-consumption in scenario 2 is notably higher than scenario 1. The reason for this observation is mainly related to the lower PV over capacities in the second scenario. In both scenarios, the total PV generation exceeds the total demand over the simulation period. The over-generation of PV in scenario 2 is 5.9% of the total demand compared to 41.5% in scenario 1.  Table 3 shows the average collective self-consumption rates of the two scenarios after 100 simulations each. Scenario 2 results in a higher collective self-consumption rate, and this observation can be primarily attributed to the lower PV over capacities in scenario 2.  Figures 2 and 3 show the distribution of buildings according to their self-sufficiency rate in scenarios 1 and 2. In both scenarios, energy sharing allows the buildings to achieve better self-sufficiency rates. However, the contribution of energy sharing with aggregated community storage has a dominant value in scenario 2 in the presence of several prosumers with low PV and storage capacities. Scenario 1 achieves average self-sufficiency rates of 65.1% and 69.8% at the community level, without and with energy sharing, while scenario 2 achieves 57.6% and 65.3% self-sufficiency rates respectively without and with energy sharing. The slightly lower self-sufficiency rates in scenario 2 occur due to the lower storage capacities; however, on average, energy sharing and community storage have contributed to increasing the energy community's self-sufficiency.

Energy cost reduction
The distribution of the energy cost reduction due to reduced electricity imports achieved by the prosumers over the simulation horizon is shown in Figure 4. In scenario 1, the average energy cost savings is EUR 87.50, and the maximum energy cost savings achieved by a prosumer is EUR 1,171.40. In scenario 2, the average and maximum energy cost savings are EUR 144.20 and EUR 3,819.20. Therefore, it is evident that prosumers with higher electricity demands, larger PV installations, and larger storage have a clear advantage to make more energy cost savings.

New economic value
On the other hand, the concept of new economic value extends beyond the benefits of merely energy cost savings. In particular, we recognize three kinds of economic value streams that stem from local energy exchange and community storage concepts.
1. Benefits by selling surplus PV energy to the local aggregator at a price higher than the feed-in tariff, 2. Benefits by purchasing electricity from the local aggregator at a price lower than the utility price, 3. Benefits by sharing a portion of building-level storage to the local aggregator.   Figure 5 shows the probability distribution of the benefits of exchanging energy with the local aggregator after 100 simulations in both scenarios. We observe that for both purchasing and selling, the benefits tend towards the right along the x-axis in scenario 2. Therefore, when the prosumers have a greater diversity in terms of PV and storage capacity, the benefits of the local energy exchange and aggregator tends to be higher. Figure 6 shows the distribution of the benefits of participating in a community storage aggregation scheme. We assume that the storage aggregator re-distributes all the benefits to the prosumers proportionately to the storage capacity that they committed to the storage aggregation scheme. We observe that the benefits tend to increase in scenario 2.

Discussion and conclusion
This paper presents an agent-based approach to evaluate a local energy sharing concept for an energy community with building-level storage and community aggregated storage.
The key results indicate that local energy sharing and storage aggregation positively influences the energy community's renewable energy self-consumption and selfsufficiency. The significance of energy sharing and storage aggregation becomes further apparent when the prosumers are more diverse in their PV and storage capacities. In particular, those prosumers that do not own the before-mentioned assets by themselves benefit by sharing resources with other prosumers and the aggregator in the neighborhood. Therefore, strategically, some prosumers can benefit from using shared assets, while others can benefit from investing in building shared assets. Apart from the energy cost reduction, multiple other value streams stem from local energy sharing platforms. Note that the prosumers with larger PV installations and larger storage gained more benefits in our case study. One of the reasons is the way the storage aggregator distributes its benefits among the participants. The price that the aggregator offers and takes also influences the overall economic value distribution. Therefore, the exact scale of benefits depends on the energy market design, business models, and the strategy to distribute the benefits among all the participants. In our use case, the storage aggregator re-distributes all its benefits to the prosumers proportionately to the storage capacity they commit to community storage, which can be seen as a theoretical upper-limit to the achievable economic benefits in this example.
Another advantage of energy sharing concepts is the improvement of energy asset utilization. In our results, we observe that scenario 2 (with energy sharing) can generate more benefits with comparable self-consumption and self-sufficiency rates but at lower PV and storage installed capacities. As the development of renewable energies at the local level is being encouraged, it is essential to be aware that without proper coordination (and digital platforms to enable such coordination), communities might add an extensive amount of under-utilized renewable energy assets.
Further research work must be carried out to understand the effect of different strategies, capacity purchase vs. capacity investment decisions, and the network limitations to implement such strategies. This publication is supported by M4_LAB. M4_LAB is a transfer project at the University of Applied Sciences -Stuttgart within the framework of the "Innovative Hochschule" initiative funded by the Federal Ministry of Education and Research under the grant number 03IHS032A. The author also wishes to thank Stuttgart Region Economic Development Corporation (WRS) and Joint Science Conference (GWK) for their contributions. The author is grateful for the technical support related to SimStadt from Rushikesh Padsala, Sally Koehler, and Verena Weiler, comments and advice from Prof. Andreas Sumper, and the organizational support provided by Prof. Dr. Uta Bronner and Christina Rehm.