Methods, devices and equipment for detecting abnormal flow in flow meters

CN122365305BActive Publication Date: 2026-08-14HANGZHOU SANCHUAN GUODE INTERNET OF THINGS TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-04
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0002]当前,行业实践中针对流量计数据的异常检测主要采用基于单个流量计的统计方法,然而这些方法在复杂管网系统的物理约束下,难以实现对流量计异常的精准、可靠检测

Benefits of technology

[0064]本发明实施例通过根据目标流量计的安装位置与管段关系,构建以流量计为观测节点的流量守恒网络拓扑图,再获取流量守恒网络拓扑图中各观测节点在设定周期内的累计流量时序数据,并基于质量守恒原理计算各管段的流量理论值,生成流量守恒网络拓扑图中所有管段的理论流量矩阵与实际观测流量矩阵,再根据理论流量矩阵与实际观测流量矩阵,计算各观测节点的流量残差序列,再通过基于统计分布的四分位距法与基于波动分析的方差法,分别确定流量残差序列是否存在显著偏离与异常波动,生成对应的第一分析结果,并根据第一分析结果确定流量守恒网络拓扑图中是否存在流量计异常的情况,若判定存在流量计异常,则基于流量残差序列的时空分布特征,通过预设的异常溯源算法定位具体的异常流量计。如此,通过构建流量守恒网络拓扑图并基于质量守恒原理计算流量理论值以检测异常,解决了现有技术忽视网络约束导致误报漏报高的问题,能够提高流量计异常检测的准确性和可靠性,减少误报和漏报。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122365305B_ABST
    Figure CN122365305B_ABST
Patent Text Reader

Abstract

This application proposes a flow anomaly detection method, detection device, and detection equipment for flow meters, relating to the field of anomaly detection technology. The flow anomaly detection method includes: constructing a flow conservation network topology diagram based on the installation location of the target flow meter and its relationship to pipe segments; acquiring cumulative flow time-series data, calculating the theoretical flow value of each pipe segment based on the principle of mass conservation, and generating a theoretical flow matrix and an actual observed flow matrix for all pipe segments; calculating a flow residual sequence based on the theoretical flow matrix and the actual observed flow matrix; determining whether there are significant deviations or abnormal fluctuations in the flow residual sequence, and generating a first analysis result; determining whether there is a flow meter anomaly; if a flow meter anomaly is determined to exist, locating the specific abnormal flow meter based on the spatiotemporal distribution characteristics of the flow residual sequence using a preset anomaly tracing algorithm. This application can improve the accuracy and reliability of flow meter anomaly detection, and reduce false alarms and missed alarms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of anomaly detection technology, and in particular to a method, detection device and detection equipment for detecting flow anomalies in a flow meter. Background Technology

[0002] Currently, industry practice mainly uses statistical methods based on individual flow meters to detect anomalies in flow meter data. However, these methods are difficult to achieve accurate and reliable detection of flow meter anomalies under the physical constraints of complex pipeline systems. Summary of the Invention

[0003] The main objective of this invention is to provide a method for detecting abnormal flow in a flow meter, which aims to improve the accuracy and reliability of abnormal flow meter detection and reduce false alarms and missed alarms.

[0004] To achieve the above objectives, the present invention provides a method for detecting flow anomalies in a flow meter, the method comprising:

[0005] Based on the installation location of the target flow meter and its relationship with the pipe section, a flow conservation network topology diagram with the flow meter as the observation node is constructed.

[0006] Obtain the cumulative flow time series data of each observation node in the flow conservation network topology diagram within a set period, calculate the theoretical flow value of each pipe segment based on the principle of mass conservation, and generate the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology diagram.

[0007] Based on the theoretical flow matrix and the actual observed flow matrix, calculate the flow residual sequence for each observation node;

[0008] The interquartile range method based on statistical distribution and the variance method based on fluctuation analysis are used to determine whether there are significant deviations and abnormal fluctuations in the flow residual sequence, and the corresponding first analysis results are generated.

[0009] Based on the first analysis result, determine whether there is a flow meter malfunction in the flow conservation network topology diagram;

[0010] If a flow meter malfunction is determined, the specific malfunctioning flow meter is located using a preset malfunction tracing algorithm based on the spatiotemporal distribution characteristics of the flow residual sequence.

[0011] Optionally, the step of determining whether there are significant deviations and abnormal fluctuations in the flow residual sequence using the interquartile range method based on statistical distribution and the variance method based on fluctuation analysis, respectively, and generating corresponding first analysis results, includes:

[0012] Calculate the first and third quartiles of the flow residual sequence, and calculate the interquartile range accordingly;

[0013] The product of the first quartile minus the first preset multiple and the interquartile range is used as the lower limit, and the product of the third quartile plus the first preset multiple and the interquartile range is used as the upper limit to determine the normal range of residuals.

[0014] If the values ​​in the flow residual sequence exceed the normal range of the residuals, it is determined that the flow residual sequence has a significant deviation;

[0015] Calculate the population variance of the flow residual sequence;

[0016] If the total variance is greater than a preset variance threshold, it is determined that the flow residual sequence has abnormal fluctuations.

[0017] Optionally, determining whether there is a flow meter malfunction in the flow conservation network topology based on the first analysis result includes:

[0018] If the first analysis result shows that the flow residual sequence has both significant deviation and abnormal fluctuation, it is determined that there is an anomaly in either the jump-type flowmeter or the impact-type flowmeter.

[0019] If the first analysis result indicates that the flow residual sequence does not deviate significantly but exhibits abnormal fluctuations, the determination is based on the integrity of the data uploaded by the observation node.

[0020] If the flow residual sequence shows a significant deviation but no abnormal fluctuation, and the mean of the flow residual sequence is close to zero, then an anomaly is determined to exist in the constant deviation flowmeter.

[0021] If the flow residual sequence has neither significant deviation nor abnormal fluctuation, and the variance of the flow residual sequence is zero, the node is identified as either a data invariance anomaly or a minimal change anomaly based on the relationship between the maximum and minimum cumulative flow values ​​within the same period.

[0022] Optionally, when the flow residual sequence has neither significant deviation nor abnormal fluctuation, and the variance of the flow residual sequence is zero, determining whether the data is an anomaly of invariance or an anomaly of minimal change based on the relationship between the maximum and minimum cumulative flow values ​​of the node within the same period includes:

[0023] Extract the cumulative flow time-series data of the observation node within the set period, and identify the maximum and minimum cumulative flow values ​​from the cumulative flow time-series data;

[0024] Calculate the absolute difference between the maximum and minimum cumulative flow values ​​to generate the corresponding flow range;

[0025] Obtain the upper limit of the flow meter corresponding to the observation node, and determine the distribution range of its flow range under normal operating conditions based on the historical normal data of the flow meter.

[0026] The dynamic proportional coefficient is determined based on the distribution range, and the dynamic threshold corresponding to the dynamic proportional coefficient and the upper limit of the range is determined.

[0027] Compare the flow range with the dynamic threshold; if the flow range is not greater than the dynamic threshold, determine that the data remains unchanged (abnormal).

[0028] If the flow range is greater than the dynamic threshold, perform a difference operation on the cumulative flow time series data to generate a flow change rate sequence between adjacent time points, calculate the average absolute value of the flow change rate sequence, and determine the average absolute value as the average change rate.

[0029] Extract the average rate of change reference value of the same observation node under the same period from historical normal data, and calculate the rate of change ratio with the average rate of change reference value and the average rate of change;

[0030] The rate of change is compared with a preset second threshold; if the rate of change is not greater than the preset second threshold, the change is determined to be extremely small and abnormal; if the rate of change is greater than the preset second threshold, the data change is determined to be normal.

[0031] Optionally, the step of constructing a flow conservation network topology with the flow meter as the observation node based on the installation location of the target flow meter and the relationship with the pipe segment includes:

[0032] Obtain physical data of the target pipeline network, including the unique identifier of each pipe segment, connection relationship, pipe segment length, pipe segment diameter, installation location of each flow meter, and device identifier of each flow meter;

[0033] Each flow meter is abstracted as an observation node, and a unique node number is assigned to each observation node;

[0034] Each pipe segment is abstracted as a directed edge, and the direction of the edge is determined according to the actual flow direction of the fluid;

[0035] If the flow direction is unknown, it is determined by inference based on the location of the water source and the topology of the pipeline network;

[0036] Establish an observation node-edge association matrix, where rows correspond to observation nodes and columns correspond to pipe segments. The values ​​of the matrix elements represent the connection relationship between the node and the pipe segment and the flow direction.

[0037] The connectivity of the topological graph corresponding to the observed node-edge association matrix is ​​checked using a graph traversal algorithm; if an isolated node exists, a topological error warning is issued.

[0038] Calculate the hydraulic impedance weight of each side based on the physical parameters of each pipe section;

[0039] The flow conservation network topology is generated by assigning weight values ​​to each edge in the observation node-edge correlation matrix according to the hydraulic impedance weight.

[0040] Optionally, the step of assigning weight values ​​to each edge in the observation node-edge correlation matrix according to the hydraulic impedance weights to generate the flow conservation network topology graph includes:

[0041] Based on the physical parameters of each pipe segment and combined with the preset fluid dynamics calculation formula, the basic hydraulic impedance value of each pipe segment under standard operating conditions is calculated.

[0042] Acquire real-time operational data corresponding to each observation node within a set period, wherein the real-time operational data includes fluid pressure, temperature, and viscosity;

[0043] The dynamic operating condition correction factor for each pipe section is calculated based on the real-time operating data. The basic hydraulic impedance value is multiplied by the corresponding dynamic operating condition correction factor to determine the actual hydraulic impedance weight of each pipe section within the set period.

[0044] Train a hydraulic parameter-weight mapping model using historical normal operation data;

[0045] The physical parameters and real-time operating data of each pipe segment are input into the hydraulic parameter-weight mapping model to generate the recommended weight value output by the hydraulic parameter-weight mapping model. The recommended weight value is then weighted and fused with the actual hydraulic impedance weight to generate the comprehensive weight value of the corresponding edge in the observation node-edge association matrix.

[0046] The comprehensive weight value is assigned to the corresponding edge in the flow conservation network topology graph to complete the weight allocation and generate the flow conservation network topology graph.

[0047] Optionally, the step of obtaining the cumulative flow time-series data of each observation node in the flow conservation network topology diagram within a set period, calculating the theoretical flow value of each pipe segment based on the principle of mass conservation, and generating the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology diagram includes:

[0048] The cumulative flow time series data within a set period is collected from each observation node. The data is cleaned, missing values ​​and outliers that are significantly beyond the physical range are removed, and the timestamps are aligned.

[0049] The cleaned cumulative flow data is converted into instantaneous flow data using the time difference method, generating the instantaneous flow value of each observation node in each time interval;

[0050] Based on the node-edge correlation matrix in the flow conservation network topology, establish a flow balance equation for each internal observation node;

[0051] Combine the flow balance equations of all internal observation nodes to construct a system of linear equations with the instantaneous flow rate of each pipe segment as the unknown.

[0052] The linear equations are solved using the least squares method to determine the theoretical flow rate of each pipe segment at each time point.

[0053] The theoretical flow rate of each pipe segment at all time points is arranged in chronological order to generate the theoretical flow rate matrix.

[0054] The actual instantaneous flow values ​​of each observation node are arranged in the same order to generate an actual observed flow matrix.

