A natural gas leakage quantification method based on a double-branch neural network

By constructing time-series feature data based on a dual-branch neural network and combining it with an LSTM network, the problem of insufficient accuracy in natural gas leak quantification under complex environments, especially in low-flow leak scenarios, is solved, achieving high-precision and real-time automated monitoring.

CN120579426BActive Publication Date: 2026-07-07CHONGQING UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHONGQING UNIV
Filing Date
2025-05-13
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing methods for quantifying natural gas leaks lack accuracy in complex environments, especially in low-flow leak scenarios, making it difficult to achieve automated continuous monitoring.

Method used

By employing a dual-branch neural network approach, this method constructs time-series feature data, utilizes a heterogeneous feature extraction architecture of main branch and small flow branch, and combines a bidirectional LSTM network and a deep fully connected network to achieve accurate prediction of natural gas leakage flow.

Benefits of technology

It improves the quantification accuracy of small-flow leakage, has good stability and strong generalization ability, can adapt to complex environments, realizes automated monitoring and real-time early warning, and overcomes the problems of insufficient accuracy and real-time performance of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120579426B_ABST
    Figure CN120579426B_ABST
Patent Text Reader

Abstract

The application discloses a natural gas leakage quantification method based on a double-branch neural network, which comprises the following steps: S1, loading original monitoring data, extracting basic features, constructing time sequence features based on the basic features and derived features, and performing standardization processing on the time sequence features; S2, dividing the time sequence features into small flow and conventional flow data and dividing them into a training set, a verification set and a test set with 0.1 m3 / h of leakage flow as a threshold; S3, constructing a double-branch neural network model; S4, formulating a training strategy, designing a loss function, verifying the performance of the model, and saving the last saved model as the best model after the training is completed; S5, inputting the test set data into the model, obtaining a leakage flow prediction value, calculating evaluation indexes, verifying the performance of the model on the test set, and confirming the effectiveness and generalization ability of the model. The application realizes accurate prediction from monitoring data to leakage flow, has good stability and strong generalization ability, and is especially capable of quantifying small flow leakage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural gas safety monitoring technology, and in particular relates to a method for quantifying natural gas leaks based on a dual-branch neural network. Background Technology

[0002] Natural gas is widely used as an important clean energy source, but leaks during its production, storage, transportation, and use not only waste resources and emit greenhouse gases, but can also cause safety accidents such as fires and explosions. Statistics show that approximately 1%-4% of methane leaks occur in the global natural gas supply chain, resulting in significant economic losses and adverse environmental impacts. Therefore, accurately quantifying natural gas leak flow rates is crucial for energy security, environmental protection, and cost control.

[0003] Currently, methods for quantifying natural gas leaks can be broadly categorized into two types: direct measurement methods and indirect estimation methods. Direct measurement methods include the bagging method, high-flow sampling, and tracer gas methods; indirect estimation methods include Gaussian plume models, computational fluid dynamics (CFD) inverse simulation, and empirical formula methods.

[0004] The bagging method is a traditional direct measurement method. Its basic principle is to completely enclose the leak source in a plastic bag or a specially designed sampling bag to directly collect and measure the leaked gas. This method is simple, intuitive, and offers high measurement accuracy, and is recognized as a standard quantitative method by the U.S. Environmental Protection Agency (EPA) and other regulatory agencies. However, the bagging method has the following drawbacks: the measurement process requires on-site personnel, resulting in low measurement frequency; it is difficult to implement for inaccessible leak points or leaks in large equipment; the measurement results are significantly affected by environmental conditions and operator skill; and it only obtains leak data at the moment of measurement, lacking continuous monitoring capabilities and exhibiting poor timeliness.

[0005] High-flow-rate sampling uses portable equipment to capture leaking gas and measure its concentration and flow rate, enabling the quantification of multiple leak points in a short time. However, this method is susceptible to fluctuations in background concentration and exhibits significant measurement uncertainty in low-flow-rate leak scenarios. Studies have shown that under certain conditions, high-flow-rate samplers may underestimate the actual leak volume by 30%–100%.

[0006] The tracer gas method quantifies the leakage rate by injecting a known concentration of inert tracer gas (such as sulfur hexafluoride, SF6) into the leaking system, utilizing the principle of gas mixing. In practice, the tracer gas is released simultaneously with natural gas, and the leakage rate is calculated by detecting the concentration ratio of the tracer gas to methane downwind, combined with the mass conservation equation. This method can cover a large area and is suitable for locating and quantifying complex pipeline networks or concealed leak points, and is effective for small leaks (<0.05m). 3The tracer gas is relatively sensitive ( / h). However, its disadvantages are: it requires additional purchase of tracer gas and high-precision detection equipment, resulting in higher costs; the operation process is complex, and the release conditions of the tracer gas must be strictly controlled to avoid background interference; it cannot achieve continuous monitoring and is only suitable for phased leak assessment.

[0007] The Gaussian plume model is the most widely used indirect estimation method. Based on diffusion theory, it uses methane concentration, meteorological parameters, and distance information at measurement points to infer the intensity of the leak source. While the Gaussian model is computationally simple and can achieve real-time estimation, its applicability is stringent, requiring flat terrain, uniform wind fields, and stable meteorological conditions. In complex environments such as urban natural gas plants, the prediction accuracy of the Gaussian model decreases significantly due to factors such as building obstruction, equipment interference, and local turbulence, with an average error exceeding 50%, especially for small-flow leaks (<0.1 m³). 3 The quantification capability of / h) is even more limited.

