Introduction

This study explores the implementation of an energy storage system within the context of Energy Communities, with the objective of enhancing their resilience while harnessing renewable energy sources, specifically Photovoltaic systems. Furthermore, in light of the essential requirements of the main grid and Distribution System Operators (DSOs), the ability to store energy becomes crucial to mitigate disruptions in grid supply. Therefore, it becomes imperative to analyze these systems to determine their suitability for specific scenarios, whether for building-level integration or within the broader framework of an Energy Community.

Energy Community

Energy Communities (EnC), predominantly reliant on microgrids, play a pivotal role in contemporary electrical power grids. The operation of a microgrid-based EnC presents intricate challenges characterized by uncertainties, intricacies, and the frequent clash of objectives. Additionally, like any other grid, they are susceptible to operational faults. To bolster their resilience, the adaptability of EnCs can offer valuable support to the entire community.

As per the European Commission’s definition, Energy Communities (EnCs) are characterized as collectives that include inhabitants, individuals, and various entities, encompassing social entrepreneurs, public authorities, and community organizations. These groups engage actively in the four pillars of the energy system: generation, trading, distribution, and consumption of sustainable energy [1, 2]. Furthermore, with the progress and increased accessibility of renewable energy, citizens have taken on a notable role in the energy system, often referred to as prosumers. Traditionally, a community is typically composed of individuals who share common traits and can actively engage in energy generation or utilization as consumers. As issues related to renewable energy have gained more prominence and accessibility, citizens are now acknowledged as active participants within the system and are commonly labeled as prosumers. In essence, a community is a social collective with shared interests, comprised of users who can actively engage in either energy consumption or production [3, 4].

EnCs come into existence through the integration of energy conversion, transmission, and consumption at the community level. In the energy context, EnCs can effectively address a range of pertinent concerns, including reduction of peak load during high-demand periods, the equilibrium of energy flow, the implementation of territorial energy planning, the mitigation of environmental impacts and the interconnection of diverse energy sources [5, 6].

Contrarywise, in the event of a fault occurring within the Electrical Power Grid (EPG), there can be a reduction in power or a complete power outage. EnCs offer a solution not only to uphold power supply within the community but also to enhance the overall resilience of the EPG. This can be achieved by leveraging the energy flexibility inherent in each household and throughout the entire community. The concept of energy flexibility revolves around the strategic management of household appliances within the EnC to adjust their operation schedules and thereby balance power distribution, particularly in response to decreased power availability [7].

Within this study, the term Energy Community denotes a network of users interconnected through the Low Voltage (LV) grid, as illustrated in Fig. 1. In an Energy Community, households have the capacity for renewable energy production and control over electrical devices, alongside the option of integrating storage systems. Rather than exclusively utilizing produced energy for personal consumption, users can store and share it within the community, making it accessible as needed. Moreover, by factoring in the energy flexibility of select consumption devices, it becomes feasible to regulate the community’s energy consumption, thus enhancing the resilience of the LV grid in response to changes within the main grid.

Fig. 1
figure 1

Energy community structure

As technology and solutions in the realm of Nearly Zero Energy Buildings (NZEBs) continue to advance, the concept has evolved into the domain of Positive Energy Buildings (PEBs). Therefore, a building is categorized as a PEB if it exports more energy than it imports over a defined period, typically a year [8]. Furthermore, as depicted in Fig. 1, clusters of buildings that actively manage their energy consumption and distribution, striving to achieve a net annual energy surplus while interacting with the larger energy system, are commonly termed as Positive Energy Blocks (PEBlocks) or Positive Energy Districts (PEDs) [9,10,11,12].

Energy Storage Systems

Energy storage systems (ESS) involves the conversion of electrical energy into various forms that can be retained and subsequently reconverted into electrical energy as required. A wide range of storage technologies is available and can be categorized based on several criteria, including the type of storage (mechanical, electromechanical, electrical, chemical, or thermal), duration of storage (short-term or long-term), capital cost, capacity, efficiency, or environmental impact [13]. In this work, these technologies will be classified according to the type of storage, as depicted in Fig. 2, following a comprehensive review of the literature.

