Integration of prosumer peer-to-peer trading decisions into energy community modelling

Peer-to-peer (P2P) exchange of renewable energy is an attractive option to empower citizens to actively participate in the energy transition. Whereas previous research has assessed P2P communities primarily from a techno-economic perspective, little is yet known about prosumer preferences for solar power trading. Importantly, impacts of community members’ trading decisions on key performance indicators, such as individual electricity bills, community autarky and grid stress, remain unknown. Here, we assess P2P trading decisions of German homeowners on the basis of an online experimental study, and simulate how various decision-making strategies impact the performance of P2P communities. The findings suggest that community autarky is slightly higher when prosumers are enabled to trade energy compared to when they merely aim to maximize their self-consumption. Our analysis, moreover, shows that P2P energy trading based on human decision-making may lead to financial benefits for prosumers and traditional consumers, and reduced stress for the grid. Peer-to-peer energy trading can foster participation in the energy transition, but little is understood about prosumer preferences and their effect on the grid. Pena-Bello et al. use an online experiment among German homeowners to study decision-making strategies and simulate their impact on the operation of an energy community.

R enewable energy communities (RECs) are expected to play a key role in the transition towards clean and affordable energy. The European Union, for instance, has put RECs in the spotlight of its energy strategy, the Clean Energy for all Europeans Package 1 . This enacted the right of citizens to consume, store and sell self-generated renewable energy, either individually or in communities. RECs can be defined as renewable-based and distributed energy systems that are embedded within or close to consumption centres 2 . Members of RECs share several attributes, including space and networks, and/or several interests, such as renewable electricity supplies and decarbonization, and they actively participate in the project across one or more phases 3 . RECs may enable citizens to actively engage in the energy transition; for instance, by participating in collective investment in technology, the provision of self-generated electricity and community decision-making processes 3, 4 .
Several types of RECs have been discussed in previous literature, such as cooperatives, self-consumption communities, virtual power plants, energy hubs and peer-to-peer (P2P) electricity trading communities [5][6][7] . Among these, P2P communities offer citizens real-time market participation 8 . Specifically, P2P community members can buy and sell self-generated electricity on a local market; a characteristic that differentiates P2P communities from other forms of RECs. In organic P2P electricity markets, which refer to fully distributed structures that rely on grassroots initiatives from citizens 9,10 , community members become an integral part of the community decision-making process, determining how much and when renewable energy is shared within the community 9,[11][12][13] . In such P2P markets, community members with photovoltaic-coupled (PV-coupled) batteries have the highest degree of flexibility as they can decide whether they want to sell electricity to other community members, or increase their individual autarky.
There are indications that a notable number of citizens from industrialized countries have a positive attitude towards P2P energy communities, and would generally be willing to participate in related projects. Previous studies involving citizens interested in renewable energy indicate willingness-to-participate rates ranging between 74.5% and 79.0% (refs. 10,14,15 ). In a representative UK survey, willingness-to-participate ranged from 54% to 67% depending on the characteristics of the P2P community, such as its geographical range 16 . Moreover, 89.5% of a representative sample of 998 Swiss citizens reported that they would prefer P2P electricity trading to be based on their individual preferences over an entirely automatic decision-making process (Supplementary Note 1). However, trading decisions in the context of P2P communities are complex as multiple factors, such as dynamic electricity prices, state of charge (SOC) of batteries and PV generation forecasts, need to be considered. Agents that both consume and produce energy (that is, prosumers) further have to make trade-offs, since selling self-generated electricity at high market prices can be financially attractive, contribute to increased renewable energy consumption at the community level and lower grid stress, but it can also reduce individual autarky. In contrast, prioritizing autarky at the individual level may forego financial benefits from trading, as well as potentially intensifying grid stress. In light of these trade-offs, it is intriguing to ask under what conditions prosumers would be willing to provide electricity to a P2P community, and whether their trading decisions would lead to benefits at the individual, collective and grid levels.
Recent research revealed factors that influence homeowners' P2P trading decisions 10,17 , but the impact of such decisions on key performance indicators has not yet been sufficiently examined. Past research on P2P energy communities has primarily addressed techno-economic aspects; for instance, underlying technologies 18,19 and pricing mechanisms [20][21][22] . User behaviour has been reported for small P2P pilot trials, but has not yet been taken into account for the design and modelling of P2P communities 8 . Instead, community members have been modelled as rational agents with exclusively economic interests [18][19][20][21][22] . This reductive view on human preferences and decision strategies is at odds with theories and empirical findings from psychology, which have illustrated that human preferences and decisions notably tend to deviate from assumptions made by standard economic theory [23][24][25] . Moreover, recent research on P2P energy trading has illustrated that individuals vary in their trading preferences, and apply different decision-making strategies in P2P scenarios, rather than responding in a uniform fashion 10 . Thus, integrating actual human preferences and P2P decision strategies in energy modelling can result in more realistic projections of the potential of P2P communities at various levels. Finally, human-centred modelling more adequately responds to the principal idea that P2P communities foster social empowerment and participation in the energy transition 26 .
In this paper, we report an interdisciplinary approach, bridging psychology with the engineering sciences, to address the need for integrating human decision preferences into the analysis of P2P energy communities. We first assessed homeowners' P2P trading preferences by means of an online experimental study, and then integrated the decision data into an energy simulation. Our findings show that homeowners' trading decisions can result in benefits at the individual, collective and grid level. The benefits, however, vary across community members and depend on the applied P2P trading strategy of prosumers. The findings inform the design of P2P communities and provide new pathways towards human-centred REC design.