[0008] CFD numerical simulation methods can consider the effects of complex terrain, buildings, and equipment, and inversely infer leakage by combining measured data. However, this method has high computational complexity and requires a large amount of computing resources, especially since repeated iterations are needed during the inversion process, making it difficult to meet the needs of real-time monitoring. At the same time, CFD simulation results are highly dependent on boundary conditions, the accuracy of mesh generation, and the quality of input data. The stability of the optimization algorithm must also be considered when inverting leakage, resulting in significant uncertainty in practical applications.

[0009] Empirical formula methods establish simplified mathematical relationships between leakage rate and key parameters (such as pipeline pressure, orifice diameter, and time) based on experimental data or historical leakage cases. For example, the orifice leakage formula recommended by the U.S. Environmental Protection Agency (EPA). In the process, by calibrating the flow coefficient C d Estimate the leakage amount. This method is fast and requires no complex equipment, and is often used for emergency response or rapid risk assessment. However, its disadvantage is that the formula parameters (such as C)... d The fitting results are highly dependent on specific operating conditions and have poor universality; the influence of dynamic environmental factors (such as wind speed and turbulence) is ignored, which is not applicable to small flow leakage (<0.1m). 3 The adaptability of ( / h) is insufficient, and the actual error can reach 50%-200%.

[0010] In recent years, with the rapid development of artificial intelligence and deep learning technologies, machine learning-based leakage quantification methods have gradually emerged. Some studies have attempted to establish a mapping relationship between concentration and leakage flow using algorithms such as Support Vector Machines (SVM), Random Forests (RF), and Artificial Neural Networks (ANN). However, most of these methods are designed for single operating conditions or simplified scenarios, failing to fully consider temporal and spatial characteristics. Their effectiveness in complex environments and low-flow leakage scenarios still needs improvement. In particular, how to effectively integrate temporal information, extract key features, and enhance the quantification capability for low-flow leakage remains a key technical challenge that urgently needs to be addressed in this field.

[0011] Therefore, developing a method that can adapt to complex environments, improve the quantification accuracy of small-flow leakage, and achieve automated continuous monitoring has significant practical value and innovative significance. Summary of the Invention

[0012] The purpose of this invention is to provide a natural gas leakage quantification method based on a dual-branch neural network that can improve the quantification accuracy of small-flow leakage.

[0013] The objective of this invention is achieved through the following technical measures: a method for quantifying natural gas leakage based on a dual-branch neural network, characterized by comprising the following steps:

[0014] S1. Load experimental and simulated data, extract basic features, calculate derived features based on basic features, construct time-series features based on basic and derived features through a sliding window mechanism, and then standardize the time-series feature data.

[0015] S2, with a leakage flow rate of 0.1m 3 Using / h as a threshold, the standardized time-series feature data is divided into low-flow data and regular-flow data. The time-series feature data is further divided into training set, validation set and test set, and each dataset consists of low-flow data and regular-flow data. At the same time, it is ensured that the proportion of low-flow data in each dataset is consistent with the proportion of low-flow data in the experimental data.

[0016] S3. Constructing a dual-branch neural network model: First, the 11-dimensional input features are projected onto a 64-dimensional feature space through a one-dimensional convolutional layer. Then, the projected 64-dimensional features are simultaneously input into a parallel main branch and a small-flow branch. The main branch processes the projected 64-dimensional features using a standard structure, while the small-flow branch processes the projected 64-dimensional features using a structure specifically optimized for small-flow samples. The 64-dimensional features output by the small-flow branch are then processed by a multi-scale convolutional module to capture feature changes at different time scales. The output features of both the main branch and the small-flow branch are added and fused after adaptive average pooling. Then, a bidirectional LSTM network is used to process the temporal information extracted from the two branches, and a deep fully connected network is used for dimensionality reduction. Finally, the logarithmic domain prediction value y of the main branch is output. main Logarithmic domain prediction y of small flow branches small The initial 64-dimensional features are then processed by a flow classifier. Specifically, the projected 64-dimensional features are processed through convolutional layers, batch normalization, residual blocks, pooling, and fully connected layers, ultimately outputting a weight coefficient α with a value between 0 and 1. The predicted natural gas leakage flow rate is calculated using the following formula:

[0017] y pred =α·y small +(1-α)·y main Formula ⑴;

[0018] S4. Formulate a training strategy, design a loss function, and use the validation set data in step S2 to perform performance validation. Save the model only when the current validation loss is lower than the historical best validation loss and the current relative error is lower than the historical best relative error. After training, the last saved model will be used as the final best model.

[0019] S5. Load the best model obtained from training, input the test set data from step S2 into the model, obtain the predicted leakage flow value, calculate various evaluation indicators, verify the performance of the model on the test set, and confirm the effectiveness and generalization ability of the model.

[0020] This invention employs a dual-branch network model, which enables accurate prediction of leakage flow from monitoring data, especially for the quantification of small-flow leakage, and has good stability and strong generalization ability.

[0021] The basic features described in this invention include CH4 concentration, measuring point height, leakage flow rate, wind speed, measuring point x-coordinate, measuring point y-coordinate, and leakage height; the derived features include concentration change rate, concentration acceleration, concentration moving average, wind speed square, relative height, and logarithmic transformation of leakage flow rate; wherein leakage flow rate is used as the original monitoring label, the logarithmic transformation value of leakage flow rate is used as the model training target value, and the remaining 11 features are used as model input.