Fig. 2
figure 2

Energy storage technologies

The selection of the appropriate storage method hinges on a set of considerations, including factors such as the quantity of energy or power to be stored, the duration of storage (whether short-term or long-term), portability, energy efficiency, and associated costs, among others. For short-term applications, options like flywheels or supercapacitors find utility. Conversely, for scenarios demanding high energy storage during peak-hour load leveling, CAES or flux batteries prove to be suitable choices. The distinctive attributes of these storage methods are compared in Table 1.

Table 1 Assessment of the technical attributes of energy storage systemsa

Hybrid Energy Storage Systems

Hybrid Energy Storage Systems (HESS) incorporate two or more distinct Energy Storage (ES) technologies. Typically, one of these storage components is designed to address “high power” demands, transients, and rapid load fluctuations, featuring swift responsiveness and high efficiency [13, 29]. The other storage element serves as the “high energy” storage, characterized by a low self-discharge rate and more economical energy installation costs. Choosing the right combination of energy storage systems is pivotal in line with the system requirements, and some combinations are more suitable than others. On Fig. 3, it is possible to analyze the current combinations of ES technologies.

Fig. 3
figure 3

Current combinations of ES technologies

Technologies like CAES, Fuel Cells, and high-energy batteries offer extended storage durations and high energy rates, in contrast to SMES, supercapacitors, flywheels, or high-power batteries, which are characterized by high power rates and short discharge durations.

Combinations of this kind yield several advantages, as outlined in reference [29]:

  • The reduction of total investment costs,

  • Increase of storage and system lifetime,

  • Increase of total system efficiency.

A prime example of Hybrid Energy Storage System (HESS) can be observed in the combination of batteries and supercapacitors, as depicted in Fig. 3. This configuration marries high storage capacity with rapid response times [30]. Various authors have proposed viable solutions incorporating battery and supercapacitor storage systems for applications in buildings, microgrids with renewable energy production, or hybrid systems for electric vehicles. Such arrangements are known to enhance performance, increase efficiency, and extend battery life [31,32,33]. For instance, surplus photovoltaic energy can be stored in batteries, with real-time power control achieved through supercapacitors.

HESS strategically combine different storage technologies to maximize the benefits of each. The combination of high power and high energy components allows HESS to effectively manage both transient power demands and sustained energy needs, making them a versatile solution for enhancing energy community resilience and efficiency. The technical attributes listed in Table 1 provide a detailed understanding of the strengths and limitations of each technology, which are critical for selecting the appropriate combination in HESS.

Community Energy Storage Systems

Energy storage devices serve the purpose of capturing excess power during periods of surplus generation and releasing it when demand exceeds available supply. Community energy storage (CES) systems are gaining increasing prominence as innovative solutions for fostering sustainable energy transitions.

According to Parra et al., a CES operates at the consumption level, yielding positive impacts for end-users and network operators [34]. In a similar vein, Van der Stelt emphasizes community engagement and highlights CES as a system situated at the consumption level, capable of serving multiple functions to manage demand and supply, benefiting both consumers and Distribution System Operators (DSOs) [35]. Furthermore, as defined by Van Oost Koirala, CES represents an energy storage system owned and governed by the community, aiming to generate collective socio-economic advantages, including higher renewable energy penetration and self-consumption, while reducing reliance on fossil fuels, lowering energy costs, and boosting local economies [36]. In addition, Barbour and Parra’s research findings conclude that CES is a more efficient system than residential energy storage and, from an economic standpoint, it reduces the life-cycle cost of energy storage by 37% when compared to individual household applications [37, 38]. Koirala, [36], presented different CES configurations that are described below:

  • Shared residential energy storage (SRES): In this setup, each consumer can have their individual energy storage units, typically with a capacity of up to 20 kWh, located on their own residence/building. The energy stored can be shared amongst community users via the local physical grid.

  • Shared local energy storage (SLES): In this configuration, the energy storage capacity is more substantial, ranging from tens to hundreds of kWh, and it is placed within the local neighborhood. It is shared via the physical grid and is collectively owned by the community. SLES offers advantages such as increased flexibility and energy security.

  • Shared virtual energy storage (SVES): Unlike the previous two configurations, SVES represents a virtual community. Energy storage units are installed at different locations, both inside and outside the Energy Community (EnC) and are owned and governed independently. These storage units are combined and virtually distributed via the main grid, considering market design and regulatory structures.

