Optimizing Heat Pump Operation of Residential Buildings Using Calibrated R-C and Deep Learning Models and Electricity Costs Forecasts

. The aim of this research is to improve the efficiency of energy systems using the mass of the building as thermal storage. We present a case study of a residential building, in which a detailed monitoring system was installed to measure, among other parameters, the electricity consumption, the indoor air quality, and the operation of the heating system, consisting on a Heat Pump (HP) and a radiant floor. Based on the data collected, both a lumped parameter model (R-C Model) and a Deep Learning (DL) Model have been calibrated to simulate the apartment analyzed. Both models provide a significantly accurate simulation of the apartment under real operating conditions. Then, using the simulation models, different operation scenarios have been analyzed. One of the scenarios considers the thermal inertia of the apartment and the electricity costs forecast to optimize the operation of the HP. Within this scenario, energy savings up to a 35.1%, and electricity costs savings up to a 47.3%, may be achieved during a winter season, when compared to the standardized operation of the HP.


Introduction
The Intergovernmental Panel on Climate Change (IPCC) has identified in its latest report [1] that buildings are one of the most important sectors with potential to reduce Greenhouse Gases (GHG).Buildings account for 40% of the energy consumed and 36% of energy-related Greenhouse Gas (GHG) emissions in the European Union (EU) [2].The Energy Performance of Buildings Directive Recast (EPBD) of 2018, [3], the European Green Deal [4] and the Renovation Wave Communication [5] have stablished a comprehensive framework to make the EU building stock more efficient and reduce the associated emissions.
The most effective actions to improve the efficiency and reduce GHG emissions in buildings point towards the electrification of the energy systems and the installation of on-site renewable energies.However, greater efforts are needed in order to achieve the 2030 Climate Target of reducing emissions by at least 55% compared to 1990.Another important aspect that must also be considered to improve the efficiency of buildings is the optimization of the control of the Heating, Ventilation and Air Conditioning (HVAC) systems.With more electrification, the flexibility of the technical systems of the buildings increases.For instance, in systems in which a Heat Pump (HP) is used to provide heating, the schedule may be adapted to the electricity costs or the weather forecast.Besides, the thermal inertia of the building may be considered as to storage thermal energy.In this sense, the Energy Storage Task 43 of the International Energy Agency (IEA ES Task 43) [6] is committed to analyze the storage for renewables and flexibility through standardized use of building mass.In any case, when the optimization of the control of HVAC systems is intended, an accurate control system to model the operation of the building is needed.
Within the literature, plenty of work of research can be found regarding the different modelling techniques used to control the HVAC systems in buildings, from white-box to blackbox models, including gray-box models [7], [8].Gray-box models are considered by the majority of researchers as the best comprise between simplicity (white-box) and accuracy (blackbox) [8].Lumped parameter models, such as R-C Models, have proven to be one of the best options to accurately characterize the real thermal behavior of buildings [9], and also adequately represent real-life occupied houses [10].These models of lumped parameters also make it possible to quantify the viability of real buildings as energy accumulators for the optimization and regulation of consumption control, at the user level, and production at the general grid level [11].
More recently, Artificial Intelligence (AI) models are also being considered as a suitable solution to control HVAC systems, taking into account the high level of monitoring data now available in buildings.In this sense, Deep Learning (DL) are currently being a disruptive methodology, revolutionizing various fields with its ability to automatically learn patterns and representations from data.Specifically, Long Short-Term Memory (LSTM) networks stand out as a remarkable architecture that captures short-term and long-term dependencies in sequential da-ta.This makes LSTM suitable for tasks involving temporal dynamics, such as time series prediction [12].In the realm of building energy management, DL has implications for optimizing heating systems, enhancing energy efficiency, and reducing operational costs [13].Also, the previously mentioned R-C models have also being identified as agile models to be used as a reference model for AI-based control systems [14].
In this research, we use a case-study building which has been monitored in detail since the last 3 years.The ENEDI Research Group of the University of the Basque Country and the Energy Technology Research Group (GTE) of the University of Vigo, are developing a project [15] which intends to analyze the use of the building mass as thermal storage to improve the efficiency of the renewable energy systems and reducing energy costs.In this research, we have calibrated an R-C Model and trained a DL Model, using detailed monitoring data, to simulate the operation of an apartment of the building.The heating system of the analyzed apartment consists of a HP with radiant floor.The models will consider the thermal inertia of the apartment since the measurements are being recorded under real operating conditions.Then, using these models, we have simulated three scenarios of operation of the energy systems of the apartment.One of the scenarios considers the thermal inertia of the apartment to optimize the energy costs.Finally, we compare the electricity consumption of the HP and the electricity costs, and discuss the characteristics of both R-C and DL Models for the intended purpose.

