Development of an AI Model Utilizing Buildings’ Thermal Mass to Optimize Heating Energy and Indoor Temperature in a Historical Building Located in a Cold Climate

: Historical buildings account for a significant portion of the energy use of today’s building stock, and there are usually limited energy saving measures that can be applied due to antiquarian and esthetic restrictions. The purpose of this case study is to evaluate the use of the building structure of a historical stone building as a heating battery, i


Introduction
At present, approximately 25% of the buildings within the European Union are historic buildings [1] and 75% of the total building stock is characterized by energy inefficiency [2].Space heating accounts for approximately 68% of the total energy use in residential buildings in Europe [3], and the Council and the European Parliament have reached a political agreement on stronger emission reduction targets for member states in different sections, including the building sector [4].In an ambitious launch of a program for reducing greenhouse gas (GHG) emissions, the European Commission decided to promote the Green Deal [5], which encompasses the energy renovation of buildings that have poor energy performance.At the same time, historic buildings have poor energy performance and, simultaneously, need indoor thermal comfort [6][7][8], but local, regional and national regulations may prohibit energy efficiency measures that intrude on the appearance, proportions or expressions of the building.
The potential for enhancing the energy efficiency of cultural heritage buildings is constrained by preservation issues within building regulations.Typically, the structures of historic buildings consist of massive constructions composed of materials with high heat capacity and thermal conductivity [9].This characteristic presents opportunities for substantial energy storage, minimizing variations in internal temperatures over time [10,11].However, the impact that heat capacity (thermal mass) has on thermal inertia is also influenced by the building's heat loss coefficient, made up of the insulating level, the air tightness of the building envelope (often poor), and the extent of ventilation, often assumed to be high during the winter season.The thermal time constant (inertia) of a building, estimated by dividing the thermal mass by the overall heat loss coefficient, could be considerable in older buildings.This characteristic affects their responsiveness to temperature changes in the outdoor climate and the question of how to supply space heating.
Buildings contribute to approximately 22% of Sweden's greenhouse gas emissions.With a national goal of achieving zero net emissions by 2045, there is a pressing need to reduce the energy and heat demand of buildings.District heating (DH) plays a significant role, supplying around 50% of total heating for all building types in Sweden, with a share exceeding 90% for multifamily buildings and 78% of the tertiary sector's buildings [12].Moreover, district heating is derived from sources such as waste heat from industry, geothermal heat, and combined heat and power (CHP) plants burning biofuels and/or municipal solid waste incineration.The associated greenhouse gas emissions, on a national average, stand on average at approximately 51.4 g CO 2 eq/kWh [13].Despite these advancements, there are challenges, particularly during peak hours, where fossil fuels might still be utilized to meet district heating network demands [14].
Energy storage can improve the flexibility in a district heating network, which is even more important when variable renewable energy sources and/or waste heat are added to the grid.One important source of energy storage is the thermal mass of the buildings as well as large storage units (thermal batteries such as water tanks) or even electrical batteries in the electricity grid.Vandermeulen et al. [15] reviewed different control strategies quantifying the network flexibility.According to the study, flexibility in a thermal network such as district heating is defined by the ability to delay or speed up the extraction or injection of thermal energy from or into a thermal network system.The fundamental requirement is to store energy in the thermal capacity of the system, maintained by its thermal inertia; for instance, thermal inertia enclosed within the building envelope.However, the capacity of this inertia is limited and therefore limits the storage capacity for shorter periods of time, i.e., for intra-day flexibility.Building inertia can also be used in coordination with the electricity generation system, playing a crucial role in demand response control.This approach addresses intermittency by modifying heating demand, either aligning it away from or toward periods characterized by shortages or surpluses of renewable energy sources, respectively.Numerous studies have highlighted the potential for the flexible utilization of building inertia in this context [16,17].
Additionally, Reynders [18] conducted a study examining the impact of design parameters on structural thermal storage for active demand response in residential buildings.His findings demonstrated that the cautious utilization of heat storage can reduce peak loads and decrease greenhouse gas emissions.Kensby et al. [19] studied the building time constant as a characteristic of thermal inertia and short-term storage capacity in DH-connected buildings.Considering a varying building thermal time constant instead of a mean value, they highlighted the resilience of heavy concrete buildings to fluctuations in delivered DH, minimizing impacts on indoor temperature and thermal comfort.
Storing heat during periods of lower demand and preceding colder outdoor intervals serves as a strategy for load management and sustainable energy supply planning.Consequently, the heat supply to the building can be temporarily decreased during peak power periods, allowing the utilization of stored thermal energy within the building's structures.Hayati et al. investigated the indoor temperature decay under the influence of the reduced delivery of heating power to a multifamily building, with a focus on calculating the heating storage capacity and thermal inertia [20].In the conducted decay test, the estimated energy supply reduction was 61% over 5 h, resulting in a minimal temperature decrease of only 0.3 • C.
Older buildings can act as large heating batteries capable of storing and later releasing energy when outdoor temperatures drop.The efficiency of this energy storage relies on factors such as the building's size, internal thermal mass, heat loss coefficient, and the degree of allowable indoor temperature fluctuations.According to studies conducted [21][22][23], Maintaining a delicate balance between preserving the historical authenticity and incorporating energy efficiency measures is crucial.By coordinating modern technology with commitment to energy efficiency targets whilst preserving history, we can guarantee that historic buildings endure as symbols of our cultural heritage, and simultaneously play a role in fostering a more sustainable future in view of energy efficiency.Ultimately, this is a non-intrusive energy efficiency measure in listed buildings that aims to transform the building into a heating battery, by utilizing energy within the existing structures without any physical alterations.Utilizing Artificial Intelligence and machine learning models, the heat supply is strategically regulated based on weather forecasts and a binary calendarization on occupancy.This approach allows for the optimization of energy consumption and power demand while maintaining comfortable indoor temperatures.Furthermore, the technique permits a temporary reduction in heating without compromising thermal comfort within the premises.
The project assesses the potential for enhancing thermal comfort, energy efficiency and peak shaving in delivered heating power in historical buildings through the development of an AI model.The proposed AI model can predict the DH demand in advance based on inputs of the weather forecasts, binary calendarization on occupancy, and learnt patterns of internal loads and heat storage in the building structures and control of heating, ventilation, and air conditioning (HVAC) systems' operation and performance.The proposed AI model has three main features, and utilization can be chosen in view of these and their combination through weighting factors:

•
Optimal power (peak shaving of the DH supply).

The Case Study
The subject of this case study is the City Hall (coordinates: 60.6749 • N, 17.1413 • E), located in the city of Gävle in mid-Sweden.The annual mean temperature is 5.5  C in summer.The building represents a classic heavyweight historic office structure encompassing three floors (incorporating 66 spaces), a basement, and an attic.The total usable floor area is 2100 m 2 [7, 33,34].It features robust brick construction and tall double-glazed windows with wooden frames.The average floor-to-ceiling height is approximately 4 m, with open offices and seminar rooms having slightly higher ceilings, at around 5 m.The building's longer facades face northwest and southeast, while the shorter ones have northeast and southwest orientations.See Figure 1 for an illustration of the building.Thermostats in office rooms regulate the air flow provided by the air handling units (AHUs) with energy recovery, and the supply air is conditioned (depending on season) between 15 and 25 • C. The air change rate maximum is 1.3 air change rate per hour and ventilation is on during working hours (h 06:00-18:00), and otherwise off.The zones are heated by hydronic radiators that are equipped with return-valve thermostats.The temperature of the circulating radiator water increases as the outdoor temperature declines according to a pre-set heating curve.Alterations to the building's envelope, particularly any modifications to its external appearance, are restricted due to the building's cultural and historic heritage.
The data for indoor temperature, delivered DH, and supply water temperature were collected from the building management system (BMS), Schneider model ZS101 [35].In the year 2021, the building energy use included 111 kWh/m 2 DH and 37 kWh/m 2 electricity.Air indoor temperature profiles were computed utilizing the recorded air temperatures from zones on the BMS and were derived from the floor area average values across the measured period.The weather data, including outdoor temperature, were accessed from the Swedish Meteorological and Hydrological Institute (SMHI) [36], and are measured by a weather station in the vicinity of the city.
Buildings 2024, 14, x FOR PEER REVIEW 5 of 28 from the Swedish Meteorological and Hydrological Institute (SMHI) [36], and are measured by a weather station in the vicinity of the city.In the local DH network, the energy carrier (hot water) is heated by using the excess heat produced in a CHP plant and/or the waste heat from industry.DH is distributed to customers such as residential buildings, offices, schools, etc., via the so-called primary piping network.Each DH central unit encompasses a heat exchanger that transfers heat from the primary side to the secondary side in the building, to fulfill the demand for both domestic hot water and space heating [20].The focus in this study is the delivered or supplied DH for space heating.In each DH central, there is a Digitalized DH Central Unit (DUC) by which the temperature of the delivered DH is controlled and measured.The DUC, installed on the primary side, regulates the heat exchange process, which is governed by outdoor temperature sensing.