Energy Community’s Storage System

In this section, a storage system within an energy community is presented, and the application of Genetic Algorithms to enhance the utilization of renewable energy throughout the daytime is explored.

Framework Description

For the sake of simplicity, in Fig. 1 presents an overview of an Energy Community (EnC) scheme. This EnC encompasses N residential units, each equipped with controllable household electrical devices. Among these units, n are assumed to be equipped with renewable energy sources in the form of PV systems, while y are considered to have storage systems.

The modeling framework for the Energy Community (EnC) is structured into three distinct layers: at the bottom, the physical layer; in the middle, the modeling layer; and on the top, the device layer.

  1. 1.

    The Physical Layer: This layer provides a comprehensive representation of the community, including details about the number of homes and occupants. It also outlines the equipment in each residence, covering appliances, storage solutions, and energy supply infrastructure.

  2. 2.

    The Modeling Layer: This layer is responsible for translating the data gathered from the physical layer into parameters. It also focuses on modeling the various aspects of the EnC, including renewable energy sources, storage devices, and household appliances.

  3. 3.

    The Device Layer: this layer operates as the governing system for the Energy Community (EnC), overseeing its functionality and adaptability. It is responsible for managing the demand, storage, and supply of each residence within the community, as well as the overall EnC. Through this layer, the EnC’s system and its flexibility are controlled and regulated, ensuring efficient energy management and distribution across the community.

These three layers work in tandem to create a robust foundation for understanding and managing the Energy Community’s energy dynamics and can be visualized in Fig. 4.

Fig. 4
figure 4

Representation of an EnC by layers

In the context of this Energy Community (EnC), the framework incorporates a 24-h active power chart that encompasses both the demand and generation aspects, as outlined by Eqs. (1) and (2) respectively. In these two equations, the symbol (d) denotes the demand power, while the symbol (g) stands for the generated power.

$${d}^{N} \equiv \left[{d}^{N}\left(1\right) \cdots {d}^{N}\left(t\right)\right],t\in \left[0-24\right]$$
(1)
$${g}^{N} \equiv \left[{g}^{N}\left(1\right) \cdots {g}^{N}\left(t\right)\right], t\in \left[0-24\right]$$
(2)

The number of considered EnC houses’ is denoted by N and time by t.

(Td) denotates the community’s total demand and (Tg) the total PV generation, both are set by Eqs. (3) and (4), respectively.

$${T}_{d}=\sum_{i=1}^{N}\left(d(i)\right)$$
(3)
$${T}_{g}=\sum_{i=1}^{N}\left(g(i)\right)$$
(4)

At the device layer, the management of supply and demand loads for individual houses within the community, as well as the community as a whole, will consider their respective levels of flexibility.

Photovoltaic System

The modeling of the PV system is performed using Eq. (5), which takes into account specific information about the chosen PV panel, the power inverter, as well as ambient temperature (Tamb) and solar radiation data (G). By applying Eq. (5) the Energy Community (EnC) can estimate the output power for each house within the system.

$${P}_{PV\_dc} = {PV}_{Peak\_Power} -\left(\alpha \times {PV}_{Peak\_Power} \right)\times \left({T}_{cel} - {T}_{c. STC}\right)$$
(5)

The notation \({PV}_{Peak\_Power}\) represents the PV system’s peak power, where \(\alpha\) means the temperature coefficient of the maximum output power, \({T}_{cel}\) refers to the temperature of the PV panel cells and \({T}_{c. STC}\) indicates the reference cell temperature at standard test conditions (STC). Equations (6) and (7) are used to define the PV system’s peak power and the temperature of the PV cells, respectively.

$${PV}_{Peak\_Power} = \frac{G}{1000}\times {P}_{p}$$
(6)
$${T}_{cel} = {T}_{amb}+ \left(\frac{\left({T}_{c,NOCT}- {T}_{a, NOCT}\right)}{{G}_{NOCT}}\right)\times \frac{G}{1000}$$
(7)