Materials
The case-study building is a small residential building located in the old town of the city of Vitoria-Gasteiz, in northern Spain.The building is divided in three floors, with an apartment in each of them.The apartment located in floor 0 (F0) is the one which has been chosen for this study.The building underwent a deep renovation in 2019, which included the insulation from the inside of the façade and the replacement of windows.Regarding the energy system, a high efficiency HP was installed to supply both heating and Domestic Hot Water (DHW).The heating system in the selected apartment consists of a radiant floor.Besides, mechanical ventilation with heat recovery was installed.Following Figure 1 shows a picture of the building, before and after the renovation process.A detailed monitoring system was installed coinciding with the renovation process.Following Figure 2 shows a scheme of the monitoring system available in the analyzed apartment.Indoor temperature, relative humidity and CO 2 concentration is being measured in each room of the dwelling.The temperature and volumetric flow of the ventilation system are also being monitored, as well as the inlet and outlet temperature and volumetric flow of the radiant floor system.All of the electricity consumptions are being measured, namely, the HP consumption, appliances consumption and lightning.The superficial temperature of the walls is also measured on the indoor side and external side, as well as the heat flux.Besides, a weather station was installed on the roof of the building, which measures outdoor temperature, relative humidity and CO 2 concentration.
The monitoring frequency is every minute, and has been operative since the renovation process in 2019.Thus, the size and quality of the monitoring sample is considerably significant, which will allow us to properly calibrate and model the dwelling using the proposed methodologies.Besides, the apartment has been occupied in all of the monitoring period, which implies that the monitoring data considers the real behavior of the dwelling.

Methodology
In this study, we have set two objectives, as summarized in following Figure 3.The first objective is to compare two different types of models of the dwelling, using the high quality monitoring data.One model is a calibrated concentration parameter model (R-C Model); the other models are trained Deep Learning (DL) models.In following sub-sections, we explain the calibration and training process of both models, and in Section 4.1, we compare the results obtained with each model.
The second objective of this research is to compare three different scenarios of operation of the heat pump, in order to minimize the electricity costs.To do this, we use the previously calibrated R-C Model and trained DL Models to simulate the real operation of the dwelling.In Section 3.3 we explain the conditions stablished for each scenario, and in Section 4.2 we compare the results obtained in each scenario, and discuss the pros and cons of the two models used.

R-C model
As explained before, one of the models used to simulate the operation of the apartment is a Lumped parameter model, specifically, an R-C Model.Following Figure 4

HP operation optimization and electricity costs analysis
representation of the R-C Model used to represent the dwelling.Different methodologies may be used to estimate the parameters, the conductivities (H x ) and capacitances (C x ) of the R-C Model.In this case, we have combined the Output Error Method (OEM) and the Prediction Error Method (PEM) to find the best comprise between agility and accuracy.The calibration has been performed using the monitoring data collected every 10 minutes during January 2022, that is to say, almost 4,000 data points.The solar radiation during the calibration month is not significant, due to the orientation and location of the apartment, thus this input has not been considered for the R-C Model, as depicted in Figure 4.One of the advantages of the R-C Models is that they allow to stablish at least three different objective functions.In this case, we have adjusted the model to meet the indoor air temperature (T i ), the internal wall surface temperature (T spi ) and the external wall surface temperature (T spi ).With this, the R-C Model accurately simulated the behavior of the apartment based not only in one parameter, but in three different nodal temperatures.Following Table 1 summarizes the nodal temperatures of the R-C Model, as well as the values of the conductivities and capacitances after the calibration process.As depicted from this Table, the highest conductivity is between the radiant floor water and the radiant floor (H 1 ), as expected.In addition, the highest capacitance, by far, is the one associated with the wall (C p ).The latter will be of vital importance to analyze the thermal inertia of the building in the simulated scenarios.Finally, using Matlab, we have developed three different control scripts to simulate the operation of the HP, to implement the operation scenarios, described later in Section 3.3.With the scripts, we control the operation of the HP.Specifically, we adjust the operation schedules of the HP and the heat provided by the radiant floor, in order to meet a specified indoor air temperature (T i ).The thermal power (Q) provided by the HP to the radiant floor, in Watts, is estimated using following Equation (1):