Assessment and integration of prosumer decision-making
We first conducted an online experimental study with 251 German homeowners willing to participate in a P2P community (see Methods for detailed sample information). We assessed decisions to trade self-generated PV electricity within a P2P community as a function of P2P market prices (€0.04 per kWh to €0.28 per kWh in steps of €0.08 per kWh), SOC of privately owned 10 kWh batteries (30-90% in steps of 30%) and time until the next solar generation surplus (more or less than 12 hours). Supplementary Fig. 1 depicts the trading decisions of the sample as a function of these three factors.
We then integrated the data derived from the experimental study into an open-source model of P2P communities. Specifically, we simulated an organic P2P community 9,10 , where members buy and sell electricity directly amongst themselves over a period of one year. Charging the battery from the grid was not considered. The community was located behind a single point of common coupling (PCC), a common interconnection point for different consumers connected to the same utility power supply 27 . The community encompassed 100 households in Germany, including both prosumers (with PVs or with PVs and battery) and consumers. Considering the future-oriented nature of P2P communities, we assumed a scenario with 50% PV penetration and 25% battery penetration (see Supplementary Note 2 for a sensitivity analysis covering a broad range of community sizes, PV penetration and battery penetration). To match demand and PV supply in the P2P community, we created a dynamic price structure with a uniform price for all community members at a given point in time. Furthermore, to increase the robustness of the results, we used the Monte Carlo method to sample 1,000 P2P communities, in which all households were randomly assigned to an electricity demand profile 28 , and prosumer households to a PV capacity, considering a representative distribution of PV plant sizes. Demand profiles and PV sizes were based on German data. Additionally, for every simulation, each prosumer with a battery was randomly assigned to a decision profile of one participant from the experimental study, reflecting their individual trading decisions. The link between the experimental psychological data and the simulation allowed us to determine, for each point of time in the simulation, whether or not a respective prosumer household would be willing to provide electricity to the community given the market price, battery SOC and surplus forecast.
To assess the impact of homeowners' trading decisions at the individual, collective and grid levels, we compared P2P communities with a baseline scenario with the same installed technologies and capacities but a different strategy (Supplementary Table 2). We refer to this baseline strategy as self-consumption (SC) maximization. In this baseline case, prosumers with PV-coupled batteries did not trade electricity from their batteries, in contrast to P2P communities. Thus, only surplus PV electricity was injected into the main grid, which was consumed locally if there was demand from other neighbouring households located behind the same PCC. These conditions reflect the status quo in Germany at the time of data collection, in which a utility serves as an intermediary among households. Accordingly, consumed electricity was bought at the retail price (€0.28 per kWh) and sold at the feed-in-tariff (FiT, €0.04 per kWh). We compared both prosumer models (P2P and self-consumption maximization) using various performance indicators, including the bill for prosumers and traditional consumers, as well as self-consumption and autarky at the individual and aggregated level measured at the PCC. Moreover, we accounted for grid exchanges in terms of maximum power imported from and exported to the main grid, and for the so-called 'duck-curve' , which can be observed in areas with large PV generation 29 . This reflects a need for fast ramping-up of capacity after sunset and represents a major challenge for grid stability 29 .

Impact of prosumer decision-making at the individual level
We find that P2P energy trading on the basis of homeowners' trading strategies may lead to economic benefits for prosumers with and without batteries, as well as for traditional consumers, compared to the baseline case where households maximize self-consumption (see Supplementary Note 3 for results considering a similar price structure for both models). Figure 1a illustrates that annual electricity bills were lower for all household types in P2P communities, compared to self-consumption maximization. The largest reduction, corresponding to a median value of €262.20 per annum (confidence interval (CI) based on 1,000 simulations: CI 95% (€261.90, €262.60) per annum) was observed for traditional consumers. Prosumers with only PV showed the lowest annual bill reduction, with a median difference of €98.10 per annum (CI 95% (€97.90, €98.20) per annum). This amount increased slightly to €115.30 per annum (CI 95% (€114.70, €115.80) per annum) for prosumers with batteries. For consumers and prosumers, the differences between a P2P community and the use of a self-consumption maximization strategy were statistically significant (P ≤ 0.001). Figure 1b presents the distribution of the average self-consumption and autarky for prosumers with PV-coupled batteries in P2P communities and the self-consumption baseline. In P2P communities, in contrast to self-consumption maximization, individual self-consumption was, on average, reduced by 6.6 percentage points (CI 95% (6.59, 6.61) percentage points) and autarky was reduced by 12.19 percentage points (CI 95% (12.17, 12.22) percentage points). For households with only PVs, the indicators remained unchanged. Furthermore, prosumers with PV-coupled batteries were net producers of electricity regardless of the strategy, as indicated by their position above the diagonal in Fig. 1b. This means that their aggregated annual PV generation was higher than their aggregated annual electricity consumption.

