Characterization and optimization of energy sharing performances in energy-sharing communities in Sweden, Canada and Germany

Peer-to-peer (P2P) renewable power sharing within a building community is a promising solution to enhance the community ’ s self-sufficiency and relieve the grid stress posed by the increased deployment of distributed renewable power. Existing studies have pointed out that the energy sharing potentials of a building community are affected by various factors including location , community scale , renewable energy system (RES) capacity , energy system type , storage integration , etc. However, the impacts of these factors on the energy sharing potentials in a building community are not fully studied. Being unaware of those factors ’ impacts could lead to reduced energy sharing potentials and thus limit the associated improvement in energy and economic performances. Thus, this study conducts a comprehensive analysis of various factors ’ impacts on the energy sharing performances in building communities. Two performance indicators are first proposed to quantify the energy sharing performances: total amount of energy sharing and energy sharing ratio (ESR). Then, parametric studies are conducted based on real electricity demand data in three countries to reveal how these factors affect the proposed indictors and improvements in self-sufficiency, electricity costs, and energy exchanges with the power grid. Next, a genetic algorithm based design method is developed to optimize the influential parameters to maximize the energy sharing potentials in a community. The study results show that the main influential factors are RES capacity ratio , PV capacity ratio , and energy storage system capacity . A large energy storage capacity can enhance the ESR. To achieve the maximized ESR, the optimal RES capacity ratio should be around 0.4 ~ 1.1. The maximum energy sharing ratio is usually smaller in high latitude districts such as Sweden. This study characterizes the energy sharing performances and provides a novel perspective to optimize the design of energy systems in energy sharing communities. It can pave the way for the large integration of distributed renewable power in the future.

• Propose two parameters to quantify energy sharing performances in a building community.
• Investigate various factors' impacts on energy sharing performances in three countries using real data.
• Verify effectiveness of the two proposed parameters in quantifying energy sharing performances.
• Develop a design optimization method of influential factors to maximize energy sharing potentials.
• Significantly increase the renewable self-utilization and reduce electricity bills and grid interactions.Peer-to-peer (P2P) renewable power sharing within a building community is a promising solution to enhance the community's self-sufficiency and relieve the grid stress posed by the increased deployment of distributed renewable power.Existing studies have pointed out that the energy sharing potentials of a building community are affected by various factors including location, community scale, renewable energy system (RES) capacity, energy system type, storage integration, etc.However, the impacts of these factors on the energy sharing potentials in a building community are not fully studied.Being unaware of those factors' impacts could lead to reduced energy sharing potentials and thus limit the associated improvement in energy and economic performances.Thus, this study conducts a comprehensive analysis of various factors' impacts on the energy sharing performances in building communities.Two performance indicators are first proposed to quantify the energy sharing performances: total amount of energy sharing and energy sharing ratio (ESR).Then, parametric studies are conducted based on real electricity demand data in three countries to reveal how these factors affect the proposed indictors and improvements in self-sufficiency, electricity costs, and energy exchanges with the power grid.Next, a genetic algorithm based design method is developed to optimize the influential parameters to maximize the energy sharing potentials in a community.The study results show that the main influential factors are RES capacity ratio, PV capacity ratio, and energy storage system capacity.A large energy storage capacity can enhance the ESR.To achieve the maximized ESR, the optimal RES capacity ratio should be around 0.4 ~ 1.1.The maximum energy sharing ratio is usually smaller in high latitude districts such as Sweden.This study characterizes the energy sharing performances and provides a novel perspective to optimize the design of energy systems in energy sharing communities.It can pave the way for the large integration of distributed renewable power in the future.