The Calculation Procedure and Development of the AI Model
With regard to DH, which is the focus of this study, via the DUC system, the entire heat supply in each DH center is controlled by regulating the supply temperature of the heating system.Moreover, the energy and power supply, as well as indoor temperature, are monitored and registered in real time centrally by the BMS.
To be able to develop and train AI models, a well-structured (almost one and half year) data history of the City Hall was collated, as below: 1. Delivered hourly DH power in kWh/h for the whole building-space and domestic hot water heating combined.2. Indoor zonal temperature in °C (floor-area-weighted for the entire building and hourly averaged value).3. Water temperature in °C, supplied to the radiators and air pre-heating (hourly averaged value).4. Hourly outdoor temperature in °C.
We developed a Convolutional Neural Network (CNN) deep learning model [37] to train models based on the collected data.In this study, the focus was on optimizing the DH supply values to maintain a comfortable indoor temperature for a specific building.The goal was to identify a sequence of supply temperature values that minimizes delivered energy (in terms of DH) with low peaks while ensuring that the indoor temperature remains within a specified range (e.g., above 21 °C) for the next 48 h.The approach is depicted in Figure 2 and involves three key components: a generative model (conditional variation auto-encoder), a dynamic model (prediction model), and an optimizer.Briefly (but described further below), the generative model generates diverse sequences of supply temperature values, considering past data.The prediction model forecasts indoor In the local DH network, the energy carrier (hot water) is heated by using the excess heat produced in a CHP plant and/or the waste heat from industry.DH is distributed to customers such as residential buildings, offices, schools, etc., via the so-called primary piping network.Each DH central unit encompasses a heat exchanger that transfers heat from the primary side to the secondary side in the building, to fulfill the demand for both domestic hot water and space heating [20].The focus in this study is the delivered or supplied DH for space heating.In each DH central, there is a Digitalized DH Central Unit (DUC) by which the temperature of the delivered DH is controlled and measured.The DUC, installed on the primary side, regulates the heat exchange process, which is governed by outdoor temperature sensing.

The Calculation Procedure and Development of the AI Model
With regard to DH, which is the focus of this study, via the DUC system, the entire heat supply in each DH center is controlled by regulating the supply temperature of the heating system.Moreover, the energy and power supply, as well as indoor temperature, are monitored and registered in real time centrally by the BMS.
To be able to develop and train AI models, a well-structured (almost one and half year) data history of the City Hall was collated, as below: 1.
Delivered hourly DH power in kWh/h for the whole building-space and domestic hot water heating combined.

2.
Indoor zonal temperature in • C (floor-area-weighted for the entire building and hourly averaged value).

3.
Water temperature in • C, supplied to the radiators and air pre-heating (hourly averaged value).

4.
Hourly outdoor temperature in • C.
We developed a Convolutional Neural Network (CNN) deep learning model [37] to train models based on the collected data.In this study, the focus was on optimizing the DH supply values to maintain a comfortable indoor temperature for a specific building.The goal was to identify a sequence of supply temperature values that minimizes delivered energy (in terms of DH) with low peaks while ensuring that the indoor temperature remains within a specified range (e.g., above 21 • C) for the next 48 h.The approach is depicted in Figure 2 and involves three key components: a generative model (conditional variation auto-encoder), a dynamic model (prediction model), and an optimizer.Briefly (but described further below), the generative model generates diverse sequences of supply temperature values, considering past data.The prediction model forecasts indoor temperatures based on various inputs, including supply temperatures and forecasted outdoor temperatures.Finally, the optimizer utilizes the generated sequence to find the optimal supply temperature values, ensuring efficient district heating control for enhanced comfort and energy optimization.As mentioned in the aims of the study, the proposed AI model has different features, and DH prediction can be chosen based on prioritizing (or choosing optimal) thermal comfort, delivered energy, and/or power.By implementing priority weighting factors, the 48 h predictions are calculated in terms of the three different features: optimal thermal comfort, optimal energy (minimizing the DH supply), and optimal power (peak shaving of DH supply).These priority-weighting factors are entered by the facility manager.
mal supply temperature values, ensuring efficient district heating control for enhanced comfort and energy optimization.As mentioned in the aims of the study, the proposed AI model has different features, and DH prediction can be chosen based on prioritizing (or choosing optimal) thermal comfort, delivered energy, and/or power.By implementing priority weighting factors, the 48 h predictions are calculated in terms of the three different features: optimal thermal comfort, optimal energy (minimizing the DH supply), and optimal power (peak shaving of DH supply).These priority-weighting factors are entered by the facility manager.
Moreover, we developed a baseline linear model for the sake of comparison, which was based on a strict linear heat curve from the BMS.This linear model resembles the control strategy which is utilized today, where supply temperatures linearly increase as outdoor temperatures decrease.In general, the flow of data, in conjunction with Figure 2, is an iterative process: Here, weights can be adjusted to prioritize thermal comfort, energy efficiency, and/or peak power shaving.4. The solution with minimum cost is chosen based on output from the optimizer.
In the next sections, the three key components are further described.

Prediction Model
The prediction model takes in the building's past indoor and outdoor temperatures and delivered DH, in this case for the past week on an hourly basis, as illustrated in Figure 3 (pertaining to one CNN model in the ensemble).Also, it accounts for the forecasted outdoor temperature and occupant presence by an hourly Boolean vector (calendarization), and a planned (optimized) supply temperature for, in this case, chosen 48 h prediction.The output of the model is the predicted indoor temperature and delivered district heating for the next hour.The model has several constraints and limits assigned for the building's heating system: for the indoor temperature set points, these are 21 °C during Moreover, we developed a baseline linear model for the sake of comparison, which was based on a strict linear heat curve from the BMS.This linear model resembles the control strategy which is utilized today, where supply temperatures linearly increase as outdoor temperatures decrease.
In general, the flow of data, in conjunction with Figure 2, is an iterative process: 1.
Sequences of supply temperatures (in this case, 1000 sets) are suggested by the generative model, on the basis of patterns learned on training data.

2.
Related predictions (based on each solution), given future outdoor temperatures and calendarized occupancy, are made by an ensemble of CNN models, where each CNN has been trained with different objectives.

3.
Related cost values (based on each prediction) are determined in terms of fulfilment of the objective function, and are quantified by the optimizer by alternating weights to different aspects of the predictions.Here, weights can be adjusted to prioritize thermal comfort, energy efficiency, and/or peak power shaving.

4.
The solution with minimum cost is chosen based on output from the optimizer.
In the next sections, the three key components are further described.