[0055] Optionally, the step of obtaining the cumulative flow time-series data of each observation node in the flow conservation network topology diagram within a set period, calculating the theoretical flow value of each pipe segment based on the principle of mass conservation, and generating the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology diagram further includes:

[0056] A pipe section leakage loss term is introduced into the flow balance equation. The pipe section leakage loss term is related to the current pressure of the pipe section, the aging coefficient of the pipe material, and the service life.

[0057] The leakage model is trained using historical normal data, the leakage coefficient of each pipe section is estimated through regression analysis, and the leakage coefficient is substituted into the flow balance equation as a known parameter.

[0058] The linear equations are re-solved using the weighted least squares method, where the weight matrix is ​​composed of the confidence weight of each observation node and the reciprocal of the leakage coefficient of each pipe segment.

[0059] A time smoothing constraint is added during the solution process to limit the variation of the theoretical flow rate of the same pipe segment at adjacent time points to not exceed the preset smoothing threshold.

[0060] Calculate the spatial autocorrelation index of the residual matrix. If the autocorrelation index exceeds a preset autocorrelation threshold, it indicates that there may be unidentified topological errors or systematic data deviations, and triggers the topology map review process.

[0061] The parameters and weight matrix of the leakage model are dynamically adjusted based on the statistical characteristics of the residual matrix, and iterative optimization is performed until the norm of the residual matrix is ​​less than the convergence threshold. The final theoretical flow matrix and the actual observed flow matrix are then output.

[0062] In addition, to achieve the above objectives, the present invention also provides a detection device, the detection device comprising: a memory, a processor, and a flow meter flow anomaly detection program stored in the memory and executable on the processor, the flow meter flow anomaly detection program being configured to implement the flow meter flow anomaly detection method as described above.

[0063] In addition, to achieve the above objectives, the present invention also provides a detection device, including the detection apparatus as described above.

[0064] This invention constructs a flow conservation network topology with flow meters as observation nodes based on the installation location of the target flow meter and its relationship with the pipe segments. It then acquires the cumulative flow time-series data of each observation node within a set period and calculates the theoretical flow value of each pipe segment based on the principle of mass conservation. This generates a theoretical flow matrix and an actual observed flow matrix for all pipe segments in the flow conservation network topology. Based on these matrices, the flow residual sequence for each observation node is calculated. The interquartile range method based on statistical distribution and the variance method based on fluctuation analysis are then used to determine whether there are significant deviations or abnormal fluctuations in the flow residual sequence, generating corresponding first analysis results. Based on these first analysis results, it is determined whether there are any flow meter anomalies in the flow conservation network topology. If a flow meter anomaly is identified, a preset anomaly tracing algorithm is used to locate the specific abnormal flow meter based on the spatiotemporal distribution characteristics of the flow residual sequence. Thus, by constructing a flow conservation network topology and calculating the theoretical flow value based on the principle of mass conservation to detect anomalies, the problem of high false alarms and missed alarms caused by neglecting network constraints in existing technologies is solved. This can improve the accuracy and reliability of flow meter anomaly detection and reduce false alarms and missed alarms. Attached Figure Description

[0065] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0066] Figure 1 This is a schematic flowchart of a flow meter flow anomaly detection method according to an embodiment of the present invention;

[0067] Figure 2 This is a schematic flowchart of a flow meter flow anomaly detection method according to another embodiment of the present invention;

[0068] Figure 3This is a schematic flowchart of a flow meter flow anomaly detection method according to another embodiment of the present invention;

[0069] Figure 4 This is a schematic flowchart of a flow meter flow anomaly detection method according to another embodiment of the present invention;

[0070] Figure 5 This is a schematic flowchart of a flow meter flow anomaly detection method according to another embodiment of the present invention;

[0071] Figure 6 This is a schematic flowchart of a flow meter flow anomaly detection method according to another embodiment of the present invention;

[0072] Figure 7 This is a schematic flowchart of a flow meter flow anomaly detection method according to another embodiment of the present invention;

[0073] Figure 8 This is a schematic flowchart of a flow meter flow anomaly detection method according to another embodiment of the present invention.

[0074] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0075] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Well-known modules, units, and their connections, links, communications, or operations are not shown or described in detail. Furthermore, the described features, architectures, or functions can be combined in any way in one or more embodiments. Those skilled in the art should understand that the various embodiments described below are only for illustrative purposes and not for limiting the scope of protection of the present invention. It is also readily understood that the modules, units, or processing methods in the various embodiments described herein and shown in the accompanying drawings can be combined and designed in various different configurations. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0076] As core metering and monitoring devices in fluid distribution systems such as water supply networks, industrial water systems, gas transmission networks, heat supply systems, chemical process pipelines, and municipal drainage systems, the accuracy of flow meters directly affects the accuracy of system safety operation, energy consumption management, leak control, and economic accounting. With the popularization of Internet of Things (IoT) technology, a large number of deployed flow meters can continuously upload cumulative flow data, providing a data foundation for real-time monitoring and anomaly early warning of the system status. Therefore, accurate and efficient detection of the flow meter's own operating status and timely identification of abnormal readings (such as jumps, stagnation, or drift) are crucial for ensuring the reliability of data and the level of intelligent operation of the entire distribution system.

[0077] Currently, industry practice for anomaly detection in flowmeter data primarily employs statistical methods based on individual flowmeters. These methods include setting fixed threshold ranges to check or analyze the statistical characteristics of the data sequence itself (including sliding variance calculation and simple abrupt change detection). However, these methods have significant drawbacks: they process the data sequence of each flowmeter in isolation, completely ignoring the specific location of the flowmeter in the actual pipeline network and its physical correlation and constraints with other flowmeters determined by the law of mass conservation. In a real pipeline network topology, the readings of multiple flowmeters are interconnected through pipe segments, forming a flow conservation network; the data at each node are not independent. Because existing technologies fail to incorporate this networked physical constraint into the analysis model, the reliability of anomaly detection results is insufficient, resulting in high false alarm and false negative rates. Specifically, fluctuations in individual flowmeter data caused by normal operating conditions or changes in upstream and downstream water usage may be misjudged as instrument malfunctions; conversely, minor deviations caused by internal problems in the flowmeter may be missed because the reading remains within the "normal" range of isolated statistics. This limitation makes it difficult to achieve accurate and reliable detection of flowmeter anomalies under the physical constraints of complex pipeline systems.

[0078] The main solution of this application embodiment is as follows: A flow conservation network topology is constructed based on the installation location of the target flow meter and its relationship with the pipe segments. Then, the cumulative flow time-series data of each observation node in the flow conservation network topology within a set period is obtained. Based on the principle of mass conservation, the theoretical flow value of each pipe segment is calculated, generating a theoretical flow matrix and an actual observed flow matrix for all pipe segments in the flow conservation network topology. Based on the theoretical flow matrix and the actual observed flow matrix, the flow residual sequence of each observation node is calculated. Then, using the interquartile range method based on statistical distribution and the variance method based on fluctuation analysis, it is determined whether there are significant deviations or abnormal fluctuations in the flow residual sequence, generating corresponding first analysis results. Based on the first analysis results, it is determined whether there are any flow meter anomalies in the flow conservation network topology. If a flow meter anomaly is determined, the specific abnormal flow meter is located based on the spatiotemporal distribution characteristics of the flow residual sequence using a preset anomaly tracing algorithm.

[0079] In this embodiment, for ease of description, the following description will focus on the detection device as the main execution subject.

[0080] This application provides a solution that detects anomalies by constructing a flow conservation network topology and calculating the theoretical flow value based on the principle of mass conservation. This solves the problem of high false alarms and missed alarms caused by neglecting network constraints in existing technologies, and can improve the accuracy and reliability of flow meter anomaly detection, and reduce false alarms and missed alarms.

[0081] Therefore, this invention proposes a method for detecting abnormal flow in a flow meter. It is understood that the detection device is equipped with a detection device for storing and executing the following method. The detection device can be implemented using a main controller, such as an MCU (Micro Controller Unit), a DSP (Digital Signal Processor), an FPGA (Field Programmable Gate Array), or a SOC (System On Chip).

[0082] Existing methods for detecting flow meter anomalies typically analyze individual flow meter data sequences in isolation, neglecting the surrounding pipeline environment and the physical connections and constraints between the flow meter and other flow meters determined by the law of conservation of mass. This results in high false alarm and false negative rates, making it difficult to achieve accurate and reliable detection and identification of flow meter anomalies under the physical constraints of complex pipeline systems. For example, fluctuations in normal operating conditions or changes in upstream and downstream water usage may be misjudged as instrument anomalies, while minor fault deviations may be missed.

[0083] Therefore, referring to Figure 1In one embodiment of the present invention, the flow anomaly detection method of the flow meter includes steps S100-S600, wherein:

[0084] S100. Based on the installation location of the target flow meter and the relationship with the pipe section, construct a flow conservation network topology with the flow meter as the observation node.

[0085] S200. Obtain the cumulative flow time series data of each observation node in the flow conservation network topology diagram within a set period, calculate the theoretical flow value of each pipe segment based on the principle of mass conservation, and generate the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology diagram.

[0086] S300. Based on the theoretical flow matrix and the actual observed flow matrix, calculate the flow residual sequence for each observation node;

[0087] S400. Using the interquartile range method based on statistical distribution and the variance method based on fluctuation analysis, determine whether there are significant deviations and abnormal fluctuations in the flow residual sequence, and generate the corresponding first analysis results.

[0088] S500. Based on the first analysis result, determine whether there is a flow meter malfunction in the flow conservation network topology diagram.

[0089] S600. If a flow meter malfunction is determined, the specific malfunctioning flow meter is located using a preset malfunction tracing algorithm based on the spatiotemporal distribution characteristics of the flow residual sequence.

[0090] Flow meters are used in water supply networks, industrial water systems, gas transmission networks, heat supply systems, chemical process pipelines, and municipal drainage systems. A flow meter is a device used to measure fluid flow rate, and the accuracy of its data is crucial for the safe operation, energy management, leakage control, and economic accounting of fluid distribution systems. This equipment can be applied to scenarios such as water supply networks, industrial water systems, gas transmission networks, heat supply systems, chemical process pipelines, and municipal drainage systems. A flow conservation network topology diagram is an abstract model representing the structure of a pipeline system, where flow meters are abstracted as observation nodes, and pipe segments are abstracted as edges connecting nodes. This topology diagram reflects the flow path and connection relationships of fluids in the pipeline network and is constructed based on the principle of mass conservation to ensure flow balance among nodes in the network. An observation node, in the flow conservation network topology diagram, refers to each flow meter abstracted as an observation node, representing a location in the pipeline network where flow data can be collected and monitored.

[0091] The cumulative flow time series data refers to the cumulative flow values ​​continuously collected and recorded by each observation node (flowmeter) within a set period. These data are arranged in chronological order to form a time series. The principle of mass conservation states that in a fluid distribution system, in the absence of leakage or injection, the mass of fluid flowing into a region is equal to the mass of fluid flowing out of that region; that is, at any node, the sum of the inflow flow rate equals the sum of the outflow flow rate. The theoretical flow rate value refers to the expected flow rate value of each pipe segment at a specific time point, calculated through a mathematical model based on the flow conservation network topology and the principle of mass conservation. The theoretical flow rate matrix contains the theoretical flow rate values ​​of all pipe segments in the flow conservation network topology at each time point within the set period, organized in matrix form. The actual observed flow rate matrix contains the actual instantaneous flow rate values ​​of each observation node in the flow conservation network topology at each time point within the set period, organized in matrix form.