Introduction
Renewable energy is a promising solution to the increasing energy crisis and environmental issues.To promote the utilization of renewable energy, many governments and organizations have set targets.For instance, the European Union 2030 climate and energy framework set targets at the European level that there is at least 32 % share for renewable energy by 2030 [1].Scotland has a target of 100 % renewable electricity in 2020, and around 97.4 % of the electricity came from renewable sources in 2020 [2].The Swedish government has set a target to achieve 100 % renewable power supply by 2040 [3].Denmark has committed to a 100 % renewable energy supply by 2050 [4].In response to these renewable targets, an increased number of distributed renewable energy systems (RES), such as photovoltaics and wind turbines, are being installed nowadays.The large distributed RES penetration, if not well regulated, will cause problems such as the voltage deviations and overloading of components to the power grid [5].Peer-to-peer (P2P) renewable energy sharing within a building community (i.e., a group of neighbouring buildings connected in the same microgrid) is an effective way to relieve the grid stress posed by the increased deployment of distributed RES.Via P2P sharing, the buildings with surplus renewable power production can share their surplus power with others nearby in shortage, thus facilitating the local utilization of more renewable energy and improving self-sufficiency [6].Such P2P energy sharing can further reduce the community peak power demand, peak renewable power exports and the amount of grid power imports, as well as the associated electricity bills.Luthander et al. [7] has showed in their study that implementing a simple energy sharing (i.e., aggregate the power demand and PV power production from each building) in a community of 21 residential buildings could contribute to over 15 % increase in the PV power self-consumption.By integrating energy storage technology, advanced controls and system designs, the energy sharing performances can expected to be better.
Many efforts have been devoted to facilitating the P2P energy sharing implementation in practice.Currently in Sweden direct current (DC) microgrid has been deployed in building sectors for energy sharing and promoting the local utilization of renewable energy in some projects.When the local micro gird consists of DC lines that directly connect PV production plants, they are covered by the exemption under §22(a) of the IKN Regulation 2007:215 [8], i.e., energy sharing is partially allowed.For instance, Ferroamp, a company in Sweden, developed an EnergyHub and DC microgrid system for enabling power sharing within a building community [9].There are also some pilot schemes designed for creating platforms for the P2P energy sharing.For instance, in the U. S., the Brooklyn Microgrid [10], a community energy market platform, was developed in 2018, within which the members can buy and sell energy from each other with smart contracts based on blockchain).In the UK, the Centrica pic (2018) [11] and Picio (2019) [12] projects were both established for developing local energy markets which allows energy sharing among participants to balance power generation and power demand.The sonnenCommunity (2019) [13] developed in Germany, allows the sharing of self-produced renewable power by individual consumers.In this platform, the surplus energy is fed into a virtual energy pool which can be used by other community members.And the electricity price is fixed within the community, as EUR 23 cents/kWh.These legislation and platforms provide solid basis for implementing the P2P energy sharing technology in the future.
Besides these legislations and hardware, existing studies have developed dedicated controls for coordinating the operation of energy systems to facilitate energy sharing in a community.For instance, in [14] a top-down control method is proposed for maximizing the energy sharing in a community via optimizing the operation of distributed battery storage systems.The proposed control first considers the whole building community and the systems as one virtual building and optimizes its performances using the genetic algorithm.Then, a nonlinear programming algorithm is used to coordinate the operation of individual energy systems.Nik et al. [15] proposed using the collective intelligence for demand side management in urban areas considering the different climate scenarios.The collective intelligence allows a simple communication strategy among buildings using forward and backward signals, so as to enhance the demand flexibility and climate resilience.In this study [16], a coordinated control of energy storage systems and electric vehicles is proposed, which is able to not only maximize the energy sharing in a building community but also make use of the flexible energy storage capacity of electric vehicles.The proposed control could coordinate the charging and discharging of distributed batteries and electric vehicles, to optimize the community aggregated-level performances.With the same target of enhancing community-level performance, Fan et al. [17] also developed a collaborative control optimization method of grid-connected building community.Their proposed control conducts sequential optimization of single energy storage's charging/discharging rates based on the previous optimized system performances.Such collaborative control could achieve up to 87.5 % cost saving contributed by energy sharing in the community.These coordinated controls of energy systems in a building community can effectively facilitate the energy sharing and thus improve performances.However, the upper limit of the performance improvements is decided by the energy sharing potentials in a community.If the energysharing building community and energy systems are not well designed (e.g., all the buildings and energy systems are identical), the energy sharing potentials will be very limited.The abovementioned advanced controls will not work effectively.
Regarding the design of the energy sharing community, Jafari-Marandi et al. [18] proposed a homogeneity index based on a selforganizing map clustering algorithm to quantify the diversity of load/ supply profiles in a building community.They also developed a bi-level distributed decision model for investigating the energy sharing potentials.Using the homogeneity index and the bi-level distributed decision model, they analysed the impacts of homogeneity on the energy sharing potentials of a community.Their study results pointed out that the diversity of the power demand and local renewable power production has large impacts on the energy sharing potentials in a community.Considering such diversity, a clustering-based grouping method is proposed for identifying the best combinations of buildings in a neighborhood to form energy-sharing communities with the maximized energy sharing potentials [19].The proposed grouping method first applies a clustering algorithm to identify representative power mismatch (i.e., deviation between the power demand and renewable power supply) profiles of each building.Then, different combination alternatives are produced.Finally, the energy sharing potentials of each combination are evaluated and the optimal design is selected from the comparison.Notably, Duvignau et al. [20] proposed a realistic and comprehensive cost-optimization model for energy sharing communities, which uses limited forecast as inputs for the optimization.They defined an indicator 'weight' to assess the economic benefits from energy sharing.Using such indicator, they investigated different scenarios of cooperation scale, demand level, prosumer/consumer ratio, action preferences, business models, and analyzed the impacts of these factors on the energy sharing performances in a community.Considering the data privacy, they concluded that energy sharing in small groups (2 ~ 5 participants) could achieve almost 96 % of the ideal maximum performance gain.However, in this study, the considered buildings are all residential buildings, and the analysis is only limited to the Swedish weather condition.
The existing studies have pointed out that the design of buildings (e. g., building types, scale of community) and energy systems (e.g., energy system capacity, storage integration, etc) both have large impacts on the energy sharing performances in a community.However, until now, there is still a lack of suitable indicators to quantify the energy sharing potentials.Systematic and quantitative studies of how various factors affect the energy sharing potentials in a building community are also lacking.Some of these factors may have large impacts on the energy sharing potentials in a building community and thus should be carefully selected when designing/planning an energy sharing community.Otherwise, the improvements in the energy and economic performances (e.g., self-sufficiency, peak power demand/supply, and electrical bills) at the building community level can be restricted due to the limited energy sharing potentials.This will make the implementation of energy sharing in a building community (i.e., installing microgrids and power P. Huang et al. flow controllers) not economical.To bridge this knowledge gap, this study conducts a comprehensive analysis of various factors' impacts on the energy sharing potentials in a building community.Parametric studies are conducted to quantitatively identify how each factor will affect the energy sharing performances.It will reveal the relation between the building community parameters and energy sharing potentials, which will help the design of energy sharing communities to enhance the energy sharing performances.The major contributions of this study are summarized as follows.
• Two parameters, namely the total amount of energy sharing and energy sharing ratio (ESR), are proposed to quantify the energy sharing performances in a building community.• The impacts of climate/location, community scale, RES capacity, PV capacity ratio and centralized battery storage capacity on the community energy sharing performances are systematically investigated using the real electricity demand data in three locations.• The effectiveness of the two proposed parameters in quantifying the community energy sharing performances are verified.• A design optimization method is developed to search the best combination of influential factors to maximize energy sharing potentials inside a community.This is one of the first papers optimizing the energy system design from the perspective of energy sharing.
This paper is organized as follows: Section 2 presents the methodology, including the principle of energy sharing, configuration of parametric studies, as well as the performance indicators for assessing the energy sharing performances.Section 3 shows the modelling of the buildings and energy systems.Case studies and results analysis are provided in Section 4. A discussion regarding the design optimization of energy systems is presented in Section 5, and the conclusions are given in Section 6.

Methodology
This section first introduces the principles of energy sharing.Then, the detailed methodology for investigating various factors' impacts on the community energy-sharing potentials is presented.After that, the indicators for quantifying energy sharing potentials are explained.