Prediction Model
The prediction model takes in the building's past indoor and outdoor temperatures and delivered DH, in this case for the past week on an hourly basis, as illustrated in Figure 3 (pertaining to one CNN model in the ensemble).Also, it accounts for the forecasted outdoor temperature and occupant presence by an hourly Boolean vector (calendarization), and a planned (optimized) supply temperature for, in this case, chosen 48 h prediction.The output of the model is the predicted indoor temperature and delivered district heating for the next hour.The model has several constraints and limits assigned for the building's heating system: for the indoor temperature set points, these are 21 • C during working hours (06:00-18:00 h) and 18 • C during non-working hours (18:00-06:00 h during the weekdays and all hours during weekends and holidays).Working and non-working hours are identified by a preset calendarization of occupancy (ones or zeros) per day, denoting working days or holidays and weekends.In both cases, the temperature is allowed to reach a maximum of one degree below the setpoint for a few hours during the coldest days in the heating season.Additionally, the predicted DH obviously should never reach below zero, and the minimum supply water temperature delivered to the heating radiators is 18 • C according to the installed heating curve in the building.The maximum supply water temperature is set to 93 • C, according to the measured data.
works (CNN) with three 1D convolutional layers followed by two fully connected layers, as displayed in Figure 3.An ensemble of models refers to a technique in machine learning where multiple individual models, often of the same type, are combined to form a unified, more robust predictive model.This results from such combinations that can be achieved through techniques like averaging, voting, or weighted averaging, among others [38].Within this project, a number of CNNs are used.Each CNN is trained through supervised learning, utilizing the mean squared error (MSE) as the loss function (cost), depending on its objective (thermal comfort, energy use and/or peak shaving).Training is performed by selecting batches of samples from the training dataset.The parameters of the model are optimized by using Stochastic Gradient Descent over the samples from the batch [38].When making inferences using an ensemble of variously trained models, we can obtain a notion of probability or confidence in the predictions, considering the individual training conditions and model uncertainties in general.Thus, the ensemble combines the predictions from various individual models, each with its own strengths and weaknesses, and this diversity allows the ensemble to capture different aspects of the data distribution.As a result, the ensemble can provide a more comprehensive assessment of uncertainty and provide probabilistic estimates for each prediction.By incorporating a notion of probability, we gain insights into the uncertainty associated with each prediction.This is especially valuable in decision-making processes where having a measure of confidence allows us to make more informed choices, accounting for potential uncertainties and assessing the reliability of the model's predictions in different scenarios.The prediction model is implemented using an ensemble of convolutional neural networks (CNN) with three 1D convolutional layers followed by two fully connected layers, as displayed in Figure 3.An ensemble of models refers to a technique in machine learning where multiple individual models, often of the same type, are combined to form a unified, more robust predictive model.This results from such combinations that can be achieved through techniques like averaging, voting, or weighted averaging, among others [38].Within this project, a number of CNNs are used.Each CNN is trained through supervised learning, utilizing the mean squared error (MSE) as the loss function (cost), depending on its objective (thermal comfort, energy use and/or peak shaving).Training is performed by selecting batches of samples from the training dataset.The parameters of the model are optimized by using Stochastic Gradient Descent over the samples from the batch [38].
When making inferences using an ensemble of variously trained models, we can obtain a notion of probability or confidence in the predictions, considering the individual training conditions and model uncertainties in general.Thus, the ensemble combines the predictions from various individual models, each with its own strengths and weaknesses, and this diversity allows the ensemble to capture different aspects of the data distribution.As a result, the ensemble can provide a more comprehensive assessment of uncertainty and provide probabilistic estimates for each prediction.By incorporating a notion of probability, we gain insights into the uncertainty associated with each prediction.This is especially valuable in decision-making processes where having a measure of confidence allows us to make more informed choices, accounting for potential uncertainties and assessing the reliability of the model's predictions in different scenarios.

Generative Model
The utilization of the data generated by the generative model enables the optimizer to query the prediction models only for reliable inputs, avoiding out-of-distribution (OOD) samples that may hinder accurate predictions.Moreover, the optimizer ensures the safe delivery of supply temperature outputs to the building by closely aligning these with previously delivered values.The generative model is a conditional variational autoencoder (cVAE) [39].It generates a sequence of supply temperature values, conditioned on a given variable (in this case, the supply temperature value and a randomly sampled latent vector from a normal distribution, from the optimizer).The conditional input is included to maintain continuity between the supply temperature values at different time steps.It is essential that the latent variables have no physical significance; they simply serve as inputs to the generative model for generating diverse sequences.

Optimizer
The Optimizer aims to find an optimal sequence of supply temperature values to maintain the indoor temperature within a specified range.The fulfilment of the objective function is quantified for each sequence that is delivered from the prediction model's ensemble (indoor temperatures and DH) with the weight factors.Additionally, the mean and maximum DH values are minimized as secondary objectives to reduce energy use.High DH values, even for short periods, can be economically costly, so it is crucial to mitigate peak values alongside mean values.A penalty term is added as a disagreement between the dynamic models (CNNs) in the ensemble.In summary, the optimizer uses the weighting of factors to minimize the three objectives: (1) the mean of the delivered DH, (2) the peak DH value, and (3) the uncertainty of the dynamic model for the prediction.
The optimization starts by using the random shooting of many latent values (e.g., 1000 values) through the generative model.These samples are passed to the generative model, which generates sequences of supply temperature values.The generated sequences are then evaluated using the prediction model to calculate the cost for each sequence based on the objective function.As feedback, the sequence with the lowest cost is considered the optimal DH values for the next hours.The optimization process can be performed on an hourly basis for different time periods (for instance, 24 h or 48 h), depending on the frequency of the supply temperature delivery adjustments.

Piece-Wise Linear Model
In order to evaluate the efficiency of the proposed neural network approach, we implement a piece-wise linear model which maps outdoor temperature to the required district heating, optimized by stochastic gradient descent (SGD).The optimization is performed by running SGD on all batches sampled from the entire training dataset for a number of epochs.This model is a close representation of how the actual control of the supply temperature is operated in the building, and is hereby called the "linear model".