[0022] In step S1 of this invention, the standardization process employs a robust standardization method. The specific calculation process is as follows: for each feature sequence, after removing outliers, the median and interquartile range are calculated, and then scaled according to the following formula:

[0023] x scaled =(x-median) / IQR Formula (2)

[0024] Where x is the feature value before standardization, x scaled is the standardized feature value, median is the feature median, and IQR is the difference between the 75th percentile and the 25th percentile.

[0025] In step S2 of this invention, the constructed experimental data sequence is divided into a training set, a validation set, and a test set in a ratio of 72:13:15. Then, all simulated data sequences are added to the training set, with a weight of 2.0 for low-volume samples and a weight of 0.4 for simulated data.

[0026] In step S2 of this invention, data augmentation is performed on all training samples, that is, Gaussian white noise with a standard deviation of 0.01 is added with a 60% probability, and additional enhancement is performed on low-volume samples, that is, Gaussian noise with a standard deviation of 0.015 is superimposed with an 80% probability, linear scaling in the range of [0.97, 1.03] is performed with a 40% probability, and temporal shift with a step size of [-2, 2] is performed with a 30% probability.

[0027] In step S3 of this invention, the dual-branch neural network adopts a heterogeneous feature extraction architecture. The main branch contains two standard residual blocks, each of which uses a 3×1 convolutional kernel and integrates a channel-space dual attention mechanism. Channel attention is achieved through compression activation of a fully connected layer, and spatial attention uses a 7×1 convolution to capture long-range dependencies. The low-flow branch contains heterogeneous residual blocks with 5×1 and 7×1 convolutional kernels, followed by a multi-scale feature fusion module, which uses four types of convolutional kernels (3×1, 5×1, 7×1, and 9×1) in parallel to extract features at different time scales.

[0028] In step S3 of this invention, the calculation process of the channel attention mechanism is as follows: the feature map is compressed into a 1×1×C global description by adaptive average pooling, and then 16 times dimensionality reduction and restoration are performed through two fully connected layers. The channel weight matrix is ​​generated by Sigmoid activation. The spatial attention mechanism uses 7×1 convolution to generate a spatial weight map, which is then multiplied with the original feature after Sigmoid activation.

[0029] In step S4 of this invention, the training strategy includes: using the Adam W optimizer with an initial learning rate of 0.0003 and a weight decay coefficient of 0.01; adding Gaussian noise with a standard deviation of 0.01 to all samples with a probability of 0.6; reducing the learning rate to 0.3 times the original value when the validation loss does not improve within 12 consecutive epochs; using gradient clipping with a threshold of 0.5; terminating training when the validation loss does not improve within 25 consecutive epochs; and ensuring that the model is saved while both the validation loss and the relative error are better than the historical best values.

[0030] In step S4 of this invention, the calculation formula for the designed loss function is as follows:

[0031]

[0032] In the formula: For the predicted value, y i For the true values ​​(all in the logarithmic field), w i For composite weights, calculate using the following formula:

[0033] w i =w base ·w dynamic ·[1+w rel Formula (4)

[0034] Where: dynamic weight w dynamic Set to: flow rate < 0.05m 3 The value is 6.0 per hour; the flow rate is between 0.05 and 0.1 m³ / h. 3 The value is 4.0 per hour; the flow rate is between 0.1 and 0.3 m³ / h. 3 The value is 2.5 per hour; the flow rate is ≥0.3 m³ / h. 3 The value is 1.0 when / h;

[0035] base weight w base The settings are: experimental data = 1.0; predicted data = 0.4;

[0036] relative error weight w rel Set to: flow rate < 0.05m 3 The value is 2.0 per hour; the flow rate is between 0.05 and 0.1 m³ / h. 3 The value is 1.6 per hour; the flow rate is ≥0.1 m³ / h. 3 The value is 1.0 when / h.

[0037] h(x) is the Huber loss, and its expression is shown below, where x is the relative error.

[0038]

[0039]

[0040] In step S5 of this invention, the evaluation indicators include interval statistical indicators, specifically dividing the flow rate into four intervals: micro-flow (<0.1m³ / s). 3 / h), low flow rate (0.1-0.5m³ / ...). 3 / h), medium flow rate (0.5-1.0m³ / h), medium flow rate (0.5-1.0m 3 / h), large flow rate (>1.0m³ / ...) 3 / h), MSE, RMSE, MAE and mean relative error index are calculated independently for each interval.

[0041] Compared with the prior art, the present invention has the following significant effects:

[0042] (1) The average relative error of each flow range in this invention is controlled between 10% and 17.5%, with an overall average relative error of 12.18%. Therefore, this invention has high prediction accuracy. Compared with the direct measurement method, it overcomes the shortcomings of the bagging method, which relies on manual operation and has a low measurement frequency, and the high flow sampling method, which is susceptible to background interference and has a large quantification error for small flow leakage. In the complex environment of urban natural gas plants, the prediction accuracy of this invention is significantly improved compared with traditional indirect estimation methods such as Gaussian plume models and empirical formulas. At the same time, it eliminates the dependence of CFD inverse simulation on high-cost computing resources (the time for a single analysis is reduced from several hours to less than 1 second), taking into account both high accuracy and real-time requirements, and in particular, enhancing the quantification capability for small flow leakage.