Principle of energy sharing 2.1.1. How energy sharing works
Fig. 1 gives an example of how P2P power sharing works [19].In principle, the energy sharing performance of a building community is determined by the diversity of individual buildings' power demand/ supply profiles: the larger the diversity, the larger the energy sharing potentials [18,19].For instance, in Case 1 in Fig. 1, the two buildings have surplus renewable power production (i.e., power demand is smaller than supply) and insufficient renewable power production (i.e., power demand is larger than the supply) in the same period.Thus, the power sharing potentials are very limited.On the contrary, in Case 2, the two buildings have surplus renewable power production and insufficient renewable power production in different periods.The surplus renewables from one building can be used to meet the large power demand in another building, and thus the energy sharing potentials are much larger.

How various factors affect the energy sharing performance
This study considers five factors which have large impacts on the energy sharing performances, namely climate/location, community scale, RES capacity, PV capacity ratio, and battery storage capacity.How these factors may potentially affect the energy sharing performances is briefly introduced below.Until now, a quantitative study of their potential impacts is still lacking.Moreover, the impacts of some factors are correlated.The impacts of one factor could be very different when another factor is charging.This study will bridge the knowledge gaps by quantitively investigating the combined impacts of various factors on the community energy sharing potentials.
• Impacts of climate/location: The climate/location, such as temperature, solar radiation and wind resources, will have large impacts on the renewable power production (such as the PV and wind power production) and the electricity demands.In cold-climate/highlatitude areas (such as Sweden), the heating load can be covered by district heating systems and thus the electricity demands only include the electric appliances, such as lighting, cooking, dish washer, etc.While in hot tropical areas, electricity is sometimes used for powering the air-conditioning system to regulate the indoor environment.
• Impacts of community scale: With the increase of a community scale (i.e., the number of buildings in a community), the diversity in power demand and power supply profiles tend to be larger.Such increased diversity could contribute to enhanced energy sharing potentials in the community.But on the other hand, the benefits brought by increased energy sharing potentials may decrease when divided for each individual building, as the increase of energy sharing potentials may not be at the same pace as the increase of the community scale.

Fig. 1.
Examples of the P2P energy sharing between two buildings in the same building community.Note in practice, there are usually more than two buildings in a community.
• Impacts of RES capacity ratio: The RES capacity will affect the selfsufficiency of each household, and further the self-sufficiency of each household will affect the energy sharing performances.With the increase of RES capacity, each household will gradually change from self-insufficient to self-sufficient, and thus the energy sharing potentials might be affected.This study uses the capacity ratio as a changing variable to study its impacts on the energy sharing performances.When the capacity ratio is 1 for a household, it represents that its annual renewable power production equals the annual electricity demand.Likewise, a RES capacity ratio of 0.5 represents that the household's annual renewable production reaches only half of the annual electricity demand.

• Impacts of PV capacity ratio:
The type of renewable energy systems and the composition of renewable power will affect the power balance of each household.For instance, in high latitude region like Sweden, PV power is largely dependent on the season.The households could have more renewable power production in summer periods while less in winter periods.As a result, there can be large power imbalance in both seasons, which could affect the energy sharing potentials.The PV capacity ratio is calculated as the amount of annual PV power production to the total RES annual power production.When PV capacity ratio equals 0.5, it represents that PV produces half of the total renewable power.

• Impacts of centralized battery storage capacity:
The centralized energy storage system can make direct contributions to increasing the energy sharing of a community, i.e., storage sharing.The surplus PV power can be stored in the battery, and when there is a lack of PV power production, the battery can be used to meet the large power demand.

Methodology for investigating various factors' impacts on energy sharing performances and design optimization of the energy systems for maximized energy sharing performances
This study conducts parametric studies to investigate the impacts of various factors (as described in Section 2.1.2) on the community energy sharing performances.A design optimization method of the energy systems, which can maximize the energy sharing potentials, is also developed to explore how the energy systems should be designed in of an energy-sharing community.The processes for the parametric studies and energy system design optimization are illustrated in Fig. 2. The whole methodology consists of four steps.
In Step 1, the scenarios for parametric studies are defined.Since the Step 1: Definition of scenarios Step 2: Data collection and construction of models Step 4: Design optimization of energy systems based on findings from the parametric study  different parameters can affect another in the community energy sharing performances, this study will consider the combined impacts of various parameters.In total, three sets of combined impacts will be investigated (as highlighted in Fig. 2): the first set will consider the combined impacts of climate/location, RES capacity and community scale; the second set will consider the combined impacts of climate/location, RES capacity and PV capacity ratio; and the third set will consider the combined impacts of climate/location, RES capacity and battery storage capacity.Table 1 summarizes the detailed configurations of each set of analysis.Three climates (locations), namely Uppsala in Sweden, Prince George in Canada and Munich in Germany, are selected.The three locations are selected with two considerations: latitude and data availability.The latitude will on the one hand affect the electricity demand (e.g., caused by the different occupant behaviors in terms of lighting and cooking) and on the other hand the renewable power production (e.g., the PV power production profiles).This study selected the three locations with a latitude difference of around 6 • spreading in three countries, so that the impacts of latitude can be investigated.The other concern is that the data availability, as the high-quality real electricity demand data are available only in these locations.
In Step 2, data collection and modeling are conducted.To make the analysis close to practice as much as possible, this study uses hourly electricity demand profiles collected from real households through a full year.For more information about the hourly electricity demand profiles, please refer to Section 3.1.The power production of RES (with different capacity and PV capacity ratio) in each scenario is modeled in TRNSYS.The detailed modeling is presented in Section 3.2.The battery storage operation is modeled in Matlab, and the detailed modeling is introduced in Section 3.3.The electricity demand data is collected from real buildings.Corresponding to the defined community scale, a specific number of electricity demand profiles will be selected and used to size the individual renewable energy systems of each household.The defined RES capacity ratio, the PV capacity ratio, and the electricity demand of each selected household will be used as inputs for deciding the renewable energy system capacity (i.e., including both the PV system capacity and wind turbine system capacity) of each household.Then, the renewable power production of each household will be evaluated in TRNSYS.After obtaining the electricity demand, renewable power production of the individual households in the community, the information together with the aggregated battery capacity is imported into a performance evaluation engine for assessing the detailed energy sharing performances of the community, as well as the performance improvements contributed by energy sharing.
In Step 3, the energy sharing performances in each scenario are simulated based on the collected data and constructed model in Step 2. Two performance indicators, namely total energy sharing amount and ESR, will be assessed.Meanwhile, the community performance improvements contributed by energy sharing are evaluated from both the energy and economic perspectives.Conclusions and generic findings will be derived from the results obtained in Step 3.
In Step 4, the energy systems are optimized in each location with the purpose of maximizing the ESR.As the energy storage system capacity is influential in affecting the ESR, this study takes it as a fixed input and changes it manually in each iteration.The study results will reveal how energy systems should be designed in an energy-sharing community to optimize the energy sharing performances.Considering the ability to converge and the computational speed, genetic algorithm (GA) is then used to search for the optimal RES capacity ratio and PV capacity ratio for each community.The inputs for GA include the annual power demand and renewable power production of individual households in the community, and shared battery storage (from the iterator).The outputs are the optimized RES capacity ratio, PV capacity ratio, and the maximum ESR for the community under the specific battery storage capacity.The optimization is conducted in Matlab.