In Eq. (7), the temperature of PV cell denotes by \({T}_{cel}\), the ambient temperature is represented by \({T}_{amb}\), \({T}_{c,NOCT}\) is the nominal operating cell temperature (NOCT), \({T}_{a, NOCT}\) and \({G}_{NOCT}\) is the ambient temperature and the solar radiation at NOCT, respectively.

Household Devices

This study focuses on event-based appliances among flexible household devices, which are both controllable and adaptable without compromising user comfort. These appliances offer diverse time profiles that users can select.

Controllable devices are represented using a generic finite state machine, as depicted in Fig. 5. This state machine comprises four distinct states: “Machine OFF,” “Machine Ready,” “Machine ON,” and “Machine Complete.” Transitions between these states are controlled by two user-defined signals, “Ready_work” and “Time_ON,” which characterize the appliance’s operation. The parameter “Appliance_Time” is specific to each appliance and is based on its individual characteristics and the chosen operation program. For clarity, Fig. 5 can be explained with the following example:

  • The initial state is “Machine OFF,” indicating that the appliance is turned off.

  • When the appliance is prepared to begin its cycle, the state changes to “Machine Ready” through the “ready_work” signal. The appliance will be ready to start its operation when the specified time arrives.

  • The “Time_ON” signal is triggered when the clock matches the user’s chosen start time, transitioning the state to “Machine ON.”

  • The appliance operates for the duration specified by the “Appliance_Time” signal, and the power it consumes during this period is the output of the state machine.

  • Once the appliance completes its operation, a “complete” signal is triggered, transitioning the appliance to the “Machine Complete” state.

  • If the machine is set to run another cycle, the “cont_work” signal is triggered, and the state machine remains in the “Machine Ready” state until the next signal to commence operation.

  • Alternatively, the “OFF” state will be activated to turn off the machine if no further cycles are expected, and the state will return to “Machine OFF.”

Fig. 5
figure 5

Appliances finite state machine

Storage System

As seen in chapter 1, there are different types of ESS that can be used. In this work the chosen one was the battery system that is represented mathematically by Eq. 8, where \({E}^{b}\left(t\right)\) is battery’s energy on time t (kWh), \({E}^{b}\left(t-1\right)\) is battery’s energy on time t-1 (kWh), \({\eta }_{c}^{b}\) the efficiency of the battery charge process (%) and \({\eta }_{d}^{b}\) the efficiency of the battery discharge process (%). \({b}^{c}\) and \({b}^{d}\) are the signals of battery charge (0 or1) and discharge (0 or 1), respectively. Finally, \(\Delta P\left(t\right)\) is the liquid power of system on time t (kW) and \(\Delta T\) the time resolution (h).

$${E}^{b}\left(t\right)= {E}^{b}\left(t-1\right)+\left({\eta }_{c}^{b}\Delta P\left(t\right)\Delta T{b}_{c}+ \frac{\Delta P\left(t\right)\Delta T}{{\eta }_{d}^{b}} {b}_{d}\right), \forall t$$
(8)

