Energy Management System for a Residential Positive Energy District Based on Fuzzy Logic Approach (RESTORATIVE)

: There is a clear European Strategy to transition by 2050 from a fossil fuel-based economy to a completely new system based on renewable energy resources, with electricity as the main energy carrier. Positive Energy Districts (PEDs) are urban areas that produce at least as much energy as their yearly consumption. To meet this objective, they must incorporate distributed generation based on renewable systems within their boundaries. This article considers the fluctuations in electricity prices and local renewable availability and develops a PED model with a centralised energy storage system focused on electricity self-sufficiency and self-consumption. We present a fuzzy logic-based energy management system which optimises the state of charge of the energy storage solution considering local electricity production and loads along with the contracted electric tariff. The methodology is tested in a PED comprising 360 households in Bilbao (a city in the north of Spain), setting various scenarios, including changes in the size of the electric storage, long-term climate change effects, and extreme changes in the price of energy carriers. The study revealed that the assessed PED could reach up to 75.6% self-sufficiency and 76.8% self-consumption, with climate change expected to improve these values. On economic aspects, the return on investment of the proposal ranges from 6 up to 12 years depending on the configuration choice. Also, the case that boosts the economic viability is tight to non-business as usual (BaU), whichever event spiked up the prices or climate change conditions shortens the economic variables. The average bill is around 12.89 EUR/month per house for scenario BaU; meanwhile, a catastrophic event increases the bill by as much as 76.7%. On the other hand, climate crisis events impact energy generation, strengthening this and, as a consequence, slightly reducing the bill by up to 11.47 EUR/month.


Introduction
Energy is one of the key resources for human society [1], ensuring its comfort standards are met [2].The traditional development of energy supplies has resulted in the massive use of fossil fuels, which has several harmful externalities [3].In this regard, the energy roadmap for Europe aims at producing 75% of gross final energy consumption and 97% of electricity consumption through Renewable Energy Sources (RES) by 2050 [4,5].This is evidenced by the International Energy Agency (IEA) stressing transport, industry, and buildings as key areas for reducing carbon emissions by 2050 [6].Buildings are expected to reduce emissions by 40%, while transport applications (with greater technological constraints) by 10% [7].
With this in mind, European countries are developing a new concept: Positive Energy District (PED).The Joint Programming Initiative Urban Europe (JPI) defines PEDs as areas or groups of interconnected buildings [8,9] that produce more energy on-site than is needed to meet their demand.PEDs may or may not comprise energy storage systems (ESS) and thermal and/or electric renewable systems.Currently, more than 100 cities in Europe are incorporating PED developments into their decarbonisation roadmaps [10].
Despite PEDs' advancements, there is a significant research gap in the effective integration of energy management systems (EMSs) that optimise self-sufficiency and participation in flexibility markets.Existing studies have not comprehensively addressed the simultaneous management of e-mobility, home appliances, thermal demands (cooling, heating, and domestic hot water), and smart pole demands using a heuristic strategy considering battery State of Charge and electricity pricing conditions.This research's underlying motivation focuses on improving resilience values and enabling PEDs to participate in flexibility markets.By optimising self-consumption systems, the aim is to reduce the losses inherent in energy transport and decrease the need for investments in distribution network infrastructure.This approach increases energy efficiency and aligns sustainability objectives with economic viability.
Furthermore, enabling developing countries to participate in flexible markets has the potential to diminish operating costs and generate new sources of revenue, which represents a significant step towards energy self-sufficiency and resilience of urban communities.These developments are fundamental to the transition towards a more sustainable and decentralised energy model, where consumers play an active role in the management and commercialisation of the energy they produce.
The most common renewable energy source in PEDs is geothermal energy, which powers district heating [8,11].Nevertheless, the electrification of the transport sector would necessitate the massive deployment of batteries within the PED, as electric vehicles (EVs) can be considered mobile batteries.It is well-known that the most expensive item in EVs is its energy storage system (ESS), although technological progress is reducing its cost [12].
In this regard, this study proposes a communitarian on-site energy management system (ESS) for a residential PED based on the fuzzy logic approach.This setup relies on an ESS for a small residential PED, where electricity is generated through renewable systems.The efficacy of a heuristic approach for the ESS is tested.
This study aims to fill this gap by proposing a communitarian on-site energy management system (ESS) for a residential PED based on the fuzzy logic approach.This setup relies on an ESS for a small residential PED, where electricity is generated through renewable systems.The efficacy of a heuristic approach for the ESS is tested.This system, called RESTORATIVE, aims to guarantee a high level of self-sufficiency and self-consumption that can dramatically reduce the electricity bill for PED residents.
In addition, while technically viable, RESTORATIVE does not seek total energy independence due to the high investments required [13].Instead, this rule-based energy management system promotes the local use of electricity while optimising batteries' State of Charge (SOC) so that electricity imports are synchronised (as much as possible) with low-cost tariff periods.
This study reveals that, when optimally managed, it can ensure that no renewable electricity is wasted while using the utility grid for backup purposes.This would make the local ESS the main driver for cost-effectively meeting the residents' energy demands.Similar setups have been deployed in places such as Sønderborg, Denmark, where a residential electricity storage system has been implemented coupled with photovoltaic (PV) systems [10] to provide some flexibility from the utility grid.
As a result, the unique contribution of this study lies in its holistic integration of local energy systems to optimise energy balance, profile smoothing, and electricity cost through a heuristic approach.Furthermore, it carries out a long-term evaluation considering climate change to evaluate the stability of the system under significant climate fluctuations, which has not been previously explored in the literature.This approach addresses the identified research gap and promotes the development of PEDs.
To sum up, the authors believe the current study presents relevant novelties.The study focuses on advancing the current state of the art in medium-sized PEDs, fully integrated into electric systems to attain comfort systems in buildings, and also includes electromobility demands, which is a concern for energy producers and grid operators due to their future impact on the grid.The approach optimises local energy systems jointly for energy balance, energy profile smoothing, and electricity cost by using a heuristic approach.Furthermore, a long-term assessment in light of climate change is performed to evaluate system stability under important climatic fluctuations.

Related Work
Previous studies on electric energy management systems (EMS) have employed various scopes and approaches to buildings, considering EV load, local electric generation (mostly PV), the interaction of electric and thermal systems [14], sizing and management criteria of ESSs, etc.For example, the study [15] performed a statistical evaluation of the self-consumption (SC), self-sufficiency (SS), and Loss-Of-Load Probability (LOLP) for a 55-house Mediterranean community.They applied the generation-to-demand ratio (GTDR) to characterise buildings by their energy performance.Loads in these communities were mainly governed by cooling and heating services.For Cyprus households, the average yearly consumption was 7179.40 kWh, and the generation was 4660.86 kW.The outcomes included 50% self-consumption, 30% self-sufficiency, and 70% LOLP, with SCs higher than those reported in UK and Australian cases [16].Although increasing PV capacity from 3 kWp to 5 kWp per household did not increase the SC, significant reductions in energy imports (2600 kWh) and increases in energy exports (5100 kWh) were reported [15].The study also revealed that households producing more energy than they consumed had a lower potential for CO 2 emissions reduction per installed kWp within the building limits [15].
The introduction of e-mobility in grids was considered in another study [17], where the authors demonstrated an EMS providing electricity uninterruptedly following a fixed price tariff in a small grid, which could be interpreted as the PED's mobility needs.They decreased the charging price by 16.1% and the burden on the utility grid by 93.7% with a rule-based energy management scheme.Primarily in the form of 'if-then' descriptions.The 'if' statements are linked to various scenarios and the 'then' statement executes the operating mode.
More complex technical systems have been studied [18], comprising not only PV and ESS but also wind turbines and thermal storage.Profitable SC in the range of 85% was reported.Key success factors in this output were the complementarity of wind and PV electricity generation and the ESS configuration.
Other authors [19][20][21] assess how EMS behave under short-and long-term changing conditions.This requires a robust but flexible system operation to properly adapt to load, weather, and climate changes.To this end, the authors deployed a multi-agent scheme based on fuzzy logic to manage the facility's assets.
In [22], the authors implemented a smart energy management system (SEMS) that used Internet of Things (IoT) technology to reduce electricity consumption by air conditioning use in Pakistan for industrial, commercial, and residential sectors.This system included an energy controller and an IoT intermediate module, which collected energy consumption data from smart devices and optimised the use of air conditioning systems according to the temperature conditions and operational dynamics of the buildings.This system demonstrated significant energy savings, between 15% and 49%, after its implementation in four buildings.
Moreover, Table 1 gathers an interesting group of assessments that have conducted similar studies; however, the methodologies can vary from the perspective used for RESTORA-TIVE.This table is organised as follows: title; values of SS and SC; method employed; and reference number, in order to benchmark these studies with an energy management system for a residential positive energy district based on a fuzzy logic approach (RESTORATIVE).
The studies in Table 1 analyse the self-sufficiency (SS) and/or self-consumption (SC) of various urban energy communities and districts.The self-consumption rates range from 42% to 85%, with one study forecasting that 77% of participants will achieve selfconsumption.Self-sufficiency rates are more varied, from 24% with no energy storage system up to 76%.The methodologies used include agent-based modelling, GIS-LCA multi-criteria analysis, rule-based control strategies, economic optimization using tools like MaT4EnergyPLAN, and Pareto-optimal solutions from differential evolution.One study used a simple generation-to-demand ratio metric.While the results depend on the specific district and modelling approach, these studies demonstrate that urban energy communities can achieve substantial self-consumption and self-sufficiency, especially with the right mix of distributed renewable generation, energy storage, and smart controls.However, further research is needed to generalize the findings and optimize the techno-economic trade-offs.
Finally, a group of energy management strategies that advance traditional power flow strategies was studied [23].The authors addressed off-peak grid electricity shifting, the enhancement of renewable penetration, and battery ageing.They also stated that net present value (NPV) and self-sufficiency (SS) are highly dependent on the energy paradigm and the energy management strategy.
We think it is worth highlighting that none of the studies portrayed in Table 1 overperforms RESTORATIVE in both aspects, such as SS and SC.The studies that overperform RESTORATIVE are focussed on one out of two of the most important aspects but none of them both.While studies that were conducted using the two variables SS and SC were not able to reach the results achieved in this manuscript.

