Optimal determination of resistance coefficient of heating pipe network based on genetic algorithm

The variable resistance of pipe network is a key problem in the heating field. In order to get the variable resistance coefficient of pipe network more accurately in the heating process, this paper proposed an optimization identification method of variable resistance coefficient of heating pipe network based on genetic algorithm. Firstly, considering that the pressure data in the heating network is difficult to measure, this paper established a mathematical model for optimizing the identification of variable resistance coefficient at each end of the heating network under the condition of only flow observation data; Secondly, genetic algorithm was used to solve it. Finally, the model and algorithm were applied to practical engineering for verification. The relative error of identification results was less than 5%, and the algorithm had good stability and convergence. The results showed that this method could obtain the variable resistance coefficient of heating network with high accuracy when only the flow observation data was available, which could provide guidance for the operation adjustment of heating system.


Introduction
With the popularity of heating metering system and the installation of temperature control device and differential pressure balancing valve, the resistance coefficient of heating system will change in real time. These real-time changing resistance coefficient values reflect the current operation status of the pipe network, which is of great significance to the operation adjustment of heating pipe network.
Liu Yongxin [1] put forward a method to identify the resistance coefficient of the heating network by using the heating network model combined with the minimum norm solution of the equation when the pressure of each node in the heating network can be observed. This method had high requirements on the observed values of pipe network pressure, and the accuracy of identification will decrease when there are only few observed data. Du Qingting [2] analyzed the feasibility and scheme of pipe network identification from the mechanism, gave the mathematical model of resistance coefficient identification of heating pipe network under multiple working conditions when the node pressure and flow were known, and obtained a complete theoretical analysis of resistance coefficient identification, but paid no attention to practical problems. Javier [3] put forward a recursive estimation method of pipeline friction, which was evaluated by simulation software. However, this method was aimed at several special pressure observation conditions and could not fully adapt to the actual observation conditions. The above studies are aimed at the correction of fixed resistance coefficient of pipe network, which requires a large number of flow and pressure observation data. For large-scale and complex heating pipe network, the installation of a large number of flow and pressure sensors is too expensive for construction and maintenance, and the installation of a large number of pressure sensors is easy to cause leakage of pipe network, which is difficult to be popularized in practice. With the popularity of metering heating system and the installation of a large number of heat metering instruments, it is convenient and simple to obtain the real-time flow data of each pipe section. Therefore, this paper proposes a new identification method and adopts a new objective function form. This method can realize the real-time resistance coefficient identification of each Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI. end pipe section only by using the flow observation data of heat metering instruments on each end pipe network connected with heat users.
In the early days, the classical optimization algorithm was widely used in this optimization problem, because it has the advantages of perfect theory and high computational efficiency. Kang [4] proposed a joint estimation model of water demand and roughness coefficient based on the least square method, and finally iterated the optimization calculation by gradient method. Recently, Gao [5] has improved the least square model, taking the head loss as the adjustment object, and calculating the resistance coefficient by the ratio of simulation loss to adjustment loss. By this method, the original nonlinear optimization problem was changed into linear optimization problem, which makes the optimization calculation simpler. Zhang [6] made the least square model approach the optimal value gradually through Jacobian matrix and completed the calibration of resistance coefficient and water demand at the same time combined with grouping method. Through the above methods, the classical optimization algorithms can still be applied to this kind of optimization problems, but the traditional optimization algorithms often have few shortcomings, such as unable to converge to the global optimal solution, easy to fall into the local optimal solution, and high requirements for initial value setting. However, genetic algorithm makes use of the law of natural selection in nature and takes the individual fitness as the judgment standard, which can solve the problem of large-scale parameter identification, especially for the identification of resistance coefficient of large-scale complex heat supply pipe network [7].
Based on this, this paper established a heat supply network resistance coefficient identification model only using flow data, combined genetic algorithm to identify and solve the model, and analyzed the errors in the identification results. The results showed that this method is practical and can guide the operation adjustment of heating system.

Hydraulic calculation model of heating network
The determination of a variable resistance coefficient requires a hydraulic model that can simulate the flow in pipe networks. According to graph theory and Kirchhoff's law [8], the hydraulic calculation model of the heat supply network with b pipe segments and + n 1 nodes can be expressed by the continuity, pressure drop, and energy equations [9]: a xy is the incidence matrix, G is the column vector of the flow in each pipe section, is a diagonal matrix of order Y , where the diagonal elements S y represent the impedance of each pipe section, is the diagonal matrix of order Y , where the diagonal element G y represents the absolute value of the flow of each pipe section, is the potential energy difference vector between two nodes in a pipe segment, and DH is the pump vector of the pipe section.