[0092] The flow residual sequence refers to the sequence of differences between the actual observed flow values ​​at each observation node and the theoretical flow values ​​calculated based on the principle of mass conservation, reflecting the degree of deviation between the actual and theoretical flow. The interquartile range (INR) method is an anomaly detection method based on statistical distribution. It determines the normal range of the data by calculating the quartiles and INR, thereby determining whether there is a significant deviation. The variance method is an anomaly detection method based on fluctuation analysis. It measures the degree of data fluctuation by calculating the variance of the data sequence, thereby determining whether there is abnormal fluctuation. The first analysis result refers to the comprehensive judgment on whether there is significant deviation and abnormal fluctuation in the flow residual sequence after analyzing it using the INR and variance methods. The anomaly tracing algorithm is a pre-defined algorithm used to further analyze and locate the specific abnormal flow meter after determining that an anomaly exists, based on the spatiotemporal distribution characteristics of the flow residual sequence.

[0093] First, based on the installation location of the target flowmeter and its relationship to the pipe segments, a flow conservation network topology diagram is constructed, with the flowmeters as observation nodes. This topology diagram can be constructed manually. For example, based on pipeline engineering drawings or field survey results, each flowmeter is marked as an observation node, and the network diagram is drawn according to the connection relationships of the pipe segments. The flow direction in the pipe segments can be initially determined based on experience or simple pressure differences.

[0094] Secondly, the cumulative flow time-series data of each observation node in the flow conservation network topology is obtained within a set period. Based on the principle of mass conservation, the theoretical flow value of each pipe segment is calculated, and the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology are generated. For example, the cumulative flow data can be periodically read through the local storage of the flow meter or a simple remote data acquisition module. When calculating the theoretical flow value, for each observation node, the sum of the instantaneous flow of all inflow pipe segments can be simply compared with the sum of the instantaneous flow of all outflow pipe segments, and it is assumed that they should be equal. The theoretical flow matrix and the actual observed flow matrix are then directly constructed from these data and calculation results.

[0095] Specifically, based on the theoretical flow matrix and the actual observed flow matrix, the flow residual sequence for each observation node is calculated. Specifically, the actual instantaneous flow value at each observation node at each time point can be subtracted point-by-point from the theoretical instantaneous flow value calculated using the principle of mass conservation, thereby obtaining the flow residual sequence for that observation node.

[0096] Based on this, the interquartile range method (based on statistical distribution) and the variance method (based on fluctuation analysis) are used to determine whether the flow residual sequence exhibits significant deviations and abnormal fluctuations, respectively, generating the corresponding first analysis results. For example, a fixed residual threshold can be preset; if any value in the flow residual sequence exceeds this threshold, it is considered that there is a significant deviation. Similarly, a fixed variance threshold can be preset; if the variance of the flow residual sequence exceeds this threshold, it is considered that there is abnormal fluctuation. These two judgment results can be combined to form the first analysis result.

[0097] Next, based on the results of the first analysis, it is determined whether there are any flow meter anomalies in the flow conservation network topology. This can be done using simple logical judgment based on the first analysis results. For example, if the first analysis results show significant deviations or abnormal fluctuations, a preliminary judgment is made that a flow meter anomaly exists. If neither of these exists, it is determined that there is no anomaly.

[0098] Finally, if a flow meter anomaly is determined, the specific abnormal flow meter is located based on the spatiotemporal distribution characteristics of the flow residual sequence using a pre-defined anomaly tracing algorithm. For example, a simple rule base can be pre-defined: if the residual sequence of a certain observation node is consistently positive and has a large value, it may indicate that the flow meter reading is too high. By consulting these pre-defined rules and combining the performance of the residual sequence at different time points and different observation nodes, the specific abnormal flow meter can be located.

[0099] The flow anomaly detection method for flow meters proposed in this embodiment constructs a flow conservation network topology and incorporates the principle of mass conservation into the calculation of theoretical flow values, achieving networked and global analysis of flow meter data. This method effectively overcomes the limitations of traditional isolated detection methods, significantly reducing false alarm and false negative rates. By combining statistical distribution and fluctuation analysis, and performing anomaly tracing, this embodiment can accurately identify and locate various flow meter anomalies in complex fluid distribution systems such as water supply networks and industrial water systems, thereby ensuring the reliability of system data and the level of intelligent operation.

[0100] This embodiment constructs a flow conservation network topology with the flowmeter as the observation node based on the installation location of the target flowmeter and its relationship with the pipe segment. It then acquires the cumulative flow time-series data of each observation node within a set period in the flow conservation network topology and calculates the theoretical flow value of each pipe segment based on the principle of mass conservation. This generates a theoretical flow matrix and an actual observed flow matrix for all pipe segments in the flow conservation network topology. Based on these matrices, the flow residual sequence for each observation node is calculated. The interquartile range method based on statistical distribution and the variance method based on fluctuation analysis are then used to determine whether there are significant deviations or abnormal fluctuations in the flow residual sequence, generating corresponding first analysis results. Based on these first analysis results, it is determined whether there are any flowmeter anomalies in the flow conservation network topology. If a flowmeter anomaly is identified, a pre-defined anomaly tracing algorithm is used to locate the specific abnormal flowmeter based on the spatiotemporal distribution characteristics of the flow residual sequence. Thus, by constructing a flow conservation network topology and calculating the theoretical flow value based on the principle of mass conservation to detect anomalies, the problem of high false alarms and missed alarms caused by neglecting network constraints in existing technologies is solved. This can improve the accuracy and reliability of flow meter anomaly detection and reduce false alarms and missed alarms.

[0101] In practical applications, the key is how to specifically quantify "significant deviation" and "abnormal fluctuation". Without clear judgment criteria, it may lead to ambiguity or misjudgment of abnormal detection results, thereby affecting the accuracy and reliability of the entire detection method.

[0102] Therefore, referring to Figure 2 Another embodiment of the present invention provides a method for detecting abnormal flow in a flow meter, based on the above. Figure 1 The illustrated embodiment uses the interquartile range method based on statistical distribution and the variance method based on fluctuation analysis to determine whether there are significant deviations and abnormal fluctuations in the flow residual sequence, respectively, and generates corresponding first analysis results, including steps S410-S450, wherein:

[0103] S410. Calculate the first and third quartiles of the flow residual sequence, and calculate the interquartile range accordingly.

[0104] S420. The product of the first quartile minus the first preset multiple and the interquartile range is used as the lower limit, and the product of the third quartile plus the first preset multiple and the interquartile range is used as the upper limit to determine the normal range of residuals.

[0105] S430. If the value in the flow residual sequence exceeds the normal range of the residual, it is determined that the flow residual sequence has a significant deviation.

[0106] S440. Calculate the total variance of the flow residual sequence;

[0107] S450. If the value of the total variance is greater than the preset variance threshold, it is determined that the flow residual sequence has abnormal fluctuations.

[0108] First, the first and third quartiles of the flow residual sequence are calculated, and then the interquartile range (IQR) is calculated based on these. For example, the first quartile (Q1) represents the value at the 25th percentile after sorting the flow residual sequence from smallest to largest, while the third quartile (Q3) represents the value at the 75th percentile. The IQR is the difference between the third quartile and the first quartile. It reflects the dispersion of the middle 50% of the data set, is insensitive to outliers, and effectively resists the influence of extreme values, providing a robust statistical basis for subsequent anomaly detection. The calculation method typically involves sorting the flow residual sequence and then performing interpolation calculations based on the data volume and the definition of quartiles.

[0109] Next, a normal residual interval is determined by using the product of the first quartile minus a first preset multiple and the interquartile range as the lower limit, and the product of the third quartile plus the first preset multiple and the interquartile range as the upper limit. The first preset multiple is an adjustable parameter, which can be set to 1.5, but can also be adjusted according to the actual application scenario and the requirements for anomaly sensitivity. By multiplying the interquartile range by this multiple and subtracting from or adding to the third quartile from the first quartile, an interval containing the vast majority of normal data can be constructed. This interval can effectively exclude outliers, i.e., residual values ​​that significantly deviate from the main data distribution, thus providing a clear boundary for judging significant deviations. If the value in the flow residual sequence exceeds the normal residual interval, i.e., less than the lower limit or greater than the upper limit, then the flow residual sequence is determined to have a significant deviation. This interquartile range-based method can robustly identify residual values ​​that significantly deviate from the main data distribution, effectively avoiding the problem of traditional fixed threshold methods being susceptible to extreme values.

[0110] Furthermore, to assess the volatility of the flow residual sequence, this embodiment also includes calculating the overall variance of the flow residual sequence. Variance is a commonly used statistic to measure the degree of data dispersion; it represents the average of the squares of the differences between each value in the sequence and its mean. The larger the variance, the stronger the volatility of the flow residual sequence, and the greater the deviation of the data points from the mean. The calculation method typically involves first calculating the mean of the sequence, then calculating the square of the difference between each data point and the mean, summing the results, and dividing by the number of data points (or the number minus one). If the value of the overall variance is greater than a preset variance threshold, it is determined that the flow residual sequence exhibits abnormal volatility. This variance threshold is a critical value set based on historical normal operation data or expert experience. When the calculated overall variance of the flow residual sequence exceeds this threshold, it indicates an abnormally increased volatility in the residual sequence, which may indicate unstable flowmeter readings, intermittent malfunctions, or drastic changes in the measurement environment, thus being judged as exhibiting abnormal volatility.

[0111] Through the above technical solution, this embodiment provides a specific and quantitative method to determine whether there are significant deviations and abnormal fluctuations in the flow residual sequence. By introducing the first quartile, the third quartile, and the interquartile range, a normal residual interval robust to extreme values ​​is constructed, making the judgment of significant deviations in the flow residual sequence more accurate and stable, avoiding the problem of being easily disturbed by extreme values ​​in the single threshold method. In addition, by calculating the overall variance of the flow residual sequence and comparing it with a preset variance threshold, abnormal fluctuations in the flow residual sequence can be sensitively captured, effectively identifying the instability or intermittent faults of the flowmeter readings. This comprehensive judgment mechanism combining statistical distribution and fluctuation analysis makes the first analysis result of flow anomaly detection more refined and reliable, providing a solid data foundation for subsequent determination of flowmeter anomaly types and anomaly tracing, significantly improving the accuracy and robustness of flow anomaly detection.

[0112] A simple judgment based solely on the presence or absence of deviation or fluctuation is insufficient to provide sufficiently specific information about the type of anomaly, thus limiting the efficiency of subsequent fault diagnosis and maintenance. Different types of flowmeter anomalies may exhibit similar deviation or fluctuation characteristics, but their root causes and handling methods differ significantly. Therefore, a more refined anomaly classification mechanism is needed to provide maintenance personnel with more instructive diagnostic results.

[0113] Therefore, referring to Figure 3 Another embodiment of the present invention provides a method for detecting abnormal flow in a flow meter, based on the above. Figure 1 The embodiment shown determines whether there is a flow meter malfunction in the flow conservation network topology based on the first analysis result, including steps S510-S540, wherein:

[0114] S510. If the first analysis result shows that the flow residual sequence has both significant deviation and abnormal fluctuation, it is determined that there is a jump-type flowmeter abnormality or an impact-type flowmeter abnormality.