Impact of prosumer decision-making at the aggregated level
The findings show, moreover, that P2P trading brings higher financial benefits for community members at the collective level. In the P2P community, the annual aggregated bill was 22.8% lower (equivalent to €18,479 per annum CI 95% (€18,475, €18,484) per annum) compared to self-consumption maximization (P ≤ 0.001; Fig. 1c). The economic benefits of P2P communities can be further quantified through the benefit index 21 , which measures the percentage of households that obtain more financial benefits when taking part in a P2P community (Methods). We find that the benefit index ranges between 95% and 100% (median of 100%, CI 95% (99%, 100%)), indicating that most of the households benefited from P2P trading and dynamic prices.
Furthermore, trading within P2P communities led to a small but consistent increase of both self-consumption and autarky at the aggregated level, relative to prosumers maximizing self-consumption (Fig. 1d). Aggregated self-consumption increased from 49.6% (CI 95% (49.5%, 49.7%)) to 51.9% (CI 95% (51.8%, 52.0%)), while aggregated autarky increased from 47.9% to 50.1% on average. This finding can be explained by a more flexible distribution of locally produced PV electricity at the aggregated level, due to prosumers providing extra electricity from their batteries in P2P communities.

Impact of prosumer decision-making at the grid level
In addition to the impact of P2P energy trading on households and communities, we analysed power exchanges with the distribution grid. We further analysed distribution grid reinforcement, taking into account the distribution grid constraints, which are vital factors for understanding future investments in electricity infrastructure [30][31][32][33] . To visualize the duck-curve, we analysed the average weekly grid exchanges across one year for one randomly selected simulation. As illustrated in Fig. 2a, the data reflect a duck-curve pattern at the PCC: PV electricity exported to the grid shows a maximum around midday when solar generation is the highest. This grid injection is followed by a sharp ramp-up of net electricity demand of 22 kW per hour in the early evening when prosumers maximize self-consumption, due to both the solar sunset and electricity peak demand. Importantly, we notice that P2P trading can help to reduce the magnitude of the duck-curve by 10% when   compared to self-consumption maximization (that is, the ramp-up is 20 kW per hour for P2P). On average the import power peak in the P2P community is reduced by 19.5% around 20:00 (that is, a reduction from 58.4 kW to 47.0 kW). Furthermore, the peak in exported PV power is reduced by 4.6% (that is, reduction from 100.7 kW to 96.1 kW).
To compare the yearly differences in power exchanges with the grid, we used peak-to-peak amplitude differences per season for 1,000 simulations. Figure 2b shows that the peak-to-peak reduction for P2P trading is maintained across all seasons, with the largest reductions occurring in spring (10.88 kW; CI 95% (10.85 kW, 10.90 kW), that is, 4.49%; CI 95% (4.48%, 4.50%)), and the smallest reductions occurring in winter (4.96 kW; CI 95% (4.95 kW, 4.97 kW), that is, 2.62%; CI 95% (2.61%, 2.62%), P ≤ 0.001). Additionally, we modelled a synthetic distribution grid and transformer, including network constraints such as voltage violation and cable and transformer overloading (see Methods and Supplementary Note 4). On the basis of our analysis, the main limiting factor to PV hosting capacity is transformer overloading, which can be addressed if maximum grid import and export peaks are reduced. Therefore, we analysed the maximum grid import and export peaks across an entire year to understand whether P2P trading can alleviate them ( Fig. 2c). We found that, relative to self-consumption maximization, the maximum export peak was marginally higher in a P2P community with a median difference of 1.69 kW (P ≤ 0.001, CI 95% (1.67 kW, 1.71 kW)), while the maximum import peak was slightly lower with a median difference of −3.54 kW across the year (CI 95% (−3.57 kW, −3.50 kW)).