[0043] (2) The present invention has designed a branch structure specifically for small flow leakage, which has strong quantification capability for small flow leakage.

[0044] (3) In 24-hour continuous monitoring, the prediction error fluctuation of this invention is controlled within ±1%, thus the invention has good stability.

[0045] (4) This invention requires no manual intervention, enabling automated monitoring and early warning; it is highly practical.

[0046] (5) This invention can adapt to the complex environment of different natural gas plants and has strong generalization ability. Attached Figure Description

[0047] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.

[0048] Figure 1 This is a diagram of the core deep learning technology architecture of the present invention;

[0049] Figure 2 This is a flowchart of the algorithm workflow of the present invention;

[0050] Figure 3 This is a diagram of the dual-branch network model architecture of the present invention;

[0051] Figure 4 This is a graph showing the change in loss value and relative error during the training process of the dual-branch network model of the present invention;

[0052] Figure 5 This is a hexagonal density distribution diagram showing the predicted and actual values ​​of the present invention.

[0053] Figure 6 This is a distribution diagram of the prediction error density of the present invention;

[0054] Figure 7 This is a comparison chart of the predicted and actual values ​​of the present invention;

[0055] Figure 8 This is a time stability analysis diagram of the 24-hour prediction error of the present invention. Detailed Implementation

[0056] The present invention will now be described in detail with reference to the embodiments and accompanying drawings to help those skilled in the art better understand the inventive concept of the present invention. However, the scope of protection of the claims of the present invention is not limited to the following embodiments. For those skilled in the art, all other embodiments obtained without creative effort without departing from the inventive concept of the present invention are within the scope of protection of the present invention.

[0057] This invention is based on a dual-branch neural network structure, with time series regression as the core task, to realize the mapping relationship between time series feature data obtained from the processing of raw monitoring data and leakage flow.

[0058] like Figure 2 As shown, this invention discloses a natural gas leakage quantification method based on a dual-branch neural network, which mainly comprises four stages: data preparation, model building, model training, and model evaluation. The theoretical basis of the entire method is built upon... Figure 1 The deep learning core technology architecture shown includes convolutional neural networks (CNN), long short-term memory networks (LSTM), and attention mechanisms.

[0059] The present invention specifically includes the following steps:

[0060] S1. Extract basic features from the raw monitoring data, calculate derived features based on the basic features, and then construct time-series features based on the basic and derived features using a sliding window mechanism. The time-series feature data is then standardized. Leakage flow is used as the original monitoring label, and its logarithmic transformation value is used as the model training target value; neither is standardized. Specifically:

[0061] In the data preparation phase, the raw monitoring data included experimental and simulated data. The simulated data was generated using a hybrid Gaussian plume model and a CFD model, producing 1000 samples and 15000 data points. The simulated data covered the value ranges of various parameter dimensions, with sufficient data within the key parameter ranges, providing a good training foundation for subsequent deep learning-based leakage flow inversion research. Basic features were extracted from the raw monitoring data, including CH4 concentration, measuring point height, leakage flow rate, wind speed, measuring point x-coordinate, measuring point y-coordinate, and leakage height. Derived features were calculated based on these basic features, including concentration change rate, concentration acceleration, moving average of concentration, squared wind speed, relative height, and logarithmic transformation of leakage flow rate. This invention introduces a logarithmic transformation of leakage flow rate into the derived features. This nonlinear transformation effectively compresses the numerical range and optimizes flow prediction problems at different orders of magnitude.

[0062] Constructing temporal features: A sliding window mechanism is adopted, with a fixed window size of 15 time steps and a sliding step size of 1 time step. At the same time, a maximum time interval threshold of 2 seconds is introduced to ensure the temporal continuity of the temporal features.

[0063] Standardize the time series feature data: Use a robust scaling method based on quartiles to standardize the time series feature data. This method is not sensitive to outliers and can better maintain the relative distribution characteristics of the data.

[0064] The following is a list of features of the leakage quantization algorithm:

[0065]

[0066] (Table 1)

[0067] S2, with a leakage flow rate of 0.1m 3 Using / h as a threshold, the standardized time-series feature data is divided into low-flow data and regular-flow data. The time-series feature data is further divided into training set, validation set, and test set, with each dataset consisting of low-flow data and regular-flow data. This ensures that the proportion of low-flow data in each dataset is consistent with the experimental data. The training data is weighted, with the weight of low-flow samples increased (weight 2.0) and the weight of simulated data decreased (weight 0.4). Data augmentation is performed on all samples.

[0068] In the dataset partitioning phase, the system employs a stratified sampling strategy, with a leakage flow rate of 0.1m. 3 Using / h as a threshold, the standardized time-series feature data is divided into two categories: low-flow and regular-flow. This ensures that each dataset maintains the proportion of low-flow data found in the experimental data. For example, if the experimental data contains 500 sequences (time-series feature data), among which 100 are low-flow sequences (flow < 0.1 m³ / s),...3 The training set, consisting of 400 regular traffic sequences and 400 samples, is divided in a 72:13:15 ratio. The validation set should contain 65 sequences, including 13 small traffic sequences; the test set should contain 75 sequences, including 15 small traffic sequences. This ensures that the proportion of small traffic sequences in each dataset is consistent with the experimental data. In this embodiment, the ratio of the training, validation, and test sets is 72:13:15, and all simulated data is added to the training set to increase sample diversity.