Publication Title
Self-Sufficiency

Self-Consumption Method or Technique Reference
Energy communities to advance towards positive energy districts as a strategy towards decarbonisation NA 77% foresee Not Provided [24] Energy Self-Sufficiency Urban Module (ESSUM): GIS-LCA-based multi-criteria methodology to analyse the urban potential of solar energy generation and its environmental implications 70% NA GIS-LCA-based multi-criteria methodology [25] Towards energy self-consumption and self-sufficiency in urban energy communities

53-67% 52% A metaheuristic PSO technique [26]
A techno-economic analysis of an optimal self-sufficient district 76% NA Two methods, a rule-based control method (EnFloMatch tool) and a deterministic optimisation method [27] Agent-based modelling of a local energy market: A study of the economic interactions between autonomous PV owners within a micro-grid Considering the above-mentioned points, the state of the art on PEDs, microgrids, ESS, and PV system sizing and management can be consolidated to a large extent.No evidence was found suggesting that a study like this has already been conducted, where mobility, home appliances, thermal demands (cooling, heating, and domestic hot water), and smart pole demands are governed by a heuristic strategy that simultaneously considers the battery and electricity pricing conditions.This paper is remarkably different in three key aspects: first, the renewable production is on-site, adhering to the PED's approach; second, the strategy is fully oriented to avoid buying electricity from the utility grid (U)G as much as possible.However, if purchasing is necessary, the tariff scheme with three points (Supervalley, Flat, and Peak prices) is used; third, the PED analysis considers the potential impact of climate change on the district and the effects of crises such as wars or lockdowns on residents' bills; in consequence, prices of energy are high.

Methodology
This Section outlines the methodological approach in this study.This paper presents the archetype built on Simulink, the FL-based management strategy, and the scenarios implemented for testing the study's proposal.The list of tools in the document presents a set of solutions primarily created in European projects targeting specific problems of energy communities.None of the proposed solutions include an EMS for a PED that comprises electric, thermal, and transport loads.

Definition of the PED
The PED comprises six residential buildings, each with 10 floors and 6 apartments per floor.Their thermal characteristics align with those of buildings retrofitted to the "C" energy label [35].The energy demand in C-labelled residential buildings in Bilbao is 20.23 kWh/m 2 and 10.4 kWh/m 2 for heating and domestic hot water (DHW) consumption, respectively (see Appendix A Table A1).
On average, apartments have an area of 85 m 2 , consistent with average sizes of 76 to 90 m 2 per apartment in Spain [36].The PED's total floor area (30,716 m 2 ) is equivalent to approximately 360 flats.Figure 1 presents the six buildings' energy needs including thermal (heating, cooling, DHW), electrical, and mobility demands.They are presented in MWh/year, MWh/day, and MWh/m 2 to facilitate their comparison.As can be seen, the largest burden is always on heating systems.mobility demands have been included, assuming partial electrification.According to INE, the number of vehicles per household in Spain is 1.4, and they are driven an average of 33 km daily [38].It has been issued that mobility demand is constant throughout the year, with each EV running 12,045 km/year [38].This adds a total of 155.56 MWh/year to the PED (assuming 100 EVs for the 6 buildings).Since 360 households can own up to 504 vehicles, this assumption represents about 20% of mobility electrification.The data used to perform the research activities came from archetypal data used in the ATELIER project [4] and thus are purely synthetic.On the one hand, synthetic aggregated thermal and electrical energy consumption estimated in the project that the district was going to demand was disaggregated by dividing the total surface of the neighbourhood by the average house size in Spain [37].This resulted in 360 houses that consume the same amount of energy.Moreover, the electromobility data are also synthetic.These data come from the average use of private vehicles in Spain published by the National Statistics Bureau [38].
The geothermal system is supported by a heat pump system, which raises the temperature from around 13-14 • C up to the PED's requirement of 60 • C.Moreover, their mobility demands have been included, assuming partial electrification.According to INE, the number of vehicles per household in Spain is 1.4, and they are driven an average of 33 km daily [38].It has been issued that mobility demand is constant throughout the year, with each EV running 12,045 km/year [38].This adds a total of 155.56 MWh/year to the PED (assuming 100 EVs for the 6 buildings).Since 360 households can own up to 504 vehicles, this assumption represents about 20% of mobility electrification.
On this topic, the definition of mobility demands is based on the arbitrary requirement of 100 EVs throughout the year.Spain has one of the lowest mobility electrification rates in the European Union, with only around 5% of the fleet being electric, followed only by Italy, Poland, and the Czech Republic [39].However, Spain is promoting politics to boost EV adoption.We did not include Vehicle-to-Grid (V2G) in this setup since we do not have the data, and also it is not part of the vision of the project.
Regarding lighting systems, the simulation model comprises 20 smart poles with lighting and monitoring services (noise, particle matter, etc.) distributed across the PED.These lamps are LED-based, and their consumption is hardly perceptible.
Thermal loads (heating, cooling and DHW) are met through a geothermal heat pump system, with a coefficient of performance (CoP) of 4.7 for electric loads.These are the largest PED demands, with large variations over the year.However, it is important to note that the energy consumption for smart lighting is the smallest demand of the PED.Also, in the experimental setup, energy used for mobility remains constant throughout the year.Figure 2 shows that electricity and mobility demands are constant throughout the year, whereas DHW demand slightly varies with the seasons, decreasing in the summer.Additionally, Figure 2 illustrates the behaviour of thermal demand in the PED, indicating that these demands are seasonal.The thermal demands are heating in winter and air conditioning in summer, and DHW remains with minimal variation along the year.
On this topic, the definition of mobility demands is based on the arbitrary requirement of 100 EVs throughout the year.Spain has one of the lowest mobility electrification rates in the European Union, with only around 5% of the fleet being electric, followed only by Italy, Poland, and the Czech Republic [39].However, Spain is promoting politics to boost EV adoption.We did not include Vehicle-to-Grid (V2G) in this setup since we do not have the data, and also it is not part of the vision of the project.
Regarding lighting systems, the simulation model comprises 20 smart poles with lighting and monitoring services (noise, particle matter, etc.) distributed across the PED.These lamps are LED-based, and their consumption is hardly perceptible.
Thermal loads (heating, cooling and DHW) are met through a geothermal heat pump system, with a coefficient of performance (CoP) of 4.7 for electric loads.These are the largest PED demands, with large variations over the year.However, it is important to note that the energy consumption for smart lighting is the smallest demand of the PED.Also, in the experimental setup, energy used for mobility remains constant throughout the year.Figure 2 shows that electricity and mobility demands are constant throughout the year, whereas DHW demand slightly varies with the seasons, decreasing in the summer.Additionally, Figure 2 illustrates the behaviour of thermal demand in the PED, indicating that these demands are seasonal.The thermal demands are heating in winter and air conditioning in summer, and DHW remains with minimal variation along the year.The PED, which is an archetype, is equipped with PV systems for electricity generation (see Figure 3) and geothermal rings to meet heating needs through heat pumps.In this case, the PED has a surface covered by PV modules of approximately 3050 m 2 .This can combine rooftops and facades to maximise PV energy production within the limited space.The chosen technology for this system is monocrystalline, with an efficiency of 24.5%.This technology generates between 11 and 41 kW for the total area in the oceanic climate of Bilbao.These values range from 3.61 kW/m 2 to 13.44 kW/m 2 for months like January and May, respectively.
Figure 3 shows the energy flows to the different loads in the archetype PED where RESTORATIVE is tested.These loads include the six buildings that require electricity for thermoregulation, electromobility, and lighting systems.Additionally, the buildings The PED, which is an archetype, is equipped with PV systems for electricity generation (see Figure 3) and geothermal rings to meet heating needs through heat pumps.In this case, the PED has a surface covered by PV modules of approximately 3050 m 2 .This can combine rooftops and facades to maximise PV energy production within the limited space.The chosen technology for this system is monocrystalline, with an efficiency of 24.5%.This technology generates between 11 and 41 kW for the total area in the oceanic climate of Bilbao.These values range from 3.61 kW/m 2 to 13.44 kW/m 2 for months like January and May, respectively.
Figure 3 shows the energy flows to the different loads in the archetype PED where RESTORATIVE is tested.These loads include the six buildings that require electricity for thermoregulation, electromobility, and lighting systems.Additionally, the buildings incorporate roof-mounted PV modules to generate electricity on-site and incorporate heat pumps to fulfil thermal energy demands (heating, cooling, and DHW).All these systems are connected to the UG for constant balancing of the PED's electric network.
incorporate roof-mounted PV modules to generate electricity on-site and incorporate heat pumps to fulfil thermal energy demands (heating, cooling, and DHW).All these systems are connected to the UG for constant balancing of the PED's electric network.