Performance indicators 2.3.1. Energy sharing performance indicators
The energy sharing potentials are determined by the diversity of the individual power demand and renewable power production profiles.Until now, there are only limited studies on developing indicators to quantify their performances.A homogeneity index was developed in [18] to evaluate the heterogeneity of different building clusters configurations.An indicator 'weight' was defined in [20] to assess how good a pair of buildings is, and it is evaluated as the cooperative gain achieved when the pair cooperates as a P2P energy sharing community.Both the indicators are quantifying the energy sharing potentials indirectly, either by evaluating the diversity or by evaluating the economic gains.Indictors which can more directly quantify the energy sharing potentials are still lacking.Therefore, this study proposes two indictors, total amount of energy sharing (which assesses the possible maximum amount of energy sharing within a community) and the energy sharing ratio (which shows the percentage of energy sharing compared to the energy demand or supply), to directly quantify the energy sharing potentials in a community.These two indicators are more straightforward compared to the existing indicators.

Total energy sharing.
The total energy sharing represents the amount of energy sharing that a building community can have (in one year).In each hour, each building will have three states: with surplus power production, with balanced power, or with large power demand.The buildings with surplus power production can share their surplus power with the buildings with large power demand.Thus, the energy sharing potential in each hour is calculated as the smaller value of the hourly aggregated surplus power in the community and the hourly aggregated large power demand.The calculation of the total amount of energy sharing inside a community is explained step-by-step below.
Step 1: Calculate the hourly power mismatch of every single building.
The power mismatch (P j,i mis (kW)) of the j th building in the i th hour is calculated as the deviation of the power demand (P j,i d (kW)) and PV power production ((P j,i s (kW))) in this hour: In Eq. ( 1), N is the number of buildings.The power mismatch is calculated for all the buildings inside the community.A positive power mismatch value indicates the state that a building has large demands (i.e., insufficient PV power production).While a negative power mismatch value represents the state that a building has surplus PV power production.When the power mismatch value is zero, the building is selfbalanced and does not need to join in the P2P energy sharing.
Step 2: Calculate the aggregated power insufficiency in a community.
The aggregated power insufficiency (P i insuff ,tot (kW)) in the i th hour is calculated by aggregating the power insufficiency of each single building (if the PV power production is not sufficient).Mathematically, it is calculated by aggregating the power mismatches with positive values, as depicted by.
Step 3: Calculated the aggregated surplus PV power production in a community.
The aggregated surplus PV power production (P i surplus,tot (kW)) in the i th hour is calculated by aggregating the surplus PV power production of each single building.Mathematically, it is calculated by aggregating the power mismatches with negative values, as depicted by.
Step 4: Compare and calculated the hourly energy sharing in a community.
The maximum power sharing potential (P i share (kW)) in the i th hour in the community is calculated by comparing the hourly aggregated power insufficiency (as calculated by Eq. ( 2)) and hourly aggregated surplus PV power production (as calculated by Eq. ( 3)).When the aggregated power insufficiency is smaller than the aggregated surplus PV power production, part of the aggregated surplus power can be shared to meet the aggregated power insufficiency, while the remaining part will be balanced by external resources, such as the power grid.On the country, when the aggregated power insufficiency is larger than the aggregated surplus PV power production, all the surplus power will be shared within the community.Mathematically, the maximum power sharing potential is calculated as the small one of the hourly aggregated power insufficiency and hourly aggregated surplus PV power production, as depicted by.
Step 5: Calculate the total energy sharing of a community.Finally, the annual total energy sharing (E share (kW⋅h)) of a community is calculated by aggregating the maximum power sharing potentials in each hour (P i share ) during a full year period (i.e., 8760 h), as depicted by.
For each community, the same processes are implemented to get its full energy sharing potentials.

Energy sharing ratio (ESR).
The total energy sharing can be used for evaluating the full energy sharing potential in a community, but it is not so suitable for comparing the energy sharing performances of different communities.For instance, the full energy sharing potential in a small building community could be much less compared to a community with twice the number of buildings.In order to enable the comparison of the energy sharing performances between different communities, the ESR indicator is proposed and used for analysis.It is calculated as the ratio of the total amount of energy sharing and the total amount of peak power (i.e., the larger one of the power demand or the power supply) in the community.By normalizing the energy sharing potential with total peak power (either demand or supply), this indicator can be used for energy sharing performance comparison in different communities.The ESR r share (dimensionless) of a community is calculated as below, The first indicator quantifies the total amount of energy sharing within a building community, while the second indicator quantifies the percentage of energy sharing as compared to the total energy demand or energy production.The first indicator can be used for evaluating the energy sharing potentials for a specific community.The second indicator, which is dimensionless, can be used for comparing the energy sharing performances in different communities with different community scale and system sizes.

Indicators for evaluating performance improvements contributed by energy sharing
Energy sharing among neighboring households can make substantial contributions to the performance improvements in different perspectives.This study selected three indicators, namely self-sufficiency, electricity costs, and energy exchanges with the power grid, to evaluate the performance improvements contributed by energy sharing.These indicators are calculated for both the case with energy sharing and the one without energy sharing, and their deviations are considered as the performance improvements.