It is also important to consider the power, energy and charge and discharge conditions, presented below:

  • Power:

    $$\left\{\begin{array}{l}0 \le \Delta P\left(t\right)\ge {P}_{c}^{b}max\\ 0 \le \left|\Delta P\left(t\right)\right|\ge {P}_{d}^{b}max\end{array}\right.$$
    (9)
  • Energy:

    $$\left\{\begin{array}{l}{E}_{min}^{b} \le {E}^{b}\left(t\right)\ge {E}_{max}^{b}\\ {E}^{b}\left(-1\right)= {E}_{inicial}^{b}\end{array}\right.$$
    (10)
  • Charge and discharge:

    $$\left\{\begin{array}{l}{b}_{c}+ {b}_{d}=1,\\ {b}_{c}=1 \,and \,{b}_{d}=0\, if \,\,\Delta P\left(t\right)>0\\ {b}_{d}=1\,and\,{b}_{c}=0 \,\,if\, \Delta P\left(t\right)<0\end{array}\right.$$
    (11)

In terms of power conditions as expressed in Eq. (9), it is guaranteed that battery terminals’ power it is not higher than nominal charge power and that the amount of power needed by the installation does not exceed the nominal discharge power.

These conditions serve as protective measures for the battery. Discharging the battery completely can lead to permanent damage. Typically, the minimum usage limit is set between 30% and 50% of the maximum battery capacity to prevent over-discharge damage. Similarly, for the upper limit, it is essential to ensure that the energy stored in the battery does not exceed its maximum capacity, safeguarding against overcharging.

Furthermore, concerning the charging and discharging conditions outlined in Eq. (11), they are employed to ensure that the battery does not simultaneously charge and discharge. This is determined by two signals: \({b}_{c}\,\text{ and}\,{b}_{d}\).The former indicates whether the battery is in the process of charging, taking the value of 1 when the system’s net power (∆P(t)) is positive. Conversely, the latter signal indicates if the battery is discharging, taking the value of 1 when the net power of the system is negative. Regarding the EnC, was considered that the ESS was a shared local energy storage, so the ESS is one single system for the entire EnC.

Genetic Algorithms to Improve Flexibility in Energy Communities

In order to enhance Energy Community flexibility, the cost function presented in Eq. (14) seeks to minimize a combination of n factors. In this particular instance, it is focused on minimizing a combination of two cases:

  1. (1)

    \({X}_{A}\), formulated in Eq. (12), calculates the cumulative difference between the initially selected start times for household appliances, chosen by the users, and the adjusted start times determined by the algorithm.

  2. (2)

    \({X}_{B}\), formulated in Eq. (13), computes the disparity between power consumption and the power available within the solar curve. When this difference is minimized, it indicates that photovoltaic power utilization is maximized.

In various simulations and scenarios, the weights assigned to these cases, \({X}_{A} \text{and} {X}_{B}\), may differ, with their sum totaling 100%. Additional cases can be incorporated into the cost function as needed, depending on the specific optimization goals.

$$\left\{\begin{array}{l}{X}_{A}= \sum \left|{Ap}_{initial}\left({h}_{n},{a}_{n}\right)- {Ap}_{final}\left({h}_{n},{a}_{n}\right)\right|\\ {Ap}_{initial}\left({h}_{n},{a}_{n}\right)={hour}_{initial}\left({h}_{n},{a}_{n}\right)*60+ {minute}_{initial}\left({h}_{n},{a}_{n}\right), in\, minutes\\ {Ap}_{final}\left({h}_{n},{a}_{n}\right)={hour}_{final}\left({h}_{n},{a}_{n}\right)*60+ m{inute}_{final}\left({h}_{n},{a}_{n}\right), in\,minutes\end{array}\right.$$
(12)
$${X}_{B}= \left|\left(\sum {Power}_{available}(t)\right)- \left(\sum {Power}_{consumption}\left(t\right)\right)\right|$$
(13)
$${f}_{cost }=\text{min}\left(\left({X}_{A}*{w}_{a}\right)+\left({X}_{B}*{w}_{b}\right)\dots +({X}_{n}*{w}_{n}\right)$$
(14)

Considering:

$${h}_{n}-\text{represents the house number}$$
$${a}_{n}-\text{represents appliance number}$$
$$t-\text{represents solar window}, t\in \left[10 \text{am};6\text{pm}\right]$$
$${w}_{a}, {w}_{b}, \dots , {w}_{n}-\text{represents the weight of each category }(\text{\%})$$

For the simulation of this work the following combination of weights was considered:

$${f}_{cost1}=\text{min}({(X}_{A}*50\%)+({X}_{B}*50\%))$$

This approach will facilitate an understanding of the diverse behaviors exhibited within the energy community, particularly concerning energy flexibility and the utilization of photovoltaic systems, all while prioritizing the well-being of the users.

Framework Solution Summary

The system, presented in “Framework Description” section, comprehensively manages the entire EnC, integrating user devices, energy production, available storage, and power load, as illustrated in Fig. 6. Upon detecting a fault or receiving a directive from the Distribution System Operator (DSO), the management system employs optimization algorithms. These algorithms are instrumental in pinpointing optimal solutions for managing the EnC’s loads under various test scenarios. The system evaluates a wide array of potential solutions and combinations, with this range expanding proportionally to the number of households within the EnC. The experimental design encompasses scenarios over a 24-h (1440-min) period. Following the optimization process, resilience metrics are applied to demonstrate the enhanced resilience of the EnC.

Fig. 6
figure 6

Flowchart about system framework

Simulation

In this study, two energy communities were taken into account for simulation purposes: one comprised of 10 houses and the other with 50 houses. These communities feature consumption devices, PV systems with specifications outlined in Table 2, and an integrated storage system within the community.

Table 2 Characteristics of the PV model and inverter employed in the 4 kWp reference system

Also, it is important to mention that EnC is working completely disconnected from the main grid in order to analyze the EnC’s behavior in the event of a total failure.

To assess various options at the community level within the system, different scenarios were taken into account for testing in both energy communities.

As Fig. 7 shows, for each one of the energy communities considered a group of nine different simulations were applied. One of the advantages of the work presented is the possibility to understand if the storage system chosen fits the energy community in question.

Fig. 7
figure 7

18 different scenarios tested

Regarding the scenarios were considered three different % of households with PV system installed, namely 30%, 60% and 80%, as well as three different storage system capacity, specifically 30, 60 and 100 kWh.

Initially, the algorithm assesses the load and production equilibrium within each household and the Energy Community (EnC), drawing upon available data. This entails factoring in the potential fault scenarios, integrating user-provided information regarding power consumption, and considering available power production. Subsequently, the genetic algorithm is executed to identify the optimal solution, taking into account population size and other algorithm parameters.

To support the simulations performed in this study, ambient temperature data (T_amb) and solar radiation data (G) were obtained from the Photovoltaic Geographical Information System (PVGIS). This data was collected at 15-min intervals, with the reference location being the NOVA School of Science and Technology (38° 39′ 36′′ N/9° 12′ 11′′ W).

As for household devices, the load of noncontrollable devices is determined using Richardson’s model [39], which factors in whether it’s a weekday or weekend and the number of residents in the dwelling. Given that noncontrollable devices remain fixed, the load for each household is considered constant and encompasses items such as lights, laptops, TVs, Wi-Fi, TV boxes, microwaves, and electric ovens. For the sake of simplicity, a maximum of three appliances per day were assumed to be in operation, namely a washing machine, dryer, and dishwasher, with their specifications provided in Table 3. Users can select the appliance’s start time (in HH:MM format) and specify whether the house has a functioning PV panel using a dedicated application interface.

Table 3 List of electrical appliance considered for the simulations

Considering the scenarios outlined previously, Table 4 offers specific details for each simulation, including the number of households equipped with PV systems. Additionally, Fig. 8 exhibits the aggregate EnC load consumption for the community, considering the initial working hours of appliances, for both 10 and 50 households, alongside the respective PV production for each case.

Table 4 PV System criteria for different simulations
Fig. 8
figure 8

Total house load for each energy community and different criteria for PV System

Considering Fig. 8, it becomes evident that a significant amount of solar energy is worthless in both scenarios due to appliances operating outside of solar hours. Through the implementation of GA optimization, the objective is to enhance the utilization of photovoltaic production and energy storage. Figure 9 displays the outcomes concerning the amount of energy required from the main grid following the optimization process. Some of the 18 simulations will be discussed in detail below.

Fig. 9
figure 9

Energy consumption from main grid for each scenario

10 Houses Simulation

Concerning the EnC comprising 10 houses, 25 selected controllable loads within this community had scheduled their starting time. In Fig. 8 the initial consumption load is illustrated in blue. Additionally, in Fig. 10a, b, the final consumption load is displayed following the optimization process. This optimization led to the adjustment of the starting times for all 25 appliances within the solar hours, a notable improvement from the initial consumption pattern, where 14 out of 25 appliances operated outside of the solar hours. However, despite the alignment of all controllable appliances with the solar period, a substantial amount of power is still consumed outside the solar hours due to noncontrollable appliances. This is when the ESS should be available in order to use only EnC energy.

Fig. 10
figure 10

Final consumption load for EnC with 10 houses, an ESS of 60kh and: a 30% PV system; b 80% PV system

Examining Fig. 10, it is possible to observe that in the scenario depicted in Fig. 10a, this community will rely on energy from the main grid starting from 8 pm onwards, as the ESS is fully discharged. Contrariwise, Fig. 10b demonstrates an EnC that can operate autonomously, as the ESS contains sufficient energy during nighttime to meet the community’s requirements. The difference between those two EnC is the number of houses that has PV system installed and consequently the total amount of PV production inside the EnC. In Fig. 10a, the ESS never get fully charged instead of Fig. 10b where the EnC as sufficient solar power to charge the ESS and use that power during nighttime.

Although the optimization substantially reduces the need for use the main grid, the EnC in Fig. 10a still needs 23.43 kWh from the main grid, as demonstrated in Fig. 11 by the orange line.

Fig. 11
figure 11

Energy consumption initial vs after optimization methods

50 Houses Simulation

Concerning the EnC comprising 50 houses, 124 selected controllable loads within this community had scheduled their starting time of which 76 are outside of solar hours.

In these two simulations, the focus of the analysis is on the PV production that isn’t stored or sold to the main grid, as the EnC operates independently without any connection to it. This unutilized energy is categorized as “surplus energy,” which encompasses the energy produced by PV system when the storage system has reached its maximum capacity and isn’t being used.

Looking to Fig. 12, it is possible to understand that, in both cases (a) and (b), the ESS and PV system it is not enough to guarantee the EnC consumption since the storage system goes until the minimum capacity during nighttime, in case (a) from 16:00 h and in case (b) from 18:00 h onwards. Table 5 presents the energy consumption that was not satisfied by the EnC system as well as the surplus energy for both cases, as well as for a third case that will be used as comparison.

Fig. 12
figure 12

Final consumption load for EnC with 50 houses, a 30% PV system and a ESS of 30 kWh; b ESS of 100 kWh

Table 5 Simulation data regarding energy consumption and waste

Considering Table 5 and Fig. 12, it is evident that in both scenarios, as previously noted, the EnC system was unable to completely meet the total load consumption. In case (a), there was a deficit of 279.3 kWh, while in case (b), the deficit was 211.6 kWh. However, the two scenarios differ in terms of surplus energy. In Fig. 12a), where the ESS has a capacity of 30 kWh (smaller than in simulation b), it can be observed that from approximately 11:00 am to 4:00 pm, the storage system reaches its maximum capacity, resulting in 21.76 kWh of unutilized PV production. Although this was insufficient to meet the EnC’s load consumption, it would have resulted in reduced energy consumption from the main grid.

On the other hand, in Fig. 12b), with a storage capacity of 100 kWh, the ESS never reaches its maximum capacity, leading to no surplus energy in this particular case. This led to the conclusion that, depending on what is the purpose of the EnC it is possible to have different combinations of ESS and PV system that will make sense for different purposes, for example if it is more important to minimize the surplus energy or minimize the consumption from the main grid.

Results and Discussion

Examining Fig. 13 reveals that, similar to both scenarios in Fig. 12, the EnC system falls short of meeting the consumption requirements. However, a deeper analysis of the results in Table 5 indicates that by comparing the energy that should be drawn from the main grid (193.1 kWh) with the surplus energy (282.9 kWh), it can be deduced that in this specific case, if the ESS had the capacity to store the surplus energy, it would have been adequate to meet the unfulfilled needs of the EnC (193.1 kWh) and likely accommodate a smaller PV system, as there would still be surplus energy available thereafter.

Fig. 13
figure 13

Final consumption load for EnC with 50 houses, a 60% PV system and 30 kWh ESS

On the other hand, looking at the entirety of the 18 simulations conducted, a set of five metrics was utilized to effectively compare the different scenarios. These metrics results are presented in Table 6, and are as follows:

Table 6 Metrics results for the 18 scenarios
  • Metric 1: Number of appliances working on Solar time, maximum is 25 for EnC with 10 houses and 124 for EnC with 50 houses;

  • Metric 2: Energy community load deviation, i.e., percentage of load consumption that was not satisfied;

  • Metric 3: Battery capacity in EOD (minimum is 5%);

  • Metric 4: Average daily value of battery capacity;

  • Metric 5: Surplus energy in EOD.

Based on the outcomes presented in this chapter, the study deduces that for the operation of a fully autonomous EnC, totally disconnected from the main grid, an ESS is imperative. While some appliances can be adjusted and optimized within the solar time window, others cannot, underscoring the necessity for a suitable ESS within the community. This system not only stores surplus energy generated by the PV system but also sustains the energy needs of the EnC during nighttime hours.

Through these simulations, it was apparent that the energy flexibility of households can serve not only to uphold the well-being of users during faults or when altering energy flow becomes necessary, but also to explore more favorable energy price markets, enhance grid resilience, and even consider integrating electric vehicles into the community’s grid.

Conclusions

This paper demonstrated the positive impact of incorporating a storage system into an energy community, ensuring the users’ energy comfort during EPG faults that can lead to total disconnection of EnC from EPG, like in the presented scenarios. The work presented investigates two separate energy communities, considering both uncontrollable and controllable devices within individual households as consumption sources, in addition to power supply sources such as PV systems installed in community residences, as well as power derived from the storage system.

The study “Energy Community Resilience Improvement Through a Storage System” underscores the crucial role of ESS in enhancing the resilience and efficiency of EnCs. By storing surplus energy generated by PV systems, ESS ensures a continuous energy supply even during grid disruptions or at times when solar energy is unavailable. The implementation of GA optimization and the strategic scheduling of household appliances within the solar time window significantly enhance energy efficiency and reduce dependence on the main grid. Simulations for communities of different sizes demonstrated that higher PV installation combined with larger ESS capacities leads to greater grid independence and energy efficiency.

Moreover, the study highlights the potential of energy flexibility in households to not only ensure user well-being during grid faults but also create opportunities for market participation and integration of electric vehicles. Enhancing energy flexibility helps balance energy supply and demand within the community, contributing to overall grid resilience. The research suggests that continued advancements in energy storage technologies and optimization methods will be vital for the sustainable development of smart grids and resilient energy infrastructures, positioning energy communities as key players in modern power systems.

One important direction for future work is to conduct simulations with the other configurations of CES mentioned on this work. Exploring different configurations will provide deeper insights into the optimal design and deployment strategies for CES in energy communities. By evaluating a range of CES setups, including varying capacities, technologies, and integration methods, the study can identify the most effective configurations for enhancing grid independence, energy efficiency, and overall resilience. This approach will also help in understanding the trade-offs between different storage solutions and their impacts on community energy dynamics, enabling the development of tailored CES solutions that meet specific community needs and conditions.

Another critical aspect for future research is the economic evaluation of ESS, particularly in the context of Portugal’s renewable energy landscape. ESS are essential for balancing supply and demand, especially with the increasing integration of renewable energy sources such as wind and solar. In Portugal, where renewable energy constitutes a significant portion of the energy mix, ESS can optimize energy usage, reduce costs, and enhance grid reliability. Future studies should focus on comparing the costs associated with implementing ESS against the costs of loss of load and corresponding energy costs. This economic analysis will provide valuable insights into the financial viability of ESS investments, highlighting potential cost savings and benefits for both consumers and the grid. Such evaluations will inform policy decisions and investment strategies, promoting the adoption of ESS to support Portugal’s renewable energy goals and ensure a stable, efficient energy system.

Finally, an additional area for future work involves performing a sensitivity analysis of the GA optimization used in the study. Sensitivity analysis will help in understanding how different parameters within the GA influence the optimization outcomes and the overall performance of the energy system. By systematically varying key GA parameters, such as population size, mutation rate, crossover rate, and selection method, researchers can identify the most influential factors and their interactions. This analysis will provide insights into the robustness and reliability of the GA optimization process, ensuring that the proposed solutions are not only optimal under specific conditions but also adaptable to a range of scenarios. The results of this sensitivity analysis will guide further refinement of the GA approach, enhancing its applicability and effectiveness in real-world energy community settings.