[0069] S3. Constructing a dual-branch neural network model: First, the 11-dimensional input features are projected onto a 64-dimensional feature space through a one-dimensional convolutional layer. Then, these projected 64-dimensional features are simultaneously input into two parallel branches: the main branch processes the projected features using a standard structure, while the smaller flow branch processes the same projected features using a structure specifically optimized for smaller flow samples. The 64-dimensional features output by the smaller flow branch are then processed by a multi-scale convolutional module to capture feature changes at different time scales. The output features of both branches are added and fused after adaptive average pooling. Then, a bidirectional LSTM network processes the temporal information extracted by the main branch and the smaller flow branch, and a deep fully connected network is used for dimensionality reduction. Finally, the logarithmic domain prediction value y of the main branch is output. main Logarithmic domain prediction y of small flow branches small The 64-dimensional features after initial projection are then directly processed using a flow classifier (the same input as the main branch and small flow branches). Through convolutional layers, batch normalization, residual blocks, pooling, and fully connected layers, a weight coefficient α between 0 and 1 is finally output. The final predicted natural gas leakage flow rate is calculated using the following formula:

[0070] y pred =αy small +(1-α)·y main Formula ⑴

[0071] like Figure 3 As shown, a dual-branch neural network with a main branch and a small flow rate branch is adopted. The input of the dual-branch neural network is time-series feature data containing 11 features: CH4 concentration, wind speed, x-coordinate of the measuring point, y-coordinate of the measuring point, height of the measuring point, leakage height, concentration change rate, concentration acceleration, moving average of concentration, square of wind speed, and relative height. Among them, the logarithmic transformation of leakage flow rate is the prediction target. The time-series feature data of these 11 features are mapped through a one-dimensional convolutional input projection layer with a kernel size of 1, projecting the 11-dimensional feature space to a 64-dimensional feature space, and then entering the main branch and the small flow rate branch.

[0072] The main branch first uses an initial one-dimensional CNN layer to extract local temporal features (such as local fluctuation patterns in concentration and wind speed over time. These features may include short-term trends, periodic changes, or sudden outliers). Then, it connects two improved residual blocks, each consisting of: two convolutional layers with identical configurations (kernel size 3, padded with one position at each end), a batch normalization layer, an attention module (containing channel attention and spatial attention), skip connections (adding the input directly to the output), and a ReLU activation function. Each residual block contains two convolutional layers with identical configurations. The attention module in the residual block consists of two sub-modules: channel attention and spatial attention. The channel attention mechanism first compresses features through adaptive average pooling, then performs feature transformation (dimensionality reduction) through two fully connected layers, and finally obtains the channel weights through the Sigmoid function. Channel attention dynamically enhances features important for prediction (such as strengthening the effect of concentration change rate) by analyzing the global information of each feature channel (such as concentration and wind speed). The spatial attention mechanism employs a one-dimensional convolutional kernel of size 7, utilizing a larger receptive field to capture spatial dependencies in the temporal dimension, focusing on key segments in the time series (such as abrupt changes in the early stages of leakage) and identifying important time points. While the channel attention mechanism focuses on "what the features are," the spatial attention mechanism focuses on "where the features are," effectively enhancing the expressive power of key features. The small-flow branch, specifically designed for small-flow prediction, uses progressively larger convolutional kernel configurations and a multi-scale feature extraction module. This significantly enhances the model's ability to identify weak features (such as subtle concentration changes under low flow rates) in small-flow leakage scenarios. The first residual block uses a convolutional kernel of size 5, and the second residual block uses a convolutional kernel of size 7, capturing a wider range of temporal dependencies by progressively expanding the receptive field. This small-flow branch also incorporates a multi-scale feature extraction module, using four convolutional layers with different configurations and kernel sizes of 3, 5, 7, and 9 in parallel, achieving comprehensive extraction of feature patterns across multiple time scales. Features from the main branch and minor branches are downsampled using an adaptive average pooling layer, compressing the original 15 time points into 7 (i.e., feature fusion, a spatial feature compression and fusion that preserves key temporal features while reducing computational complexity in subsequent processing). These features are then fed into a bidirectional LSTM network. This bidirectional LSTM network employs a two-layer stacked structure, with each layer having a hidden state dimension of 32, and introduces a 0.3 dropout mechanism between layers to prevent overfitting. The features output from the LSTM layers are then dimensionality-reduced using a deep fully connected network containing three hidden layers with dimensions of 256, 128, and 64, respectively.

[0073] To further improve prediction accuracy, this invention designs a flow classifier that generates weighting factors based on the characteristics of the input data, dynamically balancing the contributions of the main branch and the minor flow branch. For example, for regular flow data, features of the main branch may be assigned higher weights; for minor flow data, features of the minor flow branch may have higher weights. When the flow classifier determines that the probability of a minor flow is high, it outputs a weighting coefficient close to 1; otherwise, it outputs a weighting coefficient close to 0, achieving adaptive weighted fusion of the prediction results from the two branches.

[0074] The flow classifier dynamically assesses the probability that a sample belongs to a small flow rate based on the original features, outputting a weight coefficient α. The final logarithmic domain prediction result (predicted natural gas leak flow rate) is calculated using the following formula:

[0075] y pred =α·y small +(1-α)·y main Formula ⑴