[0115] S520. If the first analysis result indicates that the flow residual sequence does not have a significant deviation but has abnormal fluctuations, the determination is made based on the integrity of the data uploaded by the observation node.

[0116] S530. If the flow residual sequence has a significant deviation but no abnormal fluctuation, and the mean of the flow residual sequence is close to zero, it is determined that there is an abnormality in the constant deviation flow meter.

[0117] S540. When the flow residual sequence has neither significant deviation nor abnormal fluctuation, and the variance of the flow residual sequence is zero, the data is determined to be either unchanged or extremely small based on the relationship between the maximum and minimum cumulative flow values ​​of the node in the same period.

[0118] When the first analysis results indicate that the flow residual sequence exhibits both significant deviation and abnormal fluctuations, this typically signifies a drastic and unstable change in the flowmeter reading. Significant deviation indicates that the residual value consistently exceeds the normal range, while abnormal fluctuations suggest that these residual values ​​are not stable within a deviation state but rather exhibit high-frequency or large-amplitude irregular changes. This combined pattern often corresponds to sudden and highly destructive anomalies, such as sudden damage to internal flowmeter components, external impact on the sensor, or drastic transient changes in the measured medium. Therefore, classifying these as jump-type or impulse-type flowmeter anomalies can quickly alert maintenance personnel to potential fault types requiring urgent attention. Jump-type anomalies may manifest as readings jumping from one stable value to another within a short period, while impulse-type anomalies may manifest as brief but dramatic peaks or troughs.

[0119] In another scenario, if the first analysis shows no significant deviation in the flow residual sequence but abnormal fluctuations exist, it indicates that while the flowmeter readings do not consistently deviate from the theoretical value overall, their stability or consistency is poor, exhibiting irregular jitter or noise. To avoid misjudgment, this embodiment introduces a step of evaluating the integrity of the data uploaded by the observation node. Data integrity can include indicators such as packet loss rate, transmission delay, and checksum error rate. If data integrity is low, abnormal fluctuations may not originate from a physical fault in the flowmeter itself, but rather from an unstable data transmission link, a communication module failure, or a problem with the data acquisition system. By combining data integrity assessment, flowmeter hardware faults and data link problems can be effectively distinguished, thereby avoiding unnecessary on-site inspections and improving diagnostic accuracy.

[0120] Furthermore, when the flow residual sequence exhibits significant deviations but no abnormal fluctuations, and the mean of the flow residual sequence approaches zero, this indicates that although the flowmeter readings deviate from the theoretical value at certain times or stages, this deviation is relatively stable, and positive and negative deviations cancel each other out over the entire observation period, resulting in an average residual close to zero. This pattern may indicate a constant deviation anomaly in the flowmeter. For example, the flowmeter may consistently overestimate or underestimate the flow rate under specific operating conditions, but as the operating conditions change, the direction of its deviation may reverse, resulting in a zero mean over a long period. This constant deviation anomaly is usually related to the flowmeter's calibration error, sensor aging, or systematic errors under specific environmental conditions, requiring recalibration or component replacement.

[0121] Finally, for the most subtle anomaly, namely when the flow residual sequence shows neither significant deviation nor abnormal fluctuation, and the variance of the flow residual sequence is zero, this indicates that the flowmeter reading is almost constant throughout the observation period and consistent with the theoretical value. However, in actual operation, pipeline flow is usually dynamic. Therefore, if the cumulative flow value reported by the flowmeter remains unchanged or changes very little over a period of time, even if the residual analysis results seem normal, it may indicate that the flowmeter has "stuck" or stopped working. In this case, this embodiment analyzes the relationship between the maximum and minimum cumulative flow values ​​of the node within the same period to determine whether there is a data invariance anomaly or a minimal change anomaly. If the maximum and minimum cumulative flow values ​​are exactly the same, it can be determined as a data invariance anomaly; if the difference between the two is very small, it may be a minimal change anomaly. This meticulous judgment can discover those "silent" faults, that is, the flowmeter does not report erroneous data, but it also does not report true data, thereby avoiding monitoring blind spots caused by flowmeter failure.

[0122] Through the above technical solution, this embodiment can classify flow meter anomalies more precisely and accurately. This multi-dimensional, hierarchical anomaly diagnosis method can not only identify whether a flow meter is abnormal, but more importantly, it can distinguish the type of anomaly, such as sudden jumps or shocks, fluctuations caused by data transmission problems, systemic constant deviations, or hidden faults such as flow meter "stalling" or data stagnation. This detailed classification information provides maintenance personnel with clear diagnostic basis, enabling them to take targeted maintenance strategies for different types of anomalies, such as immediately checking sensors, troubleshooting communication links, recalibrating flow meters, or replacing faulty equipment, thereby significantly improving the efficiency and accuracy of fault diagnosis, reducing false alarm rates, and ensuring the stable operation of the pipeline network system.

[0123] In certain scenarios, when the flow residual sequence shows neither significant deviation nor abnormal fluctuation, and its variance is zero, traditional analysis methods may struggle to accurately distinguish whether the flow meter is in a "data-unchanged anomaly" state (i.e., the data is completely stagnant or fixed) or a "minimally changing anomaly" state (i.e., the data shows slight changes but are insufficient to trigger conventional anomaly detection mechanisms). This ambiguity can lead to misjudgments of the flow meter's true operating status, affecting subsequent fault diagnosis and maintenance decisions.

[0124] Therefore, referring to Figure 4 Another embodiment of the present invention provides a method for detecting abnormal flow in a flow meter, based on the above. Figure 3 The illustrated embodiment, where the flow residual sequence has neither significant deviation nor abnormal fluctuation, and the variance of the flow residual sequence is zero, determines whether the data is an anomaly of invariance or an anomaly of minimal change based on the relationship between the maximum and minimum cumulative flow values ​​of the node within the same period, including steps S541-S548, wherein:

[0125] S541. Extract the cumulative flow time series data of the observation node within the set period, and identify the maximum and minimum cumulative flow values ​​from the cumulative flow time series data;

[0126] S542. Calculate the absolute difference between the maximum cumulative flow value and the minimum cumulative flow value, and generate the corresponding flow range;

[0127] S543. Obtain the upper limit of the flow range of the flow meter corresponding to the observation node, and determine the distribution range of the flow range under normal operating conditions based on the historical normal data of the flow meter.

[0128] S544. Determine the dynamic proportional coefficient based on the distribution range, and determine the dynamic threshold corresponding to the dynamic proportional coefficient and the upper limit of the range;

[0129] S545. Compare the flow range with the dynamic threshold; if the flow range is not greater than the dynamic threshold, determine that the data remains unchanged and is abnormal.

[0130] S546. If the flow range is greater than the dynamic threshold, perform a differential operation on the cumulative flow time series data to generate a flow change rate sequence between adjacent time points, calculate the absolute average value of the flow change rate sequence, and determine the absolute average value as the average change rate.

[0131] S547. Extract the average rate of change reference value of the same observation node under the same period from historical normal data, and calculate the rate of change ratio with the average rate of change reference value and the average rate of change;

[0132] S548. Compare the rate of change ratio with a preset second threshold; if the rate of change ratio is not greater than the preset second threshold, determine that the change is extremely small and abnormal; if the rate of change ratio is greater than the preset second threshold, determine that the data change is normal.

[0133] First, obtain the basic data for analysis, namely the cumulative flow records of the flow meter within a specific time period. By identifying the maximum and minimum values ​​from these records, we can gain a preliminary understanding of the overall fluctuation range of the flow data within that period. For example, this can be achieved by traversing the entire time-series dataset or by directly obtaining the maximum and minimum record values ​​using database query functions.

[0134] Next, the absolute difference between the maximum and minimum cumulative flow values ​​is calculated to generate the corresponding flow range. The flow range is an intuitive indicator of the magnitude of data change within a given period. By calculating the absolute difference between the maximum and minimum cumulative flow values, the total change in the flow meter within that period can be quantified, providing key parameters for subsequent anomaly detection.

[0135] Subsequently, the upper limit of the flowmeter's range corresponding to the observation node is obtained, and based on the flowmeter's historical normal data, the distribution range of its flow range under normal operating conditions is determined. The upper limit of the flowmeter's range is the boundary of its designed operating range, usually provided by the equipment manufacturer. Historical normal data refers to a dataset collected and validated during the flowmeter's normal operation. By performing statistical analysis on this historical normal data, such as calculating the mean, standard deviation, percentiles, or constructing a probability density function, a benchmark can be established to assess whether the current flow range is within the normal range.

[0136] Based on this, a dynamic proportional coefficient is determined according to the distribution range, and a dynamic threshold corresponding to the dynamic proportional coefficient and the upper limit of the flow range is determined. The dynamic proportional coefficient can be adaptively adjusted according to the distribution characteristics of the historical normal flow range (such as dispersion and fluctuation) as well as factors such as the accuracy class of the flow meter and the application scenario. For example, it can be set as the ratio of a certain percentile of the historical normal range distribution to the upper limit of the flow range, or an empirical value can be set according to the accuracy class of the flow meter. The dynamic threshold is obtained by multiplying the dynamic proportional coefficient by the upper limit of the flow meter's flow range, which can provide a more adaptive judgment standard based on the characteristics of the flow meter and its historical operating conditions.

[0137] Then, the flow rate range is compared with the dynamic threshold; if the flow rate range is not greater than the dynamic threshold, the data invariance anomaly is determined. This step, by comparing the currently calculated flow rate range with the dynamic threshold, preliminarily determines whether the flow data is in a state of almost no change. If the flow rate range is very small, even close to zero, and not greater than the dynamic threshold, it indicates that the flow meter's data output may have stagnated or become fixed, i.e., a data invariance anomaly has occurred.

[0138] If the flow range exceeds the dynamic threshold, a difference operation is performed on the cumulative flow time series data to generate a flow change rate sequence between adjacent time points. The absolute average of the flow change rate sequence is then calculated and determined as the average change rate. When the flow range exceeds the dynamic threshold but is still insufficient to be identified as an anomaly by conventional fluctuation analysis methods, a more refined analysis of its changing trend is required. The difference operation (i.e., calculating the difference in cumulative flow between adjacent time points) can reveal the instantaneous flow changes. By calculating the absolute average of these instantaneous flow change rates, an indicator reflecting the average activity level of the flow data, namely the average change rate, can be obtained.

[0139] This process involves extracting a reference value for the average rate of change of the same observation node within the same period from historical normal data, and calculating the ratio of this average rate of change to the reference value and the corresponding average rate of change. To standardize the evaluation of the currently calculated average rate of change, a reference benchmark is needed. This reference value is statistically derived from the average rate of change of the flowmeter within the same set period under historical normal operating conditions. By calculating the ratio between the current average rate of change and this reference value, the influence of absolute value differences between different flowmeters or under different operating conditions can be eliminated, making the comparison more fair and effective.

[0140] Finally, the rate of change ratio is compared with a preset second threshold. If the rate of change ratio is not greater than the preset second threshold, the change is determined to be extremely small (abnormal); if the rate of change ratio is greater than the preset second threshold, the data change is determined to be normal. The preset second threshold is an empirical value or a critical value determined through historical data analysis, used to distinguish between "extremely small change" and "normal change." If the rate of change ratio is lower than or equal to this threshold, it indicates that although the flow data has changed, its degree of change is far below the average level under normal operating conditions, thus it is judged as extremely small (abnormal). Conversely, if the rate of change ratio exceeds this threshold, the flow data is considered to be in a normal change state.