Self-sufficiency.
A large amount of energy sharing in a building community does not imply that the community also has high ratio of utilizing the locally produced renewable power.Thus, this study considers the self-sufficiency (SS) as an indicator for evaluating the performance of a building community while implementing energy sharing.The SS (in percentage) represents the annual average of the rate at which the electricity used by the building is provided by the local renewable energy systems.It is defined in Eq. (7).
where E d,res (kW⋅h) is the aggregated electricity demand that is supplied by the PV system during one-year period, and it is equal to E res,onsite (kW⋅h).E d,grid (kW⋅h) is the aggregated electricity demand that is supplied by the power grid.The sum of these two terms equals E d,whole (kW⋅h) (i.e., the total electricity demand) of the community regardless of which source is providing it, a larger SS indicates a better performance as it shows that a community is less dependent on the grid.Note this study focuses on the building community-level performances, the SS of the whole community, instead of individual buildings, is calculated.
The total electricity demand of the community (E d,whole (kW⋅h)) is calculated by aggregating the power demand of all the buildings in the community, as expressed by the equation below, The renewable power used on-site is calculated by aggregating hourly power demand of the community (P c,i d,onside (kW)) which is covered by the renewable power generated on-site, as shown by the equation below, P c,i d,onside (kW) is the aggregated power demand of the community, as In Eq. ( 11), χ i (kr/(kW⋅h)) is the electricity price in the i th time slot.χ buy (kr/(kW⋅h)) is the price of purchasing electricity from the power grid, and χ sell (kr/(kW⋅h)) is the feed-in-tariff.For simplicity and the purpose of comparison, in this study the purchasing price of electricity is set to be 1.6 kr/(kW⋅h) and the feed-in-tariff is set to be 0.2 kr/(kW⋅h) for all the different locations.P cm,i ex (kW⋅h) is the community hourly power exchanges with the grid.A positive value of power exchange indicates importing power from the grid, while a negative represents exporting power to the grid.The hourly power exchange with the grid is calculated as the aggregation of the community power mismatches (P cm,i mis (kW)) and the centralized battery charging/discharging rates (u i (kW)): The calculation of centralized battery charging/discharging rates (u i (kW)) is further introduced in Section 3.3.The community power mismatches (P cm,i mis (kW)) is calculated as the aggregation of the individual households' power mismatches: where P j,i mis (kW) is the hourly power mismatch of the j th building in the community, which is calculated by Eq. (1).

Energy exchanges with the grid.
This study considers the annual total amount of energy exchanges with the grid as an indicator of the grid interaction.It is calculated as the aggregation of the hourly energy exchanges with the grid, as depicted by.
A larger value of the annual total energy exchange indicates more dependence on the power grid, as the community requires the grid for balancing the surplus renewable power production or large power demand.

Buildings and energy system modelling
This section presents the modelling of buildings and energy systems.Based on the data availability, this study considers three different locations, Uppsala in Sweden, Prince George in Canada, and Munich in Germany.

Building modelling
This study uses real data from the buildings for the analysis.The sources of electricity demand data are summarized in Table 2. Some of the collected data are spread over multiple years.Preliminary analysis found that the power demand profiles do not show any correlation with season (there are separate energy sources for providing heating/cooling).Thus, this study assumed that the electricity demand profiles is mostly affected by the occupants' behavior and the occupants' behaviour do not change significantly in different years and different locations in the same country.For each household, the hourly power demand data over a full year period (8760 h) are selected.The households with missing data are removed from the database.In total, there are 35 residential household power demand profiles collected for Sweden, 25 profiles collected for Canada, and 74 profiles collected for Germany.
Note that the collected data may cover households across a large area in a country.Since the demand profiles do not show obvious seasonal variation, this study allocates a specific location for the datasets in each country and assumes all the households are located in this city.Considering that the latitudes will have large impacts on the PV power production, this study selected three cities at an interval of around 6 • latitude difference.The detailed power demand patterns can be found in Section 4.1.

Renewable energy system modelling
The power generation from the PV panel P PV (kW) is calculated by [24,25].(15) where γ (dimensionless) is the transmittance-absorptance product of the PV cover for solar radiation at a normal incidence angle, ranging from 0 to 1; I AM (dimensionless) is the combined incidence angle modifier for the PV cover material, ranging from 0 to 1; I T (W/m 2 ) is the total amount of solar radiation incident on the PV collect surface; η is the overall efficiency of the PV array; CAP PV (m 2 ) is the PV surface area.
The power generated from a wind turbine P WT (kW) is described by the equation below [24,25].
In Eq. ( 16), C P (dimensionless) is power efficiency, which is a function of the axial induction factor; ρ air (kg/m 3 ) is air density; A R (m 2 ) is the rotor area; U 0 (m/s) is the wind velocity in the free stream; CAP WT (kW) is the capacity of wind turbine.

Electrical battery modelling
This study considers a centralized energy storage system for a community in the scenarios when energy storage systems are integrated.A simplified electrical battery model is used.The electricity stored in the battery is calculated using a simplified model.It is estimated as the aggregated hourly charging rates and discharging rates [26], The electricity stored in the battery (E bat,i (kW•h)) in the i th hour is calculated by Eqn.(17).τ is the charging duration (1 h), and u i (kW) is the charging rate in the i th hour.The hourly charging/discharging rate of the centralized energy storage system is related to the aggregated power mismatch of the whole community (P cm,i mis (kW), as calculated by Eqn. ( 13)) in that hour.In each hour, the charging/discharging rate of the battery should meet the following constraints.• Discharging state: When the community-level power mismatch (P cm,i mis (kW)) is larger than zero, the building community has insufficient PV power generation, and thus the battery is in discharging state.The battery discharging rates u i (kW) should be smaller than both the amount of electricity stored in the battery and the battery charging limits, as shown by In Eq. ( 18), u limit (kWh) is the maximum charging/discharging rates of the battery in each hour.ϕ i (kW⋅h) is the amount of electricity stored in the battery in the i th hour, which is calculated by.
• Charging state: When the community-level power mismatch (P cm,i mis (kW)) is smaller than zero, the building community has surplus PV power generation, and thus the battery is in charging state.The battery charging rates u i (kW) should be smaller than both the remaining storage capacity of the battery and the battery charging limits, as shown by CAP(kW⋅h) is the capacity of the centralized energy storage system.