Deep Learning Model
The other simulation model used in this research are DL Models.In this case, two DL models were implemented: the first one predicts the interior temperature inside the building, and the second one estimates the heating consumption of the HP.To develop both models, a combination of LSTM and multi-layered perceptron (MLP) neural networks were used, so the thermal inertia of the building is considered [12].The thermal behavior of the building throughout the simulation period is performed by merging the heating and temperature predictions.This combination allows, in a first step, to predict the necessary thermal loads in the building.Once the thermal loads are recognized, the value is used as input to predict the interior temperature.
Thus, an iterative algorithm is carried out where the trained models simulate the dynamic heating behavior of the building.Following Figure 5 illustrates the described approach.

Data pre-processing
The input data to train the models should include the weather conditions and the building parameters that have a significant influence on the predicted variables.As the aim of the first DL model is to determinate the indoor temperature, the time of day, exterior temperature, electricity gains and heating consumption will be used as inputs.The second DL model predicts the heating consumption by using the time of day, electricity gains, indoor temperature, exterior temperature and the temperature difference between both temperatures.The variables were selected due to their inherent relationship with the variations in the output variable.
Even though the monitoring has been collecting data for the last three years, there are significant periods (weeks or months) that contain missing values.Those periods were directly removed from the dataset, as it cannot ensure the continuity in time required by DL models.
Before training the models, a data cleaning process is conducted to enhance the performance of pattern recognition by the models.The first step involves resampling the data from minute frequency to hourly.Then, the data is filtered to detect wrong measurements and outliers.The methodology used is based on the interquartile range: values outside the ranges given by Equation (2) and Equation (3) are not considered valid [16].
where "ub" and "lb" are the upper bound and lower bound, respectively, "Q3" and "Q1" are the third and the first quartile, and "IQR" is the interquartile range.
The detected outliers are set as missing values.In cases where missing data is into a period of three timesteps or less, then gap is interpolated.AI models are more accurate when the variables included have similar data ranges, so a scaling stage is needed.The building parameters and weather conditions are standardized by subtracting the standard deviation and dividing it by the mean.
Finally, the model is trained using data from the winters of 2021/2022 and 2022/2023, excluding January 2022, which is later used to test the model.By using cross-validation technique, 10% of the training data is used to test the performance of the models created.This allows contrasting the interdependence of the sets and ensuring the reliability of the model when new data is used.

Neural network
Two neural networks were developed: the first one for predicting the interior temperature and the second one to estimate the heating consumption.Both are composed by a combination of LSTM and MLP layers, where the number of each one depends on the specific case.LSTM, a variant of recurrent neural networks (RNNs), utilizes memory blocks capable of retaining information from previous time steps.These blocks effectively regulate the flow of information through three gates-forget gates, input gates, and output gates-enabling the retention or omission of information based on its relevance.
A genetic algorithm was used to determinate the hyper-parameters that better approximates the reality.Following Table 2 shows the architecture of each neural network:

DL Models performance evaluation
Two error metrics were used to compare the performance of the models: normalized mean bias error (nMBE), Equation (4), and normalized root mean squared error (nRMSE), Equation .
On the one hand, nMBE represents underestimation or overestimation of the data when positive and negative values are reached, respectively.On the other hand, the nRMSE measures the dispersion between the experimental and estimated values.

Analyzed scenarios
As explained before, the second objective of this research is to compare different scenarios of the operation of the HP.The base scenario (S0) represents the current situation of the dwelling.Nowadays, the tenants use the heating system to maintain the indoor temperature around 21.5 ºC throughout the winter.The first scenario (S1) represents a standardized schedule of the heating system during the heating season, according to the Spanish regulation CTE DB-HE [17].This standardized schedule consists of ensuring a minimum indoor temperature of 20 ºC between 07:00 hours and 22:59 hours, and 17 ºC the rest of the day.Finally, the second scenario (S2) is intended to optimize the operation of the heat pump by minimizing the electricity costs.To do this, we consider the electricity costs forecast of the next 24 hours.At the beginning of each day (00:00 hours), the control system finds the hour of the minimum cost of that specific day, and activates the HP at this time of the day.The HP heats the dwelling until the indoor temperature reaches 23 ºC.With this, we use the thermal inertia of the dwelling.During the rest of the day, the HP is also activated if the temperature falls below the limits of S1.Following Table 3 summarizes the schedules and set-points of the three scenarios analyzed.

Scenario Name of the scenario Description of the scenario S0
Base scenario Current operation of the dwelling, maintaining the indoor temperature around 21.5 ºC during all the winter.

S1
Standardized scenario Maintain the indoor temperature according to the CTE DB HE standard, which is, 20 ºC between 07:00h and 22:59h, and 17ºC the rest of the day.