[0141] Through the above technical solution, this embodiment effectively solves the problem of accurately distinguishing between "data invariance anomalies" and "minor variation anomalies" when the flow residual sequence has neither significant deviation nor abnormal fluctuation, and the variance is zero. First, by extracting the cumulative flow time-series data of the observation nodes and calculating their flow range, an adaptive dynamic threshold is generated by combining the upper limit of the flowmeter's range and the dynamic proportional coefficient determined from historical normal data. Comparing the flow range with this dynamic threshold allows for the preliminary and accurate identification of "data invariance anomalies" where the data is completely stagnant or fixed, avoiding misjudgments caused by minor noise or system errors. Second, for cases where the flow range exceeds the dynamic threshold but remains in a low-fluctuation state, this embodiment introduces the concepts of differential operation and average rate of change, comparing it with the average rate of change reference value in historical normal data to calculate the rate of change ratio. By comparing this rate of change ratio with a preset second threshold, "minor variation anomalies" can be finely distinguished, where the data changes but the degree of change is extremely low, thus avoiding misjudgment as normal data. This layered and dynamic judgment mechanism makes full use of the flow meter's own characteristics and historical operating patterns, improving the accuracy and robustness of anomaly detection. It enables the accurate identification of potential flow meter failure modes even when the flow data appears stable, providing a more reliable basis for subsequent fault diagnosis and maintenance.

[0142] In practical applications, relying solely on the installation location of flow meters and pipe segment relationships may not fully reflect the actual flow characteristics of the fluid. This results in the constructed topology map failing to accurately support flow calculations based on the principle of mass conservation, thus affecting the accuracy of flow anomaly detection. The challenge lies in accurately and comprehensively transforming physical pipe network information into a topology structure usable for flow conservation calculations, while ensuring its effectiveness and accuracy.

[0143] Therefore, referring to Figure 5 In another embodiment of the present invention, a method for detecting abnormal flow in a flow meter is provided, based on the above. Figure 1 The illustrated embodiment constructs a flow conservation network topology with the flow meter as the observation node based on the installation location of the target flow meter and the relationship with the pipe segment, including steps S110-S180, wherein:

[0144] S110. Obtain the physical data of the target pipeline network, including the unique identifier of all pipe segments, connection relationship, pipe segment length, pipe segment diameter, installation location of each flow meter, and device identifier of each flow meter.

[0145] S120. Abstract each flow meter into an observation node and assign a unique node number to each observation node;

[0146] S130. Abstract each pipe segment as a directed edge, and the direction of the edge is determined according to the actual flow direction of the fluid;

[0147] S140. If the flow direction is unknown, it shall be determined by inference based on the location of the water source and the topology in the pipeline network.

[0148] S150. Establish an observation node-edge association matrix, wherein the rows of the observation node-edge association matrix correspond to the observation nodes, the columns correspond to the pipe segments, and the values ​​of the matrix elements represent the connection relationship between the node and the pipe segment and the flow direction.

[0149] S160. Check the connectivity of the topological graph corresponding to the observed node-edge association matrix using a graph traversal algorithm; if there are isolated nodes, issue a topological structure error warning.

[0150] S170. Calculate the hydraulic impedance weight of each side based on the physical parameters of each pipe section.

[0151] S180. Assign the weight values ​​of each edge in the observation node-edge correlation matrix according to the hydraulic impedance weight, and generate the flow conservation network topology.

[0152] The physical data refers to an objective description of the pipeline network. This data includes the unique identifiers of all pipe segments, their connection relationships, segment lengths, pipe diameters, installation locations of each flowmeter, and the device identifiers of each flowmeter. This data forms the basis for constructing the flow conservation network topology diagram, and its accuracy directly affects the correctness of the subsequent topology diagram and the precision of flow calculations. It can be obtained through various means, such as Geographic Information Systems (GIS), Supervisory Control and Data Acquisition (SCADA) systems, design drawings, or on-site surveys.

[0153] Next, each flowmeter is abstracted as an observation node, and a unique node number is assigned to each observation node. Flowmeters are the devices that actually measure flow, and abstracting them as observation nodes is the core idea of ​​network topology modeling. Each observation node represents a flow measurement point and is a key data input and output point in the flow-conserving network. Assigning unique node numbers helps to identify and manage each flowmeter during data processing and algorithm execution, ensuring data consistency and traceability. This abstraction simplifies the complex physical network structure, enabling it to be analyzed in a graph-theoretic manner.

[0154] Subsequently, each pipe segment is abstracted as a directed edge, with the direction of the edge determined based on the actual flow direction of the fluid. A pipe segment is a physical channel connecting different flow meters or network nodes. Abstracting it as a directed edge is to represent the flow path and direction of the fluid in the topology diagram. Directed edges accurately reflect the unidirectional flow of fluid from one node to another. Determining the actual flow direction of the fluid is crucial, as it directly affects the establishment of the flow conservation equation. The flow direction can be determined based on the design flow direction of the network, historical operating data analysis, pressure gradient judgment, or simulation calculations. If the flow direction is unknown, it is inferred based on the location of the water source and the topology of the network. In some cases, the actual flow direction of a pipe segment may not be directly obtainable or may be uncertain. In such cases, inference methods are required. The location of the water source is usually the starting point of the fluid; combined with the topology of the network (such as branches and confluences), the possible flow direction of the fluid can be logically inferred. This inference mechanism improves the robustness of the topology diagram construction, allowing for preliminary modeling even with incomplete data.

[0155] Based on this, an observation node-edge correlation matrix is ​​established. This matrix is ​​a mathematical representation used to accurately describe the connection relationships between observation nodes and pipe segments, as well as the direction of fluid flow at these connections. Rows in the matrix correspond to observation nodes, columns correspond to pipe segments, and the values ​​of matrix elements represent the connection relationship between the node and the pipe segment, as well as the flow direction (negative for inflow, positive for outflow). This matrix representation provides a standardized data structure for subsequently constructing flow balance equations, facilitating computer processing and calculation.

[0156] To ensure the validity of the constructed topology graph, a graph traversal algorithm is used to check the connectivity of the topology graph corresponding to the observed node-edge association matrix, ensuring that all observed nodes belong to the same connected component. If an isolated node exists, a topology error warning is issued. Connectivity checking is a crucial step in ensuring that the constructed topology graph effectively reflects the flow conservation relationships of the entire pipeline network system. If an isolated node exists (i.e., a flow meter or pipe segment is not connected to other parts), it means that the topology graph has structural errors or missing data, making comprehensive flow conservation analysis impossible. Issuing a warning prompts the user to check the original data or topology construction logic, avoiding subsequent calculations based on an incorrect topology.

[0157] The hydraulic impedance weight of each edge is calculated based on the physical parameters (length, diameter, roughness) of each pipe segment. This weight is used in subsequent flow distribution calculations. Hydraulic impedance is a quantitative representation of the resistance encountered by fluid flowing through a pipe segment; it is closely related to the physical characteristics of the pipe segment and the properties of the fluid. Calculating the hydraulic impedance weights is to more accurately simulate the actual flow behavior of the fluid in the flow conservation network. These weights play a crucial role in subsequent flow distribution calculations; for example, in multi-path flow or when inferring unknown flow directions, the flow will tend to flow towards the path with lower impedance. The calculation methods can be based on fluid mechanics principles such as the Darcy-Weisbach formula or the Heizen-Williams formula.

[0158] Finally, the weight values ​​of each edge in the observation node-edge association matrix are assigned according to the hydraulic impedance weights to generate the flow conservation network topology graph. This step integrates the calculated hydraulic impedance weights into the topology graph. In the observation node-edge association matrix, in addition to representing the connection relationships and directions, each edge (pipe segment) can be assigned a weight value, i.e., its corresponding hydraulic impedance. These weight values ​​make the topology graph not just a simple connection graph, but a weighted graph with physical attributes.

[0159] Through the above technical solution, this embodiment can acquire the physical data of the pipeline network and abstract it into a topological structure with defined nodes and directed edges. By introducing a flow direction inference mechanism and connectivity checks, the integrity and robustness of the topology graph are ensured. More importantly, by calculating and allocating the hydraulic impedance weights of each pipe segment, the constructed flow conservation network topology graph can more realistically reflect the actual flow characteristics of the fluid in the pipeline network, providing a more accurate and reliable foundation for subsequent calculations of theoretical flow values ​​based on the principle of mass conservation. This significantly improves the accuracy and reliability of flow anomaly detection, effectively solving the simplification and distortion problems that may exist in the topology construction of traditional methods, thereby enabling more accurate identification and location of flow anomalies in the pipeline network.

[0160] Weights calculated solely based on static physical parameters may not fully reflect the real-time impact of dynamic factors such as fluid characteristics and environmental conditions on hydraulic impedance during actual operation of the pipeline network. This could lead to inaccurate weight allocation in the flow conservation network topology, which in turn affects the accuracy of subsequent theoretical flow calculations and reduces the sensitivity and reliability of flow anomaly detection.

[0161] Therefore, referring to Figure 6 Another embodiment of the present invention provides a method for detecting abnormal flow in a flow meter, based on the above. Figure 5 The embodiment shown generates the flow conservation network topology by allocating the weight values ​​of each edge in the observation node-edge correlation matrix according to the hydraulic impedance weights, including steps S181-S186, wherein:

[0162] S181. Based on the physical parameters of each pipe segment and combined with the preset fluid dynamics calculation formula, calculate the basic hydraulic impedance value of each pipe segment under standard operating conditions.

[0163] S182. Obtain the real-time operating data corresponding to each observation node within a set period, wherein the real-time operating data includes fluid pressure, temperature and viscosity;

[0164] S183. Calculate the dynamic operating condition correction factor for each pipe section based on the real-time operating data, multiply the basic hydraulic impedance value by the corresponding dynamic operating condition correction factor, and determine the actual hydraulic impedance weight of each pipe section within the set period.

[0165] S184. Train a hydraulic parameter-weight mapping model using historical normal operation data;

[0166] S185. Input the physical parameters and real-time operation data of each pipe segment into the hydraulic parameter-weight mapping model, generate the recommended weight value output by the hydraulic parameter-weight mapping model, and weight and fuse the recommended weight value with the actual hydraulic impedance weight to generate the comprehensive weight value of the corresponding edge in the observation node-edge association matrix.

[0167] S186. Assign the comprehensive weight value to the corresponding edge in the flow conservation network topology graph to complete the weight allocation and generate the flow conservation network topology graph.

[0168] First, based on the physical parameters of each pipe segment and combined with preset fluid dynamics calculation formulas, the basic hydraulic impedance value of each pipe segment under standard operating conditions is calculated. The physical parameters typically refer to inherent properties of the pipe segment, such as length, diameter, and roughness, which are determined during pipeline network design and construction. The preset fluid dynamics calculation formulas, such as the Darcy-Weisbach formula or the Heizen-Williams formula, are used to calculate the energy loss or resistance of fluid flowing in the pipeline based on the physical properties of the fluid and the geometric characteristics of the pipeline. The standard operating conditions refer to calculations performed under specific, idealized operating conditions (e.g., constant temperature, pressure, fluid density, and viscosity), and the resulting basic hydraulic impedance value serves as the benchmark for subsequent dynamic corrections.