Impact of different prosumer P2P decision-making strategies
Finally, we examined the extent to which differences in P2P trading strategies impact autarky and electricity costs at the individual and community levels, as well as their impacts on the grid. To this end, we divided the sample into three groups on the basis of the distribution of participants' trading decisions in the experimental task. Specifically, we composed three subgroups that either traded electricity in a restrained (below μ − σ; whereas μ is referring to the mean and σ to the standard deviation), moderate (between μσ and μ + σ) or intensive way (above μ + σ) as represented by the red, green and blue areas in Fig. 3a, respectively. We then created three P2P communities that were composed of the same share of traditional consumers (50%) and prosumers (25% with PVs only, 25% with PV-coupled batteries) as in the previous analyses. The Import Export  P2P communities differed with respect to whether their prosumers with PV-coupled batteries traded electricity in a restrained, moderate or intensive way, using the three created trading subgroups. This approach allowed us to examine how different trading patterns impact the performance of P2P communities (Fig. 3b,c; see Supplementary Fig. 2 for results on self-consumption).
The analysis points to an optimal trading window associated with a moderate trading pattern, which led to relatively high autarky at both the individual (70.13%, CI 95% (69.40%, 70.85%)) and community levels (49.71%, CI 95% (49.68%, 49.73%)). This decision pattern also resulted in the highest economic benefits at the individual level, with bill reductions for households with PV-coupled batteries of €46 and €44 per annum (CI 95% (€45, €47) and (€42; €46) per annum) compared to restrained and intensive trading patterns (P ≤ 0.001). Similarly, it also resulted in significant bill reductions of €1,226 and €918 per annum at the community level compared to restrained and intensive trading, respectively (CI 95% (€1,224, €1,254) and (€911; €920) per annum, P ≤ 0.001). Moreover, the maximum weekly peak-to-peak magnitude of the duck-curve was, on average, 4.9% lower for moderate compared to restrained traders. In contrast, restrained traders achieved higher autarky at the individual level (77.57%, CI 95% (76.93%, 78.20%)), but lower autarky at the community level, compared to the moderate trading group (decrease by 1.3 percentage points; CI 95% (1.2, 1.4), P ≤ 0.001). In contrast, intensive trading resulted in the highest community autarky, leading to an increase of 1 percentage point compared to moderate traders (CI 95% (0.9, 1.1), P ≤ 0.001). Intensive trading also has the highest potential to reduce the duck-curve magnitude, with an average decrease of 2.6% compared to moderate trading. However, this trading pattern reduced autarky at the individual level by 14 percentage points compared to moderate traders (P ≤ 0.001). Lower individual autarky resulted in higher bills for intensive   traders compared to moderate traders (see above) and statistically similar bills than restrained traders.