Model for determining resistance coefficient of heating network
At present, the flow measurement data can be obtained after the installation of a heat metering system in China. Thus, this paper proposes a mathematical model based on flow data to determine the drag coefficient of each end pipe section of the heating network based on optimization. Its essence is to find a set of most suitable resistance coefficients based on only flow observation data, so that the difference between the flow calculated by the hydraulic model and the actual pipe end flow observed by the pipeline network is a minimum. The mathematical model of the optimization process is as follows: where S is the resistance coefficient of the pipe network,

Determination process based on genetic algorithm 4.1. Identification method
The flow chart of the proposed optimization identification method of variable resistance coefficient based on flow data is shown in figure 1. Firstly, the resistance coefficient of pipe network under design conditions is obtained, and the search range of the resistance coefficient is determined. Then N groups of resistance coefficient row vectors are generated in the search range. Then N groups of flow vectors are obtained by substituting the resistance coefficient row vectors into the hydraulic calculation model, and the objective function is optimized by genetic algorithm. In order to ensure the accuracy, the calculated flow data substituted into the hydraulic calculation model is compared with the measured flow data, and the resistance coefficient column vector is output when it is within 5% (including 5%). When the error does not meet the requirements, N groups of resistance coefficient column vectors are regenerated for optimization.

Algorithm application
As shown in equation (2), the objective function for the variable resistance coefficient optimization is highly nonlinear, and the decision variable of the objective function is not an explicit function of the resistance coefficient S. Meanwhile, the constraint condition also includes explicit constraints on the drag coefficient S. Classical optimization algorithms involve complex concepts, many matrix operations, and theoretical derivations, and thus, it is difficult to solve problems with these methods. The genetic algorithm is an evolutionary algorithm that is simple and does not involve complex matrix computations. It can handle large parameter determination problems and is also suitable for large-scale heat pipe networks. Moreover, the genetic algorithm can be used to determine multiple model parameters simultaneously, has good compatibility with complex search spaces, and exhibits high global search performances. Therefore, the genetic algorithm was adopted in this work to solve the optimization problem of equation (2). The flow chart of the genetic algorithm is given in figure 2. The determination of the resistance coefficient of the heat supply network was decomposed into two independent processes: nonlinear programming with explicit constraint conditions and calling the external hydraulic calculation model repeatedly to obtain the corresponding flow rate G S for different drag coefficients S. This method was used to minimize the objective function. Thus, the solution process could automatically satisfy the necessary constraint conditions, such as the continuity equation and energy conservation equation of the pipe network, which simplified the optimization process of the model and helped to improve the speed of the solution.
As shown in figure 1, the main parameters of the genetic algorithm were the population size, crossover probability, mutation probability, and termination condition of the evolutionary algebra. The size of the population determined the convergence speed of the genetic algorithm and the diversity of the population. In this paper, N groups of resistance coefficient column vector are generated randomly in the range of the resistance coefficient S, and the value of N was 20-200. If the crossover were too large, the excellent structure of the population obtained via the evolutionary process could be destroyed, which would make the search too random. However, a smaller cross probability would lead to the slow discovery of new individuals. Thus, the cross-probability range was selected as 0.4-0.99 [10]. If mutation probability were too small, the ability of the mutation operation to produce new individuals and the ability to avoid premature convergence would be poor. If the probability of mutation were too high, the randomness would be too large. Thus, the mutation probability range was set as 0.005-0.01. When the following conditions were met, the evolution of the genetic algorithm population was terminated: the population algebra reached 200 generations and the weighted average change of the population fitness function value was less than 10−6 or the evolution algebra exceeded 50 generations.

Determination of search range for resistance coefficient
As shown in equation (2), the optimization model of the variable drag coefficient included explicit constraints of the decision variable S. For the normal operation of the heat supply network, the difference between the actual operating resistance coefficient and the design resistance coefficient of each section is within a certain range. The design resistance coefficient of the pipeline was calculated as follows:  3 and a is the ratio of the local resistance along the pipeline. It can be seen from the above formula that the main reasons for the deviation between the actual value and the design value of the resistance coefficient are the equivalent absolute roughness of the inner wall of the pipeline and the inaccurate estimation of the local resistance equivalent length of the pipeline section. b ¢ i represents the true local resistance ratio of the pipe. Then the ratio of the true resistance coefficient to the design resistance coefficient of the pipeline is: Where S i is the design resistance coefficient of i pipe sections; K i is the equivalent absolute roughness of the inner wall of the design pipeline of i sections; b i is the design local resistance ratio of section i.