[0169] Secondly, real-time operational data corresponding to each observation node within a set period is acquired. This real-time operational data includes fluid pressure, temperature, and viscosity. The real-time operational data is pipeline status data continuously collected by sensors or monitoring equipment during actual operation. Fluid pressure reflects the energy state within the pipeline network, affecting the flow trend and velocity of the fluid; temperature affects the fluid's density and viscosity, thus affecting its flow resistance. For example, increased water temperature reduces its viscosity, thereby decreasing flow resistance; viscosity is the fluid's ability to resist shear deformation and is a key factor affecting hydraulic impedance. This real-time data reflects the dynamic operating state of the pipeline network, providing a basis for accurately calculating hydraulic impedance.

[0170] Next, based on the real-time operating data, a dynamic operating condition correction factor for each pipe section is calculated. The basic hydraulic impedance value is then multiplied by the corresponding dynamic operating condition correction factor to determine the actual hydraulic impedance weight of each pipe section within the set period. The dynamic operating condition correction factor is a dimensionless coefficient used to adjust the basic hydraulic impedance value to adapt it to the current actual operating conditions. This factor can be obtained based on real-time pressure, temperature, viscosity, and other data through empirical formulas, lookup tables, or calculation methods based on physical models. For example, a viscosity correction coefficient can be calculated based on the effect of temperature on fluid viscosity. The actual hydraulic impedance weight is the result of multiplying the basic hydraulic impedance value by the dynamic operating condition correction factor; it more accurately reflects the hydraulic impedance characteristics of the pipe section under the current real-time operating conditions.

[0171] Furthermore, a hydraulic parameter-weight mapping model is trained using historical normal operation data. This model takes the physical parameters of the pipe segment and its real-time operating data as input, and outputs optimized weights. The historical normal operation data refers to long-term operating data of the pipeline network under normal conditions, including the physical parameters of the pipe segment, real-time operating data, and corresponding actual flow data. The hydraulic parameter-weight mapping model can employ machine learning algorithms, such as support vector machines, neural networks, random forests, or gradient boosting trees. This model learns the complex nonlinear relationship between physical parameters, real-time operating data, and actual flow in historical data, thereby predicting or optimizing the weight values ​​of the pipe segment. The training process iteratively optimizes the model's internal parameters to minimize the error between the predicted weights and the actual weights, enabling it to learn the optimal weight mapping relationship from the input data.

[0172] Subsequently, the physical parameters and real-time operating data of each pipe segment are input into the hydraulic parameter-weight mapping model to generate recommended weight values ​​output by the model. These recommended weight values ​​are then weighted and fused with the actual hydraulic impedance weights to generate the comprehensive weight values ​​for the corresponding edges in the observation node-edge association matrix. The recommended weight values ​​are predicted or suggested by the hydraulic parameter-weight mapping model based on the current real-time input data, incorporating historical experience and complex pattern recognition capabilities. The weighted fusion combines the model-recommended weight values ​​with the actual hydraulic impedance weights calculated through fluid dynamics. A simple weighted average can be used for the fusion, for example, comprehensive weight value = α * recommended weight value + (1-α) * actual hydraulic impedance weight, where α is the fusion coefficient, which can be determined based on experience or optimization algorithms. This fusion aims to combine the accuracy of the physical model with the adaptability of the data-driven model to obtain more robust and accurate weights. The comprehensive weight value is the final weight used for edges in the flow conservation network topology graph, comprehensively considering static physical characteristics, dynamic operating conditions, and complex patterns learned from historical data.

[0173] Finally, the comprehensive weight values ​​are assigned to the corresponding edges in the flow conservation network topology graph, completing the weight allocation and generating the flow conservation network topology graph. Assigning weights means using the calculated comprehensive weight values ​​as attributes of each edge in the flow conservation network topology graph. Completing the weight allocation ensures that the weights of all pipe segments in the topology graph have been determined according to the above comprehensive method. The final flow conservation network topology graph not only includes the connection relationships between nodes and edges but also contains comprehensive weight information reflecting the actual hydraulic characteristics of the pipe segments, providing a more accurate basis for subsequent calculations of theoretical flow values ​​based on the principle of mass conservation.

[0174] By employing the aforementioned technical solution, the construction of the flow conservation network topology not only considers the static physical parameters of the pipe segments but also incorporates real-time operational data to dynamically correct hydraulic impedance. Furthermore, it integrates a smart model trained on historical data for weight optimization and fusion. This multi-dimensional and dynamic weight allocation mechanism allows the weights of each edge in the topology to more accurately reflect the actual hydraulic characteristics of the pipe network under different operating conditions. Therefore, the theoretical flow values ​​of each pipe segment calculated based on this topology will be closer to reality, significantly improving the accuracy of the flow residual sequence. This helps to more sensitively and reliably identify flowmeter anomalies; for example, it can distinguish between normal flow fluctuations caused by changes in pipe network operating conditions and abnormal data caused by flowmeter malfunctions, thereby avoiding false alarms and missed alarms and improving the accuracy and robustness of the entire flow anomaly detection method.

[0175] The actual collected cumulative flow time-series data often has problems such as missing data, anomalies, or inconsistent timestamps. If it is directly used to construct and solve the flow balance equation, it may lead to inaccurate calculation of theoretical flow values, which in turn affects the reliability of subsequent anomaly detection.

[0176] Optionally, refer to Figure 7 Another embodiment of the present invention provides a method for detecting abnormal flow in a flow meter, based on the above. Figure 1 The embodiment shown obtains the cumulative flow time-series data of each observation node in the flow conservation network topology diagram within a set period, calculates the theoretical flow value of each pipe segment based on the principle of mass conservation, and generates the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology diagram, including steps S2010-S2070, wherein:

[0177] S2010. Collect cumulative flow time-series data within a set period from each observation node, clean the data, remove missing values ​​and outliers that obviously exceed the physical range, and align the timestamps.

[0178] S2020: Convert the cleaned cumulative flow data into instantaneous flow data using the time difference method, and generate the instantaneous flow value of each observation node in each time interval;

[0179] S2030. According to the node-edge correlation matrix in the flow conservation network topology diagram, establish a flow balance equation for each internal observation node (the sum of the instantaneous flow of all pipe segments flowing into the node is equal to the sum of the instantaneous flow of all pipe segments flowing out of the node).

[0180] S2040. Combine the flow balance equations of all internal observation nodes to construct a system of linear equations with the instantaneous flow rate of each pipe segment as the unknown.

[0181] S2050. Solve the linear equations using the least squares method to determine the theoretical flow rate of each pipe section at each time point.

[0182] S2060. Arrange the theoretical flow values ​​of each pipe segment at all time points in chronological order to generate the theoretical flow matrix;

[0183] S2070. Arrange the actual instantaneous flow values ​​of each observation node in the same order to generate an actual observation flow matrix.

[0184] First, cumulative flow time-series data for a set period are collected from each observation node. After data collection, these data undergo rigorous cleaning, including removing missing values ​​and outliers that significantly exceed the physical range, and aligning the timestamps of all data to ensure data integrity, accuracy, and temporal consistency. For example, missing values ​​can be handled using interpolation methods (such as linear interpolation or spline interpolation) or by filling in predictions based on historical data; outliers can be identified and removed using statistical methods (such as the 3σ criterion or box plot method) or based on physical constraints; and timestamp alignment can be achieved through resampling or time synchronization protocols to ensure that data points from different observation nodes correspond to the same time scale.

[0185] Subsequently, the cleaned cumulative flow data is converted into instantaneous flow data using the time difference method, thereby generating the instantaneous flow value of each observation node within each time interval. The instantaneous flow value can be calculated as the difference in cumulative flow between two adjacent time points divided by the corresponding time interval. This allows the cumulative quantity to be converted into an instantaneous quantity, enabling its application to the mass conservation principle based on instantaneous flow.

[0186] Based on this, a flow balance equation is established for each internal observation node according to the node-edge association matrix in the flow conservation network topology graph. This equation follows the principle of mass conservation, that is, the sum of the instantaneous flows of all pipe segments flowing into the node is equal to the sum of the instantaneous flows of all pipe segments flowing out of the node. For example, if a node has multiple pipe segments flowing in and out, a linear equation can be constructed to describe the flow balance relationship of the node based on the flow direction defined in the node-edge association matrix.

[0187] Next, the flow balance equations of all internal observation nodes are combined to construct a system of linear equations with the instantaneous flow rate of each pipe segment as the unknown. This system of equations mathematizes the flow balance relationship of the entire pipeline network, forming a solvable mathematical model.

[0188] To obtain the theoretical flow rate of each pipe segment under the principle of mass conservation, the least squares method is used to solve the linear equations, thereby determining the theoretical flow rate of each pipe segment at each time point. The least squares method can find the optimal solution by minimizing the sum of squared residuals, and can provide a robust solution even when the data contains some noise or the equations are overdetermined / underdetermined.

[0189] Finally, the theoretical flow rates of each pipe segment at all time points are arranged in chronological order to generate the theoretical flow rate matrix. In addition, the actual instantaneous flow rates of each observation node are arranged in the same order to generate the actual observed flow rate matrix. The generation of these two matrices aims to standardize and organize the theoretical calculation results and the actual observation results, providing standardized data input for subsequent flow residual calculations and anomaly detection.

[0190] The above technical solution first involves rigorous data cleaning and timestamp alignment of the cumulative flow time-series data collected from each observation node. This effectively eliminates missing values, outliers, and temporal inconsistencies, ensuring the data quality for subsequent analysis. Next, the cleaned cumulative flow data is precisely converted into instantaneous flow data using the time-difference method. This allows the flow balance equation to be constructed based on instantaneous flow, more accurately reflecting the dynamic flow distribution of the system within each time interval. By systematically establishing and solving a system of linear equations with the instantaneous flow of each pipe segment as unknowns, the theoretical flow value of each pipe segment at each time point can be accurately calculated based on the principle of mass conservation, generating a standardized theoretical flow matrix and an actual observed flow matrix. This not only improves the accuracy and reliability of theoretical flow value calculation, providing a solid foundation for subsequent flow residual sequence calculation, but also greatly facilitates the comparative analysis of theoretical and actual observed values ​​through data standardization and matrix organization, thereby significantly improving the accuracy and efficiency of flow anomaly detection.

[0191] In actual pipeline operation, leaks may occur in pipe sections, and noise or systematic biases may exist during data acquisition. This makes it difficult for simple flow balance equations and least squares methods to accurately reflect the real flow distribution, thereby affecting the accuracy of theoretical flow values ​​and the stability of solutions. It may even mask potential topological errors or data problems.

[0192] Therefore, referring to Figure 8 Another embodiment of the present invention provides a method for detecting abnormal flow in a flow meter, based on the above. Figure 7 The embodiment shown obtains the cumulative flow time-series data of each observation node in the flow conservation network topology diagram within a set period, calculates the theoretical flow value of each pipe segment based on the principle of mass conservation, and generates the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology diagram. It also includes steps S2080-S2130, wherein:

[0193] S2080. Introduce a pipe section leakage loss term into the flow balance equation. The pipe section leakage loss term is related to the current pressure of the pipe section, the aging coefficient of the pipe material, and the service life.

[0194] S2090. Train the leakage model using historical normal data, estimate the leakage coefficient of each pipe section through regression analysis, and substitute the leakage coefficient as a known parameter into the flow balance equation.

[0195] S2100. The linear equation system is resolved using the weighted least squares method, wherein the weight matrix is ​​composed of the confidence weight of each observation node and the reciprocal of the leakage coefficient of each pipe section.