Results and Discussion
This section first presents the AI model predictions for annual space heating and saved peaks (peak shaving).Next, daily averaged results are presented in terms of district heating, the daily peaks in DH per 24 h (max-DH), indoor temperature (Tin), and outdoor temperature (Tout).Finally, energy and power signatures are provided on an hourly basis, to provide analysis of the various operational strategies of the HVAC system and night setback's influence on the results.
Table 1 presents the annual measured DH energy use (kWh), DH peak power demand (kWh/h), and top 10 DH peak power demands (kWh/h), as well as those predicted by both the linear model and the three different AI models.The annual DH peak power demand was calculated as the sum of daily DH peak power demands over the year.The annual saved DH energy use and DH peak power demand, in comparison to the measured values, are also presented.As presented in Table 1, optimizing energy and power, respectively, using the AI model led to different savings.This may initially appear counterintuitive, given that both models aim to optimize delivered DH and mitigate peaks.The reason behind this discrepancy lies in the valley filling and peak shaving methods employed by the energy and power model.While these techniques effectively reduce peaks in delivered heat, they can later lead to an increase in energy use in a few hours, as the model tries to shave the peaks and deliver DH more evenly during upcoming hours.This occurs as thermal losses also escalate during the storage process, resulting in a temporary elevation of indoor temperatures due to higher delivered space heating.This is in line with conclusions from [40].However, despite the potential increase in total energy storage, the economic savings associated with peak shaving remain significant, particularly when other energysaving measures are not implemented.The cost reductions stem from savings in auxiliary plant usage and the adoption of smaller plants to meet peak loads [15].District heating in Gävle, which is provided by the local energy company Gävle Energi AB, is generated entirely from renewable sources.The production mix incorporates various renewable energy elements, including waste heat from industry, condensation heat from flue gases, and heat from combined heat and power (CHP) plants fueled with biofuels like bark, recycled wood, and a small proportion of wood chips, in addition to minor amounts of bio-oil.This results in a low environmental impact, accounting for 7 g CO 2 equivalents per kilowatt-hour (kWh) in 2023 [41].As a result, the entire DH supplied to the city hall building amounts to approximately 1.4 tons of CO 2 equivalent annually, corresponding to 660 g CO 2 equivalent per square meter floor area and year for space heating.
Additionally, the pricing structure for this environmentally conscious district heating system is set at SEK 0.526 per kWh, along with some fixed charges for the year 2024 [42].Consequently, according to the annual saved district heating energy (kWh) and peaks (kWh/h) presented in Table 1, the models for optimized energy and power saving can yield approximately 38 and 29% energy savings, respectively, potentially reducing heating costs by around EUR 4000 and 3000 (1.9 and 1.4 EUR/m 2 ), respectively.The same models tend to yield approximately 23% savings of accumulated daily peak power.It is noteworthy that the linear model may slightly increase the DH demand, leading to a subsequent rise in heating costs.The results for the top 10 hourly power peaks of the year indicate a slight increase for the linear model, while the AI models for optimized energy and power saving tend to reduce these peaks by 5 and 7%, respectively.These savings are particularly important in reducing the overall maximum need for heat supplied to the building.
The anticipated reduction in overall emissions resulting from optimizing DH supply through the AI models is expected to be substantial, given the results in Table 1.This impact could be further enhanced if similar AI model optimizations are applied to all interconnected buildings within a DH network, thereby avoiding the need for auxiliary and less environmentally friendly energy sources.
Figure 4 illustrates the 24 h averaged district heating and indoor temperature (Tin), derived both from measured, i.e., delivered DH data throughout 2021 and predictions generated by both linear and AI models.Figure 4 aims to show the impact of the three different AI prediction models on the indoor thermal comfort status, i.e., indoor temperatures, compared to the measured values.The AI models encompass optimal thermal comfort, optimal energy (minimizing DH supply), and optimal delivered power (peak shaving).As depicted in the figure, DH exhibits a direct correlation with outdoor temperature, with the lowest DH observed during summertime, primarily corresponding to domestic hot water (DHW) heating demand.Conversely, higher DH demands are evident during colder winter days.The predictions for DH from the linear model align closely with the measured results, in contrast to the AI model predictions.Predictions from the optimal energy and power models indicate lower DH levels compared to the linear model, particularly noticeable during late spring and early autumn.This discrepancy can be attributed to the linear setpoint setup, known as the heating curve, embedded in the installed heating system.The heating curve embodies a direct correlation between the heating system supply temperature and the outdoor temperature.In contrast, the AI model has the ability to optimize delivered DH by considering historical data on delivered DH, indoor and forecasted outdoor temperatures, and the binary calendarization of occupancy.
According to Figure 4, the measured indoor temperature reaches its lowest levels during colder winter days.Often, the indoor temperatures predicted by the AI model are slightly lower than those predicted by the linear model or observed in reality (measured).Further, on the coldest winter days in February and December, the measured indoor temperatures can dip below the 21 • C setpoint, indicating a deficiency in the heating system's ability to meet the heating demand.In contrast, during the same period, the AI model seems to manage well by maintaining the indoor temperature at just above the lower setpoint to optimize supplied district heating without compromising thermal comfort.
Figure 5 illustrates the daily maximum DH based on measured data and predictions from the linear and AI models and measured and outdoor temperature (Tout) for the year 2021.Notably, the maximum DH predicted by the linear model surpassed the AI model predictions, highlighting the limitations of the linear model in capturing non-linear trends in DH demand.The impact of the different prediction models on the daily maximum DH use (i.e., DH peak shaving), in turn, influences the part of DH billing played by the DH supplier, which is based on "peak power demand" (i.e., economic aspect).During the summer, DH primarily supplies the domestic hot water (DHW) needs, but occasional peaks are observed, in Figure 5, when the outdoor temperature falls below 18 • C, and this, according to the heating system setpoints, leads to increased supply water temperatures in heating radiators.However, despite the occasional peaks, the AI model consistently indicates lower peaks.This suggests the AI model's effectiveness in optimizing delivered DH, even in scenarios where peaks occur, demonstrating its capability to adapt and enhance peak shaving efficiency.In economic terms, peak shaving is important on a daily basis, since DH billing usually is based on three factors, namely energy use, peak power, and the cost of flow rate.The proportions of these parts vary among the DH suppliers and the shares of the total cost.For example, Gävle Energi AB has a peak power based on the average daily energy use during a day when the outdoor temperature is −10 • C. It is therefore important that when temperatures plumet on a daily basis, the peak is accordingly shifted to warmer neighboring days.This has, on the other hand, no effect during longer cold spells.As can be seen in Figure 5, there are few days where the daily outdoor temperature is consecutively around −10 • C.  the shares of the total cost.For example, Gävle Energi AB has a peak power based on the average daily energy use during a day when the outdoor temperature is −10 °C.It is therefore important that when temperatures plumet on a daily basis, the peak is accordingly shifted to warmer neighboring days.This has, on the other hand, no effect during longer cold spells.As can be seen in Figure 5, there are few days where the daily outdoor temperature is consecutively around −10 °C.
Buildings 2024, 14, x FOR PEER REVIEW 13 of 28 Figure 6 illustrates the 24 h averaged measured outdoor temperature (Tout) as well as indoor temperature (Tin) using data from measured, delivered DH during 2021 and predictions from the linear and AI models.The indoor temperature averages are computed separately for working and non-working hours.Generally, indoor temperatures are higher during working hours compared to non-working hours, a measure taken to ensure occupants' thermal comfort.This temperature regulation is governed by specific setpoints assigned to the AI model for indoor temperature maintenance: 21 °C during working Figure 6 illustrates the 24 h averaged measured outdoor temperature (Tout) as well as indoor temperature (Tin) using data from measured, delivered DH during 2021 and predictions from the linear and AI models.The indoor temperature averages are computed separately for working and non-working hours.Generally, indoor temperatures are higher during working hours compared to non-working hours, a measure taken to ensure occupants' thermal comfort.This temperature regulation is governed by specific setpoints assigned to the AI model for indoor temperature maintenance: 21 • C during working hours (06:00-18:00) and 18 • C during non-working hours (18:00-06:00 on weekdays and throughout weekends and holidays).The studied building is used as an office building, and therefore these setpoints are designed to align with occupants' comfort preferences during different time intervals.
targeted setpoints during working and non-working hours, even during the coldest days in January and February.For instance, during working hours, the predicted indoor temperature can dip below 21 °C for a few hours, but will still be above 20 °C according to the targeted set-points.Moreover, during the whole year, the optimal energy and power model will exhibit more even indoor temperatures compared to the measured temperatures, i.e., the AI model predictions will be higher during the coldest days in winter, while the measured values will sometimes be below the setpoints (the reasons for this will be explained later), and the AI model predictions will be lower during spring and autumn, compared to the measured temperatures.Thus, the AI model attempts to set the indoor temperature as much as possible above the setpoints and at the same time optimize the supply DH.However, the predictions by the optimal thermal comfort AI model are closer to the measured DH except during the coldest days in January and February, as the aim of the model is to prioritize thermal comfort and it has stricter settings to keep the indoor temperature above the setpoints.Figure 7 illustrates the time series data for both measured and predicted DH, alongside outdoor temperature.The depicted time series cover 24 h averages and maximum DH values, along with 24 h averaged outdoor temperature data for the entire year, as well as specifically for January and February.The AI model predictions encompass results from the thermal comfort model, as well as the optimal energy and power models.Additionally, for comparative purposes, predictions from a basic linear model are included in the figure.Generally, higher peaks are noticeable during periods of lower outdoor temperatures.
There were higher average and maximum (peak) DH values during periods of lower outdoor temperature for all models, including the linear and AI models and the measured values.During the summer months, the district heating supply primarily serves domestic hot water needs, with occasional peaks observed when outdoor temperatures drop below 18 °C.Despite these sporadic peaks during the summer months, the AI models consistently forecast lower peaks, which could be space heating demands, though expectations are DHW only.In contrast, during the winter season, the AI models predict lower DH compared to the linear model, where the latter closely aligns with the measured DH.This distinction becomes more apparent when examining the January-February time series in Figure 7, where the linear model generally predicts higher DH and the AI models predict lower ones.However, predictions from the optimal thermal comfort AI model closely match the measured DH, except during the coldest days in January and February.This divergence can be attributed to the model's emphasis on prioritizing thermal comfort, resulting in stricter settings to maintain indoor temperatures above setpoints and, as will be shown in the coming section about energy signatures, the control settings of supply temperature were erroneous in the real building.
The time series illustrated in Figure 7 demonstrate that the AI models successfully reduced peaks compared to both the linear model and measured (supplied) DH, as these exhibited lower delivered DH energy and power peaks.Additionally, results highlight the linear model's inability to capture the non-linear trend in the DH pattern, thus limiting its capability to adjust and predict the optimal DH effectively.It is noticeable that the measured indoor temperature reaches its lowest points during the colder winter days, while the indoor temperatures predicted by the AI model are consistently around 1 • C higher than the measured values.The measured indoor temperatures can fall below 21 • C and affect the occupants' thermal comfort during the winter days; the probable reason is explained below in the form of energy signatures (hourly values).Meanwhile, the AI model predictions are particularly centered around the targeted setpoints during working and non-working hours, even during the coldest days in January and February.For instance, during working hours, the predicted indoor temperature can dip below 21 • C for a few hours, but will still be above 20 • C according to the targeted set-points.Moreover, during the whole year, the optimal energy and power model will exhibit more even indoor temperatures compared to the measured temperatures, i.e., the AI model predictions will be higher during the coldest days in winter, while the measured values will sometimes be below the setpoints (the reasons for this will be explained later), and the AI model predictions will be lower during spring and autumn, compared to the measured temperatures.Thus, the AI model attempts to set the indoor temperature as much as possible above the setpoints and at the same time optimize the supply DH.However, the predictions by the optimal thermal comfort AI model are closer to the measured DH except during the coldest days in January and February, as the aim of the model is to prioritize thermal comfort and it has stricter settings to keep the indoor temperature above the setpoints.
Figure 7 illustrates the time series data for both measured and predicted DH, alongside outdoor temperature.The depicted time series cover 24 h averages and maximum DH values, along with 24 h averaged outdoor temperature data for the entire year, as well as specifically for January and February.The AI model predictions encompass results from the thermal comfort model, as well as the optimal energy and power models.Additionally, for comparative purposes, predictions from a basic linear model are included in the figure.Generally, higher peaks are noticeable during periods of lower outdoor temperatures.