[0076] In the formula: y small and y main These are the logarithmic field predictions for the low-flow branch and the main branch, respectively.

[0077] The overall process of constructing the dual-branch network model in this invention is briefly described as follows: First, using shared 64-channel features (from the initial projection layer) as input, the number of channels is reduced to 32 through a convolutional layer. Then, a batch normalization layer and ReLU activation function are applied for feature transformation. After deep feature extraction using an improved residual block (keeping the 32 channels unchanged, employing a large convolutional kernel and channel attention mechanism), an adaptive average pooling layer is used to compress the temporal dimension into a single time point. The flattened 32-dimensional feature vector is then dimensionality-reduced through two fully connected layers (32→16→1), which includes a ReU activation function and a Dropout regularization of 0.2. Finally, the output is mapped to the [0,1] interval using the Sigmoid function, generating dynamic weight coefficients a. The flow classifier dynamically assesses the probability that a sample belongs to a small flow based on the input features (64-channel features). When the flow classifier judges the probability of a small flow to be high, it will output a weight coefficient close to 1, and vice versa. The logarithmic domain prediction result is calculated by formula (1), and then the final predicted value of natural gas leakage flow is obtained after exponential transformation.

[0078] The parameter configurations for the dual-branch network structure are shown in the table below:

[0079]

[0080]

[0081] (Table 2)

[0082] S4. Formulate a training strategy, design a loss function, and use the validation set data from step S2 to perform performance validation. Save the model only when the current validation loss is lower than the historical best validation loss and the current relative error is lower than the historical best relative error. After training, the last saved model is taken as the final best model.

[0083] The model training phase includes three key steps: training strategy formulation, loss function design, and performance verification. Regarding the training strategy, this invention employs an Adam W-based optimizer with an initial learning rate of 0.0003, a weight decay coefficient of 0.01, and enables the amsgrad technique to improve momentum estimation. To enhance the model's generalization ability, data augmentation is performed during training. Gaussian noise with a standard deviation of 0.01 is added to all samples with a probability of 0.6 to simulate random errors in actual measurements. For low-volume samples, stronger augmentation measures are used, including adding Gaussian noise with a standard deviation of 0.015 with a probability of 0.8 and performing random scaling of 0.97-1.03 times with a probability of 0.4. The training process was set to a maximum iteration period of 200, and a dual adjustment mechanism based on validation loss was designed: an early stopping strategy was used to monitor the training process, terminating training when the validation loss did not improve within 25 consecutive iterations; simultaneously, a dynamic learning rate adjustment strategy was employed, reducing the learning rate to 0.3 times its original value when the validation loss did not improve within 12 consecutive iterations, with a minimum learning rate set to 1e. -6 .

[0084] The hyperparameter configurations for model training are shown in the table below:

[0085]

[0086] (Table 3)

[0087] To address the core aspects of the training process, this invention designs a composite loss function comprising four main components: basic loss calculation, dynamic weight adjustment, relative error weighting, and Huber loss fusion. In the logarithmic domain, the basic loss is calculated using the mean squared error form. The dynamic weight adjustment component applies differentiated weights to different flow ranges, and the relative error weighting component applies weights to extremely small flow ranges (<0.05m). 3 / h) and small flow rates (0.05-0.1m) 3 The / h) samples are assigned higher error weights, further enhancing the model's emphasis on predicting low traffic volumes. The Huber loss fusion component improves the model's robustness to outliers through a piecewise function. The weight configurations of each component are shown in Table 4. All weight values ​​deviating from the baseline (1.0) in the table were determined after repeated adjustments and evaluation of model performance on the validation set. The mathematical expression of the loss function is shown below:

[0088]

[0089] Among them, w i For composite weights, For the predicted value, y i These are the true values ​​(all in the logarithmic domain). Composite weight w i The calculation is shown in the following formula:

[0090]

[0091] Among them, w base Based on the weights, w dynamic For dynamic weights, w rel Let h(x) be the relative error weight, and h(x) be the Huber loss, expressed as follows, where x is the relative error.

[0092]

[0093]

[0094] The weight configuration during model training is summarized in the table below:

[0095]

[0096]

[0097] (Table 4)

[0098] In the performance validation phase, the model's performance is evaluated on the validation set to guide the optimization and adjustment of the training process. The performance change curve of the model during training is shown in the figure below. Figure 4 As shown, during the training process, the model reached its optimal state after 117 training rounds. At this point, the training loss was 0.1785, the validation loss was 0.1548, and the relative error dropped to 13.58%, demonstrating good convergence characteristics and prediction performance.

[0099] S5. Load the best model obtained from training, input the test set data from step S2 into the model, obtain the predicted leakage flow value, calculate various evaluation indicators, verify the performance of the model on the test set, and confirm the effectiveness and generalization ability of the model.

[0100] During the model evaluation phase, the test set data from step S2 was input into the best-trained model, and the model outputs a predicted value for leakage flow in the logarithmic domain. The predictive performance of this model was systematically evaluated on the test set from three dimensions: overall evaluation metrics, interval error analysis, and predicted value distribution characteristics. The overall performance evaluation metrics and interval error analysis results of the model are shown in Tables 5 and 6.

[0101]

[0102] (Table 5)

[0103]

[0104] (Table 6)