S2
Inertial-Optimized scenario Optimized operation of the HP: increase the indoor temperature of the dwelling until 23ºC when the cost of the daily electricity is minimum.
The three scenarios have been simulated, both using the scripts in Matlab with the calibrated R-C Model, and using the DL Models, during four months of the winter, between November 2022 and February 2023.For all the scenarios, we have considered a constant COP of the HP of 3.5.

Comparison between R-C Model and DL Model
This first section shows the validation of the models developed for the temperature prediction.As explained before, the R-C Model uses three objective functions to estimate the lumped parameters (Indicated in previous Table 1).Following Figure 6 shows the predicted and measured values of the objective functions, namely, (a) the indoor air temperature (T i ), (b) the internal wall surface temperature (T spi ) and (c) the external wall surface temperature (T spi ).The average nRMSE of the three objective functions is 0.154 ºC.To test the DL Model, the indoor air temperature of the building is simulated knowing the building conditions in an untrained dataset, in this case January 2022.Figure 7 shows the predicted and measured indoor air temperature of the trained DL Model.It can be seen that the prediction is significantly positive.Indeed, the nRMSE obtained with the DL Model is 0.164 ºC, very similar to the error obtained with the R-C Model.Thus, we can affirm that both the R-C Model and the DL Model provide a significantly accurate simulation of the operation of the apartment under real conditions.The difference in the number of datapoint between Figure 6 and Figure 7 is because of the different timesteps used in each Model.As explained before, the averaged hourly indoor temperature was considered to train the DL Model, whereas the R-C Model uses the average indoor temperature every 10 minutes.

Heat pump operation scenarios
In this section, we present and compare the results of the energy consumption of the HP and electricity costs obtained when simulating the three proposed scenarios, explained in section 3.3.Following Figure 8 shows, in the upper part, the outdoor temperature and the indoor temperature of the dwelling in each of the three scenarios, as well as the lower and upper limits of the set-point temperatures, during a specific week of the winter.In the lower part of the figure, we represent the hourly electricity costs of that specific week and the thermal power (Equation 1) provided by the HP during the second scenario (S2).
As depicted from Figure 8, during the base scenario (S0, yellow line) the indoor temperature is stable around 21.5 ºC.In the first scenario (S1), the indoor temperature follows the standardized temperature set-points between 17 ºC and 20 ºC.At the beginning of the day, at 00:00 hours, the set-point indoor temperature is 17 ºC.At 07:00 hours, the set-point is stablished in 20 ºC, so the HP starts working and the dwelling is heated until the indoor temperature of 20 ºC is reached.The rest of the day, until 23:00 hours, if the temperature falls below 20 ºC, the HP is again activated.
In the second scenario (S2), the operation of the HP is optimized according to the electricity costs forecast.For instance, on Tuesday, 17 th of January of 2023, the lowest price of the electricity was scheduled at 02:00 hours.Thus, the control system activates the HP at that time (see green line in Figure 8) and keeps working until the indoor temperature reaches 23 ºC, around 06:00 hours in this specific day.Then, the HP is turned off, and the rest of the day the thermal inertia of the dwelling maintains the indoor temperature above the minimum set-point.Only at 21:00 hours, when the temperature falls below 20 ºC, the HP is again briefly activated to heat the dwelling.Another situation that may happen during the operation of the second scenario (S2) occurs on Saturday, 21 st of January 2023.On that day, the minimum electricity cost was scheduled at 15:00 hours.In this case, the HP is firstly activated at 07:00 hours to reach the minimum required indoor temperature of 20 ºC, and later is turned off around 10:00 hours, when that temperature is reached.Later, at 15:00 hours, when the minimum price of the electricity is scheduled, the HP is activated again and heats the dwelling until reaching 23 ºC.Unlike the other days of the week, since the dwelling is heated during the afternoon, the minimum indoor temperature is maintained until 07:00 of the next day.Following Table 4 summarizes the main results of each scenario, namely, the average indoor temperature, the electricity consumption of the HP and the electricity costs, during the analyzed winter, both for the R-C Model and the DL Model.From the results shown in Table 4 we can, in the first place, compare the results obtained with the R-C Model for the three scenarios.It can be depicted that the average indoor temperature during the winter is the same, 21.5 ºC, for the base scenario and the second scenario.On the contrary, the average indoor temperature during the first scenario is slightly lower, 19.5 ºC, because the set-point ranges between 17 ºC and 20 ºC.If we analyze the thermal energy provided the HP during the four months winter, it can be clearly seen that the second scenario considerably reduces the electricity consumption.Specifically, the thermal energy with S2 is a 44.7% lower than the S0, and a 35.1% lower than the S1.This significant reduction of the energy consumption of the HP is due to the use of the thermal inertia of the dwelling.Also, if we compare the electricity costs, we can see that the S2 implies a significant improvement since the costs are a 53.1% lower than in S0 and a 47.3% lower than in S1.In this case, the cost reduction is due to the control system, which uses the hours with the minimum electricity costs to heat the dwelling until 23 ºC.
Besides, we can compare the results obtained for the base scenario (S0) using the R-C Model and the DL Model.We can see that the average indoor temperature differs in only 0.2 ºC, and that the thermal energy obtained with the DL Model is an 8.9% lower than the electricity consumption obtained with the R-C Model.Consequently, the electricity costs obtained with the DL Model is also lower, specifically a 9.8% lower than the electricity costs obtained with the R-C Model.Thus, we can affirm that both the R-C Model and the DL Model lead to very similar results when simulating the operation of the dwelling in the base scenario.
However, as depicted in Table 4, the DL Model has not been able to simulate both the S1 and S2 scenarios.This is because of the range of the data used to train the model.The measured indoor temperature of the monitoring data is around 21.5 ºC during all the period used for the training.Thus, when the DL Model is forced to simulate scenarios far from the training conditions, the model saturates and is not capable of simulating the scenario.Following Figure 9 shows how, when asking the DL Model to turn on the HP and reach 23 ºC of indoor temperature, the model saturates and is not able to reach the set-point temperature.It get close, but never reaches the required 23 ºC.This may be solved by using synthetic training data, which covers the set-points of the S1 and S2 scenarios, but these are out of the scope of this first part of the research.