Discussion
Our study, bridging experimental psychological research with robust energy modelling, indicates that social empowerment in P2P communities may lead to multiple benefits for community members, including prosumers as well as traditional consumers. Our findings have four key implications for industry, policy-makers and academics. First, we find that traditional consumers obtain the highest financial benefits in P2P communities. As consumers do not generate their own electricity, they generally have higher electricity bills than prosumers, and thus have the largest reduction potential (Fig. 1). This finding has implications for distributional energy justice; referring to the allocation of benefits and costs within a community [34][35][36] . On the one hand, P2P communities can foster energy justice as they increase access to renewable electricity at a low price, including households that do not have the financial resources to invest in renewable energy technology. On the other hand, investments in renewable energy technology need to pay off for community members to ensure availability of locally generated electricity. A fair distribution of the costs inherent to P2P communities, including investments in PV and storage systems, may be achieved by differentiated membership fees in the function of a member being a traditional consumer, prosumer with PV or prosumer with both PV and battery.
Second, we find that aggregated autarky was slightly lower overall when prosumers maximized their self-consumption than when they shared energy within P2P communities. Prosumers who aim to maximize their individual autarky paradoxically reduce autarky at the aggregated level. In P2P communities, electricity trading liberates battery capacity, enabling recharging with more self-generated PV electricity when the next surplus occurs. In contrast, when prosumers aim to maximize self-consumption, their batteries remain idle for longer periods as no energy is shared from their batteries. Therefore, P2P communities reduce yearly PV electricity exports to and imports from the grid, increasing autarky at the collective level.
Third, our analysis of grid impacts shows that the duck-curve is flattened in P2P communities compared to a strategy where prosumers maximize self-consumption, all else being equal. P2P communities enable the supply of more PV electricity on-demand, reducing the duck-curve and thereby decreasing the need for cost-intensive non-renewable energy supply, power balancing and other ancillary services. However, extreme import peaks remain at similar levels for both types of prosumer strategies. Thus, while P2P communities may help to flatten the duck-curve, they can neither increase the hosting capacity of the distribution grids, nor defer their final upgrade. To further reduce the impact of high PV penetration on the grid (for example, more than 75% of households with PV in the community, see Supplementary Note 4), the implementation of flexibility strategies such as demand-side management can be considered. Implementing additional flexibility strategies would require close cooperation between P2P communities and network operators. Policy-makers should therefore promote such cooperation, and provide new regulation of data access, privacy and cybersecurity to ensure that the rights of P2P members are fully respected when enabling network operators to procure flexibility using P2P resources.
Fourth, our interdisciplinary analyses show that homeowners apply different P2P trading strategies 10 , which may lead to more or less beneficial outcomes for themselves and the community. Specifically, either overly restrained or overly intensive trading strategies resulted in financial-and autarky-related disadvantages at the individual and community levels. Our results pinpoint a moderate trading strategy to maximize benefits, reflecting decisions of the majority of participants in our sample (Fig. 3). For the design of a P2P community, this means that responsible stakeholders should dare to involve community members in the operation of P2P communities, since their decisions seem well calibrated to produce individual and collective benefits. As an additional effect, involvement in P2P operations may increase social empowerment, which eventually may lead to co-benefits, such as increased satisfaction, participation rates and technology investments.
Limitations and future pathways. Our interdisciplinary approach is novel, but not without limitations. Although our methodology is based on the assessment of actual decisions of homeowners, it is important to note that these decisions were made in a controlled experimental setting. In our experimental design, homeowners received a predefined set of information, including energy prices, the SOC of their battery and PV surplus forecasts. Our rationale was based on literature illustrating that laypersons have limited knowledge about energy-related variables and the energy system 37,38 . We therefore limited our focus to the factors that were previously identified as having an important impact on homeowners' trading decisions 10,12,39 . Our research can thus be a starting point for future research considering additional factors in P2P trading, including further technical information, such as battery aging, either provided to prosumers or integrated into energy simulations and algorithms. For applications where batteries perform more cycles, such as batteries charging from both a PV system and the grid, or for batteries performing benefit stacking, aging may become relevant. Another limitation of our experimental approach is that real-life prosumer decisions might be influenced by situational factors, such as time constraints, which we did not consider in our experimental study. Large-scale field trials, including an in-depth analysis of user decision-making, would thus be a natural extension of our research, to increase external validity. Our findings can inform the design of future field trials, which should aim to include broad samples of prosumers and consumers, and thereby go beyond existing pilot trials with restricted samples 8 .
A discussion of external validity is closely linked to the question of how individual decisions could be implemented in future P2P communities. While it would be very demanding for prosumers to make each individual trading decision manually, their decision preferences could be integrated into trading algorithms that would administer trading in everyday life. To this end, prosumers would configure trading algorithms by means of prototypical decision situations similar to those applied in the present study, and the resulting decision profiles would then be used to calibrate decision algorithms. As illustrated in Supplementary Note 1, 68.1% of citizens would prefer this option, in which a trading algorithm administers trading in everyday life on the basis of pre-assessed individual preferences, compared to 21.3% preferring manual scheduling and 10.5% preferring entirely automatic decisions. Taken together, our research corroborates recent research on the need for responsible, human-centred, algorithm design and demonstrated methodological pathways to achieve such design objectives 40 .
Future research can build upon our methodology to develop alternative pricing mechanisms or auction systems that account for user preferences. It would be of importance for such studies to exploit various means to integrate network charges in P2P market prices to ensure a fair distribution of costs for citizens within the community. Considering that P2P communities reduce the use of the main grid, reduced network charges for energy traded within the P2P community compared to existing charges are conceivable. Additionally, network charges may be distributed among community members according to their final peak flow (that is, their peak export and import), to avoid free-riding and to increase distributional fairness within the community.
The grid-friendly operation of P2P communities should be further investigated by applying more detailed distribution grid models, which take into account the characteristics of local grids and trading decisions. Finally, the spectrum of considered technologies within P2P communities could be extended to other low-carbon technologies, such as heat pumps and electric vehicles. Given the high storage potential of electric vehicles, it is an intriguing question how prosumers would be willing to trade electricity when using electric vehicle batteries. We consider that future research with user-centred modelling approaches coupled with field trials can provide a more complete understanding of citizens' interactions in RECs, and thus may inform the design of future RECs that achieve both citizen empowerment and renewable flexibility procurement for the energy transition.

