CET-vol 105 DOI: 10.3303/CET23105003 Paper Received: 18 February 2023; Revised: 7 May 2023; Accepted: 28 September 2023 Please cite this article as: Maestre V.M., Ortiz A., Ortiz I., Rodríguez De Lope L., Diez L., Aguero R., 2023, Digitalizing an Electrically Self- Sufficient Social Dwelling of Spain, Chemical Engineering Transactions, 105, 13-18 DOI:10.3303/CET23105003 CHEMICAL ENGINEERING TRANSACTIONS VOL. 105, 2023 A publication of The Italian Association of Chemical Engineering Online at www.cetjournal.it Guest Editors: David Bogle, Flavio Manenti, Piero Salatino Copyright © 2023, AIDIC Servizi S.r.l. ISBN 979-12-81206-04-5; ISSN 2283-9216 Digitalizing an Electrically Self-Sufficient Social Dwelling of Spain Víctor M. Maestrea, Alfredo Ortiza, Inmaculada Ortiza,*, Laura Rodríguez de Lopeb, Luis Diezb, Ramón Agüerob a Chemical and Biomolecular Engineering Department, Universidad de Cantabria, Av. Los Castros 46, 39005, Santander, Spain. b Communications Engineering Department, Universidad de Cantabria, Av. Los Castros 46, 39005, Santander, Spain. ortizi@unican.es The urgent climate situation resulting from the indiscriminate consumption of fossil fuels together with the current geopolitical instability has prompted a series of policies in Europe to boost the energy transition through the large-scale installation of renewable energy sources (RES). To combat the intermittency and fluctuations associated with their operation, renewable hydrogen is presented as a versatile solution to decarbonize different economic sectors. Hence, the design and implementation of a hybrid renewable-hydrogen power system has turn out in the first electrically self-sufficient social housing of Spain installed in the town of Novales (Cantabria, Spain). The entire process is automated and controlled by a programmable logic controller (PLC) and monitored by a SCADA system. Under this framework, the HY2RES project proposes a digital twin (DT) modeling of the pilot plant to optimize the control system and the operating parameters thanks to the application of machine learning (ML) and artificial intelligence (AI) techniques to the data collected. The paper shows some initial results of the proposed DT, which features the electrical components of the physical system. The obtained results both validate the proposed methodology and evince the possibilities brought by it. 1. Introduction Since the Conference of the Parties (COP) 21 in Paris in 2015 (United Nations 2015), different governmental bodies around the world, international companies and agencies, as well as different stakeholders have promoted a series of roadmaps and strategies to limit the harmful effects caused by climate change. Thus, the dependence of today's society on fossil fuels is the main factor responsible for the global climate situation. In particular, energy-related activities contribute to more than three quarters of total carbon dioxide equivalent (CO2eq) emissions (IEA 2020; Ritchie and Roser 2020). Global primary energy consumption in 2021 rebounded after the COVID-19 pandemic to 595 exajoules (EJ), a growth of 1.8% over 2019 (bp, 2022). In this context, the European Union has approved the "Fit for 55" plan that includes limiting greenhouse gas (GHG) emissions by 55% by 2030. On the other hand, the current geopolitical instability resulting from the war between Ukraine and the Russian Federation has caused an unprecedented inflation of the economy and a shortage of fossil fuels (mainly natural gas and oil) imported from Russia (European Council, 2023). Given this situation, the large-scale deployment of renewable energy sources (RES) is essential to ensure a decarbonized energy system, in addition to encouraging energy independence through these efficient and sustainable solutions to reduce fossil fuel exports. However, it is essential to find efficient technological solutions for energy storage that respond quickly, safely and flexibly to the intermittent and fluctuating behavior of RES. For this reason, the European Commission approved the REPowerEU plan for 2022; with this, the EU seeks to promote Europe's energy independence through RES, increased energy efficiency and the hydrogen economy. Hence, the use of hydrogen as energy vector and commodity is an efficient and sustainable solution for large- scale and seasonal energy storage without degradation to boost RES penetration in the energy mix and decarbonize different energy-related sectors (European Council, 2022). 13 mailto:ortizi@unican.es In this sense, the residential and building sector is a massive energy consumer in the EU, contributing to 40% of the final energy consumption and being highly inefficient due to its aging, which negatively contributes to the carbon footprint of this sector. Furthermore, the unprecedented economy inflation has aggravated the situation of most vulnerable citizens, leading them to energy poverty. Therefore, it is fundamental to improve the energy performance of the residential and building sector to abate its contribution to the climate change and to cheapen the electricity bills that are deteriorating the quality standards of the population (Maestre et al., 2022). Hence, the design and implementation of a hybrid renewable-hydrogen power system has turned out in the first electrically self-sufficient social housing of Spain installed in the town of Novales (Cantabria, Spain) in the framework of the European project SUDOE ENERGY PUSH (Maestre et al., 2022). To further develop and optimize the operation of the renewable hydrogen-based system (RHS), a digital twin (DT) modelling of the pilot plant has been proposed under the HY2RES project. The concept of DT was originally proposed at the beginning of the century (Grieves, 2014) for industrial environments, and recently applied to different sectors (Tao et al., 2019) leveraging the digitalization and higher capabilities of communication and computation systems. Thus, through the application of machine learning (ML) and artificial intelligence (AI) techniques to the data collected, the main objective is the enhancement of the RHS performance under different dynamic circumstances. This type of system and methodologies has been proposed in the literature for the energy sector (Nguyen et al., 2021), and for the particular case of residential environments (Agostinelli et al., 2021). In this work, the overarching methodology of the project and DT modelling strategy are presented, along with some preliminary results. 2. Methodology The RHS designed and deployed in the framework of the SUDOE ENERGY PUSH proposal combines both renewable energies and novel hydrogen technologies to ensure the complete electricity self-sufficiency of a social dwelling over the year. Thus, the photovoltaic (PV) panels installed on the roof of the building harvest solar energy to be used in the dwelling as primary energy. Then, if PV panels generate excess energy, it is firstly accumulated in a lithium-ion battery pack for short-term energy storage and, subsequently, employed for hydrogen generation, compression and storage for seasonal energy saving. During periods of PV energy scarcity or at night, batteries initially supply electricity to the load and then, they are charged by means of a fuel cell that finally covers the demand of the home. Figure 1 presents a schematic overview of the pilot plant and electricity and hydrogen flows within the system. Figure 1: Schematic diagram of the hybrid RHS deployed in Novales (Cantabria, Spain). The pilot plant has been completely automated and controlled remotely thanks to the aid of a programmable logic controller (PLC). Furthermore, the RHS is operated under an energy management strategy based on the status of the stored autonomy and it is monitored in a supervisory control and data acquisition (SCADA) system. Under this framework, the HY2RES project proposes a digital twin (DT) modeling of the pilot plant to optimize 14 the control system and the operating parameters thanks to the application of machine learning (ML) and artificial intelligence (AI) techniques to the data collected. To develop the DT, the HY2RES project proposes an architecture that embraces three main components. The first one is devoted to the physical-virtual interaction, to gather information from the real system, and to send back decision policies. On top of it, the architecture includes elements for data management, and integrates external data sources, such as weather forecast. Leveraging the aforementioned modules, the DT is implemented by a set of software libraries that replicate the behaviour of the real system. In this sense, once the input/output and control variables of the main components of the RES system are identified, we will tackle their modeling. This includes algorithmic solutions when the underlying behaviour is well known, and ML techniques otherwise. Eventually, the HY2RES project will exploit the DT to assess the performance of various control policies over the digital replica, including those based on weather forecast. In addition, it will also allow a “what if” analysis of the system under different circumstances for a given policy. Figure 2 graphically depicts the HY2RES project scope and underlying structure. Figure 2: Scope and structure of HY2RES project. 3. DT Modelling The DT is composed of software modules, each of them emulating the behaviour of one or more physical components. These modules, or blocks, are characterized by a set of control, input and output variables. Input and output variables correspond to physical magnitudes, while control variables mimic decision signals, such as those sent by the PLC. This way, when certain control and input variables are applied, the module generates output variables, replicating its physical counterpart. The different modules are connected so that the output variables of a module might act as inputs for others. In fact, some signals are fed back into the system, like the battery State of Charge (SOC). Figure 3 depicts the modules that we have identified so far, along with the variables currently considered. Among them, we differentiate between controlled and external ones. The former, are modelled by the DT, since their values depend on the control system. On the other hand, the latter are independent of the control system. As can be observed in the figure, we are currently using the power demand and PV power supply as external variables, and others will be integrated in the next stages of implementation. The main module mimics the PLC, since it integrates the management logic of the system. This module will implement the optimized control algorithms, so as to be validated before applying them to the real system. Besides, the PLC module is fed with the power demand and PV power generation, as well as with variables that bear the state of all the components: state of charge of batteries (SOC) and hydrogen storage systems ’ pressure. Finally, different external data sources, such as weather forecast, will be integrated by means of additional input variables. Using the input variables, the PLC model generates control signals to manage the system as follows. In case of excess of energy from the PV panels, e.g. once the home demand has been satisfied, this surplus is distributed into the storage systems following the energy management strategy or exported to the grid. This boils down to sending it first to the battery, and later to the hydrogen (H2) storage chain through the electrolyzer. In turn, the hydrogen is first kept at a buffer, and then compressed in a H2 tank. Otherwise, if there is a lack of energy to cover the home demand, it will be either obtained from the storage system or imported from the grid. When using the storage system, the battery is used first, and when this is not enough, the fuel cell starts working, LCA Ex te rn al Da ta HY2REs prototype -Modeling, design, -Installation -Operation T2.2 DT Model & Control System - ML/AI techniques - Control Optimization T3.2 Legal Energy Framework T2.1 Data management - DMP enforcement - Data modeling T3.3 DT Design & Implementation - Storage, processing - Communication - Access to External data T3.1 Control policies Raw Data Processed Data Optimization Goals D ata M o d els D ata Sh arin g T2.3 Climate Conditions Solar Radiation House Electrical Load Electricity grid fees Real-time or short term predictionsAverage or long term predictions O ptim ized H Y2REs Prototype 15 consuming hydrogen, first from the buffer and later from the compressed hydrogen tank. The particular control algorithm will determine the threshold and corresponding policies to decide one of the available options. The inverter module takes the on/off signals generated from the PLC, plus the external variables, to distribute the energy to the different storage modules as has been described. Then, the battery module uses the charge, or discharged energy, to update the SOC, which can be in turn used by the PLC. The electrolyzer module models the H2 flow and generates input variables to the storage modules. Other variables, such as environmental temperature will be also considered to model the behavior of this block. In parallel, the on/off compressor variable from the PLC determines whether the H2 flow must be stored in the buffer or in the compressed H2 tank. The pressures of both buffer and compressed H2 tank are fed back to the PLC to aid the decision making process. Figure 3: DT modules and variables. In the figure, dotted and solid lines represent control and input/output variables respectively. From an implementation perspective, the DT modules are being developed in Python, as independent classes with well defined interfaces. This will permit us to modify the different module models to perform a ‘what if’ analysis. 4. Results In the initial stage of the HY2RES project, the implementation has focused on the modules of the electrical components, namely PLC, inverter and battery. In this stage, the modelling has followed an algorithmic approach, which uses the logical operation of the system and the physical equations that govern its behavior. Other data driven approaches will be adopted in subsequent phases, according to the observed prediction accuracy. In order to validate their correct modeling, this section presents an analysis of the outcome of the mentioned components, focusing on the interaction between inverter and battery. In the case of the inverter, the analysis considers the power supplied/consumed to/from the battery (variable Battery Pw in Figure 3) when the input signals to the model are the generated PV power, the home power demand and the PLC estimated signals. For the battery, the SOC output is assessed by means of its charge/discharge power, which is used as an input signal for the model. In all cases, samples from the physical system are taken every 5 seconds during a period of 2 weeks, and one estimate is generated for every sample. Figure 4 shows the instantaneous evolution of the discharge power from the battery during 5 days. In the shaded background we represent the difference between the two input variables, PV power supply and home load, whose scale is indicated in the right axis. Blue and orange dots represent the real and estimated values of the battery discharge, respectively. A closer view is illustrated in Figure 5a, where the high similarity between the proposed model estimations (orange) and real measurements (blue) is clearly observed. 16 Figure 4. Instantaneous evolution of the discharge power. Real (blue) and estimated (orange) values are shown. Figure 5b shows the relationship between the measured and estimated values during the whole measurement period. We plot the values obtained with the DT, and we also represent the ideal behavior with an orange line, where estimate and real samples are alike. As can be observed, the model is able to mimic the real behavior in most of the cases, although there is some mismatch where the model yields values in the whole range, while the measurement system indicates that there is no discharge whatsoever. This behavior might be caused by gaps in the monitoring process for some time intervals. To numerically measure the corresponding deviation, the Normalized Root Mean Squared Error (NRMSE) has been calculated based on the battery discharge power estimations, yielding a NRMSE of 0.0588. a) b) Figure 5. a) Detail of power discharge time evolution b) Battery load: real vs estimated Figure 6 shows the temporal evolution of the measured and predicted battery SOC, with blue and orange lines, respectively. To better illustrate the observed behavior, the input variables of the proposed battery model, input/output power from the inverter, are represented with the shaded background. As can be seen, both real and predicted variables follow the same trend. In a closer look, it can be seen that the model performs quite well at medium SOC values, while at high and low SOC values the difference is more relevant. In this case, the NRMSE obtained from the whole measurement period 0.0864. Figure 6. SOC real (blue) and estimated (orange) vs battery charged/discharged power (grey). 17 5. Conclusions This paper presents the initial steps in the design and development of a DT implementation for a hybrid renewable-hydrogen power system, which is installed in a housing in the town of Novales (Spain). The DT, which is structured in functional modules that emulate the physical components, uses as input variables the housing load and the energy generated by the PV panels, while it predicts the rest of the variables. The results obtained for the initial DT models, which feature the electrical components of the physical system, show a rather good match between the values monitored in the physical system and those obtained with the proposed DT model, with quite low NRMSE. In our future work, we will extend the DT functionality implementing the different components both as independent software modules, which will be connected by means of the appropriate variables. Moreover, alternatives based on ML will be analysed whenever the main cause for the prediction mismatch is not clear, as was the case of the SOC extreme values. Nomenclature AI - Artificial Intelligence NRMSE - Normalized Root Mean Squared Error CO2eq - Carbon dioxide equivalent PLC - Programmable Logic Controller COP - Conference of the Parties PV - Photovoltaic DT - Digital Twin RES - Renewable Energy Sources EJ - Exajoules RHS - Renewable Hydrogen-based System GHG - Greenhouse Gases SCADA - Supervisory Control and Data Acquisition ML - Machine Learning SOC - State of Charge Acknowledgments This research is being supported by projects TED2021-129951B-C21, TED2021-129951B-C22 and PLEC2021- 007718 financed by MCIN/AEI/10.13039/501100011033 and European Union Next GenerationEU/RTRP. The authors also acknowledge the project PID2021-123120OB-I00 funded by MCIN/AEI/10.13039/501100011033/ FEDER, UE. References Agostinelli S., Cumo F., Guidi G., and Tomazzol C., 2021. “Cyber-Physical Systems Improving Building Energy Management: Digital Twin and Artificial Intelligence”. Energies 2021, 14, 2338. bp. 2022. Statistical Review of World Energy 2022. European Council. 2022. “REPowerEU: Affordable, Secure and Sustainable Energy for Europe.” (https://commission.europa.eu/strategy-and-policy/priorities-2019-2024/european-green-deal/repowereu- affordable-secure-and-sustainable-energy-europe_en) accessed 13.03.2023. European Council. 2023. “Fit for 55 - The EU’s Plan for a Green Transition.” (https://www.consilium.europa.eu/en/policies/green-deal/fit-for-55-the-eu-plan-for-a-green-transition/) accessed 07.03.2023. Grieves. M., 2014. "Digital twin: manufacturing excellence through virtual factory replication." White paper 1, pp. 1-7 IEA. 2020. CO2 EMISSIONS FROM FUEL COMBUSTION 2020 EDITION DATABASE DOCUMENTATION. Maestre V.M., Ortiz A., and Ortiz I., 2022. “Transition to a Low-Carbon Building Stock . Techno-Economic and Spatial Optimization of Renewables ‑ Hydrogen Strategies in Spain.” Journal of Energy Storage 56(PA):105889. Maestre V.M., Ortiz A., and Ortiz I., 2022. “Implementation and Digitalization of a Renewable Hydrogen- Based Power System for Social Housing Decarbonization.” Chemical Engineering Transactions 96(November 2021):223–28. Nguyen S., Abdelhakim M. and Kerestes R., 2021. "Survey Paper of Digital Twins and their Integration into Electric Power Systems," 2021 IEEE Power & Energy Society General Meeting (PESGM), Washington, DC, USA, pp. 01-05. Ritchie, Hannah and Max Roser. 2020. “CO₂ and Greenhouse Gas Emissions.” Our World in Data. (https://ourworldindata.org/co2-and-other-greenhouse-gas-emissions) accessed 15.03.2023 Tao F., Zhang H., Liu A. and Nee. A. Y. C., 2019. "Digital Twin in Industry: State-of-the-Art," in IEEE Transactions on Industrial Informatics, vol. 15, no. 4, pp. 2405-2415. United Nations. 2015. Adoption of the Paris Agreement. 18 118maestre.pdf Digitalizing an Electrically Self-Sufficient Social Dwelling of Spain