Conclusions
In this work, we have developed both a calibrated R-C Model and a trained Deep Learning (DL) Model of a residential apartment, using detailed monitoring data under real operating conditions.Then, we have used the models to simulate different control operation scenarios of the heating energy system of the apartment, which consists on a radiant floor powered by a Heat Pump (HP).The analyzed scenarios intend to compare the energy consumption and electricity costs between the current operation of the HP against an optimized operation of the system, considering the thermal inertia of the apartment and the electricity costs forecast.
Both the R-C Model and the DL Model have shown significantly accurate adjustments to simulate the apartment under real operating conditions.The normalized Root Mean Squared Error (nRMSE) between the predicted indoor temperature and the measured indoor temperature has resulted in 0.154 ºC and 0.164 ºC, for the R-C Model and the DL Model, respectively.In this sense, the DL Model presents the advantage of being a methodology with a higher level of automation.On the contrary, the R-C Model is more suitable to perform studies of optimization of the thermal characteristics of the dwelling, namely, conductivities and capacitances.
Regarding the analyzed control operation scenarios, it has been proven that, if the control of the HP system is optimized considering the thermal inertia of the apartment and the electricity costs forecast, significant savings may be achieved.In the inertial-optimized scenario (S2), the HP has been scheduled to heat the apartment until 23 ºC when the minimum daily electricity price occurs.With this operation, energy savings up to a 35.1%, and electricity costs savings up to a 47.3% may be achieved, when compared to the standardized scenario (S1), during a winter season.
The inertial-optimized scenario has been simulated using the calibrated R-C Model.DL Models are, a priori, unable to simulate scenarios ranged out of the training conditions.However, R-C Models may be a useful tool to generate synthetic training data to feed the DL Model.This will be one of the future lines of work of this research.Also, other future works will consider the inclusion of the weather forecast and the variability of the Coefficient of Performance (COP) of the HP within the inertial-optimized scenarios.

Figure 1 .
Figure 1.(a) Picture of the case-study building before the renovation and (b) after the renovation.

Figure 2 .
Figure 2. Layout of the Floor 0 apartment and schematic representation of the sensors of the monitoring system.

Figure 3 .
Figure 3. Schematic representation of methodology and objectives of the research.

Figure 4 .
Figure 4. Schematic representation of the R-C Model of the apartment.

Figure 5 .
Figure 5. Schematic representation of the DL Model implemented for the simulation.

Figure 6 .
Figure 6.Results of the predicted and measured objective functions (temperatures) of the calibrated R-C Model.

Figure 7 .
Figure 7. Results of the predicted and measured indoor air temperature of the trained DL Model.

Figure 8 .
Figure 8. Results of the indoor temperature in S0, S1 and S2 scenarios, and electricity consumption in S2 scenario, during a week of the winter period analyzed.

Figure 9 .
Figure 9. Saturation of the DL Model when simulating the second scenario (S2).

Table 1 .
Nodal temperatures and parameters of the calibrated R-C Model.

Table 2 .
Architecture of each neural network.

Table 4 .
Summary results of the indoor temperature, electricity consumption and electricity costs, in the three scenarios analyzed, with the R-C Model and the DL Model.