Methods
Experimental online study. Sample. The study was approved by the ethics committee of the Faculty of Psychology and Educational Sciences of the University of Geneva, Switzerland, and was conducted in accordance with the ethical regulations of the university. All participants gave their consent to take part in the study and received financial compensation for participation. In total, 251 homeowners completed the study (of a total of 299 who began the study; that is, 48 participants decided not to finish the study). Data collection was assigned to a market research institute (Consumerfieldwork; experimental study date: March 2020), which contacted panel members who owned a house and were older than 18 years of age. Demographic characteristics, as well as information on PV and storage ownership and psychological variables of the full sample are depicted in Supplementary Note 5 and Supplementary Table 1. The distribution of sex, age, educational level and occupation largely corresponded to the general population of German citizens (but see the section below on 'Generalizability' for deviations). Participants completed the study online. The study was closed after the predefined number of 250 completions were attained.
Generalizability. The following aspects should be considered regarding the generalizability of our results. We specifically assessed decisions of German homeowners based on the rationale that homeowners should most likely be able to self-generate and trade electricity. This resulted in a higher median age in our sample than that of the German population, reflecting the circumstance that homeowners are, on average, older than the overall population. Additionally, the amount of women in our sample was slightly higher than in the German population. Moreover, trading decisions were only based on participants who reported that they were willing to take part in a P2P community after detailed information provision (70% of our sample, see section below on 'Pre-assessment and P2P decision task'). Our rationale was to examine trading decisions of individuals who are likely to be members of future P2P communities. Supplementary Table 1 shows detailed demographic information on the total sample, the trading sample and the non-trading sample. Furthermore, our analyses of trading decisions were based on an experimental task using a predefined set of variables, and thus decisions might deviate from those made in real life (see section on 'Limitations and future pathways' in the Discussion). Finally, to test whether the results of the simulated P2P community can also be transferred to communities with different sizes and shares of PV and battery penetrations, we conducted sensitivity analyses with various community configurations and sizes. This sensitivity analysis can be found in Supplementary Note 2.
Pre-assessment and P2P decision task. Participants first answered a series of demographic questions, including sex, age, civil status, employment status, highest achieved educational degree and household size, as well as their political ideology, general risk-taking preferences, environmental values and renewable energy technology purchase intentions (Supplementary Table 1). Participants were then introduced to the P2P energy trading scenario, which we designed to reflect future conditions in a realistic and vivid manner. The decision scenario was adapted from a recently published study by Hahnel et al. 10 . In the scenarios, participants were asked to imagine that they installed PV modules on their roof to generate electricity, as well as a 10 kWh battery in their basement to store the generated electricity. The PV system generated electricity with a levelized cost of €0.11 per kWh, which was included as reference information for comparison with the P2P market price. Inside the P2P community, participants were able to trade electricity from their batteries.
Subsequently, the P2P choice task was introduced (see Supplementary Fig. 3 for a visualization of the task). Participants were instructed that they would face several independent situations in the described scenario, and they had to repeatedly decide whether or not they wanted to sell 1 kWh electricity from their battery to the community. In each situation, they were informed about the projected next PV surplus, the SOC of their battery and the P2P market price. Before the task, participants were informed that when their battery was empty they would have to buy their energy at the current community market price. Similarly, when their battery was fully charged they would have to sell their energy at the current market price. Afterwards, participants reported their willingness to participate in the described P2P community. The specific question was: 'In general, could you imagine being part of an electricity community as described earlier, where electricity is traded among members?' . Response options were: (1) 'Yes, I can imagine that in principle'; (2) 'No, I can't imagine that in any case' . When the answer was negative (that is, 75 out of 251 participants, equivalent to 30% of the sample), participants were asked for the reason, and then the study was closed for those individuals (Supplementary Note 5 and Supplementary Fig. 4 for the reasons of respondents who did not want to participate in the proposed P2P community). Only in the case of a positive answer were the participants forwarded to the energy trading section.
P2P experimental design. The P2P choice task was based on a 4 × 3 × 2 within-subjects design, with different electricity prices being offered in the community (€0.04 per kWh to €0.28 per kWh in steps of €0.08 per kWh), SOC of the battery (30-90% in steps of 30%) and time until the next surplus (more or less than 12 hours). All possible combinations of prices, charging states, and time until next surplus were presented in a random order, resulting in a total of 24 decisions. The dependent variable was participants' choices to sell electricity from the battery to the P2P community or not.
During the task, a reminder box was displayed informing participants that the levelized cost of PV was €0.11 per kWh, that selling electricity would decrease the SOC of their battery by 10% (corresponding to 1 kWh), that a full battery was sufficient to cover the electricity demand for one day, approximately, and that their decisions would be valid for a one-hour interval and could be revised afterwards.