Building Energy Signature
The energy signature of the delivered DH is illustrated in relation to the outdoor temperature for daily values throughout 2021.Figure 8 showcases the results of employing the energy signature method on daily values for 2021 for the three AI models, which include the energy signatures for both the measured and linear models.These are based on daily mean values.There were higher average and maximum (peak) DH values during periods of lower outdoor temperature for all models, including the linear and AI models and the measured values.During the summer months, the district heating supply primarily serves domestic hot water needs, with occasional peaks observed when outdoor temperatures drop below 18 • C. Despite these sporadic peaks during the summer months, the AI models consistently forecast lower peaks, which could be space heating demands, though expectations are DHW only.In contrast, during the winter season, the AI models predict lower DH compared to the linear model, where the latter closely aligns with the measured DH.This distinction becomes more apparent when examining the January-February time series in Figure 7, where the linear model generally predicts higher DH and the AI models predict lower ones.However, predictions from the optimal thermal comfort AI model closely match the measured DH, except during the coldest days in January and February.This divergence can be attributed to the model's emphasis on prioritizing thermal comfort, resulting in stricter settings to maintain indoor temperatures above setpoints and, as will be shown in the coming section about energy signatures, the control settings of supply temperature were erroneous in the real building.
The time series illustrated in Figure 7 demonstrate that the AI models successfully reduced peaks compared to both the linear model and measured (supplied) DH, as these exhibited lower delivered DH energy and power peaks.Additionally, results highlight the linear model's inability to capture the non-linear trend in the DH pattern, thus limiting its capability to adjust and predict the optimal DH effectively.