Case studies and results analysis
This section first presents the power demand profiles the renewable power production profiles, which will both be used as inputs in the parametric analysis.Then the combined impacts of various factors on the energy sharing and the associated performance improvements are introduced.

Power demand and renewable power production
Fig. 3 shows the hourly averaged electricity demand of the collected residential households in the three locations.Each color of dots represents one household.The black curve shows the average hourly power demand of all the buildings in one location.As can be seen, the electricity demand profiles have very similar trends in the three locations, with small electricity demand at night, moderate electricity demand during daytime, and large demand in the evening.In Uppsala, Sweden, the average hourly power demand is around 2 kW.In Prince George, Canada, the hourly average power demand lies in the range of 0.5 ~ 1.3 kW, while in Munich, Germany, the average hourly demand lies in the range of 0.3 ~ 0.8 kW.
The PV power production and wind power production profiles in the three locations are also depicted in the second row of Fig. 3.The yellow filled regions are the same as the black curves in the first row.Note that since in the parametric studies the values of RES capacity are changing, here only the shape of the power production profile is considered.These profiles are normalized to be equivalent to the demand profile (i.e., the aggregated electricity production equals the aggregated electricity demand).The purple solid curve shows the average PV power production profile in a summer month (i.e., July), and the red solid curve shows the average PV power production profile in a winter month (i.e., January).As can be seen, there is large deviation between the PV power production curves of two seasons in all the three locations.But due to the high latitude, the difference is the largest in Sweden (i.e., it produces power during 5:00 ~ 20:00 in summer and during 9:00 ~ 16:00 in winter).The Dashed blue curves represent the wind power production profiles.There is a better match between average daily wind power production profile and the electricity demand compared to PV power production profile.But the match of daily average values does not represent a good match in each hour during the whole year period.

Location: Sweden, Uppsala
Location: Canada, Prince george Location: Germany, Munich Average hourly power demand Fig. 3. Hourly averaged power demand (for a full year) of the households, hourly PV power production (for both summer and winter months) and hourly wind power production (for a full year) in three different locations.

Impacts of RES capacity ratio and community scale
This section presents the impacts of RES capacity ratio and community scale on the community energy sharing performances.Fig. 4 shows the impacts of these factors on the community total energy sharing and ESR performances.
Impacts on the total amount of energy sharing.

RES capacity ratio:
With the increase of the RES capacity ratio, the total amount of energy sharing will first increase quickly and then decrease gradually.This is because when the RES capacity is small, most of the households do not have surplus renewable power to share with others.The amount of surplus power will gradually increase with the RES capacity, since some households start to have surplus renewable power which can be shared.But after a peak point, most of the households become self-sufficient and thus do not need to take surplus renewable power production from their neighboring buildings.Thus, the total amount of energy sharing shows a decreasing trend after a peak point.This is a general finding which applies to different Community scale: The total amount of energy sharing will increase with the increase of household numbers, irrespective of the RES capacity ratio.This is because with more households involved, the diversity of individual power mismatches will increase.This will benefit the energy sharing.
Impacts on the ESR.RES capacity ratio: Similar to the impacts on the total amount of energy sharing, with the increase of the RES capacity ratio, the ESR will first increase quickly and then decrease slightly.This is because the households will turn into self-sufficient from self-insufficient with the increase of RES capacity.
Community scale: In all the three places, with the increase of community scale, the ESR will first increase.Then, after reaching a peak value, it will become stable without much large changes.This is because the total amount of energy sharing (as the numerator in Eq. ( 6)) and the total electricity demand (as the denominator in Eq. ( 6)) are both increasing with the number of households in a community.As a result, the percentage of total shared energy as compared to the total power demands (i.e., ESR) does not change dramatically.It indicates that the ESR of a community is not so dependent on the community scale if the community is larger than a threshold (around 3 ~ 5 participants in this study).This is also consistent with the conclusions in [20].They concluded that energy sharing in small groups (2 ~ 5 participants) could achieve almost 96 % of the ideal maximum performance gain.Fig. 5 displays the changes in performance (i.e., self-sufficiency, electricity costs, and energy exchanges with the grid) under varying factors in the three locations.Different colors represent different RES capacity ratio, and the marker shows the number of households which can lead to the maximum ESR.Again, the ESR is more affected by the RES capacity ratio, instead of the number of households (i.e., community scale).In all the three locations, the maximum ESR can be obtained with a RES capacity ratio in the range of 0.4 ~ 0.8.As can be seen, the changes of self-sufficiency improvement are consistent with the trend of ESR variations.They both reach the peak at the same number of households.This is because as the number of households increase, on the one hand, the total amount of energy sharing increases.In other words, the total amount of self-utilized renewable energy increases.On the other hand, the total electricity demand increases.Their combine impacts lead to a similar trend as the ESR variation.While regarding the impacts of RES capacity, with its increase, the self-sufficiency improvement will first increase, and then decreases.The largest selfconsumption curves are when the RES capacity ratios are 0.8 or 1.6.The electricity costs reduction and grid interactions reduction both increase dramatically with the number of households.This is because they are directly related to the total amount of energy sharing changes: with more energy shared within the community, the amount of electricity trading with the grid will decrease.The same goes for the amount of energy exchanges with the grid.In fact, their changing trends are very similar to the changes of the total amount of energy sharing (in Fig. 4).

Impacts of RES capacity ratio and PV capacity ratio
This section presents the impacts of RES capacity ratio and PV capacity ratio on the community energy sharing performances.Fig. 6 shows the combined impacts of these factors on the community's total energy sharing and ESR performances.