Simulation. Modelling.
We developed an open-source model, schematically represented in Supplementary Fig. 5, to analyse P2P communities including prosumers with and without batteries and traditional consumers. To understand the impacts and trade-offs of human decision-making preferences and strategies towards P2P trading, we used a baseline case with the same number of prosumers and consumers, as well as the same technology capacities. In this baseline case, prosumers maximized their self-consumption, which represented the status quo in Germany and many other countries after the decline of FiTs 41 . Our open-source model is based on prosumpy, a toolkit for the simulation and economic evaluation of self-consumption with solar home battery systems 42 , which takes as inputs the community size, PV and battery penetration and the demand and generation datasets. The model and data on which this article is based are available at https://github.com/alefunxo/P2P-communities-PV-Battery.
Community conformation. For both cases, P2P communities and self-consumption maximization, we considered 100 households in the same area behind a single PCC, which were fed by a single low-voltage/medium-voltage transformer. The two strategies were compared at the individual and at the aggregated levels (that is, at the PCC). Supplementary Table 2 shows the main assumptions and technology characteristics for both P2P community trading and self-consumption maximization. We assumed 50% PV penetration (that is, 50 households with PV) and 25% battery penetration (that is, out of the 50 households with PV, 25 have access to a battery) for the main analysis. Analysis of other PV and battery penetration (25 and 75% for each device) scenarios and community sizes (20, 40, 60 and 80 households) are shown in Supplementary Note 2.
Monte Carlo simulations. To increase the robustness of our results, we ran 1,000 simulations for every community, randomly assigning to every household a demand profile and a PV system size (prosumers only), as well as a decision profile of one participant from the experimental study (prosumers with PV and battery only). We then referred to the mean values of the 1,000 simulations across the figures in this paper.
Self-consumption maximization. Here, every prosumer, with and without batteries, maximized their own self-consumption to avoid expensive electricity imports from the main grid at the retail tariff. When the battery was full and PV generation was higher than demand, surplus PV electricity was sold to the grid at the FiT (see Supplementary Note 6 for more information). We used a flat tariff of €0.28 per kWh as the retail price, which is close to the reported average retail price for households in Germany for the second half of 2019 (€0.287 per kWh) 43 . The FiT was assumed to be constant at €0.04 per kWh, which is close to the average German wholesale electricity price (€0.038 per kWh) for the years 2017-2019. Under this strategy, there was no electricity trading. However, other households in the area can make use of the PV surplus electricity, contributing to aggregated self-consumption and autarky (measured at the PCC). Battery grid charging and battery electricity injection into the main grid from the batteries were not allowed under this strategy.
P2P community. First proposed in 2007 44 , P2P trading is based on an interconnected platform that serves as an online marketplace where consumers and producers 'meet' to trade electricity directly, without the need for an intermediary 45 . In particular, we modelled an organic market (behind the PCC) with a dynamic price structure (see section below on 'Pricing mechanism in P2P community') involving prosumers with and without batteries and traditional consumers 10,45 . Therefore, electricity can be sold to the P2P community from both PV and battery systems. For the latter, we used homeowners' trading preferences derived from the experimental study, depending on the market price, battery SOC and time until the next PV surplus (Supplementary Notes 5 and 6). Trading preferences were integrated into the simulation by randomly allocating each household with PV and batteries a decision profile of one participant from the experimental study.
Pricing mechanism in P2P community. Three assumptions were considered for the proposed P2P market: (1) there is a competitive equilibrium; (2) electricity demand is inelastic; and (3) the market operator ensures that the platform is secured and trusted, and follows a balanced budget, that is, all payments effectively flow between households and the utility grid, or among various households, without receiving any dedicated profit. There is a single market price at any time. The price of a good is inversely related to the quantity offered, according to the law of supply and demand 20 . Thus, the market price increases alongside limited PV surplus available to be sold relative to the amount of electricity demand, and vice versa. When PV surplus (including both PV and batteries) is higher than the community electricity demand, surplus PV electricity must be exported to the main grid at €0.04 per kWh. Likewise, if the community electricity demand is higher than surplus PV electricity, electricity must be purchased from the main grid at the retail price (€0.28 per kWh). To the extent that demand and supply match and to the extent that prosumers are willing to sell, electricity is available for trading inside the community, depending on prosumers preferences. We used equation (1) to calculate the amount of electricity that could be traded at every time slot using the probabilities of selling electricity collected through the experimental study. To determine the market price, we used a two-step method, based on probabilities to sell (that is, ex-ante, as opposed to actual sells). First, we calculated the probabilities of selling electricity from the batteries when the SOC was 60%, accounting for the time until the next PV surplus, using the data from the experimental study. Second, for the amount of traded electricity (calculated ex-ante, based on probabilities), we determined an equilibrium price for the P2P market, that is, supply is equal to demand, and approximated the equilibrium price to those used for the experimental study (€0.04, €0.12, €0.20 and €0.28 per kWh). Therefore, the market price was constrained to be a step function, with the FiT as the lower bound, and the retail price as the higher one 20 . This dynamic price structure resulted in a uniform price for all community members. See Supplementary Note 6 for an example of two representative spring days.
where N is the number of batteries in the community and P((1 kWh) h,t |(SOC 60% ,t)) is the probability of trading 1 kWh from a prosumer with a battery when the SOC is 60% depending on the time until the next PV surplus based on the weather forecast.
Input data and assumptions. We used the distribution of PV sizes from the EEG register data and funding rates (which can be found at https://bit.ly/37d0Q6L) with 841,783 registers of small PV plants (≤10 kW p ), from which we randomly generated for each Monte Carlo simulation the PV size attached to each one of the considered households. The PV generation was modelled using a single diode equivalent circuit model using outdoor temperature and clear sky global irradiation on a horizontal plane at ground level in Munich, Germany, taken from Soda-Pro (http:// www.soda-pro.com/) from the year 2015. We generated one year of data with a 15-minute resolution, of a 1 kW p PV system, which afterwards was scaled up to the PV size assigned to a given household. In accordance with the experimental decision task, we used a 10 kWh battery system with 100% depth-of-discharge. It is worth noting that battery degradation is an important parameter to be considered by prosumers. Although we did not consider it in this study, to avoid trading electricity without a proper economic incentive, the battery degradation cost must be lower than the revenue created by the P2P trading (for a detailed discussion see Supplementary Note 7). In terms of electricity demand, we used electricity consumption data with a 15-minute temporal resolution of residential load profiles from a published German dataset 28 .
Key performance indicators definition. To evaluate the performance of the two considered strategies, we used two economic indicators, as well as three technical indexes. First, we used the individual bill (Bill j , equation (2)) and the aggregated bill (Bill agg , equation (3)). Additionally, we utilized the benefit index (BI, originally called the participation willingness index 21 ), which measures the percentage of prosumers who obtained more benefits by participating in P2P communities than those using a self-consumption maximization strategy, reflecting the overall financial benefit of the whole population (equation (4)).
(E grid−to−housei × π retaili − E house−to−grid i × π FiTi ) where, for the household j at time i, E grid−to−house i is the amount of energy consumed and E house−to−grid i is the amount of energy injected into the grid, π retaili and π FiTi are the retail prices and FiT respectively. In the case of the P2P community there is one price for electricity import and export within the community: the P2P market price. The aggregated bill is the sum of the individual bills across the members of the P2P community, with the same households considered to calculate the aggregated bill for the self-consumption maximization strategy. In both strategies, we did not consider any cost associated with the community membership. In equation (4), N Lower cost represents the number of prosumers with a lower energy cost when they participate in the P2P community compared to the cost in the self-consumption maximization strategy. In terms of technical performance, we used the indicators: PV self-consumption, which is the share of on-site PV generation (E PV ) that is used to cover one's own electricity demand (E demand ), and autarky, which is the share of one's own total demand that is covered by the on-site PV generation, at the individual and at the aggregated levels, as defined in equations (5) and (6). We show these two indicators graphically in an energy matching chart (Fig. 1).
where, E PV−demand is the PV electricity directly consumed, E PV−batt is the amount of PV electricity used to charge the battery and E PV is the annual PV generation. At the aggregated level, and to account for the interaction with the grid, we used the peak-to-peak amplitude difference to measure the daily variance of the interaction with the grid: in particular, the so-called duck-curve. The peak-to-peak amplitude difference measures the distance between the lower peak (maximum export of the day) and the higher peak (maximum import of the day), which, in graphical terms, is the distance from the bottom to the top of the duck head (in kW, see Fig. 2a). This indicator allowed us to highlight the differences between the two strategies beyond the year maxima.
Grid modelling. We included a complementary model of the distribution grid based on refs. 32,33 , using the average 15-minute profile of 100 households and the PV profile with the same temporal resolution. We assumed that the households were embedded into an area of 0.01 km 2 in Germany. The proposed distribution grid model takes a simplified approach of a radial distribution grid with a uniform distribution of consumers in the area supplied by each transformer, involving horizontal and vertical connection lines (see Supplementary Note 4 for more information). The model considers the cost of installation for the distribution grid, taking into account the transformer cost and the cost per km of the line, and takes into account losses and voltage constraints to calculate the transformer hosting capacity.
Statistical tests. To test for statistical differences across prosumer strategies, we performed a Shapiro-Wilk test to inspect the non-normality of the data, followed by a paired two-side Wilcoxon test with the Holm procedure to control the family-wise error rate. When more than two samples were compared (analysis of P2P trading groups), we used a Kruskal-Wallis test to test for differences. All statistical test results are presented in Supplementary Tables 3-6.
Reporting Summary. Further information on research design is available in the Nature Research Reporting Summary linked to this article.

Data availability
All the raw data, including the online study, and the data required to create each figure, are available at https://doi.org/10.5281/zenodo.5571499. The electricity consumption data from Germany are available at http://pvspeicher.htw-berlin.de

Code availability
All the code that supports the findings of this study, and the code used to generate the figures is available in https://github.com/alefunxo/ P2P-communities-PV-Battery. Python (v.3.7.2) and R (v.3.6.3) were used for data analysis and simulation, including the following packages: pandas (v.0.24.