Determination of parameters of genetic algorithm
When using the genetic algorithm in MATLAB to optimize the determination of drag coefficient, in addition to the accurate mathematical description of the optimized target, it is also necessary to set reasonable operation and parameters in the algorithm. In this paper, in the process of calculation, combined with the actual heating network, a group of network observation data is used for trial calculation. The calculation results are shown in figure 3: After trial calculation under different parameter settings, each operation algorithm of genetic algorithm and determination of parameters are determined as shown in table 1.

Verification of optimization method based on measured engineering data
Based on the theoretical study of the determination of the variable resistance coefficient of the heating network through optimization, the actual operation data of the heating system in a residential quarter in Luoyang from 2019 to 2020 was used to verify the proposed method. The total heating area of the district heating system was more than 72,000 m2, and it included one heat exchange station, eight residential buildings, and nine thermal entrances. Each thermal entrance was equipped with a heat metering device, which could upload the flow data of the end pipe section at each thermal entrance in real time. In addition, a dynamic pressure-difference balancing valve and other regulating devices were installed at each thermal inlet. The drag coefficient of the pipe section changed in real time as the adjustment device changed. The drag coefficient when these changes occur reflects the running state of the pipe network at the present time, and it is also the objective of the variable resistance coefficient optimization in this paper. The spatial topological structure of the heating pipe network is shown in figure 4, which consisted of 35 nodes and 44 pipes.
Based on the plane topology of the heat network, the spatial topology distinguished the heat sources, water supply network, backwater pipe network, and end heat user [11]. When the hydraulic conditions were calculated, all the heat sources and the pipe segments of the thermal user were treated as quantities to be calculated, which was more suitable for the determination of the drag coefficient of the pipeline network [12].
From the heating season of 2019-2020, 36 sets of flow observation data at the ends of pipe sections b4, b10, b14, b15, b22, b23, b28, b33, b38 and b42 at each thermal inlet of the residential quarter were obtained, which had large flow fluctuations. Traffic data upload is relatively complete for three days from January 28-30. The length of each heat inlet pipe section is 68, 68, 68, 34, 15.6, 60, 60, 60 and 34 meters respectively, and the pipe diameter is DN80. According to formula (4), the design value of the resistance coefficient of each pipe section and the upper and lower limits of the resistance coefficient during searching are shown in table 2.
Corresponding to the above 36 groups of measured flow data, b4, b10, b14, b15, b22, b23, b28, b33, b38 and b42 pipe sections are optimized and identified by genetic algorithm, and the identification results are substituted  into the hydraulic calculation model to calculate the flow value. Compared with the measured flow data, the results are shown in figures 5-8.
The resistance coefficient identified above is substituted into the hydraulic calculation model and compared with the observed data, and the result is shown in figure 9. The error of each heat inlet pipe section is basically within 5%, and the standard deviation of the identification result is 1.23%, which meets the accuracy requirements of heating pipe network.

Conclusion
Based on the related principles of mass balance, energy balance, and network graph theory, a hydraulic calculation model of a heating network was established in this paper. An identification model of pipe network resistance coefficient was proposed, which only used the data of flow observation points without pressure data. The problem of determining the resistance coefficient was transformed into a nonlinear programming problem with complex constraints. The complete mathematical description of the problem was presented. Because the optimization problem was large scale and had high dimensionality, it was difficult to apply traditional optimization algorithms, so the genetic algorithm was selected. To reduce the difficulty of solving the problem, a hydraulic calculation model of the pipe network was introduced to the optimization problem, and a simplified solution method was presented. Finally, the model and algorithm were verified using actual operation data of a heating system in a residential quarter in Luoyang from 2019 to 2020. The relative error for more than 50% of the results was between 1% and 2%, the relative error of nearly 80% of the results was less than 3%, and the  standard deviation of the algorithm results was 1.23%. This showed that the method combined the new identification model with the genetic algorithm had high accuracy, which could meet the requirements for engineering applications and guide the operation regulation of heating systems.

Data availability statement
All data that support the findings of this study are included within the article (and any supplementary files).

Funding statement
The work was supported by Chinese Government/World Bank/Global Environment Facility-phase ii funded project of China's renewable energy scale development (QUT-2017-ZX-0010)

Conflicts of interest
The authors declare that they have no conflicts of interest to report regarding the present study.