[0105] From the overall evaluation metrics, the model demonstrates good prediction accuracy: R 2 A mean squared error (MSE) of 0.9157 indicates that the model can explain 91.57% of the data variability; MSE and RMSE are 0.0067 and 0.0819 respectively, indicating a small deviation between predicted and actual values; MAE of 0.0400 further confirms the model's prediction accuracy; the overall mean relative error is 12.18%, which is within the acceptable range for engineering applications. The interval analysis results in Table 2 show that in the 0-0.1m interval... 3 In the low flow rate range of 0.1-0.5 m³ / h, the average relative error is 17.51%; in the range of 0.1-0.5 m³ / h... 3 In the small to medium flow rate range of 0.5-1.0 m³ / h, the average relative error decreased to 10.63%; 3 In the medium flow rate range of / h, the average relative error is 10.50%; in the range greater than 1.0m... 3 The average relative error is 9.31% over a large flow rate range of / h. The model has good adaptability to leakage flow rates of different magnitudes.

[0106] Figure 5-7 It shows the comparison between the model's predicted values ​​and the actual values ​​from different perspectives. For example... Figure 5 The hexagonal density distribution diagram shown indicates that the system's predicted values ​​on the test set are mainly concentrated near the ideal prediction line (y=x), suggesting that most prediction results are in high agreement with the actual values.

[0107] Figure 6 The prediction error density distribution further shows that most prediction errors fall within the 0-15% range, with a median of 7.25%. The system's overall evaluation metrics are excellent: the coefficient of determination (R²)... 2 The value reached 0.9157, with an average relative error of 12.18%.

[0108] Figure 7 The time-series comparison of predicted and actual values ​​for the first 100 samples in the test set is shown. The trends of predicted values ​​(dashed line) and actual values ​​(solid line) are highly consistent, and they can follow the changes of actual values ​​well under different flow levels.

[0109] Based on the above quantitative and qualitative analyses, the results show that the model exhibits good predictive performance across all flow ranges, especially in the range above low flow rates (0.1-1.2 m³ / s). 3The performance was even more outstanding in the / h range, with the average relative error remaining at around 10%. Although in the small flow range (0-0.1m³ / h) 3 The prediction accuracy for the / h) model is relatively low, with an average relative error of approximately 18%, but this level of accuracy is still acceptable considering the challenges of practical engineering applications. These evaluation results fully demonstrate the effectiveness and practicality of the proposed dual-branch neural network model in the task of predicting natural gas leak flow.

[0110] To verify the model's applicability in a real-world environment, this invention conducted 24-hour continuous monitoring at a natural gas plant. Five sampling points at different heights were set up in the process area, and a polling sampling method was used to achieve continuous monitoring of the entire area. After rigorous data screening and processing, the final monitoring results showed that the relative error between the model's predicted values ​​and the bagging method measurement results was 14.79%, and the prediction results exhibited good statistical distribution characteristics.

[0111] Figure 8 The 24-hour prediction error time stability analysis shown indicates that the algorithm maintains stable prediction performance during continuous operation, with the average relative error fluctuation range remaining within ±1%, confirming the stability and reliability of the algorithm.

Claims

1. A method for quantifying natural gas leakage based on a dual-branch neural network, characterized in that... Includes the following steps: S1. Load experimental and simulated data, extract basic features, calculate derived features based on basic features, construct time-series features based on basic and derived features through a sliding window mechanism, and then standardize the time-series feature data. S2, with a leakage flow rate of 0.1m 3 Using / h as a threshold, the standardized time-series feature data is divided into low-flow data and regular-flow data. The time-series feature data is further divided into training set, validation set and test set, and each dataset consists of low-flow data and regular-flow data. At the same time, it is ensured that the proportion of low-flow data in each dataset is consistent with the proportion of low-flow data in the experimental data. S3. Constructing a dual-branch neural network model: First, the 11-dimensional input features are projected onto a 64-dimensional feature space through a one-dimensional convolutional layer. Then, the projected 64-dimensional features are simultaneously input into a parallel main branch and a small-flow branch. The main branch processes the projected 64-dimensional features using a standard structure, while the small-flow branch processes the projected 64-dimensional features using a structure specifically optimized for small-flow samples. The 64-dimensional features output by the small-flow branch are then processed by a multi-scale convolutional module to capture feature changes at different time scales. The output features of both the main branch and the small-flow branch are added and fused after adaptive average pooling. Then, a bidirectional LSTM network is used to process the temporal information extracted from the two branches, and a deep fully connected network is used for dimensionality reduction. Finally, the logarithmic domain prediction value y of the main branch is output. main Logarithmic domain prediction y of small flow branches small The projected 64-dimensional features are then processed by a flow classifier. Specifically, the projected 64-dimensional features are passed through convolutional layers, batch normalization, residual blocks, pooling, and fully connected layers, ultimately outputting a weight coefficient α with a value between 0 and 1. The final predicted natural gas leakage flow rate is calculated using the following formula: y pred = α·y small +(1 - α)·y main Formula (1); S4. Formulate a training strategy, design a loss function, and use the validation set data in step S2 to perform performance validation. Save the model only when the current validation loss is lower than the historical best validation loss and the current relative error is lower than the historical best relative error. After training, the last saved model will be used as the final best model. S5. Load the best model obtained from training, input the test set data from step S2 into the model, obtain the predicted leakage flow value, calculate various evaluation indicators, verify the performance of the model on the test set, and confirm the effectiveness and generalization ability of the model.