Simulation Tool
The PED was modelled and tested in the MATLAB & Simulink environment, version 2022b.The archetype encompasses all aspects that are part of the small district modelled for this simulation exercise, including the following:  Renewable energy: Geothermal low-temperature ring (red lines in Figure 3).The geothermal system relies on a low-temperature network that maintains a steady baseline temperature of about 13-14 °C throughout the year [40].And PV facilities for the PED buildings (green lines in Figure 3). Consumption systems: Smart street-lighting systems, EV hub chargers, building demands, e.g., electricity needs, and heat pumps for thermal comfort (Figure 3). Energy storage system (ESS): A centralised ESS based on li-ion batteries (Figure 3) is implemented to support energy demands and significantly reduce PED residents' electricity bills.Furthermore, ESSs increase the flexibility of the PED by allowing the redistribution of energy from low-priced electricity to the microgrid when the cost of electricity rises due to high demand or poor generation.This ESS is formed by batteries from the RAYLITE brand, model 3 MIL17S with a capacity of 25 °C of C100 655 (Ah) [41].
Figure 4 shows how the ESS is managed depending on hourly changes, and the error produced throughout the day (difference between PV(t) and L(t)).This information is helpful in determining whether the ESS should provide energy to the PED or, conversely, purchase inexpensive electricity from the grid operator.

Simulation Tool
The PED was modelled and tested in the MATLAB & Simulink environment, version 2022b.The archetype encompasses all aspects that are part of the small district modelled for this simulation exercise, including the following:

•
Renewable energy: Geothermal low-temperature ring (red lines in Figure 3).The geothermal system relies on a low-temperature network that maintains a steady baseline temperature of about 13-14 • C throughout the year [40].And PV facilities for the PED buildings (green lines in Figure 3).

•
Consumption systems: Smart street-lighting systems, EV hub chargers, building demands, e.g., electricity needs, and heat pumps for thermal comfort (Figure 3).

•
Energy storage system (ESS): A centralised ESS based on li-ion batteries (Figure 3) is implemented to support energy demands and significantly reduce PED residents' electricity bills.Furthermore, ESSs increase the flexibility of the PED by allowing the redistribution of energy from low-priced electricity to the microgrid when the cost of electricity rises due to high demand or poor generation.This ESS is formed by batteries from the RAYLITE brand, model 3 MIL17S with a capacity of 25 • C of C 100 655 (Ah) [41].
Figure 4 shows how the ESS is managed depending on hourly changes, and the error produced throughout the day (difference between PV(t) and L(t)).This information is helpful in determining whether the ESS should provide energy to the PED or, conversely, purchase inexpensive electricity from the grid operator.
The archetype is founded on a simplified modelling methodology developed within the Simulink environment (see Appendix A Figure A1).Each block is connected to a bus distribution [11].Kirchhoff's law calculates the energy exchanges, as these align perfectly with the definition of PEDs.The archetype is founded on a simplified modelling methodology developed within the Simulink environment (see Appendix A Figure A1).Each block is connected to a bus distribution [11].Kirchhoff's law calculates the energy exchanges, as these align perfectly with the definition of PEDs.

ESS Performance Assessment
The ESS status assessment is performed by assessing the state of charge (SOC) with its minimum, mean, and maximum values calculated.The variation at the end of the day is also calculated according to Equation (1): where Capbatt is the size of the battery implemented in the simulation; Ibatt is the current drained from the battery; ESS performance in the PED frame is evaluated using self-consumption (SC) and selfsufficiency (SS) metrics.SC is the homes' ability to consume the energy generated locally, while SS refers to the PED's capacity to supply its load without importing energy.These two quantities are defined below: where  Mt, is the instantaneous overlapping part of the generation and load profiles, namely, Mt = min {Lt, Pt, +St} [42];  Lt is the instantaneous PED power consumption;  Pt the instantaneous power generation within the PED boundaries;  St is the power drain to and from the ESS of the PED.This considers losses owing to ESS charging, discharging, and storing [42].
In addition to the metrics mentioned above, the interconnection with the UG is intended to supply electricity when the Renewable Energy Systems (RESs) are unable to meet demands.The idea is to ensure the district's self-sufficiency for most of the time by using, if technically feasible, the electricity generated from the RES conversion to meet the district's requirements, thereby minimising the need to purchase electricity from the UG.A community-based Energy Storage System (ESS) would provide electricity for the PED and assist in smoothing peak demands and preventing potential curtailment when RES availability is limited.

ESS Performance Assessment
The ESS status assessment is performed by assessing the state of charge (SOC) with its minimum, mean, and maximum values calculated.The variation at the end of the day is also calculated according to Equation (1): where Cap batt is the size of the battery implemented in the simulation; I batt is the current drained from the battery; ESS performance in the PED frame is evaluated using self-consumption (SC) and self-sufficiency (SS) metrics.SC is the homes' ability to consume the energy generated locally, while SS refers to the PED's capacity to supply its load without importing energy.These two quantities are defined below: where In addition to the metrics mentioned above, the interconnection with the UG is intended to supply electricity when the Renewable Energy Systems (RESs) are unable to meet demands.The idea is to ensure the district's self-sufficiency for most of the time by using, if technically feasible, the electricity generated from the RES conversion to meet the district's requirements, thereby minimising the need to purchase electricity from the UG.A community-based Energy Storage System (ESS) would provide electricity for the PED and assist in smoothing peak demands and preventing potential curtailment when RES availability is limited.

Management Strategy
RESTORATIVE optimises the quality and availability of stored energy, enhancing the overall performance of the energy system.This involves advanced control and monitoring strategies, load/discharge optimisation, and innovative technologies to extend the lifetime of storage devices.Its goal is to maximise the value and sustainability of the PED's renewable storage systems by fostering the recovery and continuous improvement of stored energy.
RESTORATIVE relies heavily on the interaction with the UG.This requires a clear management strategy, as depicted in Figure 5.The sensors continuously monitor P grid(t) , while receiving the outputs of the Fuzzy Logic Controller (FLC) through the B control and the B charge .B charge independently determines battery charge, irrespective of UG or PV generation, while B control regulates the ESS interaction with the UG or PV.The FLC generates output after evaluating variables such as SOC, time of day, and error (difference between renewable generation and load consumption).