Impacts on the total amount of energy sharing. RES capacity ratio:
With the increase of the RES capacity ratio, the total amount of energy sharing will first increase quickly and then becomes stable (and changes slightly depending on the PV capacity ratio).The reason is the same as the analysis in Section 4.2.This is because when the RES capacity increases, most of the households will change from self-insufficient to self-sufficient.And thus, the amount of energy sharing in the community will first increase quickly, and then becomes relatively stable.
PV capacity ratio: At different RES capacity ratio, the impacts of PV capacity ratio on the total amount of energy sharing are different.In most cases, it is not the best case to have only PV system (i.e., PV capacity ratio equals 1) or only wind turbine system (i.e., PV capacity ratio equals 0).A combination of them can enhance the total energy sharing.This is because the combination of them can usually enhance the diversity of power supply profiles, which could lead to enhanced needs of surplus power inside the community.
Impacts on the ESR.RES capacity ratio: Similarly, with the increase of the RES capacity ratio, the ESR will first increase and then decrease.The decreasing trend is more obvious compared to the total amount of energy sharing.This is because the denominator for calculating ESR is the larger one of the hourly power demand and hourly RES power supply.When RES capacity ratio is very large and still increasing, on the one hand, the total amount of energy sharing will slightly decrease; on the other hand, the total amount of renewable power production will increase.This leads to a reduced ESR when there is a large RES capacity ratio.
PV capacity ratio: In all the three places, when the RES capacity ratio is fixed, an optimal PV capacity ratio exists, which could maximize the ESR.The optimal PV capacity ratio is affected by multiple factors, such as the location, the RES capacity ratio, and the battery capacity, etc.There is no general answer regarding which PV capacity ratio is the best in different locations.The optimal PV capacity ratio needs to be decided by optimization method (i.e., Step 4 in Fig. 2).Still in most cases, a combined use of PV and wind turbine system can lead to a better energy sharing performance, as the diversity in the power production can be enhanced.locations.In all the three locations, the highest ESR is achieved with a RES capacity ratio range of 0.4 ~ 1.6.Under the same number of households, battery storage capacity, RES capacity ratio and PV capacity ratio, the ESR is the highest in Munich, Germany, and the lowest in Uppsala, Sweden.This can be explained by Fig. 8.In high latitude district such as Sweden, in summer due to the large solar PV power production during the daytime, most of the buildings in the community can be self-sufficient.In other words, most of them do not need to use surplus power from the other buildings (see Region-B in Fig. 8).This is the opposite in winter when most of the buildings are self-insufficient, but it leads to the similar results, see Region-A in Fig. 8.As a result, most of them do not have surplus power to share with others.While in the other two locations, there are more periods with energy sharing.This leads to a larger amount of energy sharing compared to Sweden.When the RES capacity ratio is larger than 3 and PV capacity ratio is in the range of 0.1 ~ 0.9, the ESR becomes stable.This is contributed by the centralized battery storage system.With a capacity of 50 kWh, it can storage and use more surplus renewable energy either from the PV power or wind power.Under the fixed RES capacity ratio, the changes of self-sufficiency improvement, electricity costs reduction and grid interactions reduction are approximately consistent with the trend of ESR variations.This is because a larger ESR is correlated with more amount of energy sharing, which will lead to more performance improvements.When the RES capacity ratio increases, more performance improvements will be achieved.But after RES capacity ratio exceeds 3, the improvements in the performances become marginal.In other words, a large increase in RES will lead to only a small enhancement of the performance.This is because the increase of total amount of energy sharing becomes very small at a large RES (see Fig. 6), and thus the benefits from energy sharing becomes limited.

Impacts of RES capacity ratio and storage capacity
This section presents the impacts of RES capacity ratio and battery storage capacity on the community energy sharing performances.Fig. 9 shows the impacts of these factors on the community total energy sharing and ESR performances.
Impacts on the total amount of energy sharing.

RES capacity ratio:
Again, with the increase of the RES capacity ratio, the total amount of energy sharing will first increase quickly and then becomes stable (and changes slightly depending on the PV capacity ratio).The reasons have been explained in Section 4.2 and 4.3.
Energy storage capacity: The energy storage capacity has a positive impact on the increase of the total amount of energy sharing.This is because with a larger energy storage capacity, more surplus renewable power can be stored and used within the community.The electricity stored in the energy storage system is added up directly to the total amount of energy sharing.This is another general finding which applies to different locations.
Impacts on the ESR.RES capacity ratio: Similar to the analysis in Sections 4.2 and 4.3, with the increase of the RES capacity ratio, the ESR will first increase and then decrease.The reasons have been explained in Section 4.2 and 4.3.
Energy storage capacity: In all the three places, when the RES capacity ratio is fixed, the ESR will increase with the energy storage capacity.This is because the total amount of energy sharing will increase.As calculated by Eq. ( 6), the numerator increases while the denominator is constant.This is consistent with the findings from [18], in which they concluded that the household level battery is very cost effective for building clusters with different heterogeneity settings in terms of cost savings contributed by energy sharing.Fig. 10 displays the changes of performance (i.e., self-sufficiency, electricity costs, and energy exchanges with the grid) improvements under varying RES capacity ratios and battery storage capacity in the three locations.In all the three locations, the highest ESR is achieved with a RES capacity ratio range of around 0.8.When RES capacity ratio is fixed, the ESR increases with the battery storage capacity.Again, after RES capacity ratio becomes larger than 3, the improvements in the performances become marginal.This is because the increase of total amount of energy sharing becomes very small at a large RES (see Fig. 9), and thus the benefits from energy sharing becomes limited.While a larger battery storage capacity will always lead to more performance improvements.But the enhancement will also become marginal after the battery capacity exceeds a threshold (e.g., around 500 kWh in Uppsala, Sweden, around 250 kWh in Prince George, Canada and around 100 kWh in Munich, Germany).