2. The natural gas leakage quantification method based on a dual-branch neural network according to claim 1, characterized in that: The basic features include CH4 concentration, measuring point height, leakage flow rate, wind speed, measuring point x-coordinate, measuring point y-coordinate, and leakage height; the derived features include concentration change rate, concentration acceleration, concentration moving average, wind speed squared, relative height, and logarithmic transformation of leakage flow rate; among them, leakage flow rate is used as the original monitoring label, the logarithmic transformation value of leakage flow rate is used as the model training target value, and the remaining 11 features are used as model input.

3. The natural gas leakage quantification method based on a dual-branch neural network according to claim 2, characterized in that: In step S1, the standardization process employs a robust standardization method. The specific calculation process is as follows: for each feature sequence, after removing outliers, the median and interquartile range are calculated, and then scaled according to the following formula: x scaled = (x - median) / IQR Formula (2) Where: x is the feature value before standardization, x scaled is the standardized feature value, median is the feature median, and IQR is the difference between the 75th percentile and the 25th percentile.

4. The natural gas leakage quantification method based on a dual-branch neural network according to claim 3, characterized in that: In step S2, the constructed experimental data sequence is divided into a training set, a validation set, and a test set in a ratio of 72:13:

15. Then, all simulated data sequences are added to the training set, with a weight of 2.0 for low-volume samples and a weight of 0.4 for simulated data.

5. The natural gas leakage quantification method based on a dual-branch neural network according to claim 4, characterized in that: In step S2, data augmentation is performed on all training samples, i.e., Gaussian white noise with a standard deviation of 0.01 is added with a 60% probability, and additional enhancement is performed on low-volume samples, i.e., Gaussian noise with a standard deviation of 0.015 is superimposed with an 80% probability, linear scaling in the range of [0.97, 1.03] is performed with a 40% probability, and time-series shift with a step size of [-2, 2] is performed with a 30% probability.

6. The natural gas leakage quantification method based on a dual-branch neural network according to claim 5, characterized in that: In step S3, the dual-branch neural network adopts a heterogeneous feature extraction architecture. The main branch contains two standard residual blocks, each of which uses a 3×1 convolutional kernel and integrates a channel-spatial dual attention mechanism. Channel attention is achieved by compressing the excitation through a fully connected layer, and spatial attention uses a 7×1 convolution to capture long-range dependencies. The low-flow branch contains heterogeneous residual blocks with 5×1 and 7×1 convolutional kernels, followed by a multi-scale feature fusion module, which uses four types of convolutional kernels (3×1, 5×1, 7×1, and 9×1) in parallel to extract features at different time scales.

7. The natural gas leakage quantification method based on a dual-branch neural network according to claim 6, characterized in that: In step S3, the calculation process of the channel attention mechanism is as follows: the feature map is compressed into a 1×1×C global description by adaptive average pooling, and then 16 times dimensionality reduction and restoration is performed through two fully connected layers. The channel weight matrix is ​​generated by Sigmoid activation. The spatial attention mechanism uses 7×1 convolution to generate a spatial weight map, which is then multiplied with the original features after Sigmoid activation.

8. The natural gas leakage quantification method based on a dual-branch neural network according to claim 7, characterized in that: In step S4, the training strategy includes: using the Adam W optimizer with an initial learning rate of 0.0003 and a weight decay coefficient of 0.01; adding Gaussian noise with a standard deviation of 0.01 to all samples with a probability of 0.6; reducing the learning rate to 0.3 times the original value when the validation loss does not improve within 12 consecutive epochs; using gradient clipping with a threshold of 0.5; terminating training when the validation loss does not improve within 25 consecutive epochs; and ensuring that both the validation loss and the relative error are better than the historical best values.

9. The natural gas leakage quantification method based on a dual-branch neural network according to claim 8, characterized in that: In step S4, the formula for calculating the loss function is: In the formula: For the predicted value, y i For the true values ​​to all be in the logarithmic field, w i For composite weights, calculate using the following formula: w i =w base ·w dynamic ·[1+w rel ·h(x)] formula(4) Where: dynamic weight w dynamic Set to: flow rate < 0.05m 3 The value is 6.0 per hour; the flow rate is between 0.05 and 0.1 m³ / h. 3 The value is 4.0 per hour; the flow rate is between 0.1 and 0.3 m³ / h. 3 The value is 2.5 per hour; the flow rate is ≥0.3 m³ / h. 3 The value is 1.0 when / h; base weight w base The settings are as follows: experimental data is 1.0; predicted data is 0.

4. relative error weight w rel Set to: flow rate < 0.05m 3 The value is 2.0 per hour; the flow rate is between 0.05 and 0.1 m³ / h. 3 The value is 1.6 per hour; the flow rate is ≥0.1 m³ / h. 3 The value is 1.0 when / h; The Huber loss h(x) is expressed as follows: In the formula, x represents the relative error.

10. The natural gas leakage quantification method based on a dual-branch neural network according to claim 9, characterized in that: In step S5, the evaluation indicators include interval statistical indicators, specifically dividing the flow rate into four intervals: micro-flow: less than 0.1 m³ / s. 3 / h; Low flow rate: [0.1-0.5m] 3 / h】; Medium flow rate: 【0.5-1.0m³ / h】 3 / h】; High flow rate: greater than 1.0m³ / h 3 / h; MSE, RMSE, MAE and mean relative error index are calculated independently for each interval.