Building Energy Signature
The energy signature of the delivered DH is illustrated in relation to the outdoor temperature for daily values throughout 2021.Figure 8 showcases the results of employing the energy signature method on daily values for 2021 for the three AI models, which include the energy signatures for both the measured and linear models.These are based on daily mean values.The horizontal lines depicted in Figure 8 correspond to the constant domestic hot water (DHW) demand, which remains relatively stable throughout the year.The sloped lines primarily represent the increasing space heating requirements, correlating with declining outdoor temperatures.Notably, the AI models for optimal energy (minimizing DH supply) and optimal delivered power (peak shaving model) show significantly reduced predictions, effectively moderating the supplied DH specifically for space heating, in comparison to the optimal thermal comfort model.The optimal thermal comfort model aims to prioritize thermal comfort, placing greater emphasis on maintaining indoor temperatures close to designated set points, resulting in lower potential for energy savings with this model.In all instances, the linear model results align more closely with the measured data, as the current heat supply is determined by the linear relationship between outdoor temperature and delivered DH to the building, regulated by the heating curve settings in the DH central heat exchanger unit.
The balance temperature (Tb), along with the delivered power usage for DHW and the total heat loss coefficient (represented as the slope in Figure 8; see more about these entities in [43]), are outlined in Table 2.The balance temperature (Tb) refers to the temperature at which no heating supply is required to maintain thermal comfort within the building; in other words, internal heat gains alone are adequate to uphold indoor temperature setpoints.Figure 8 and Table 2 shed light on the saving potential of optimal energy and power AI models from another perspective compared to the previous figures.The findings reveal a lower Tb for the AI model and optimal energy and power models, indicating greater potential for savings with these models compared to the thermal comfort and linear model.A lower balance temperature implies that heat needs to be supplied until a lower outdoor temperature threshold is reached, consequently resulting in lower DH delivery to maintain indoor temperatures within setpoints.
The delivered power usage for DHW, measured in kWh/h, is observed to be lower for the optimal thermal comfort AI model.This is attributed to the model's predictions of higher balance temperature, and lower DH, with higher outdoor temperature, compared to the optimal energy and power AI models.Consequently, this leads to the remaining DH points being lower than the ones for optimal energy and power models, relative to The horizontal lines depicted in Figure 8 correspond to the constant domestic hot water (DHW) demand, which remains relatively stable throughout the year.The sloped lines primarily represent the increasing space heating requirements, correlating with declining outdoor temperatures.Notably, the AI models for optimal energy (minimizing DH supply) and optimal delivered power (peak shaving model) show significantly reduced predictions, effectively moderating the supplied DH specifically for space heating, in comparison to the optimal thermal comfort model.The optimal thermal comfort model aims to prioritize thermal comfort, placing greater emphasis on maintaining indoor temperatures close to designated set points, resulting in lower potential for energy savings with this model.In all instances, the linear model results align more closely with the measured data, as the current heat supply is determined by the linear relationship between outdoor temperature and delivered DH to the building, regulated by the heating curve settings in the DH central heat exchanger unit.
The balance temperature (Tb), along with the delivered power usage for DHW and the total heat loss coefficient (represented as the slope in Figure 8; see more about these entities in [43]), are outlined in Table 2.The balance temperature (Tb) refers to the temperature at which no heating supply is required to maintain thermal comfort within the building; in other words, internal heat gains alone are adequate to uphold indoor temperature setpoints.Figure 8 and Table 2 shed light on the saving potential of optimal energy and power AI models from another perspective compared to the previous figures.The findings reveal a lower Tb for the AI model and optimal energy and power models, indicating greater potential for savings with these models compared to the thermal comfort and linear model.A lower balance temperature implies that heat needs to be supplied until a lower outdoor temperature threshold is reached, consequently resulting in lower DH delivery to maintain indoor temperatures within setpoints.The delivered power usage for DHW, measured in kWh/h, is observed to be lower for the optimal thermal comfort AI model.This is attributed to the model's predictions of higher balance temperature, and lower DH, with higher outdoor temperature, compared to the optimal energy and power AI models.Consequently, this leads to the remaining DH points being lower than the ones for optimal energy and power models, relative to outdoor temperature.In other words, the horizontal trend line for the lowest points is slightly lower when compared to the optimal energy and power models.The total heat loss coefficient (measured in kW/ • C) reflects the thermal characteristics of the building envelope as well as ventilation losses, which appear to be quite similar across all models and the measured DH data.These values are actually the mean values of two operational cases (working and non-working hours), since the ventilation is either on or off, thus implying two heat loss coefficients.
Furthermore, alongside the energy signature diagram, Figure 9 illustrates the duration diagram for the studied cases.This figure delineates the energy-saving potential facilitated by the AI model predictions.Conversely, it highlights that the linear model sometimes even intensifies peaks in DH supply, as it lacks the capability to follow the DH supply pattern and optimize DH predictions.Importantly, the area below each curve represents the energy use for each alternative.
outdoor temperature.In other words, the horizontal trend line for the lowest points is slightly lower when compared to the optimal energy and power models.The total heat loss coefficient (measured in kW/°C) reflects the thermal characteristics of the building envelope as well as ventilation losses, which appear to be quite similar across all models and the measured DH data.These values are actually the mean values of two operational cases (working and non-working hours), since the ventilation is either on or off, thus implying two heat loss coefficients.Furthermore, alongside the energy signature diagram, Figure 9 illustrates the duration diagram for the studied cases.This figure delineates the energy-saving potential facilitated by the AI model predictions.Conversely, it highlights that the linear model sometimes even intensifies peaks in DH supply, as it lacks the capability to follow the DH supply pattern and optimize DH predictions.Importantly, the area below each curve represents the energy use for each alternative.
As depicted in Table 1, optimizing energy and power through the AI model effectively mitigates peaks in delivered heat.However, this may result in a temporary increase in energy consumption during certain hours, as the model endeavors to smooth out peaks and ensure a more consistent DH supply in the forthcoming hour.This is primarily due to the utilization of valley filling and peak shaving techniques by the optimal energy and power AI model.Figure 9 does not illustrate this phenomenon, as the proposed AI model also lowers indoor temperature, aligning with the specified setpoints, to reduce heating resources.Consequently, the AI model both reduces heating peaks and minimizes, i.e., optimizes, total DH supply by maintaining indoor temperatures close to the setpoints, thereby upholding thermal comfort.In the following section, analysis is performed on an hourly basis and separated into working and non-working hours.Figure 10 presents the measured DH as a function of outdoor temperatures.Notably, the DH for non-working hours is below that for working As depicted in Table 1, optimizing energy and power through the AI model effectively mitigates peaks in delivered heat.However, this may result in a temporary increase in energy consumption during certain hours, as the model endeavors to smooth out peaks and ensure a more consistent DH supply in the forthcoming hour.This is primarily due to the utilization of valley filling and peak shaving techniques by the optimal energy and power AI model.Figure 9 does not illustrate this phenomenon, as the proposed AI model also lowers indoor temperature, aligning with the specified setpoints, to reduce heating resources.Consequently, the AI model both reduces heating peaks and minimizes, i.e., optimizes, total DH supply by maintaining indoor temperatures close to the setpoints, thereby upholding thermal comfort.
In the following section, analysis is performed on an hourly basis and separated into working and non-working hours.Figure 10 presents the measured DH as a function of outdoor temperatures.Notably, the DH for non-working hours is below that for working hours, for two reasons: night set-back temperatures are lower than during working hours, and the ventilation system is off.When the ventilation system is off, the heat loss of the building is reduced, consequently resulting in a lower slope for the regression line.A lower indoor temperature shifts this line downward.Also, this could be due to a change in the heating curve settings when outdoor temperatures are very low; Figure 11 illustrates the measured supply temperatures and indoor temperatures, showing a malfunction in the heating system.Regarding the supply temperature, for outdoor temperatures below approximately −5 • C, the heating curve was set to a constant 65 • C.This had adverse effects on indoor temperatures, which were below 19 • C during working hours.Owing to complaints, the heating curve values were raised, which consequently raised the indoor temperature to above 21 • C. Also, note that non-working hour indoor temperatures are seemingly higher than during working hours when outdoor temperatures are above 0 • C, as indicated by the regression lines.This is due the shutting off the ventilation system, which during the warmer season has the function of removing heat from the building.
Buildings 2024, 14, x FOR PEER REVIEW 20 of 28 hours, for two reasons: night set-back temperatures are lower than during working hours, and the ventilation system is off.When the ventilation system is off, the heat loss of the building is reduced, consequently resulting in a lower slope for the regression line.A lower indoor temperature shifts this line downward.Also, this could be due to a change in the heating curve settings when outdoor temperatures are very low; Figure 11 illustrates the measured supply temperatures and indoor temperatures, showing a malfunction in the heating system.Regarding the supply temperature, for outdoor temperatures below approximately −5 °C, the heating curve was set to a constant 65 °C.This had adverse effects on indoor temperatures, which were below 19 °C during working hours.Owing to complaints, the heating curve values were raised, which consequently raised the indoor temperature to above 21 °C.Also, note that non-working hour indoor temperatures are seemingly higher than during working hours when outdoor temperatures are above 0 °C, as indicated by the regression lines.This is due to the shutting off the ventilation system, which during the warmer season has the function of removing heat from the building.When comparing measured and simulated space heating DH (Figure 12), the spread of values for each outdoor temperature is larger for the models, as indicated by reduced R 2 -values.This is because the supply temperature of the real building is controlled by a heat curve, with several damping and delay schemes.Nevertheless, the models are controlled by outdoor temperature predictions and modes for optimization.An aspect that the AI models do not explicitly have is the inertia of the HVAC system subjected to large variations in supply temperature.At the same time, all models show somewhat lower power demands than those measured during the coldest days.The power demand is consistently lower for the models during non-working hours.This is also true for working hours, except for the optimal energy model.The reason is that significant energy could be  2).
Buildings 2024, 14, x FOR PEER REVIEW 20 of 28 hours, for two reasons: night set-back temperatures are lower than during working hours, and the ventilation system is off.When the ventilation system is off, the heat loss of the building is reduced, consequently resulting in a lower slope for the regression line.A lower indoor temperature shifts this line downward.Also, this could be due to a change in the heating curve settings when outdoor temperatures are very low; Figure 11 illustrates the measured supply temperatures and indoor temperatures, showing a malfunction in the heating system.Regarding the supply temperature, for outdoor temperatures below approximately −5 °C, the heating curve was set to a constant 65 °C.This had adverse effects on indoor temperatures, which were below 19 °C during working hours.Owing to complaints, the heating curve values were raised, which consequently raised the indoor temperature to above 21 °C.Also, note that non-working hour indoor temperatures are seemingly higher than during working hours when outdoor temperatures are above 0 °C, as indicated by the regression lines.This is due to the shutting off the ventilation system, which during the warmer season has the function of removing heat from the building.When comparing measured and simulated space heating DH (Figure 12), the spread of values for each outdoor temperature is larger for the models, as indicated by reduced R 2 -values.This is because the supply temperature of the real building is controlled by a heat curve, with several damping and delay schemes.Nevertheless, the models are controlled by outdoor temperature predictions and modes for optimization.An aspect that the AI models do not explicitly have is the inertia of the HVAC system subjected to large variations in supply temperature.At the same time, all models show somewhat lower power demands than those measured during the coldest days.The power demand is consistently lower for the models during non-working hours.This is also true for working hours, except for the optimal energy model.The reason is that significant energy could be When comparing measured and simulated space heating DH (Figure 12), the spread of values for each outdoor temperature is larger for the models, as indicated by reduced R 2 -values.This is because the supply temperature of the real building is controlled by a heat curve, with several damping and delay schemes.Nevertheless, the models are controlled by outdoor temperature predictions and modes for optimization.An aspect that the AI models do not explicitly have is the inertia of the HVAC system subjected to large variations in supply temperature.At the same time, all models show somewhat lower power demands than those measured during the coldest days.The power demand is consistently lower for the models during non-working hours.This is also true for working hours, except for the optimal energy model.The reason is that significant energy could be saved during the night set-back period, but indoor temperatures must be raised to target levels in the morning at the expense of reduced increased peak power.The supply temperature plots in Figure 13 give explanations.
Buildings 2024, 14, x FOR PEER REVIEW 21 of 28 saved during the night set-back period, but indoor temperatures must be raised to target levels in the morning at the expense of reduced increased peak power.The supply temperature plots in Figure 13 give explanations.The plotted supply temperatures from the models show much more scattering than the measured ones.The optimal thermal comfort model displays trendlines that are similar to those of the measured values, and somewhat similar temperatures above outdoor temperatures above 0 °C.Below that outdoor temperature, supply temperatures become more diverse.One reason could be the change in the heat curve setting.The largest scattering is found in the R 2 -value of optimal energy; during cold outdoor temperatures, supply temperatures range from 20 °C to 93 °C.The lower supply temperatures are mainly during non-working hours, when the indoor set-point temperature is reduced.This, in turn, requires high supply temperatures in the morning to achieve higher set-point temperatures.As for optimal power, the supply temperature regressions are higher than for optimal energy, but lower than for optimal thermal comfort.An interesting aspect is that working and non-working hour regressions converge for measurements and the thermal comfort model as outdoor temperature is reduced.In contrast, the other two models have divergent regressions, suggesting that the difference in working and non-working hours' set-point temperatures makes heat storage in the building's structures possible.In turn, this will affect the indoor temperature.The plotted supply temperatures from the models show much more scattering than the measured ones.The optimal thermal comfort model displays trendlines that are similar to those of the measured values, and somewhat similar temperatures above outdoor temperatures above 0 • C. Below that outdoor temperature, supply temperatures become more diverse.One reason could be the change in the heat curve setting.The largest scattering is found in the R 2 -value of optimal energy; during cold outdoor temperatures, supply temperatures range from 20 • C to 93 • C. The lower supply temperatures are mainly during non-working hours, when the indoor set-point temperature is reduced.This, in turn, requires high supply temperatures in the morning to achieve higher set-point temperatures.As for optimal power, the supply temperature regressions are higher than for optimal energy, but lower than for optimal thermal comfort.An interesting aspect is that working and non-working hour regressions converge for measurements and the thermal comfort model as outdoor temperature is reduced.In contrast, the other two models have divergent regressions, suggesting that the difference in working and non-working hours' set-point temperatures makes heat storage in the building's structures possible.In turn, this will affect the indoor temperature.Figure 13 shows, besides measured values, how supply temperatures from the AI models could ensure that indoor temperatures do not drop significantly below the indoor temperature setpoint, i.e., 21 °C during working hours, as depicted in Figure 14.Supply temperatures have a significant impact on indoor temperatures.As previously mentioned, the measured temperatures during colder periods were unacceptably low for office work.The models' results display work time temperatures lower than 21 °C during colder periods but seldom below 20 °C, since model setting allows a "trespassing" of 1 °C below the set point temperature (see Figure 14).In general, when comparing model results, optimal thermal comfort has higher indoor temperatures, but with a small margin.The most notable differences are in non-working hours within an outdoor temperature range of −10 to +10 °C.Indoor temperatures never reach the non-working hours set-point at 18 °C, which is due to the fact that the working hours set-point is difficult to fulfill in the mornings, given that supply temperatures are limited to a maximum of 93 °C.The optimal energy model gives the lowest non-work hours indoor temperatures when the minimum is reached at approximately 3 °C outdoors.For higher outdoor temperatures, transmission losses are not large enough to reduce the indoor temperatures, given the heat stored in structures.Conversely, lower outdoor temperatures imply heat losses that make it difficult for the HVAC to achieve acceptable indoor temperatures in the morning.Logically, low indoor temperatures will lead to lower purchased energy.Considering optimal power, there are fewer but more distinct occasions where night set-back is used for peak shaving.However, and rather unexpectedly, working hour indoor temperatures during colder periods (below 0 °C) seem to be in the same order of magnitude as from the optimal energy model.The optimal thermal comfort model seemingly and systematically gives higher indoor temperatures, yet tries to shave peaks.When outdoor temperatures are above 10 °C, indoor temperatures increase under the influence of solar irradiation.Again, the high non-working hours are due to the ventilation system being off, especially during weekends and holidays.Figure 13 shows, besides measured values, how supply temperatures from the AI models could ensure that indoor temperatures do not drop significantly below the indoor temperature setpoint, i.e., 21 • C during working hours, as depicted in Figure 14.Supply temperatures have a significant impact on indoor temperatures.As previously mentioned, the measured temperatures during colder periods were unacceptably low for office work.The models' results display work time temperatures lower than 21 • C during colder periods but seldom below 20 • C, since model setting allows a "trespassing" of 1 • C below the set point temperature (see Figure 14).In general, when comparing model results, optimal thermal comfort has higher indoor temperatures, but with a small margin.The most notable differences are in non-working hours within an outdoor temperature range of −10 to +10 • C. Indoor temperatures never reach the non-working hours set-point at 18 • C, which is due to the fact that the working hours set-point is difficult to fulfill in the mornings, given that supply temperatures are limited to a maximum of 93 • C. The optimal energy model gives the lowest non-work hours indoor temperatures when the minimum is reached at approximately 3 • C outdoors.For higher outdoor temperatures, transmission losses are not large enough to reduce the indoor temperatures, given the heat stored in structures.Conversely, lower outdoor temperatures imply heat losses that make it difficult for the HVAC to achieve acceptable indoor temperatures in the morning.Logically, low indoor temperatures will lead to lower purchased energy.Considering optimal power, there are fewer but more distinct occasions where night set-back is used for peak shaving.However, and rather unexpectedly, working hour indoor temperatures during colder periods (below 0 • C) seem to be in the same order of magnitude as from the optimal energy model.The optimal thermal comfort model seemingly and systematically gives higher indoor temperatures, yet tries to shave peaks.When outdoor temperatures are above 10 • C, indoor temperatures increase under the influence of solar irradiation.Again, the high non-working hours are due to the ventilation system being off, especially during weekends and holidays.To wrap it up, an analysis of model output was undertaken considering that the results are plausible and that the course of events could be related to building physics, given large uncertainties.While AI detects patterns, it is blind to the physics behind the simulated events.However, the analysis shows that AI optimization in view of minimizing energy use, peak shaving, and/or thermal comfort is possible, in terms of trade-offs; higher indoor temperatures render higher energy use, but could use thermal inertia to shave peaks.At the same time, the current performance of the building could be improved by machine learning of the patterns instead of manual "commonsense".
Accordingly, several other studies have explored the use of Model Predictive Control applications and have demonstrated significant energy savings ranging from 10 to 53% [44][45][46][47][48][49].Additionally, these studies have highlighted the considerable potential for facilitating grid flexibility services [50,51].As mentioned earlier, few studies have been implemented to evaluate true outcomes.At the same time, AI can, within implementation, learn from the data that are generated from its real-life performance and improve its own performance, given unforeseen constraints, when provided with feedback from the building's occupants.

