1. Introduction
District heating systems (DHSs) are commonly used as an effective method forenergy supplies in the residential sector. In total, household energy consumption district heat in 2021 had 8.6% and 18.3% shares in the EU and Poland, respectively [
1]. The total length of heating networks in Poland rose by 6.6% between 2012 and 2022 [
2], reaching over 25,000 km, of which 96% was located in urban areas [
3].
Heat load in DHSs is influenced by numerous factors [
4,
5]. Hence, for efficient operation of DHS plants, various heat load prediction techniques have been developed during recent decades. In the literature [
6,
7,
8], these techniques are divided into physical-based, data-driven and hybrid methods. The physical-based models produce correlations between heat load and physical input factors (DHS parameters, material characteristics, weather, etc.). As they require a large amount of input data, they are time consuming. Data-driven models use historical energy demand and influencing factors to predict thermal load not requiring physical analysis of DHSs [
9]. Taking advantage of this feature, in combination with the use of computer techniques, a wide range of approaches have been developed, especially machine learning solutions [
10]. Among others, artificial neural networks (ANNs) are popular due to their good computing time [
11], lower complexity in multi-variable issues [
12] and easy adaptation to system nonlinearities [
13] and various heat load profiles [
14].However, despite the rapidly rising number of applications, machine learning and deep learning in DHS applications have still low shares [
15]. Therefore, this part of ANN use is of interest.
Most works have focused on the heat load prediction in DHSs applying various ANN-based models using different sets of input variables (
Table 1).
In general, the authors mainly compared various machine learning solutions in terms of their prediction accuracy. Wei et al. [
32] analysed seven models, concluding that the weather forecasting data mostly influenced model performance. Li et al. [
4] proposed an Elman neural network to model heat load using ambient temperature and sunlight factor as input variables. Using the experimental data from a heating company, they achieved a relative error for short-term prediction below 2%.
A different approach was presented by Bujalski et al. [
33]. The authors compared results from ANN predictions with those from an exponential regression model with an input ambient air temperature and obtained forecast accuracy of 6.86% and 12.92%, respectively. As more accurate planning of heat or electricity generation is of significant economic importance [
34], there is a need to analyse the potential benefits resulting from the use of ANN-based tools in relation to the usually used heat load demand curves.
As presented in
Table 1, most of the studies were devoted to 24 h ahead heat-load forecasts based on hourly weather data. The authors focused on a comparison of various ANN-based models. The use of heating curves was not shown, although in our experience these models are often used in numerous low-power facilities. In addition, such objects often do not possess archived reliable hourly data on ambient climate and heat production. But, in practise, only general daily data are available for smaller-capacity facilities. In such cases, the question arises as to whether they can be used to forecast heat production with knowledge of the basic parameter defining ambient conditions, i.e., the air temperature. This is the gap that emerged from the literature analysis presented.
The second task was the use of freely available software. This way, the user was not restricted by the need for specialised commercial software or additional costs. Therefore, Python language (version 3.10) was chosen as it is often used for data analysis and scientific computing. It also contains various packages for machine learning applications [
35], which makes this solution cheap and flexible in terms of future development.
This paper aimed to develop a neural network model designed to predict the heat demand produced in a district heating plant and to assess its accuracy in relation to the typical heating curves. The resulting model was used to write a simple application that can be used in the operation of a district heating plant to carry out a forecast of heat demand based on the ambient temperature on a given day.
This paper is structured as follows. In the design section, the process of analysing the obtained data and adapting them to the computational needs of the neural network model is presented and discussed. Then, the process of building the neural network model based on the available libraries, which are briefly presented, is described. Once the prepared model is trained and all validation calculations are performed, an interface is prepared for the heating plant staff. Then, the conclusions are given.
2. Materials and Methods
2.1. Research Strategy
The research algorithm is outlined in
Figure 1. After briefly detailing plant characteristics, a measurement data analysis was performed. All variables were outlined and then inconsistencies were identified to prepare the input dataset for further analysis.
In the next step, two kinds of forecasting models were developed and examined. The architecture of the ANN model was selected after a literature review and then several tests and validations were conducted, showing the model’s ability to properly work with the specific input dataset. Finally, it was tested and its quality was evaluated using the proposed performance indicator. Similarly, using the same data, five regression models were developed and then tested. Finally, their comparison was presented.
2.2. Operation Parameters of the Heating Plant
This study uses measurement data obtained in a municipal heating plant located in west Poland. This plant is supplied mostly by natural gas, the consumption of which in 2022 was 2.4 ∙ 106 m3. This is the main fuel used at this heating plant, but it is also possible to use heating oil, the consumption of which in 2022 was 644 m3. In further analysis, daily data from 1 January 2019 to 30 June 2022 were used.
The purpose of a district heating plant is to supply heat to consumers with a system of pipelines. The heat supplied can be determined by measuring the parameters of the district heating network. Water at a set temperature feeds into the network and then returns to the district heating plant at a correspondingly lower temperature. The temperature difference, the mass of water flowing through the network and the specific heat of the water allow for the calculation of the heat that has been discharged into the district heating network.
where
with
m—the mass of the water in the heating network, kg;
ρ—the density of the water, kg/m3;
c—the specific heat of the water, J/kgK;
—the mass flow rate of the water in the heating network, kg/s;
—the volume flow rate of the water in the heating network, kg/s;
Δτ—the time, s;
∆T—the difference between the supply and return temperature, K.
Some important aspects that may be of particular interest to energy engineers are issues such as the parameters of the district heating network, heat losses in the pipeline and ways of feeding the network. The parameters analysed and their influence on the operation of a district heating plant are given in
Table 2.
The supply pressure of the heating water at the inlet of a network can be controlled in the range of 0.18–0.70 MPa. This way, it is possible to increase the water mass flow rate. Together with the supply temperature, the heating power of the plant is controlled [
36].
The parameters presented above are mostly strictly dependent on the operation of the plant and it would be pointless to forecast them. For example, the temperature of the heating medium at the return of the network is a result of the supply temperature and the thermal energy transferred to the end-users. After an in-depth analysis, it becomes apparent that the key parameter that affects the heat demand of consumers is the ambient temperature (
Figure 2); it was chosen for further analysis.
Figure 3 presents the relation between daily heat demand and ambient temperature for the whole analysed period. During the warm season, when buildings connected to the considered network are not heated, there is almost constant heat demand (below 100 GJ),which can be attributed mainly to tap water and small commercial consumers.
Peak thermal power was 7.6 MW, 7.0 MW and 6.7 MW in 2021, 2020 and 2019, respectively (
Figure 4). Despite differences in daily values, the presented heating power duration curves are very similar. Space heating of buildings lasted for about 2/3 of the year, until the 240th day.
2.3. Input Data Preparation and Preliminary Analysis
The measurement data obtained from the district heating company were prepared in Microsoft Excel 2007 spreadsheets and Excel format spreadsheets, but without consistently using the same data storage format. In order to import the data, it was necessary to organise the data in advance and check the validity of the data types (
Table 3). To this end, after data import, information was obtained on what type of data was stored in the consecutive columns. The measurements in all columns except the date column are of the floating-point type, as expected.
Another problem encountered after data import was that unknown values were present in many records. The more significant gaps were observed in the last two columns of the data, i.e., in the operating times of the boilers. Due to the lack of data on the operating principles and operation of the heating block, these data were omitted, and this simplification did not take into account the breakdown of the operation by individual boilers. In the part of the data where the data were complete, the periods were observed when the boilers operated simultaneously or in configurations dependent on service or fault repair. This simplification unfortunately loses the possibility to take into account the relationship between the individual unit and the parameters obtained during the operation of the heating plant. With only 1593 data records available, it was necessary to focus on the most important problem of this issue, which is heat demand forecasting.
The next step in the preliminary analysis of the imported data was to calculate basic statistical information on each of the variables, such as the sum, mean value, median value, standard deviations, minimum value, maximum value, and percentages in the ranges presented (
Table 4).
Preliminary analysis of the data leads to the conclusion that the minimum values of the presented columns should not be equal to 0. Such a situation is possible, but not during the normal operation of the heat plant. Therefore, all zero records were deleted.
After this operation, the set of records was reduced to 1534. Next, to determine the relationship between the individual data columns, a heat map was generated using the SeaBorn library. This map (
Figure 5) indicates the degree of correlation between the data as determined by the value of Pearson’s correlation coefficient.
The bars in black represent correlations close to a value of −1, i.e., as the value of one parameter increases, the other decreases. The white boxes represent correlations close to 1, i.e., where, as one parameter increases, the other also increases.
The data presented above include only measured values. Sampling was carried out once a day, which resulted in each measurement being linked to a reading date. Based on the date, two additional columns were created with the day of the week (Monday–Sunday), with values from 0 to 6 corresponding to the day of the week, and a column with the month name (January–December) with values from 1 to 12.
The next step was to create graphs for each pair of parameters to illustrate the correlation between them (
Figure 6,
Figure 7,
Figure 8 and
Figure 9). Unfortunately, some of the graphs show that some data are redundant. For example, as the supplying and return temperatures were available, there was no need to use their difference.
3. Simulation Programme
3.1. Programming Environment
The data analysis as well as the entire process of creating the neural network was carried out using the Python language, which is clear and versatile. The availability of numerous libraries, add-ons and modules, which enable simple work with data, makes this language commonly used in many industrial and scientific applications. As an open-source product, it is readily used on all available platforms, such as Windows, Linux and McOS. Python is a high-level language, which makes the programme code created concise, clear and, therefore, easy and understandable for the user.
3.2. Keras Library
Keras is a machine learning library for the Python language, first released in 2015. Keras offers consistent and simple APIs, minimises the number of user actions required for typical use cases and provides clear and useful error messages. It also includes extensive documentation and guides for developers. Keras can run on a variety of engines, such as Tensorflow, Theano, PlaidML, MXNet and CNTK. In the case of this study, the Tesorflow engine was used. As Keras is based on Tensorflow, it is fully GPU-compatible, which contributes significantly to speeding up model training on large training sets.
3.3. Simulation Algorithm
The programme developed consists of two files. The first one defines the computational model of the neural network and performs the training of the network based on the imported data; the result of running it is the file
model.keras, which stores the exported network model. Then, to use the created model in practise, a file defining the user interface is written. Here, windows and functions are defined (
Figure 10).
3.4. Data Scaling
Due to the variety of input data, the different units used and the different order of stored values, it was necessary to scale the data so that the validity of any of the columns was not implied by the nature of the column value. To this end, column values were reduced to values in the range <–1,1>. For each column of values, the arithmetic mean and standard deviation were calculated. The value of the arithmetic mean was then subtracted from each value and the result was divided by the value of the standard deviation so that the values were brought into the desired range:
with
To avoid the influence of the test set on the value of the arithmetic mean and standard deviation, these were calculated using the training set and were then used to scale part of the test data.
The scaled data were fitted for further analysis. Scaling can take various forms, and in some cases, more complex methods are required, e.g., when dealing with graphics files, it is necessary to convert graphics into a sequence of numerical values.
An additional way to adapt the data to the computational needs is normalisation, which involves reducing the range of data to values in the interval <0; 1>:
with
This method can be used when the data are subject to a normal distribution. In other cases, standardisation works well.
3.5. Model of the Neural Network
Among a vast variety of possible architectures of neural networks, the authors decided to use a DNN (deep neural network) in a quite simple architecture, which was FFN (feedforward neural network). This kind of neural network allows for the regression, classification and processing of signals, such as time series, while requiring low hardware requirements. This is achieved because of several simplifications of the network design: the data flow is unidirectional, there are no loops or feedback, and the data do not return to previous layers. At the same time, such networks (FNNs) can have a multilayer structure, allowing for deeper representation, good generalisation and error reduction, flexibility in modelling, good error reduction and relatively high optimisation capabilities.
Due to the fact of having a low number of input data records (~1500), there is a high probability of the network’s overfitting during the learning process. Building a small network is one way to minimise the occurrence of this phenomenon. To choose the right solution, we performed a literature review on similar solutions (
Table 5).
Based on it, we developed a network with two hidden layers. It was created using the Sequential class from the Keras library, which means that layers are added sequentially one by one (
Figure 11).
The layers added to the model are dense (dense) layers. The first and the second dense layers have 64 units (neurons, i.e., k = 64 in
Figure 11) and use the Rectified Linear Unit (ReLu) activation functions [
45]. The last dense layer has 1 unit, suggesting that the model is intended for regression (predicting continuous values). In this layer, the activation function was not defined, which resulted in a full range of values at the output. If the sigmoid function was used, the values generated would be in the range 0–1, and it would require an additional transformation to a range appropriate for the forecasted parameter.
The model was compiled with the rmsprop optimiser. The loss function MSE (mean squared error) was used to optimise the written model and was minimised during the training. The metric MAE (mean absolute error) was used to assess the performance of the written model and the output from this function was not used when training the model.
3.6. Algorithm for k-Component Cross-Validation
The k-component validation algorithm was used to divide the entire dataset into smaller parts and then to use one of them to validate the learning process. The algorithm was executed so many times that each part, which by default was a training set, at some point became a validation set. The use of this type of algorithm minimised the error resulting from the random selection of a validation set.
Figure 12 shows the data partitioning scheme used in the network learning process for k = 4.
3.7. User Interface
In order to use the neural network model in an easy and intuitive way, it is necessary to prepare an interface intended for the users, i.e., the process engineers of the district heating plant. To this end, the PyQt5 module dedicated to GUI windows design was used. A tool for creating and editing windows, PyQt5 Designer, is available with the PyQt5 library. It is a very intuitive editor that significantly speeds up the programmer’s work. The editor offers an intuitive interface with many basic options for selecting common elements such as buttons, windows, checkboxes or labels. It is possible to create a new window and then use the drag-and-drop method to add the desired elements. Once the final visualisation of the window has been created, it is possible to save a file with the extension .ui, which then needs to be converted to a file with the extension .py to configure and adjust the logic behind the functions and individual elements.
The algorithm of this part of the developed tool is presented in
Figure 13. After importing the developed model to Keras, the programme’s main window presents a welcome message and information about the measurement data used to create the neural network model. When the button is clicked, an auxiliary window is launched with a request for the forecast ambient temperature for the day indicated by the user. After entering the value and confirming it with the ‘OK’ button, a function is started and the value of heat demand based on the entered temperature is computed. The calculation requires a neural network model created as a result of running the master file. The forecast value is presented in the message of the main window.
5. Conclusions
The main research objective of this study was to develop an efficient heat demand forecasting model using a neural network. The simple model of an ANN with two hidden layers was written in Python and built using freely available software. As it is commonly available among the variables measured in heating plants, the ambient air temperature was used as the input parameter to this model. The accuracy of the prediction assessed by mean absolute percentage error, MAPE = 15%, was at a level comparable with several studies. Some authors reported better results. However, they focused on hourly forecasts using hourly weather data. In this study, only a limited amount of daily input data were available. Therefore, it can be concluded that the developed model performed properly.
In the next step, using the same input data, four heating curves were developed and then used in the heat demand forecast. To compare their effects with the new model, there was a new indicator proposed: prediction effectiveness. The presented results showed that the ANN model performed the best.
The conclusions confirm that neural networks are promising tools in the field of artificial intelligence. However, to fully exploit their potential, further research and development of the technology are needed, especially in the context of heat demand forecasting.
In further steps, it would be advisable to develop the presented topic in two ways. The first one includes the measurement of new meteorological parameters influencing heating demand, such as solar irradiance or wind speed. The second one is to perform hourly measurements instead of current measurements with daily resolution. Then, a new, more accurate forecast model could be developed and practically used.