Discussions
The study results in Section 4 have proven that (i) the energy sharing performances are mostly affected by three factors: RES capacity, PV capacity ratio, and centralized energy storage system capacity; and (ii) in most cases, the maximized ESR can contribute to the maximized increase of self-consumption inside the community.And once the community scale is fixed, the maximized ESR also leads to the maximized reduction in the electricity costs and energy exchanges with the grid.Considering these two findings, this section thus explores the optimization of the three influential factors to maximize the ESR inside a community.25 households have been considered in each location for the analysis.In the GA setting, the population number is set to be 4000, the generation is set as 100, and the migration rate is set to be 0.35.Fig. 11 shows the optimization results of the RES capacity ratio, PV capacity ratio, and maximal ESR under different battery storage capacities.Compared with the ESR in Fig. 10, optimized design of RES capacity ratio and PV capacity ratio can improve the ESR value significantly under the same battery storage capacity (see the ESR under different RES capacity ratios).As can be seen, as the electricity storage capacity increases, the achievable maximum ESR increases as well.When the storage capacity increases from 0 to 1500 kWh, the optimal ESR increases from 2.7 % to 30 % in Uppsala, Sweden, from 4.2 % to 45.3 % in Prince George, Canada and from 4.2 % to 45.4 % in in Munich, Germany.With the increase in battery storage capacity, the optimal RES capacity increases slightly from 0.4 to 0.8 in Uppsala, Sweden, from 0.5 to 0.9 in Prince George, Canada, and 0.5 to 1.1 in Munich, Germany, respectively.While the optimal PV capacity ratio first increases to 1 and then gradually decreases in all three locations.In Sweden, when a large storage capacity is used, the preferred renewable energy system is wind turbine alone.It can also be noted that the ESR is usually smaller in high latitude districts, such as Sweden.This is because of (i) the sufficient solar radiation in summer but low radiation in winter (which leads to most buildings to be either simultaneously self-sufficient or simultaneously self-insufficient) and (ii) a better match between wind power production and the residential power demand (see the average daily load profiles in Fig. 3).
The design optimization of the energy systems also indicates that in order to achieve the best performances for energy-sharing communities, the design of distributed energy systems should be considered as a whole.By coordinating the design of individual systems, the benefits from energy sharing can be maximized.

Conclusions
This study has proposed two performance indicators to quantify the energy sharing performances in energy-sharing building communities.Then, the impacts of climate, community scale, RES capacity ratio, PV capacity ratio, and energy storage system capacity on the energy sharing performances are systematically investigated via parametric studies using real electricity demand data.The associated performance improvements contributed by energy sharing, namely self-consumption, electricity costs, and energy exchanges with the grid, have also been analysed.Based on the findings, a design optimization method has been proposed using the non-linear programming to find the best combination of the influential factors, which can maximize the ESR inside a community.The major findings are summarized as follows: • The energy sharing performances are mostly affected by three factors: RES capacity, PV capacity ratio, and centralized energy storage system capacity.• Regarding the impacts on the total amount of energy sharing, a large community scale, RES capacity or storage capacity will generally lead to its increase.While the PV capacity ratio has different impacts when the other factors are varying.• To maximize the ESR, RES capacity ratio can neither be too large or too small.This is because the households will turn into self-sufficient from self-insufficient with the increase of RES capacity.After a peak point, most of the households become self-sufficient and thus do not need to take surplus renewable power production from their neighboring buildings.The recommended range is from 0.4 to 1.1 depending on the location, and storage system capacity.While storage capacity has a positive impact: the larger the storage capacity, the larger the ESR.The optimized PV capacity ratio is location dependent.• The maximized ESR can contribute to the maximized increase of selfconsumption inside the community.And once the community scale is fixed, the maximized ESR also leads to the maximized reduction in the electricity costs and energy exchanges with the grid.This also proves that the ESR is a useful indictor for assessing the energy sharing performances in a community.• The maximum ESR is usually smaller in high latitude districts such as Sweden.This is partly because of the sufficient solar radiation in summer but low radiation in winter, which leads to most buildings to be self-sufficient or self-insufficient simultaneously.
Considering the data availability, this study only investigated the energy sharing performances in a residential community.Existing studies have also shown that the building types also have large impacts on energy sharing performance.Future work will consider more types of buildings.With the electrification of transportation, an increasing number of electric vehicles are used nowadays.The charging load of electric vehicles could also affect the community energy sharing performances, as the electric vehicles can be charged using the surplus renewables within the community.Future work will also look into such impacts.Note the electricity demand data selected in the three locations does not include the electricity use for any heating or cooling purpose.In the cases where the electricity is also used for meeting the heating or cooling needs, the impacts of some factors could be different, as the electricity demand profiles will be changed by the utilization of airconditioning system or heat pumps.Future work will investigate the impacts of including heating and cooling facilities on the community energy-sharing performances.This study analysed the community energy sharing performances from the technical perspective but did not consider the investment of the distributed energy system and energy storage.Future studies will conduct more comprehensive studies.

Declaration of Competing Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
-Peer energy sharing Energy sharing ratio (ESR) Energy system design optimization A B S T R A C T

Fig. 2 .
Fig. 2. Flowchart of parametric studies for investigating the impacts of various factors on the energy sharing performances and the process of design optimization of energy systems to maximize the energy sharing potentials.

Fig. 4 .
Fig. 4. Impacts of the RES capacity ratio and number of households on the total amount of energy sharing and the energy sharing ratio in the three locations.(PV capacity ratio = 0.5, Battery capacity = 0).

Fig. 7 Fig. 5 .
Fig. 5. Impacts of the RES capacity ratio and number of households on the ESR and energy sharing performances in the three locations.(The diamond marks show points with the largest ESR.PV capacity ratio = 0.5, Battery capacity = 0).

Fig. 6 .
Fig. 6.Impacts of the climate, RES capacity ratio and PV capacity ratio on the total amount of energy sharing and the ESR in the three locations.(Battery capacity = 50 kWh, Community scale = 25).

Fig. 7 .
Fig. 7. Impacts of the climate, RES capacity ratio and PV capacity ratio on the ESR and energy sharing performances in the three locations.(The diamond marks show points with largest ESR.Battery capacity = 0, Community scale = 25).

Performance Evaluation Engine Three locations/ weather conditions Location
: Sweden, Uppsala Location: Canada, Prince George Location: Germany, Munich RES capacity ratio Community scale Results in Section 4.2 Results in Section 4.3 Results in Section 4.4

Table 1
Configuration of the parametric studies for investigating the impacts of various factors on the community energy sharing potentials.

Table 2
Summary of the data sources for the analysis.