Management Strategy
RESTORATIVE optimises the quality and availability of stored energy, enhancing the overall performance of the energy system.This involves advanced control and monitoring strategies, load/discharge optimisation, and innovative technologies to extend the lifetime of storage devices.Its goal is to maximise the value and sustainability of the PED's renewable storage systems by fostering the recovery and continuous improvement of stored energy.
RESTORATIVE relies heavily on the interaction with the UG.This requires a clear management strategy, as depicted in Figure 5.The sensors continuously monitor Pgrid(t), while receiving the outputs of the Fuzzy Logic Controller (FLC) through the Bcontrol and the Bcharge.Bcharge independently determines battery charge, irrespective of UG or PV generation, while Bcontrol regulates the ESS interaction with the UG or PV.The FLC generates output after evaluating variables such as SOC, time of day, and error (difference between renewable generation and load consumption).The equation behaviour is as follows: The first condition states that if Bcharge receives an input of one, regardless of Bcontrol, the ESS starts to recharge and the PED is covered by PV energy.The second condition is to block the ESS charge or discharge either by extremely low or extremely high SOC.However, it could also occur due to the high electricity costs, when the SOC is within the safe zone.The third condition is when Bcharge receives an input of zero and Bcontrol an input of one, the battery interacts with the PED, delivering energy to meet energy demands.However, in this condition, the ESS does not recharge.

Fuzzy Logic Setup Strategy
RESTORATIVE is developed on an FL scheme to optimise the RES, economic operations, and battery health of an ESS within the PED frame.It is oriented towards managing the energy surplus for further use in the PED during periods with lower RES production and/or high energy prices.Figure 6 shows the three membership functions for ESS management: time of operation (TOP), SOC, and power error (PE) and also the two outputs of the system, namely, "SOC_CC/Bat_control" and "Bat_charge".The equation behaviour is as follows: The first condition states that if B charge receives an input of one, regardless of B control , the ESS starts to recharge and the PED is covered by PV energy.The second condition is to block the ESS charge or discharge either by extremely low or extremely high SOC.However, it could also occur due to the high electricity costs, when the SOC is within the safe zone.The third condition is when B charge receives an input of zero and B control an input of one, the battery interacts with the PED, delivering energy to meet energy demands.However, in this condition, the ESS does not recharge.

Fuzzy Logic Setup Strategy
RESTORATIVE is developed on an FL scheme to optimise the RES, economic operations, and battery health of an ESS within the PED frame.It is oriented towards managing the energy surplus for further use in the PED during periods with lower RES production and/or high energy prices.Figure 6 shows the three membership functions for ESS management: time of operation (TOP), SOC, and power error (PE) and also the two outputs of the system, namely, "SOC_CC/Bat_control" and "Bat_charge".
TOP identifies the time of the day according to electricity tariff profiles.Here, it is specified for Spain, with six separate periods: Supervalley (considered the cheapest period), Flat (three separate periods along the day: Flat_1, Flat_2, and Flat_3), and Peak (two separate periods along the day: Peak_1 and Peak_2).
SOC defines the level of electricity stored in the batteries.It is divided into "Extreme low" (<30%), "low", "safe", "high", and "extreme high" (>95%).The ESS should avoid the two extreme scenarios to avoid deteriorating the ESS system.The FL algorithm cuts off the ESS charge when it reaches extremely high SOC levels and redirects excess energy to the PED or UG to protect the ESS.For extremely low SOC situations, the electricity drain from the ESS is interrupted.TOP identifies the time of the day according to electricity tariff profiles.Here, it is specified for Spain, with six separate periods: Supervalley (considered the cheapest period), Flat (three separate periods along the day: Flat_1, Flat_2, and Flat_3), and Peak (two separate periods along the day: Peak_1 and Peak_2).
SOC defines the level of electricity stored in the batteries.It is divided into "Extreme low" (<30%), "low", "safe", "high", and "extreme high" (>95%).The ESS should avoid the two extreme scenarios to avoid deteriorating the ESS system.The FL algorithm cuts off the ESS charge when it reaches extremely high SOC levels and redirects excess energy to the PED or UG to protect the ESS.For extremely low SOC situations, the electricity drain from the ESS is interrupted.
PE aims to check the PV generation capacity.It flags to enable or disable the connection with UG.Error_POS_deficit reflects periods with demands larger than RES production, while error_NEG_surplus represents periods with surplus energy production.The interaction map between PE and the time of day used to manage the ESS is presented in Figure 7, where the yellow area represents the section where ESS charging from PV tends to be prioritised over UG because of the RES availability and electricity price.This means charging from the RES surplus is enabled while charging from UG is disabled.The Supervalley period from 00:00 to 08:00 h (dark blue) is preferred in terms of ESS charging from the UG because of the price and the absence of PV generation.PE aims to check the PV generation capacity.It flags to enable or disable the connection with UG.Error_POS_deficit reflects periods with demands larger than RES production, while error_NEG_surplus represents periods with surplus energy production.The interaction map between PE and the time of day used to manage the ESS is presented in Figure 7, where the yellow area represents the section where ESS charging from PV tends to be prioritised over UG because of the RES availability and electricity price.This means charging from the RES surplus is enabled while charging from UG is disabled.The Supervalley period from 00:00 to 08:00 h (dark blue) is preferred in terms of ESS charging from the UG because of the price and the absence of PV generation.
The RESTORATIVE approach is based on fuzzy logic, it has two outputs, each with its respective membership functions.The first Output "SOC_CC/Bat_control" is responsible for caring for the state of charge (SOC) of the battery.These membership functions indicate whether the state of charge is low or high and enable the controller to make management strategy decisions based on the current SOC.
The second output "Bat_charge" is related to the charge control of the energy storage system.This maintains the state of charge (SOC) of the battery within defined limits based on information from the manufacturer, always avoiding SOC > 98.5% and SOC < 20% so as not to rapidly degrade the cells that make up the batteries that are part of the battery of the ESS.
agement strategy decisions based on the current SOC.
The second output "Bat_charge" is related to the charge control of the energy storage system.This maintains the state of charge (SOC) of the battery within defined limits based on information from the manufacturer, always avoiding SOC > 98.5% and SOC < 20% so as not to rapidly degrade the cells that make up the batteries that are part of the battery of the ESS.The interaction map linking PE and SOC is presented in Figure 8.The area with steady management for electricity capture is shown in yellow (SOC in the 0.42 to 0.92 range).The section from 00:00 h to 08:00 is preferred for purchasing electricity from the grid.The dark blue region indicates when the system is allowed to obtain electricity from UG because, during this time, there is no PV generation and prices are at their lowest.The dark blue area also marks where ESS switches off to protect itself.The transition from a lighter blue to yellow signifies that the battery can provide energy to the PED since the SOC is within the safe threshold area.
The interaction between PE and TOP to manage the ESS charge/discharge process is presented in Figure 9.It shows the hours when energy is expensive and avoids recharging from UG (PE is also positive, indicating a deficit in RES generation).Therefore, the PED is supplied by the ESS (discharge) from 10 h to 14 h, and from 14 h to 24 h if the PE is negative.Additionally, the 00 h to 08 h period is ideal for ESS recharging, as shown in Figure 9.
The linkage between PE and SOC to manage the ESS charge/discharge process is presented in Figure 10.In this figure, yellow indicates charging.It shows that the ESS can be charged from the UG only when there is a deficit (positive values) in RES generation and the SOC is identified as low or extremely low.Dark blue areas designate where the ESS The interaction map linking PE and SOC is presented in Figure 8.The area with steady management for electricity capture is shown in yellow (SOC in the 0.42 to 0.92 range).The section from 00:00 h to 08:00 is preferred for purchasing electricity from the grid.The dark blue region indicates when the system is allowed to obtain electricity from UG because, during this time, there is no PV generation and prices are at their lowest.The dark blue area also marks where ESS switches off to protect itself.The transition from a lighter blue to yellow signifies that the battery can provide energy to the PED since the SOC is within the safe threshold area.
Smart Cities 2024, 7, FOR PEER REVIEW 13 becomes an electricity supplier for the PED.In sum, RESTORATIVE comprises a set of 58 rules in the fuzzy associated memory (FAM).The interaction between PE and TOP to manage the ESS charge/discharge process is presented in Figure 9.It shows the hours when energy is expensive and avoids recharging from UG (PE is also positive, indicating a deficit in RES generation).Therefore, the PED is supplied by the ESS (discharge) from 10 h to 14 h, and from 14 h to 24 h if the PE is negative.Additionally, the 00 h to 08 h period is ideal for ESS recharging, as shown in Figure 9.

Boundary Conditions
RESTORATIVE is tested against two climate and energy cost scenarios.Regarding the climate conditions, the first scenario considers mild oceanic conditions typical in Bilbao, while the second is the Mediterranean climate as this is probably the future climate