Limitations
The suggested model has not been put into practice or verified in the specific building under study.This means that caution is required when interpreting the simulated results presented here.It is worth noting that while machine learning has shown promise in researching building energy efficiency, most studies are still in experimental or testing stages.Few have applied machine learning techniques in real-world building settings and conducted evaluations after occupants have moved in [52].
One significant limitation of the AI model stems from the lack of diversity in the training data.Since the data come from an engineered controller, indoor temperatures mostly fall within a narrow range, especially during colder periods of the year.To wrap it up, an analysis of model output was undertaken considering that the results are plausible and that the course of events could be related to building physics, given large uncertainties.While AI detects patterns, it is blind to the physics behind the simulated events.However, the analysis shows that AI optimization in view of minimizing energy use, peak shaving, and/or thermal comfort is possible, in terms of trade-offs; higher indoor temperatures render higher energy use, but could use thermal inertia to shave peaks.At the same time, the current performance of the building could be improved by machine learning of the patterns instead of manual "commonsense".
Accordingly, several other studies have explored the use of Model Predictive Control applications and have demonstrated significant energy savings ranging from 10 to 53% [44][45][46][47][48][49].Additionally, these studies have highlighted the considerable potential for facilitating grid flexibility services [50,51].As mentioned earlier, few studies have been implemented to evaluate true outcomes.At the same time, AI can, within implementation, learn from the data that are generated from its real-life performance and improve its own performance, given unforeseen constraints, when provided with feedback from the building's occupants.

Limitations
The suggested model has not been put into practice or verified in the specific building under study.This means that caution is required when interpreting the simulated results presented here.It is worth noting that while machine learning has shown promise in researching building energy efficiency, most studies are still in experimental or testing stages.Few have applied machine learning techniques in real-world building settings and conducted evaluations after occupants have moved in [52].
One significant limitation of the AI model stems from the lack of diversity in the training data.Since the data come from an engineered controller, indoor temperatures mostly fall within a narrow range, especially during colder periods of the year.Additionally, data become scarce for very cold outdoor conditions, which may only occur once or twice a year, if at all.As a result, the model faces considerable challenges in accurately predicting deviations from this established range, such as extremely low temperatures.
The manner in which simulations are conducted can influence the results.In this study, we consistently optimized original data as the input for the model to avoid error accumulation from autoregressive prediction over long timeframes.Essentially, we did not consider how optimizing control signals might affect the subsequent thermal state of the building.Consequently, there is potential for the model to overly exploit the building's thermal capacity without considering its impact on timeframes longer than the optimization period.This also applies when supplying temperatures to radiators; there is considerable variation from the models as opposed to measured values, which may not be possible given the thermal inertia of the radiator system.
Furthermore, we used ground truth outdoor temperatures as forecasted future temperatures, without accounting for the uncertainties in real-world forecasts in our simulation.Given these limitations, we view our results as an upper limit of performance, with realworld performance likely to be lower.The further exploration of these effects in real-world scenarios will be the focus of future studies.

Conclusions
This case study explores the innovative use of a historical stone building's structure as a heating battery, utilizing Artificial Intelligence (AI) and Machine Learning models.The proposed AI model has three main features in which heat supply prediction can be chosen, based on prioritized thermal comfort, delivered energy (minimizing the district heating supply), and power (peak shaving of district heating supply).The approach involves controlling the heat supply based on weather forecasts and calendarization on predicted occupancy (binary rates for working and non-working hours), optimizing energy use, and managing power demand while maintaining indoor comfort.The study reveals significant savings in both total and peak energy use, suggesting applicability to similar cases.The prediction model employs an ensemble of convolutional neural networks trained through supervised learning.Simulation results indicate potential savings of 38% and 29% in annual district heating energy, predicted by the optimal energy and peak power shaving AI models, respectively, demonstrating cost reductions of approximately around EUR 4000 and 3000 (1.9 and 1.4 EUR/m 2 ).The same optimizing energy and power AI models can yield approximately 23% savings for peak power DH, calculated per 24 h.Notably, a basic linear reference model may contribute to increased heating costs by slightly elevating DH demand.In addition, it is shown that the AI models could reduce the top 10 peak power per hour values by approximately 6%.However, these results should be considered as an upper limit of performance, with real-world performance likely to be lower.
The AI model can capture non-linear trends that the current heating system lacks, because of the embedded linear setpoint setup known as the heating curve, which dictates the supply temperature for heating as a function of the momentary outdoor temperature.This means that the AI model, compared to the current heating system, manages to maintain the indoor temperatures at just above the lower temperature setpoint to optimize delivered DH without compromising thermal comfort, which could keep maximum DH powers lower, i.e., DH peak shaving, and accounts for a lower balance temperature in the building energy signature.This not only mitigates the deficiency of the current heating system's ability to keep a lower temperature setpoint during the colder winter days, but also, thanks to DH peak shaving, contributes to decreasing the part of DH billing by the DH supplier which is based on "peak power demand", leading to extra economic savings.
In terms of environmental impact, the potential savings in annual saved district heating energy and peak can lead to at least equal savings in the total emissions caused by the DH production and supply, although the district heating system's predictions in this case are from sustainable and renewable sources.The expected emissions reduction by optimizing the DH supply through the AI model would be even greater if applied to all interconnected buildings in a DH network, thereby avoiding the need for auxiliary and less environmentally friendly energy sources.Thus, a more extensive study and application of the proposed AI model on buildings within a DH network is recommended in future to reveal its substantial saving potential in terms of both energy use and total emissions.Amongst different AI models, the optimal thermal comfort AI model aims to prioritize thermal comfort, placing greater emphasis on maintaining indoor temperatures close to designated set points, resulting in less potential for energy savings compared to other AI models.The optimal power AI model yields lower DH energy savings, and consequently less reduction in overall emissions, compared to the optimal energy AI model, because the escalated thermal losses during the storage process lead to higher delivered space heating.Despite this lower potential in DH energy savings, the economic savings associated with peak shaving, i.e., the ones stemming from savings in auxiliary plant usage and the adoption of smaller plants to meet peak loads, remain significant.This provides useful information regarding decision-making on the application of different AI models.For buildings where fulfilling thermal comfort is the highest priority, the application of an optimal thermal comfort AI model is recommended.When the aim is to reduce the overall emissions in a larger system boundary, i.e., including both the end-user and the energy supplier, the application of the optimal power AI model could be suggested; otherwise, the optimal energy AI model is the best fit for a reduction in overall emissions only for the end-user.
As future work, the proposed AI model can undergo testing and verification through implementation in a real building, specifically the City Hall in Gävle, in collaboration with the building owner.Furthermore, integration into the existing building management system would enable real-time data collection and model predictions.The system could generate signals and notifications to building caretakers and users, prompting adjustments to the heating systems in the event of outliers or abnormalities.
Additional parameters, such as solar irradiation, could enhance the model if reliable data are available.Sensitivity analysis could assess the model's performance with and without these extra parameters.Currently, the model employs the area-weighted indoor temperature to develop predictions, with the output representing the district heating for the entire building, centrally governed by the district heating unit.Future iterations of the model could extend its capabilities to predict indoor temperatures for individual rooms, provided each room's thermal radiators are equipped with remotely measured thermostats for separate temperature control.
This AI model holds potential for applications in connecting multiple buildings within a district and even across an entire district heating network to optimize DH supply.Furthermore, the integration of the DH network with the electrical grid offers the opportunity to synchronize and optimize the entire energy system, incorporating various storage systems, both thermal and electrical.