[0196] S2110. Add time smoothing constraints during the solution process to limit the variation of the theoretical flow rate of the same pipe segment at adjacent time points to not exceed the preset smoothing threshold.

[0197] S2120. Calculate the spatial autocorrelation index of the residual matrix. If the autocorrelation index exceeds the preset autocorrelation threshold, it indicates that there may be unidentified topological errors or systematic data deviations, and triggers the topology map review process.

[0198] S2130. Dynamically adjust the parameters and weight matrix of the leakage model according to the statistical characteristics of the residual matrix, and perform iterative optimization until the norm of the residual matrix is ​​less than the convergence threshold, and output the final theoretical flow matrix and the actual observed flow matrix.

[0199] Traditional flow balance equations typically assume ideal, leak-free pipe networks. However, in real-world water supply, gas, and other pipe networks, pipe leakage is common. Introducing a leakage loss term can make the flow balance equations more closely reflect actual physical processes, improving the accuracy of theoretical flow calculations. This leakage loss term can be represented as an additional term in the pipe flow equation, its magnitude depending on the physical characteristics of the pipe segment (such as pipe material, service life, and diameter) and operating conditions (such as the current pressure of the pipe segment). For example, it can be modeled as a function proportional to the pipe segment pressure, considering the impact of pipe aging coefficients and service life on the leakage rate.

[0200] To accurately quantify leakage losses, this embodiment trains a leakage model using historical normal data, estimates the leakage coefficient of each pipe segment through regression analysis, and substitutes the leakage coefficient as a known parameter into the flow balance equation. The leakage coefficient is a key parameter for quantifying the degree of leakage in a pipe segment. By collecting data on flow rate, pressure, and pipe segment attributes under known normal operating conditions, a leakage model can be constructed using multiple linear regression, nonlinear regression, or machine learning methods to find the optimal parameter combination that minimizes the error between the model-predicted leakage and the actual observed leakage. The estimated leakage coefficient is then treated as a known parameter and substituted into the flow balance equation, enabling the equation to more accurately describe the flow conservation relationship including leakage.

[0201] In this embodiment, the weighted least squares method is used to resolve the linear equations. The weight matrix is ​​composed of the confidence weights of each observation node and the reciprocals of the leakage coefficients of each pipe segment. Traditional least squares treats all observation data equally. However, in practical applications, flow data from different observation nodes may have different reliability, and pipe segments with varying degrees of leakage have different impacts on the flow balance equation. The weighted least squares method allows different weights to be assigned to different data points, thus focusing more on high-confidence data and pipe segments with a greater impact on the results, improving the robustness and accuracy of the solution. The weight matrix is ​​a diagonal matrix, with its diagonal elements representing the weights of each observation or equation. The confidence weights of each observation node can be determined based on factors such as the flowmeter's accuracy class, calibration date, and historical failure rate; for example, higher-accuracy flowmeters are assigned higher weights. Using the reciprocal of the pipe segment leakage coefficient as a weight means that pipe segments with smaller leakage coefficients are given higher weight in the solution, because the flow conservation relationship of these pipe segments is more "pure", and their data contribute more reliably to the overall flow balance.

[0202] Furthermore, this embodiment incorporates a time smoothing constraint during the solution process, limiting the variation in theoretical flow rate of the same pipe segment at adjacent time points to a preset smoothing threshold, thereby improving solution stability. Instantaneous flow rate data often contains noise and fluctuations, and direct solution calculation may lead to drastic, physically inconsistent jumps in theoretical flow rate values ​​between adjacent time points. The time smoothing constraint ensures the continuity and rationality of theoretical flow rate values ​​over time, avoiding instability in the solution caused by data noise or model uncertainty. This can be achieved by adding a regularization term to the objective function of the least squares method, where the penalty term is proportional to the square of the difference between the theoretical flow rate values ​​of the same pipe segment at adjacent time points.

[0203] To improve the reliability of the model, this embodiment calculates the spatial autocorrelation index of the residual matrix. If the autocorrelation index exceeds a preset autocorrelation threshold, it indicates the possible existence of unidentified topological errors or systematic data biases, triggering a topology map review process. The spatial autocorrelation of the residual matrix (the difference between theoretical flow and actual observed flow) can reflect whether there are local or regional systematic biases in the pipeline network. If the residuals exhibit spatial clustering or regularity rather than random distribution, it may indicate undetected errors or systematic data biases in the flow-conserving network topology map. By detecting spatial autocorrelation, these deeper problems can be identified in a timely manner, and indices such as Moran's I and Geary's C are used for calculation.

[0204] Finally, this embodiment dynamically adjusts the parameters and weight matrix of the leakage model based on the statistical characteristics of the residual matrix, performing iterative optimization until the norm of the residual matrix is ​​less than the convergence threshold, outputting the final theoretical flow matrix and the actual observed flow matrix. This is an iterative optimization process aimed at minimizing the residual between the theoretical flow calculation results and the actual observed data by continuously adjusting the model parameters and weights, thereby improving the accuracy and robustness of the model. In each iteration, the linear equation system is first solved based on the current leakage model parameters and weight matrix to obtain the theoretical flow matrix and the residual matrix. Then, the statistical characteristics of the residual matrix are analyzed, and the parameters of the leakage model and the weight matrix in the weighted least squares method are dynamically adjusted based on these statistical characteristics. The iterative process continues until a certain norm of the residual matrix is ​​less than a preset convergence threshold, indicating that the model has converged to a stable state with sufficiently small errors.

[0205] By introducing a leakage loss term related to the current pressure, aging coefficient, and service life of the pipe segment into the flow balance equation, and training a leakage model using historical normal data to estimate the leakage coefficient of each pipe segment, this embodiment can more accurately simulate the leakage phenomenon commonly found in actual pipe networks, making the calculation of theoretical flow values ​​closer to the real physical process. A weighted least squares method is used to solve the linear equations, and a weight matrix is ​​constructed based on the confidence weight of each observation node and the reciprocal of the leakage coefficient of each pipe segment. This effectively improves the robustness of the solution process to data noise and varying data reliability, ensuring that high-confidence data and low-leakage pipe segments dominate the results. Furthermore, a time smoothing constraint is added during the solution process to limit the variation in the theoretical flow value of the same pipe segment at adjacent time points, significantly improving the stability of the theoretical flow sequence and avoiding drastic fluctuations that do not conform to physical laws. In addition, by calculating the spatial autocorrelation index of the residual matrix, potential unidentified topological errors or systematic data biases can be detected in a timely manner, triggering corresponding review processes, thereby ensuring the accuracy of the flow conservation network topology. Finally, by dynamically adjusting the parameters and weight matrix of the leakage model based on the statistical characteristics of the residual matrix and iteratively optimizing until convergence, this embodiment can continuously improve the model's fitting accuracy and predictive ability, outputting a more accurate and stable theoretical flow matrix and actual observed flow matrix, providing more reliable basic data for subsequent flow anomaly detection, and significantly improving the accuracy and reliability of flow anomaly detection.

[0206] Based on all the above embodiments, the core principle of the present invention includes:

[0207] Interquartile Range (IQR) Method: The normal range is divided through the quartiles of the data, and the data outside this range is determined as abnormal. Cumulative flow data usually shows a positive skew distribution, which is suitable for locating abnormalities "beyond the reasonable numerical range", such as when the cumulative flow suddenly appears negative or a value far exceeds the maximum range of the device. It requires no complex calculations and has strong resistance to extreme values.

[0208] Variance Method: The essence of the population variance is the arithmetic mean of the squares of the deviations of each data from the population mean, reflecting the discrete trend of the population data. The larger the value, the greater the data fluctuation. The cumulative flow of the flowmeter gradually increases over time. Once abnormal data, especially extreme values (maximum or minimum), appears, it will cause a large change in the variance. When the data remains unchanged or changes minimally, the variance method is more superior to the Interquartile Range (IQR) method for effective judgment.

[0209] Combining the Interquartile Range (IQR) method and the variance method can more effectively identify data outliers than using them separately.

[0210] The calculation process is as follows:

[0211] 1. Calculate quartiles

[0212] First Quartile (Q1): After sorting the data from smallest to largest, it is the value at the 25% percentile.

[0213] Third Quartile (Q3): It is the value at the 75% percentile. The formula is: Q3 position = (n + 1)×0.75 (n is odd); if n is even, Q3 = the average of the n×0.75th data and the (n×0.75 + 1)th data.

[0214] 2. Calculate the Interquartile Range (IQR): IQR = Q3 - Q1

[0215] 3. Determine the normal numerical range: Normal range = [Q1 - 1.5×IQR, Q3 + 1.5×IQR]. Cumulative flow values outside this range (such as <Q1 - 1.5IQR or >Q3 + 1.5IQR) are used as one of the judgment criteria.

[0216] 4. Calculate the variance:

[0217] Let the population contain N individuals, and the values of each individual be x1, x2, …, xN, and the population mean be μ. Then the population variance is:

[0218] ;

[0219] where,

[0220] ;

[0221] The denominator is the total capacity N, and all data are used directly for calculation.

[0222] 5. Overall evaluation:

[0223] Because flow meter readings vary, the variance of the same data fluctuation will differ depending on whether the reading is large or small. Therefore, it is necessary to set a threshold limit on the variance based on the flow meter's range. According to the calculation results, a threshold of 50 is considered generally reliable; that is, a variance below 50 indicates that there is no significant fluctuation.

[0224] Considering that data sent by the flow meter may be lost, and that re-sending the data after loss will lead to a large variance, a prediction is made based on the number of times the flow meter sends data each day. If there is a data loss of more than 80%, the flow meter will be prioritized for the incomplete data transmission range.

[0225] If the flow meter's maximum value for the day equals its minimum value, and the variance is 0, then the data is considered unchanged.

[0226] If the maximum value of the flow meter for the day is not equal to the minimum value, and the variance is 0, it is determined that the data change is minimal.

[0227] When the variance is greater than 50 and exceeds the interquartile range, it is determined that there is a jump or fluctuation.

[0228] 6. Clickhouse function characteristics:

[0229] The varPop(expr) function calculates the variance of a column of data, for example, varPop(field_name).

[0230] The `quantile(level)(expr)` function calculates the quantiles of a data column. `level` is the quantile level, ranging from 0 to 1; 0.5 represents the median. `expr` is the field name. For example, `quantile(0.5)(field name)`.

[0231] The present invention also proposes a detection device, the detection device comprising: a memory, a processor, and a flow meter flow anomaly detection program stored in the memory and executable on the processor, the flow meter flow anomaly detection program being configured to implement the flow meter flow anomaly detection method as described above.

[0232] The core innovation of this embodiment lies in integrating a flow anomaly detection method based on a flow conservation network topology into a dedicated detection device, thereby achieving global and network-based analysis of flowmeter anomalies in complex pipeline systems. Specifically, the device utilizes a memory to store program instructions and historical data. A processor executes the flow anomaly detection program for the flowmeters, constructing a flow conservation network topology based on the target flowmeter's installation location and pipe segment relationships. It then calculates the theoretical flow matrix and the actual observed flow matrix based on the principle of mass conservation, and subsequently locates the specific abnormal flowmeter through residual sequence analysis and anomaly tracing. Because this program strictly adheres to the physical constraints of the pipeline system, it effectively avoids misjudgments caused by fluctuations in normal operating conditions and missed detections due to minor fault deviations.