Boundary Conditions
RESTORATIVE is tested against two climate and energy cost scenarios.Regarding the climate conditions, the first scenario considers mild oceanic conditions typical in Bilbao, while the second is the Mediterranean climate as this is probably the future climate for this city of northern Spain.In terms of cost, there are two possible scenarios: A BaU year without catastrophic events that might drive electricity prices up, versus an abnormal evolution of energy prices with high peaks due to geopolitical events.These boundary conditions are later used to construct a few scenarios.Regarding climate, two different possible conditions are possible: 1.
Standard climate: In Bilbao, Spain, the typical climate features moderate wind speeds averaging between 10 and 20 km per hour year-round.Due to its maritime influence, relative humidity levels remain relatively high, typically ranging from 70% to 80%.
The city experiences mild winters with average temperatures of 8  11 shows the average monthly patterns.

2.
Mediterranean climate: This scenario is replicated using the solar irradiation and temperature patterns of a Mediterranean city (Alicante).In Alicante, Spain, typical conditions vary throughout the year due to seasonal changes; however, on average, wind speeds generally range from 5 to 15 km per hour.Humidity levels are lower in the dry, hot summers (40-60%) and higher in the mild, wet winters (60-80%).During summer (June to August), daytime temperatures average 28 pivotal for PED development and is closely linked with climate, our analysis offers insights adaptable beyond the studied cases, fostering broader applicability and innovation in PED initiatives.This EMS for residential PEDs, based on fuzzy logic, is perfectly extrapolatable to other frontiers.Regarding energy costs, real-time series data from the Spanish wholesale energy market are taken from Red Eléctrica Española [44].With two variations: Regarding energy costs, real-time series data from the Spanish wholesale energy market are taken from Red Eléctrica Española [44].With two variations: 1.
Business-as-usual year: Energy cost variations throughout the year are considered.The year 2019 was sampled for this purpose, with an average electricity cost in the range of 47 EUR/MWh (see Figure 13).

2.
Abnormal evolution of energy prices with high peaks due to geopolitical events: This scenario is constructed with the time series of 2022, where several geopolitical and supply-side events heavily impacted electricity costs.As can be seen in Figure 14, average prices ranged from 181 EUR/MWh (four times more than in a normal scenario), with peaks in the range of 700 EUR/MWh.
Smart Cities 2024, 7, FOR PEER REVIEW 16 1. Business-as-usual year: Energy cost variations throughout the year are considered.The year 2019 was sampled for this purpose, with an average electricity cost in the range of 47 EUR/MWh (see Figure 13).2. Abnormal evolution of energy prices with high peaks due to geopolitical events: This scenario is constructed with the time series of 2022, where several geopolitical and supply-side events heavily impacted electricity costs.As can be seen in Figure 14, average prices ranged from 181 EUR/MWh (four times more than in a normal scenario), with peaks in the range of 700 EUR/MWh.

Scenarios for PED Simulation
Considering the above-mentioned system and boundary conditions, the performance of RESTORATIVE is assessed under the following ten scenarios (Table 2).Table 2 shows the 10 scenarios studied.Each scenario is characterized by the values taken by three variables: the size of the ESS (which can take values of 100%, 80%, 60%, and 40%), the climatic profile used (the current temperate oceanic climate and the future warm-summer Mediterranean climate), and, finally, the electricity prices (which could be 'business as usual' or 'high').It is worth remarking that Scenarios 1, 5, and 6, 10 only differ in the price structures.This means that scenarios 5 and 10 are under high prices produced by non-regular events like wars, lockdowns, etc.Therefore, only tables where the economic impact is assessed will contain 10 scenarios, and tables where technical aspects are analysed will only comprise 8 scenarios.

Discussion of Results of the Simulation
This Section presents the results obtained from the simulation-based analysis of RESTORATIVE conducted within the PED framework to measure technical, economic, and environmental impacts.The Section summarises the results of the ten scenarios designed for this paper.The starting point of this simulation is to verify the irradiance patterns for the location where the PED will be deployed.
Figure 15 shows the PV potential presented on the PED.As can be seen, the window from months 4 to 8 (May and August) has the highest energy potential.Conversely, months 9 to 3 (September to March) correspond to autumn and winter, with lower energy potential.This leads us to believe that the ESS will be more relevant from September to March due to reduced solar harvesting.As a consequence of the higher irradiance from May to August, ESS should be lower.As this paper deals with a smart energy storage system for a residential PED based on the FL approach (named RESTORATIVE), assessing its self-sufficiency (SS) is emphasised (see Table 3), as this measures the proportion of total consumption supplied by on-site generation.On-site generation is a key feature of PEDs, with objectives aiming for energy generation from renewable sources to meet energy demands and produce surpluses.

Technical Assessment of RESTORATIVE's Impact on the PED
Table 3 reveals that Scenario 1 has the best self-sufficiency (50.1% total average) among the other scenarios (2, 3, and 4).However, Scenario 1 only slightly outperforms the other scenarios under normal weather conditions.It is worth noting that the summer months (June and July) perform the best, reaching 71.8% and 70.7%, respectively.Similarly, Scenario 6 (abnormal weather) surpasses Scenarios 7, 8, and 9, reaching an SS average of 57.3% with the highest records occurring during summer months, specifically, June (75.6%),July (74.8%), and August (73%).
It is worth highlighting that SS is favoured by climate change, as seen in Table 3.The scenarios under climate change outperform their counterparts under normal weather conditions.Even the mean SS of the climate change scenario (57.3%) is larger than that under normal climate (50.1%).In addition, months with poor irradiation, i.e., winter, lead to lower SS results.Conversely, months with higher irradiation, i.e., summer, achieve better results.These simulations reveal a positive impact of climate change on this PED because, under normal weather conditions, SS values are lower than in abnormal weather conditions.Therefore, SS is not only affected by low irradiance months but also by ESS size, as seen in Table 3, where in Scenario 4 (January), SS falls to 27.9% compared to 28.5% in Scenario 1.
Table 4 contains the data measured of the self-consumption (SC) of the residential PED.SC is the proportion of PV generation used to meet on-site consumption [13].Nonetheless, in this simulation, the impact of the battery on the PED was assessed, as some papers state that batteries can increase relative SC by 13-24% with an ESS [42].
Table 4 shows that SC values vary significantly depending on the scenario and the month.Scenarios 1 to 4 have higher SC than Scenarios 6 to 10, with Scenario 1 showing the highest SC average.In Scenario 1, the winter months (from December to March) show the highest SC values: 90.3%, 100%, 96.6%, and 78.5%, respectively.
Meanwhile, the summer months (June, July, and August) registered SC values as high as 76.8% and as low as 71.8%.Table 4 also shows that months with medium/good irradiation (Figure 15), i.e., April, May, September, October, and November, have the lowest SC values in Scenario 1.This diminished performance can be directly linked to the regular irradiance and the lower energy demands from comfort systems since there are no heating or cooling demands beyond DHW.These lower demand and better irradiance patterns increase the availability of energy generated from PV, thereby reducing SC.The lower the PV generation, the higher the SC.This demonstrates that high SC is directly linked to a poor irradiation profile.Still, in this use case, as demand varies throughout the year, they are also affected by the loads.Moreover, in Scenario 6 (abnormal weather), it is observed that self-consumption is higher than in Scenarios 7 to 9. Additionally, self-consumption values are similar to Scenario 1 during the summer months.The scenarios affected by climate change (from 6 to 9) underperform the SC of the normal weather.This points to an inverse relation with the high irradiance patterns in the PED.As seen in Table 4, scenarios under climate change like 6, 7, 8, and 9 do not achieve average values over 45.1%.This can be explained by the increased energy available from the PV array.It reinforces the former statement: The lower the PV generation, the bigger the SC.
It is important to analyse ESS performance through the different scenarios conducted in this study.The analysis is based on ESS's SOC, measuring the minimum, average, and maximum SOC of each sampled month.We have arbitrarily chosen the minimum value as it indicates how well sized the battery is based on how many times it was depleted throughout the year.It is crucial for the battery to remain far from minimum values (30% in the setup) to safeguard its lifetime.
Table 5 demonstrates that the ESS seems to be in consonance with the energy PED's demand since only 3 out of 120 months of the 10 Scenarios deplete the battery below the red target (SOC < 30%) previously assigned in the problem definition.This only occurs in Scenarios 2 (28%), 3 (19%), and 4 (2%) in January.In these scenarios, the ESS is reduced from its baseline (100%) and corresponds to 80%, 60%, and 40%, respectively.Meanwhile, for 87.5% of the months, the battery discharge was around 53%, which is safe for maintaining battery health.Additionally, the simulations revealed that scenarios of abnormal weather favour the batteries' threshold since almost all attain the minimum SOC of around 53%.
Table 6 shows the average behaviour of the ESS.It reveals that ESS is properly sized for the PED's demand, given most of the 120 months (10 scenarios) maintain a 60% average.The initial SOC was set as 60% for the experimentation.It is worth highlighting that scenarios impacted by climate change exhibit the best average SOC performance, with Scenarios 8 and 9 being the most prominent.This remarkable performance may be attributed to the ESS's smaller size, which facilitates battery depletion and recharge.The larger ESS size represents a lower SOC average.Meanwhile, the smaller ESS leads to higher SOC averages.The second half of the heat map shows the same colours but with lighter tones, indicating that this set of scenarios is more efficient in energy consumption/generation.Even these scenarios are more effective due to climate change.It is worth remarking that the Delving deeper into the PED balance, Figure 17 exhibits a heat map illustrating how even though the first five scenarios (1, 2, 3, 4, and 5) do not achieve a positive balance overall, they do so in certain months marked in yellow, such as April, May, and September.The brightness of the yellow corresponds to the degree of positivity per month, where brighter shades indicate higher positivity.The inverse relationship happens with the colour blue, where darker shades indicate greater negativity, implying a larger energy deficit.The second half of the heat map shows the same colours but with lighter tones, indicating that this set of scenarios is more efficient in energy consumption/generation.Even these scenarios are more effective due to climate change.It is worth remarking that the efficiency label used for this simulation is not the highest "A label".Instead, a "C label" was implemented, which means that if this test is made using a better energy classification for the buildings, the efficiency would increase and, as a result, the deficit balance can switch to a positive balance for Scenarios 1, 2, 3, and 4.  The second half of the heat map shows the same colours but with lighter tones, indicating that this set of scenarios is more efficient in energy consumption/generation.Even these scenarios are more effective due to climate change.It is worth remarking that the efficiency label used for this simulation is not the highest "A label".Instead, a "C label" was implemented, which means that if this test is made using a better energy classification for the buildings, the efficiency would increase and, as a result, the deficit balance can switch to a positive balance for Scenarios 1, 2, 3, and 4.