Figure 1 .
Figure 1.The historic office building, City Hall in Gävle.

Figure 1 .
Figure 1.The historic office building, City Hall in Gävle.

Figure 2 .
Figure 2. Schematic of the AI modelling approach used for DH and indoor temperature predictions.

1 .
Sequences of supply temperatures (in this case, 1000 sets) are suggested by the generative model, on the basis of patterns learned on training data.2. Related predictions (based on each solution), given future outdoor temperatures and calendarized occupancy, are made by an ensemble of CNN models, where each CNN has been trained with different objectives.3. Related cost values (based on each prediction) are determined in terms of fulfilment of the objective function, and are quantified by the optimizer by alternating weights to different aspects of the predictions.

Figure 2 .
Figure 2. Schematic of the AI modelling approach used for DH and indoor temperature predictions.

Figure 3 .
Figure 3.The architecture for a CNN network within the ensemble, aiming to discover the next 48 h prediction of indoor temperature and district heating (DH) supply.

Figure 3 .
Figure 3.The architecture for a CNN network within the ensemble, aiming to discover the next 48 h prediction of indoor temperature and district heating (DH) supply.

Buildings 2024 , 28 Figure 4 .
Figure 4.The 24 h averaged district heating (DH) and indoor temperature (Tin) and outdoor temperature (Tout), including results of AI models for optimized comfort (top), energy (middle), and peak power (bottom).

Figure 4 .
Figure 4.The 24 h averaged district heating (DH) and indoor temperature (Tin) and outdoor temperature (Tout), including results of AI models for optimized comfort (top), energy (middle), and peak power (bottom).

Figure 5 .
Figure 5.The 24 h averaged outdoor temperature (Tout) and maximum 24 h district heating (DH), including results of AI models for optimized comfort (top), energy (middle), and peak power (bottom).

Figure 5 .
Figure 5.The 24 h averaged outdoor temperature (Tout) and maximum 24 h district heating (DH), including results of AI models for optimized comfort (top), energy (middle), and peak power (bottom).

Figure 6 .
Figure 6.Indoor temperature (Tin) during working and non-working hours as well as the outdoor temperature (Tout), including results of AI models for optimized comfort (top), energy (middle), and peak power (bottom).

Figure 6 .
Figure 6.Indoor temperature (Tin) during working and non-working hours as well as the outdoor temperature (Tout), including results of AI models for optimized comfort (top), energy (middle), and peak power (bottom).

Figure 7 .
Figure 7.The 24 h averaged and maximum (max) district heating (DH) data, along with 24 h averaged outdoor temperature (Tout) data for the entire of 2021, on the right side of the figure.Conversely, on the left side, the figures depict the same data but specifically for January and February.

Figure 7 .
Figure 7.The 24 h averaged and maximum (max) district heating (DH) data, along with 24 h averaged outdoor temperature (Tout) data for the entire of 2021, on the right side of the figure.Conversely, on the left side, the figures depict the same data but specifically for January and February.

Figure 8 .
Figure 8. Energy signature diagrams for the supplied district heating for space heating and domestic hot water in the studied building.The points represent the daily average supplied district heating (DH) in 2021 and include results of AI models for optimized comfort (top), energy (middle), and peak power (bottom).

Figure 8 .
Figure 8. Energy signature diagrams for the supplied district heating for space heating and domestic hot water in the studied building.The points represent the daily average supplied district heating (DH) in 2021 and include results of AI models for optimized comfort (top), energy (middle), and peak power (bottom).

Figure 9 .
Figure 9. Duration diagram for the supplied district heating (DH) for space heating and domestic hot water for the studied building, for the whole year (left) and for the top 200 h of highest peaks (right).

Figure 9 .
Figure 9. Duration diagram for the supplied district heating (DH) for space heating and domestic hot water for the studied building, for the whole year (left) and for the top 200 h of highest peaks (right).

Figure 10 .
Figure 10.The energy signature based on hourly district heating (DH).On the left hand side, all district heating (DH) values are plotted.On the right hand side, domestic hot water (DHW) has been excluded (2 kWh/h corresponding to approximately 1 kWh/m 2 , as derived from Table2).

Figure 11 .
Figure 11.Measured supply temperature and indoor temperatures separated on the basis of working and non-working hours.

Figure 10 .
Figure 10.The energy signature based on hourly district heating (DH).On the left hand side, all district heating (DH) values are plotted.On the right hand side, domestic hot water (DHW) has been excluded (2 kWh/h corresponding to approximately 1 kWh/m 2 , as derived from Table2).

Figure 10 .
Figure 10.The energy signature based on hourly district heating (DH).On the left hand side, all district heating (DH) values are plotted.On the right hand side, domestic hot water (DHW) has been excluded (2 kWh/h corresponding to approximately 1 kWh/m 2 , as derived from Table2).

Figure 11 .
Figure 11.Measured supply temperature and indoor temperatures separated on the basis of working and non-working hours.

Figure 11 .
Figure 11.Measured supply temperature and indoor temperatures separated the basis of working and non-working hours.

Figure 12 .
Figure 12.Energy signature plots for measured district heating (DH) (upper left), optimal energy (lower left), thermal comfort (upper right), and power AI model district heating (DH) (lower right).

Figure 12 .
Figure 12.Energy signature plots for measured district heating (DH) (upper left), optimal energy (lower left), thermal comfort (upper right), and power AI model district heating (DH) (lower right).

Figure 13 .
Figure 13.Supply temperature signature plots for measured district heating (DH) (upper left), optimal energy (lower left), thermal comfort (upper right), and power AI model district heating (DH) (lower right).

Figure 13 .
Figure 13.Supply temperature signature plots for measured district heating (DH) (upper left), optimal energy (lower left), thermal comfort (upper right), and power AI model district heating (DH) (lower right).

Figure 14 .
Figure 14.Indoor temperature signature plots for measured district heating (DH) (upper left), optimal energy (lower left), thermal comfort (upper right), and power AI model district heating (DH) (lower right).

Figure 14 .
Figure 14.Indoor temperature signature plots for measured district heating (DH) (upper left), optimal energy (lower left), thermal comfort (upper right), and power AI model district heating (DH) (lower right).

Table 2 .
Supplied district heating in terms of energy signature parameters, measured values, and results from the different prediction models.

Table 2 .
Supplied district heating in terms of energy signature parameters, measured values, and results from the different prediction models.