[0233] It is worth noting that since the detection device of the present invention is based on the above-mentioned flow meter flow anomaly detection method, the embodiments of the detection device of the present invention include all the technical solutions of all embodiments of the above-mentioned flow meter flow anomaly detection method, and the technical effects achieved are exactly the same, so they will not be repeated here.

[0234] The present invention also proposes a detection device, which includes the detection apparatus as described in the above embodiments.

[0235] The core innovation of this embodiment lies in the systematic combination of key features such as the construction of a flow conservation network topology, the calculation of a theoretical flow matrix, and residual analysis. This enables accurate detection and tracing of flowmeter anomalies under the physical constraints of complex pipe networks. The detection device can distinguish between various anomaly types, including jump anomalies, impulsive anomalies, and constant deviation anomalies, and locate specific abnormal flowmeters based on the spatiotemporal distribution characteristics of the flow residual sequence. Through this technical solution, the false alarm rate and false negative rate of anomaly detection are significantly reduced, improving the accuracy and reliability of flowmeter anomaly identification. This provides strong support for the safe operation and intelligent management of fluid distribution systems such as water supply networks, industrial water systems, gas transmission networks, heat supply systems, chemical process pipelines, and municipal drainage systems.

[0236] It is worth noting that since the detection device of the present invention is based on the detection apparatus described above, the embodiments of the detection device of the present invention include all the technical solutions of all the embodiments of the above detection apparatus, and the technical effects achieved are exactly the same, so they will not be repeated here.

[0237] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for detecting abnormal flow in a flow meter, characterized in that, The flow anomaly detection method of the flow meter includes: Based on the installation location of the target flow meter and its relationship with the pipe section, a flow conservation network topology diagram with the flow meter as the observation node is constructed. Obtain the cumulative flow time series data of each observation node in the flow conservation network topology diagram within a set period, calculate the theoretical flow value of each pipe segment based on the principle of mass conservation, and generate the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology diagram. Based on the theoretical flow matrix and the actual observed flow matrix, calculate the flow residual sequence for each observation node; The interquartile range method based on statistical distribution and the variance method based on fluctuation analysis are used to determine whether there are significant deviations and abnormal fluctuations in the flow residual sequence, and the corresponding first analysis results are generated. Based on the first analysis result, determine whether there is a flow meter malfunction in the flow conservation network topology diagram; If a flow meter malfunction is determined, the specific malfunctioning flow meter is located using a preset malfunction tracing algorithm based on the spatiotemporal distribution characteristics of the flow residual sequence. The process of constructing a flow conservation network topology with the flowmeter as the observation node, based on the installation location of the target flowmeter and its relationship to the pipe segment, includes: Obtain physical data of the target pipeline network, including the unique identifier of each pipe segment, connection relationship, pipe segment length, pipe segment diameter, installation location of each flow meter, and device identifier of each flow meter; Each flow meter is abstracted as an observation node, and a unique node number is assigned to each observation node; Each pipe segment is abstracted as a directed edge, and the direction of the edge is determined according to the actual flow direction of the fluid; If the flow direction is unknown, it is determined by inference based on the location of the water source and the topology of the pipeline network; Establish an observation node-edge association matrix, where rows correspond to observation nodes and columns correspond to pipe segments. The values ​​of the matrix elements represent the connection relationship between the node and the pipe segment and the flow direction. The connectivity of the topological graph corresponding to the observed node-edge association matrix is ​​checked using a graph traversal algorithm; if an isolated node exists, a topological error warning is issued. Calculate the hydraulic impedance weight of each side based on the physical parameters of each pipe section; The weight values ​​of each edge in the observation node-edge correlation matrix are assigned according to the hydraulic impedance weights to generate the flow conservation network topology. The step of assigning weight values ​​to each edge in the observation node-edge correlation matrix according to the hydraulic impedance weights to generate the flow conservation network topology graph includes: Based on the physical parameters of each pipe segment and combined with the preset fluid dynamics calculation formula, the basic hydraulic impedance value of each pipe segment under standard operating conditions is calculated. Acquire real-time operational data corresponding to each observation node within a set period, wherein the real-time operational data includes fluid pressure, temperature, and viscosity; The dynamic operating condition correction factor for each pipe section is calculated based on the real-time operating data. The basic hydraulic impedance value is multiplied by the corresponding dynamic operating condition correction factor to determine the actual hydraulic impedance weight of each pipe section within the set period. Train a hydraulic parameter-weight mapping model using historical normal operation data; The physical parameters and real-time operating data of each pipe segment are input into the hydraulic parameter-weight mapping model to generate the recommended weight value output by the hydraulic parameter-weight mapping model. The recommended weight value is then weighted and fused with the actual hydraulic impedance weight to generate the comprehensive weight value of the corresponding edge in the observation node-edge association matrix. The comprehensive weight value is assigned to the corresponding edge in the flow conservation network topology graph to complete the weight allocation and generate the flow conservation network topology graph.

2. The flow anomaly detection method for a flow meter as described in claim 1, characterized in that, The method uses the interquartile range method based on statistical distribution and the variance method based on fluctuation analysis to determine whether there are significant deviations and abnormal fluctuations in the flow residual sequence, respectively, and generates corresponding first analysis results, including: Calculate the first and third quartiles of the flow residual sequence, and calculate the interquartile range accordingly; The product of the first quartile minus the first preset multiple and the interquartile range is used as the lower limit, and the product of the third quartile plus the first preset multiple and the interquartile range is used as the upper limit to determine the normal range of residuals. If the values ​​in the flow residual sequence exceed the normal range of the residuals, it is determined that the flow residual sequence has a significant deviation; Calculate the population variance of the flow residual sequence; If the total variance is greater than a preset variance threshold, it is determined that the flow residual sequence has abnormal fluctuations.

3. The flow anomaly detection method for a flow meter as described in claim 1, characterized in that, The step of determining whether there is a flow meter malfunction in the flow conservation network topology based on the first analysis result includes: If the first analysis result shows that the flow residual sequence has both significant deviation and abnormal fluctuation, it is determined that there is an anomaly in either the jump-type flowmeter or the impact-type flowmeter. If the first analysis result indicates that the flow residual sequence does not deviate significantly but exhibits abnormal fluctuations, the determination is based on the integrity of the data uploaded by the observation node. If the flow residual sequence shows a significant deviation but no abnormal fluctuation, and the mean of the flow residual sequence is close to zero, then an anomaly is determined to exist in the constant deviation flowmeter. If the flow residual sequence has neither significant deviation nor abnormal fluctuation, and the variance of the flow residual sequence is zero, the node is identified as either a data invariance anomaly or a minimal change anomaly based on the relationship between the maximum and minimum cumulative flow values ​​within the same period.

4. The flow anomaly detection method for a flow meter as described in claim 3, characterized in that, When the flow residual sequence has neither significant deviation nor abnormal fluctuation, and the variance of the flow residual sequence is zero, based on the relationship between the maximum and minimum cumulative flow values ​​of the node within the same period, it is determined to be a data invariance anomaly or a minimal change anomaly, including: Extract the cumulative flow time-series data of the observation node within the set period, and identify the maximum and minimum cumulative flow values ​​from the cumulative flow time-series data; Calculate the absolute difference between the maximum and minimum cumulative flow values ​​to generate the corresponding flow range; Obtain the upper limit of the flow meter corresponding to the observation node, and determine the distribution range of its flow range under normal operating conditions based on the historical normal data of the flow meter. The dynamic proportional coefficient is determined based on the distribution range, and the dynamic threshold corresponding to the dynamic proportional coefficient and the upper limit of the range is determined. Compare the flow range with the dynamic threshold; if the flow range is not greater than the dynamic threshold, determine that the data remains unchanged (abnormal). If the flow range is greater than the dynamic threshold, perform a difference operation on the cumulative flow time series data to generate a flow change rate sequence between adjacent time points, calculate the average absolute value of the flow change rate sequence, and determine the average absolute value as the average change rate. Extract the average rate of change reference value of the same observation node under the same period from historical normal data, and calculate the rate of change ratio with the average rate of change reference value and the average rate of change; The rate of change is compared with a preset second threshold; if the rate of change is not greater than the preset second threshold, the change is determined to be extremely small and abnormal; if the rate of change is greater than the preset second threshold, the data change is determined to be normal.

5. The flow anomaly detection method for a flow meter as described in claim 1, characterized in that, The process of acquiring the cumulative flow time-series data of each observation node in the flow conservation network topology within a set period, calculating the theoretical flow value of each pipe segment based on the principle of mass conservation, and generating the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology includes: The cumulative flow time series data within a set period is collected from each observation node. The data is cleaned, missing values ​​and outliers that are significantly beyond the physical range are removed, and the timestamps are aligned. The cleaned cumulative flow data is converted into instantaneous flow data using the time difference method, generating the instantaneous flow value of each observation node in each time interval; Based on the node-edge correlation matrix in the flow conservation network topology, establish a flow balance equation for each internal observation node; Combine the flow balance equations of all internal observation nodes to construct a system of linear equations with the instantaneous flow rate of each pipe segment as the unknown. The linear equations are solved using the least squares method to determine the theoretical flow rate of each pipe segment at each time point. The theoretical flow rate of each pipe segment at all time points is arranged in chronological order to generate the theoretical flow rate matrix. The actual instantaneous flow values ​​of each observation node are arranged in the same order to generate an actual observed flow matrix.

6. The flow anomaly detection method for a flow meter as described in claim 5, characterized in that, The process of obtaining the cumulative flow time-series data of each observation node in the flow conservation network topology diagram within a set period, calculating the theoretical flow value of each pipe segment based on the principle of mass conservation, and generating the theoretical flow matrix and the actual observed flow matrix of all pipe segments in the flow conservation network topology diagram, further includes: A pipe section leakage loss term is introduced into the flow balance equation. The pipe section leakage loss term is related to the current pressure of the pipe section, the aging coefficient of the pipe material, and the service life. The leakage model is trained using historical normal data, the leakage coefficient of each pipe section is estimated through regression analysis, and the leakage coefficient is substituted into the flow balance equation as a known parameter. The linear equations are re-solved using the weighted least squares method, where the weight matrix is ​​composed of the confidence weight of each observation node and the reciprocal of the leakage coefficient of each pipe segment. A time smoothing constraint is added during the solution process to limit the variation of the theoretical flow rate of the same pipe segment at adjacent time points to not exceed the preset smoothing threshold. Calculate the spatial autocorrelation index of the residual matrix. If the autocorrelation index exceeds a preset autocorrelation threshold, it indicates that there may be unidentified topological errors or systematic data deviations, and triggers the topology map review process. The parameters and weight matrix of the leakage model are dynamically adjusted based on the statistical characteristics of the residual matrix, and iterative optimization is performed until the norm of the residual matrix is ​​less than the convergence threshold. The final theoretical flow matrix and the actual observed flow matrix are then output.

7. A detection device, characterized in that, The detection device includes: a memory, a processor, and a flow meter flow anomaly detection program stored in the memory and executable on the processor, the flow meter flow anomaly detection program being configured to implement the flow meter flow anomaly detection method as described in any one of claims 1 to 6.

8. A testing device, characterized in that, Includes the detection device as described in claim 7.

Citation Information

Patent Citations

  • A data-driven method for anomaly detection and recovery of water network sensors

    CN122133032A

  • Method for detecting anomalies in a distribution network, in particular a water distribution network

    WO2016012971A1