Financial Assessment of the Impact of RESTORATIVE in the PED
Moreover, the bill PED residents would be required to pay is based on two years: one business as usual (BaU) and another with high fuel prices.The year used for the former was 2019 (365 days), while the period from 1 January 2022 to 31 December 2022 was used for calculating the latter since the war began.These bills are calculated for a single tenant of an average Spanish household, and the costs in Table 8 are for a single PED apartment.A total of 360 apartments were estimated.
Table 8 confirms that sudden events impacting oil prices raise bills at maximum values for Scenarios 5 and 10, at EUR 35.31 and EUR 30.71 per month, respectively.The difference between both scenarios is around 15%.On the one hand, the maximum bill for Scenarios from 1 to 4 is very similar and is about EUR 23.This amount of money is preserved steadily thanks to RESTORATIVE guidelines that state that even if the size of the ESS is widely different among scenarios, the strategy relies on the use of renewable energy produced on the PED site over outsourced energy.Similar trends are observed for scenarios under climate alteration (from 6 to 10).The monthly bill is around EUR 19 during BaU conditions; however, the increase in irradiance patterns due to climate change in the Basque country is noticeable.Unfortunately, while these changes would favour residents' economy, there is a wide gap that contrasts the mean bills of around EUR 11.5 (Scenarios 6, 7, 8, and 9) with the mean bill for Scenario 10, which is EUR 20.5, showing a 56% increment.Scenarios 6, 7, 8, 9, and 10 have reduced bills.This is due to longer solar availability resulting in more renewable-source electricity.This benefits tenants through their bills.The savings between Scenarios 1 and 6, and 5 and 10 are 20% and 14%, respectively, using maximum values.Maximum values come from highly demanding months like winter and summer, while minimum values are a consequence of months with good irradiance patterns and low thermal loads (e.g., April, May, September, October, and November).When the former comparison is made for minimum bills, the saving is reduced to 5% between Scenarios 1 and 6 and 12% for Scenarios 5 and 10.
On the other hand, assessing the economic feasibility of the PED proposal, Table 9 shows ten different possibilities.However, all scenarios demonstrate that the proposal is perfectly feasible.Considering a Return On Investment (ROI), scenario 5 is the most remarkable because the whole investment is recovered in 6 years.This represents an Internal Rate Return (IRR) of approximately 28%, followed by Scenario 10, which recovers in 7 years (see Figure 18).In this case, the IRR is around 18% due to the rise in the electricity bills.This strongly supports investing in a renewable microgrid for the PED.Despite higher electricity bills, this scenario requires one additional year for recovery, likely due to climate change facilitating more renewable energy generation for the PV facility.The significant impact of electricity costs is offset by increased renewable energy generation, resulting in the investment being recovered in 7 years.By the end of its lifetime, the PED would have saved around EUR 19,852,296.For this to be achievable, the 360 tenants must work as a unified entity.Considering a Return On Investment (ROI), scenario 5 is the most remarkable because the whole investment is recovered in 6 years.This represents an Internal Rate Return (IRR) of approximately 28%, followed by Scenario 10, which recovers in 7 years (see Figure 18).In this case, the IRR is around 18% due to the rise in the electricity bills.This strongly supports investing in a renewable microgrid for the PED.Despite higher electricity bills, this scenario requires one additional year for recovery, likely due to climate change facilitating more renewable energy generation for the PV facility.The significant impact of electricity costs is offset by increased renewable energy generation, resulting in the investment being recovered in 7 years.By the end of its lifetime, the PED would have saved around EUR 19,852,296.For this to be achievable, the 360 tenants must work as a unified entity.The best ROI among the BaU scenarios is found in Scenario 4 (9 years) because the ESS size is reduced up to 40% (314 kWh).The storing system in this simulation is the second most expensive element of the PED behind the PV facility.Similar results are obtained in climate change scenarios, with Scenario 9 achieving the best ROI, which is one year longer (10 years) than the previous case.This is because, in this case, energy generation is superior, and the bills are reduced (see Table 9).Consequently, as more energy is self-generated, less is paid to the Distribution System Operator (DSO), resulting in one additional year to recover the total investment.The best ROI among the BaU scenarios is found in Scenario 4 (9 years) because the ESS size is reduced up to 40% (314 kWh).The storing system in this simulation is the second most expensive element of the PED behind the PV facility.Similar results are obtained in climate change scenarios, with Scenario 9 achieving the best ROI, which is one year longer (10 years) than the previous case.This is because, in this case, energy generation is superior, and the bills are reduced (see Table 9).Consequently, as more energy is self-generated, less is paid to the Distribution System Operator (DSO), resulting in one additional year to recover the total investment.
From the Net Present Value (NPV) perspective, Scenario 5 is the most favourable.This scenario, though not the desired one, seems to be the best moment to achieve major electricity network autonomy due to the war because the savings for this scenario are close to EUR 5.48 million.Scenario 10 follows the same trend with savings of about EUR 1.72 million.Scenario 4 closes the top three ranking with savings of EUR 1.14 million.These electricity costs follow the same trajectory going from the cheapest in Scenario 5, with 0.83 kWh/EUR-year, to the more expensive in Scenario 1 with 1.39 kWh/EUR-year.
It is worth noting that scenarios affected by the war were calculated using an inflation rate of 8%, while others were calculated with an inflation rate of 2%.The lifetime used for the PV facility implemented in this calculation is 25 years.
In summary, Scenario 4 seems to be the most appealing from an economic perspective as this archetype's ROI requires only 9 years (see Table 9).This scenario is mainly affected by the initial investment because the size of the storing systems is only 40% of the size presented in Scenario 1.Additionally, the differences in the monthly bill are not significant compared to the other scenarios (see Table 8) due to the FL approach in RESTORATIVE.
It is important to note that this economic analysis is specific to Spain.The method of billing electricity sold to clients may vary depending on each country's legislation.However, the basic guideline followed in this paper, i.e., the price of energy consumed, power hired, and taxes for a 30-day period, helps determine electricity costs for the consumers on an annual basis.This can be implemented in other countries to determine the ROI, IRR, NPV, and Cost.

Environmental Impact of RESTORATIVE in the PED
Even if the scenarios diverge in their setup, they are not so different in terms of emissions, which is why the authors decided to only show two scenarios (1 and 6), and divide them into three categories, which are as follows: 1.
Emissions produced by thermal demands: To assess the impact of these demands, a comparison was made between the fossil generation of heat-burning gas and the renewable option, which uses heat pump systems with a CoP of 4. Emissions produced by electric demands: In this case, as the renewable electricity using PV systems (Factor of Emission = 0.00001) is almost zero, only the emissions from the electricity taken from the UG, which primarily comes from non-renewable sources, are shown.The emission factor is 0.15 kg CO 2 /kWh (Spanish case) [47,48].
In the case of the UG, the tonnes of CO 2 emitted from the energy fed into the grid using RESTORATIVE will be counted.
Figures 19 and 20 illustrate the current and future emissions of the whole PED area.These figures can be used to reference the possible improvements that must be built into the PED.Figures 19 and 20 show how the emissions for comfort systems (heating, cooling and HDW) remain equal in these simulations.This is because they maintain the same energy demand for heat, cool, and water in both scenarios.
However, the key point here is the wide difference between the emissions using only Gas Natural, which results in about 3.5 times more than the emission when using heat pump (geothermal) systems for heating and HDW, and using the UG to provide part of the electricity demanded by the systems.When the summer months come, the relation is barely reduced to around 2.75 times for meeting the cooling and HDW demands.This difference is dramatically reduced between renewable and gas systems during April, May, September, October, and November when only HDW is demanding energy from the PED.
In the last case, gas systems only emit about 20% more than renewable systems.On a yearly basis, the non-renewable system emits about 651,685 tonnes of CO2eq, whereas renewable systems only emit 187,076 tonnes of CO2eq because this partially meets with the UG.If electricity was powered by totally renewable systems, the emissions would be abolished.
Figures 19 and 20 further show a yawning gap between the emissions produced by mobility systems in this PED.As in the former case, if the electricity used for electric cars was totally renewable, the systems would reduce the emissions even more.The difference between the emissions of EVs and fossil-powered emissions is substantial for a fleet of 100 vehicles.The main difference being that fossil cars emit 7.41 times more than EVs.On a yearly basis, petrol cars emit about 3216 tonnes of CO2eq, whereas the EVs only emit 434 tonnes of CO2eq.
the PED.
In the last case, gas systems only emit about 20% more than renewable systems.On a yearly basis, the non-renewable system emits about 651,685 tonnes of CO2eq, whereas renewable systems only emit 187,076 tonnes of CO2eq because this partially meets with the UG.If electricity was powered by totally renewable systems, the emissions would be abolished.The most significant takeaway from Figures 19 and 20 is the yellow bar, which shows that in Scenario 6, emission savings increase to 535,511 tonnes of CO2eq.This improvement results from an increase in energy generation from renewable sources within the PED boundaries.As shown in Figure 19, January, February, and December have a negative impact due to higher emissions during these months (blue bar).However, the emissions for the rest of the months are offset by renewable energy generation.In Scenario 6, emissions within the PED are effectively reduced to zero because the renewable generation systems compensate for the emissions, as indicated by the blue bars.

Sensitivity Analysis of RESTORATIVE
A small sensitivity analysis was performed on the RESTORATIVE EMS.To this end, we included an additive white Gaussian noise with a 1% variance component to each one of the input variables (self-consumption and self-sufficiency) and re-ran the simulations.The results can be seen in Table 10.As can be seen in the different columns in Table 10, the outputs do not differ significantly from the original run of simulations.In particular, it is below the included perturbation, so we conclude that the control seems to be robust.The most significant takeaway from Figures 19 and 20 is the yellow bar, which shows that in Scenario 6, emission savings increase to 535,511 tonnes of CO2eq.This improvement results from an increase in energy generation from renewable sources within the PED boundaries.As shown in Figure 19, January, February, and December have a negative impact due to higher emissions during these months (blue bar).However, the emissions for the rest of the months are offset by renewable energy generation.In Scenario 6, emissions within the PED are effectively reduced to zero because the renewable generation systems compensate for the emissions, as indicated by the blue bars.

Sensitivity Analysis of RESTORATIVE
A small sensitivity analysis was performed on the RESTORATIVE EMS.To this end, we included an additive white Gaussian noise with a 1% variance component to each one of the input variables (self-consumption and self-sufficiency) and re-ran the simulations.The results can be seen in Table 10.As can be seen in the different columns in Table 10, the outputs do not differ significantly from the original run of simulations.In particular, it is below the included perturbation, so we conclude that the control seems to be robust.

Scalability of RESTORATIVE
The RESTORATIVE energy management system (EMS) for Positive Energy Districts (PEDs) presents a promising approach towards achieving high levels of self-sufficiency and self-consumption.Its design, based on fuzzy logic, allows for the optimization of energy storage systems (ESS) and can be adapted to various scenarios, including changes in energy prices and climatic conditions.The scalability of this system to other similar applications is a critical factor in determining its broader applicability and potential for widespread adoption.
Considering the need for making this tool feasible in other environments, the RESTORATIVE system is built upon a modular design that makes it adaptable to different PED configurations.The key components, such as the ESS, fuzzy logic controller, and photovoltaic (PV) systems, can be scaled up or down depending on the size and energy requirements of the PED.In this line, the fuzzy logic approach used in RESTORATIVE can be fine-tuned to accommodate various climatic conditions and energy consumption patterns, making it applicable to diverse geographical locations.Additionally, the system is designed to integrate seamlessly with multiple renewable energy sources, primarily PV systems and geothermal energy, but it can also incorporate wind turbines and other renewable technologies.This flexibility ensures that the system can be tailored to leverage the most abundant local renewable resources.The system also contributes to substantial reductions in carbon emissions, aligning with global sustainability goals and enhancing its appeal for broader application.The advanced control and monitoring strategies used in RESTORATIVE, such as load/discharge optimization and innovative technologies for extending the lifetime of storage devices, can be applied to other PEDs to improve performance and sustainability.The capability to interact dynamically with the utility grid (UG) ensures that the system can maintain optimal operation even under varying grid conditions.This interaction allows for cost-effective energy management, which can be replicated in other contexts.This application can be replicated and/or scaled to similar systems, such as urban and suburban residential areas, and commercial and industrial zones, regardless of whether the climate differs from both analyses in this study.
The RESTORATIVE energy management system's design, economic viability, and environmental benefits demonstrate its potential for scalability to other similar applications.Its modularity, adaptability, and advanced management strategies make it a versatile solution for various residential, commercial, and industrial energy management needs.The system's success in different climatic and economic scenarios further underscores its broad applicability and potential for widespread adoption in the transition towards sustainable and resilient energy systems.

Conclusions
This simulation study considers technical, economic, and environmental aspects since the city transformations definitively impact the residents.The ambitions of PEDs are to positively change the cities by making them greener and liveable.Achieving selfsufficiency would represent a paramount investment that might be the biggest challenge to the promoters of an autonomous PED.
• The potential for irradiance generation is acceptable only during the summer months from May to August; for the rest of the year, PV performance is significantly diminished due to poor sun irradiance.Climate change would favour the deployment of such facilities due to the rise in irradiation patterns.

•
SS is highly favoured by irradiance patterns that affect the PV plates.SS will increase as solar production rises.On the other hand, SC appears to be primarily affected by a combination of energy demands and low-energy harvesting.It achieved 100% SC only in January when the thermal demands are high and the energy stored in ESS is poor due to the insufficient PV harvest.• The battery is properly sized to meet PED's energy needs, as it operates mostly within safe zones, staying in the optimal state for more than 87.5% of the time.Importantly, even when the battery's energy storage capacity was reduced, the RESTORATIVE system maintained the ESS within safe operating zones, keeping electricity bills reasonable for PED residents.

•
Only scenarios under certain climate alterations reach the positivity condition to be considered a PED.There are also scenarios with major reductions in electricity bills.Scenarios 1, 2, 3, and 4 might reach positivity if the building's energy label is enhanced from "C" to "B" or even "A".• Scenario 5 had the most notable Return on Investment (ROI), with full recovery within 6 years and an Internal Rate of Return (IRR) of approximately 28%.This underscores the viability of investing in a renewable microgrid for the PED, despite a higher electricity bill.Additionally, Scenario 4 emerges as the most favourable among the BaU scenarios, achieving a 9-year ROI due to a reduced ESS size.Notably, Scenario 9, under climate change alteration, presents superior energy generation, leading to reduced bills and a 9-year ROI.From an NPV perspective, Scenario 5 also proves most favourable, signalling the potential for significant electricity network autonomy and substantial savings.• The study reveals significant disparities in emissions across thermal, mobility, and electric demands within the PED.The adoption of renewable energy solutions substantially mitigates emissions, particularly evident in the stark contrast between gas and renewable heating systems.The figures depict a compelling reduction in emissions, emphasising the pivotal role of renewables in decarbonizing PEDs.The findings underscore the urgent need for the widespread adoption of renewable energy technologies to achieve substantial emission reductions and foster sustainable energy transitions in similar urban contexts.In this regard, these rules contribute to the management strategy in several ways.They enable the controller to make decisions based on the current states of Timetable, SOC, and POWER_error.Each rule defines specific actions (SOC_CC/Bat_control and Bat_charge) to be taken for every combination of input states, ensuring an appropriate system response.
Overall, the set of rules provides a flexible and robust management strategy.It is capable of handling various operational scenarios and system conditions.This flexibility In this regard, these rules contribute to the management strategy in several ways.They enable the controller to make decisions based on the current states of Timetable, SOC, and

Figure 1 .
Figure 1.Energy needs of PED buildings in MWh (year, day, and m 2 ).Figure 1.Energy needs of PED buildings in MWh (year, day, and m 2 ).

Figure 1 .
Figure 1.Energy needs of PED buildings in MWh (year, day, and m 2 ).Figure 1.Energy needs of PED buildings in MWh (year, day, and m 2 ).

Figure 2 .
Figure 2. Disaggregated demands of the PED of Zorrozaurre included in the modelling.

Figure 2 .
Figure 2. Disaggregated demands of the PED of Zorrozaurre included in the modelling.

Figure 3 .
Figure 3. PED archetype interaction of the island of Zorrozaurre.

Figure 3 .
Figure 3. PED archetype interaction of the island of Zorrozaurre.

Figure 4 .
Figure 4. Macro scheme of the communitarian ESS.

Figure 4 .
Figure 4. Macro scheme of the communitarian ESS.

Figure 5 .
Figure 5. Scheme of ESS management for a residential PED.The mid-control is governed by the following three equations:

Figure 5 .
Figure 5. Scheme of ESS management for a residential PED.The mid-control is governed by the following three equations:

Figure 7 .
Figure 7. Map of the interaction between PE and TOP to manage the ESS.

Figure 7 .
Figure 7. Map of the interaction between PE and TOP to manage the ESS.

Figure 8 .
Figure 8. Map of the interaction between PE and SOC to manage the ESS.Figure 8. Map of the interaction between PE and SOC to manage the ESS.

Figure 8 .
Figure 8. Map of the interaction between PE and SOC to manage the ESS.Figure 8. Map of the interaction between PE and SOC to manage the ESS.

Figure 8 .
Figure 8. Map of the interaction between PE and SOC to manage the ESS.

Figure 9 .
Figure 9. Map of the interaction between PE and TOP to manage the charge of the ESS.

Figure 9 . 14 Figure 10 .
Figure 9. Map of the interaction between PE and TOP to manage the charge of the ESS.The linkage between PE and SOC to manage the ESS charge/discharge process is presented in Figure 10.In this figure, yellow indicates charging.It shows that the ESS can be charged from the UG only when there is a deficit (positive values) in RES generation and the SOC is identified as low or extremely low.Dark blue areas designate where the ESS becomes an electricity supplier for the PED.In sum, RESTORATIVE comprises a set of 58 rules in the fuzzy associated memory (FAM).Smart Cities 2024, 7, FOR PEER REVIEW 14

Figure 10 .
Figure 10.Map created among PE and SOC to manage the charge of the ESS.

Figure 11 .
Figure 11.Monthly average irradiance patterns for Standard climate.

Figure 11 .
Figure 11.Monthly average irradiance patterns for Standard climate.

Figure 11 .
Figure 11.Monthly average irradiance patterns for Standard climate.

Figure 12 .
Figure 12.Monthly average irradiance patterns for Mediterranean climate.

Figure 12 .
Figure 12.Monthly average irradiance patterns for Mediterranean climate.

Figure 13 .
Figure 13.Evolution of the electricity price in a business-as-usual year (2019).Figure 13.Evolution of the electricity price in a business-as-usual year (2019).

Figure 13 .
Figure 13.Evolution of the electricity price in a business-as-usual year (2019).Figure 13.Evolution of the electricity price in a business-as-usual year (2019).

Figure 13 .
Figure 13.Evolution of the electricity price in a business-as-usual year (2019).

Figure 14 .
Figure 14.Evolution of electricity prices in a year (2022) affected by abnormal events.Figure 14.Evolution of electricity prices in a year (2022) affected by abnormal events.

Figure 14 .
Figure 14.Evolution of electricity prices in a year (2022) affected by abnormal events.Figure 14.Evolution of electricity prices in a year (2022) affected by abnormal events.

Figure 15 .
Figure 15.Heat map based on current irradiance patterns for Bilbao.

Figure 16 .
Figure 16.PED yearly energy balance during the simulation study.

Figure 16 .
Figure 16.PED yearly energy balance during the simulation study.

Figure 16 .
Figure 16.PED yearly energy balance during the simulation study.

Figure 18 .
Figure 18.Return on investment for scenario 10.

Figure 18 .
Figure 18.Return on investment for scenario 10.

Figure 19 .
Figure 19.Emissions for scenario 1 (Normal weather) of the PED.

Figures 19 and 20
Figures 19 and 20 further show a yawning gap between the emissions produced by mobility systems in this PED.As in the former case, if the electricity used for electric cars was totally renewable, the systems would reduce the emissions even more.The difference between the emissions of EVs and fossil-powered emissions is substantial for a fleet of 100 vehicles.The main difference being that fossil cars emit 7.41 times more than EVs.On a yearly basis, petrol cars emit about 3216 tonnes of CO2eq, whereas the EVs only emit 434 tonnes of CO2eq.The most significant takeaway from Figures 19 and 20 is the yellow bar, which shows that in Scenario 6, emission savings increase to 535,511 tonnes of CO2eq.This improvement results from an increase in energy generation from renewable sources within the PED boundaries.As shown in Figure19, January, February, and December have a negative impact due to higher emissions during these months (blue bar).However, the emissions for the rest of the months are offset by renewable energy generation.In Scenario 6, emissions within the PED are effectively reduced to zero because the renewable generation systems compensate for the emissions, as indicated by the blue bars.

Figure A1 .
Figure A1.Simulink diagram of the system.

Figure A1 .
Figure A1.Simulink diagram of the system.

Table 1 .
Benchmark of different studies that perform a SS and/or SC analysis.
is the instantaneous overlapping part of the generation and load profiles, namely, M t = min {L t , P t , +S t } [42]; • L t is the instantaneous PED power consumption; • P t the instantaneous power generation within the PED boundaries; • S t is the power drain to and from the ESS of the PED.This considers losses owing to ESS charging, discharging, and storing [42].

Table 2 .
Featurization of the scenarios conducted in this paper.

Table 3 .
Monthly registers of self-sufficiency across the PED.
1As formerly mentioned, scenarios 1 and 5 only differ in economic aspects.2Scenarios6 and 10 only differ in economic aspects.

Table 3 .
Monthly registers of self-sufficiency across the PED.
1As formerly mentioned, scenarios 1 and 5 only differ in economic aspects.2Scenarios6 and 10 only differ in economic aspects.

Table 4 .
Monthly registers of self-consumption across the PED.

Table 8 .
Monthly bill of the dwelling of the PED across scenarios.

Table 9 .
Economic impact for PED residents with different scenarios.Scenarios 5 and 10 overperform ROIs of the rest scenarios, this might be due to the fact that in these two scenarios the rise of the electricity bill shortens the time for recovering the investment. * Scenarios 5 and 10 overperform ROIs of the rest scenarios, this might be due to the fact that in these two scenarios the rise of the electricity bill shortens the time for recovering the investment. * 7 for the PED archetype.The emission factor for Gas Natural in Spain is 0.252 kg CO 2 /kWh [44,45].2. Emissions produced by mobility: These are accounted for sticking to a baseline of 100 EVs.It is estimated by the approximation of 360 flats × 1.4 Vehicles [9] = 504 Cars.One hundred EVs represent about 19.84% of the PED's total vehicular fleet.This means that to make a fair comparison, the 100 EVs' emissions were measured against the same number of fossil cars in terms of emission.The emission factor is 2.35 kg CO 2 /L for Gas 95 and 2.64 kg CO 2 /L for Diesel [46].3.

Table 10 .
Results of the sensitivity analysis of RESTORATIVE.

Table 10 .
Results of the sensitivity analysis of RESTORATIVE.