Gas-liquid two-phase flow parameter prediction method, system, device and storage medium in well
Patent Information
- Application Number
- CN202610982689.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-02
- Publication Date
- 2026-10-09
AI Technical Summary
[0003]本发明的主要目的在于提供了一种井下气液两相流流量参数预测方法、系统、设备及存储介质,旨在解决如何实现对井下流量的精度预测的技术问题
[0017]本发明首先对井下DAS信号进行进行去噪,然后将去噪后的DAS信号输入至预设流量参数预测模型中,输出井下气液两相流流量参数预测结果,预设流量参数预测模型基于改进的SDAE模块、多头注意力模块、BilSTM层及全连接层组合构建,改进的SDAE模块内每层网络由线性变换、PReLU激活函数及分层归一化函数的结构组成。本发明对原始含噪DAS信号的全局噪声抑制,之后基于改进的SDAE模块、多头注意力模块、BilSTM层及全连接层组合构建的预设流量参数预测模型,实现了对井下流量的精准预测。
Smart Images

Figure CN122886362A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of downhole flow prediction technology, and in particular to a method, system, device and storage medium for predicting downhole gas-liquid two-phase flow parameters. Background Technology
[0002] In oil and gas production, the identification of flow parameters for downhole gas-liquid two-phase flow is crucial for production measurement, production optimization, and safety monitoring. Due to the complex downhole environment and strong signal noise, traditional flow calculation methods rely on empirical models, which are ill-suited to complex operating conditions and result in significant errors in flow prediction. Therefore, achieving accurate downhole flow prediction has become an urgent problem to be solved. Summary of the Invention
[0003] The main objective of this invention is to provide a method, system, device, and storage medium for predicting downhole gas-liquid two-phase flow parameters, aiming to solve the technical problem of how to achieve accurate prediction of downhole flow.
[0004] To achieve the above objectives, the present invention provides a method for predicting the flow rate parameters of downhole gas-liquid two-phase flow, the method comprising: Denoise the downhole DAS signal; The denoised DAS signal is input into the preset flow parameter prediction model, and the predicted flow parameters of the downhole gas-liquid two-phase flow are output. The preset flow parameter prediction model is constructed based on the combination of the improved SDAE module, the multi-head attention module, the BilSTM layer and the fully connected layer. Each layer of the network in the improved SDAE module consists of a linear transformation, the PReLU activation function and the hierarchical normalization function.
[0005] Optionally, the step of inputting the denoised DAS signal into a preset flow parameter prediction model and outputting the predicted flow parameters of the downhole gas-liquid two-phase flow includes: The denoised DAS signal is input into a preset flow parameter prediction model. The improved SDAE module superimposes adaptive noise and feature mapping on the denoised DAS signal to obtain a deep feature sequence. The deep feature sequence is linearly projected using a multi-head attention module, and attention scores and multi-head attention weights are fused on the projected features based on neighborhood window constraints and temporal decay factors to obtain multi-head attention enhanced features. The multi-head attention enhancement features are bidirectionally extracted and concatenated using a BilSTM layer to obtain high-dimensional temporal features. The high-dimensional time-series features are nonlinearly mapped and dimensionally transformed by a fully connected layer, and the predicted flow rate parameters of the downhole gas-liquid two-phase flow are output.
[0006] Optionally, the step of superimposing adaptive noise and feature mapping on the denoised DAS signal using the improved SDAE module to obtain a deep feature sequence includes: The denoised DAS signal is adaptively superimposed with noise using an improved SDAE module to generate a noisy vibration signal. Based on a three-layer coding layer and a bottleneck layer, the noisy vibration signal is linearly transformed, and the linearly transformed noisy vibration signal is dimensionality-reduced layer by layer by the PReLU activation function and the hierarchical normalization function to obtain the deep bottleneck features of each time step within the preset time window. The deep bottleneck features at each time step within the preset time window are spliced together along the time dimension to obtain a deep feature sequence.
[0007] Optionally, the step of calculating attention scores and fusing multi-head attention weights on the projected features based on neighborhood window constraints and temporal decay factors to obtain multi-head attention-enhanced features includes: Based on the neighborhood window constraint and the temporal decay factor, the attention score of the projected feature is calculated using the attention score formula. The attention score is converted into projected weights using a normalization function; The projected weights and the projected features are fused using a multi-head parallel fusion formula to obtain multi-head attention-enhanced features.
[0008] Optionally, the attention score formula is:
[0009] In the formula, Let i be the query vector for the i-th row. Let j be the key vector in the j-th row of the window. This is the scaling factor for the single-head feature dimension. and Let λ be the time index for time i and time j, and λ be the time decay coefficient. This is the attention score after the attenuation is superimposed.
[0010] Optionally, the multi-head parallel fusion formula is:
[0011]
[0012] In the formula, This is a feature of multi-head attention enhancement. ( ) represents vector concatenation. For the h-th independently parallel computation attention branch, For the first iThe projection matrix of the head, This is a multi-head fusion weight.
[0013] Optionally, the step of extracting and concatenating bidirectional temporal features from the multi-head attention enhancement features through a BilSTM layer to obtain high-dimensional temporal features includes: The multi-head attention enhancement features are subjected to forward LSTM traversal and backward LSTM traversal respectively to obtain forward temporal features and backward temporal features; The forward and reverse time series features are concatenated to obtain high-dimensional time series features.
[0014] Furthermore, to achieve the above objectives, the present invention also proposes a downhole gas-liquid two-phase flow parameter prediction system, the downhole gas-liquid two-phase flow parameter prediction system comprising: The noise reduction module is used to denoise the downhole DAS signal; The prediction module is used to input the denoised DAS signal into the preset flow parameter prediction model and output the predicted flow parameters of the downhole gas-liquid two-phase flow. The preset flow parameter prediction model is constructed based on the combination of the improved SDAE module, the multi-head attention module, the BilSTM layer and the fully connected layer. Each layer of the network in the improved SDAE module consists of a linear transformation, the PReLU activation function and the hierarchical normalization function.
[0015] Furthermore, to achieve the above objectives, the present invention also proposes a downhole gas-liquid two-phase flow rate parameter prediction device, the device comprising: a memory, a processor, and a downhole gas-liquid two-phase flow rate parameter prediction program stored in the memory and executable on the processor, the downhole gas-liquid two-phase flow rate parameter prediction program being configured to implement the steps of the downhole gas-liquid two-phase flow rate parameter prediction method as described above.
[0016] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a downhole gas-liquid two-phase flow rate parameter prediction program, wherein when the downhole gas-liquid two-phase flow rate parameter prediction program is executed by a processor, the program implements the steps of the downhole gas-liquid two-phase flow rate parameter prediction method described above.
[0017] This invention first denoises the downhole DAS signal, then inputs the denoised DAS signal into a preset flow parameter prediction model, outputting the predicted flow parameters of the downhole gas-liquid two-phase flow. The preset flow parameter prediction model is constructed based on an improved SDAE module, a multi-head attention module, a BilSTM layer, and a fully connected layer. Each layer of the improved SDAE module consists of a linear transformation, a PReLU activation function, and a hierarchical normalization function. This invention achieves global noise suppression of the original noisy DAS signal, and then, based on the preset flow parameter prediction model constructed from the improved SDAE module, multi-head attention module, BilSTM layer, and fully connected layer, it realizes accurate prediction of downhole flow. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of the structure of the downhole gas-liquid two-phase flow rate parameter prediction device in the hardware operating environment involved in the embodiments of the present invention; Figure 2 This is a flowchart illustrating the first embodiment of the downhole gas-liquid two-phase flow parameter prediction method of the present invention. Figure 3 This is a structural diagram of the improved SDAE module of the first embodiment of the downhole gas-liquid two-phase flow flow parameter prediction method of the present invention. Figure 4 This is a model architecture diagram based on the improved SDAE-multi-head attention mechanism-BiLSTM, representing the first embodiment of the downhole gas-liquid two-phase flow parameter prediction method of the present invention. Figure 5 This is a structural block diagram of the first embodiment of the downhole gas-liquid two-phase flow parameter prediction system of the present invention.
[0019] 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
[0020] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0021] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a downhole gas-liquid two-phase flow rate parameter prediction device for the hardware operating environment involved in the embodiments of the present invention.
[0022] like Figure 1As shown, the downhole gas-liquid two-phase flow parameter prediction device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be high-speed random access memory (RAM) or stable non-volatile memory (NVM), such as a disk storage device. Optionally, the memory 1005 may also be a storage system independent of the aforementioned processor 1001.
[0023] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on downhole gas-liquid two-phase flow rate parameter prediction equipment, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0024] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a downhole gas-liquid two-phase flow parameter prediction program.
[0025] exist Figure 1 In the downhole gas-liquid two-phase flow parameter prediction device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and memory 1005 in the downhole gas-liquid two-phase flow parameter prediction device of the present invention can be set in the downhole gas-liquid two-phase flow parameter prediction device. The downhole gas-liquid two-phase flow parameter prediction device calls the downhole gas-liquid two-phase flow parameter prediction program stored in the memory 1005 through the processor 1001 and executes the downhole gas-liquid two-phase flow parameter prediction method provided in the embodiment of the present invention.
[0026] This invention provides a method for predicting flow parameters of downhole gas-liquid two-phase flow, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the downhole gas-liquid two-phase flow parameter prediction method of the present invention.
[0027] In this embodiment, the downhole gas-liquid two-phase flow rate parameter prediction method includes the following steps: S1, denoise the downhole DAS signal.
[0028] It is easy to understand that the executing entity in this embodiment can be a downhole gas-liquid two-phase flow parameter prediction system with functions such as data processing, network communication and program operation, or other computer equipment with similar functions. This embodiment does not limit it.
[0029] Furthermore, the downhole DAS signal can be denoised in the time domain or in the frequency domain, such as by wavelet thresholding. This embodiment does not impose any limitations on this method.
[0030] It should also be noted that the downhole distributed acoustic sensing (DAS) signal is the original noisy DAS vibration signal y(t).
[0031] S2, the denoised DAS signal is input into the preset flow parameter prediction model, and the predicted flow parameters of the downhole gas-liquid two-phase flow are output. The preset flow parameter prediction model is constructed based on the combination of the improved SDAE module, the multi-head attention module, the BilSTM layer and the fully connected layer. Each layer of the network in the improved SDAE module is composed of a linear transformation, the PReLU activation function and the hierarchical normalization function.
[0032] Pre-build and train a traffic flow prediction model with preset parameters: Platform hardware: CPU is Intel(R) Core(TM) i7-13620H CPU @2.30GHz 2.40 GHz, memory is 16GB, graphics card is NVIDIA GeForce RTX4060, operating system is Windows 11 Professional 64-bit, compiler is PyCharm 2021, programming language is Python 3.7.
[0033] To verify the accuracy of this measurement under test well conditions.
[0034] Specific experimental procedure under experimental well conditions: (1) Connect the optical fiber to the DAS system to connect the server and the client; (2) Determine the frequency range of the inverter to be 10-40Hz, with a step of 1Hz; (3) Adjust the frequency according to step (1), and record the data for 10 seconds after the flow rate stabilizes; (4) Repeat step (3) until the frequency converter frequency stabilizes at 40Hz.
[0035] Construction of pipeline flow-induced vibration signal dataset: Data sets were constructed by collecting flow-induced vibration responses under different operating conditions using the DAS monitoring systems of actual shale gas production wells (XY-1, XY-2, and XY-3). The three wells covered different tubing sizes, fluid viscosities, and environmental noise levels.
[0036] The flow rate tag originates from a multiphase flow meter (calibrated accuracy ±1.5%, sampling frequency 1Hz) deployed synchronously with the DAS system on the wellhead oil production pipeline. The DAS signal (20kHz) and the flow meter data (1Hz) are synchronized and aligned using GPS timestamps, with the synchronization error controlled within ±50ms.
[0037] When constructing training samples, the flow rate label for each DAS window was the average of the flow meter readings within the start and end times of that window. In the experiment, the DAS spatial sampling interval was 1 m, and the optical fiber was arranged along the shaft axis. Thirty different flow orders were obtained by adjusting the operating conditions, covering a flow rate range of 2.28 to 20.07 m³ / h. After the flow stabilized in each group, a 10-second effective sampling segment was extracted, ultimately resulting in a vibration signal library containing 5000 samples. For sample construction, the original DAS signals were continuously acquired at a sampling rate of 20 kHz, with each original record corresponding to a complete operating period (approximately 10 seconds, containing 200,000 sampling points). A sliding window method was used to divide the samples into model input samples, with a window length T = 200 (corresponding to 10 ms physical time) and a sliding step size of 50 (75% overlap between adjacent windows). Each window was normalized by Z-score and treated as an independent sample. In terms of data distribution, normal samples (during stable production stages, bubbly flow, stratified flow, or regular slug flow conditions) account for approximately 75%, while abnormal samples (samples exhibiting significant non-stationary characteristics in the DAS signal due to pressure fluctuations, flow pattern changes, pumping operations, etc.) account for approximately 25%. The specific criteria for identifying abnormal samples are: when the standard deviation of the DAS signal amplitude exceeds the mean of the entire sequence plus twice the standard deviation within a certain time window, or when the flow rate change rate between adjacent time points exceeds 10%, it is marked as an abnormal sample. During the data cleaning stage, invalid samples due to sensor failure or signal loss were removed, and the model uniformly performed regression tasks on all samples. In the dataset allocation stage, the dataset was randomly divided into a training set (3500 sets), a validation set (500 sets), and a test set (1000 sets) in a 7:1:2 ratio, and a stratified sampling strategy was used to ensure that the proportion of normal and abnormal samples in each subset remained consistent with the overall dataset. The training set is responsible for driving model parameter iteration, the validation set is used for hyperparameter optimization and early stopping control, while the test set is strictly isolated and used only for the unbiased evaluation of the final generalization performance.
[0038] Two strategies were employed: random partitioning and leave-out based on work conditions / time. Random partitioning served as a baseline for comparison; leave-out based on work conditions and time more closely resembled real-world engineering scenarios, effectively evaluating the model's generalization ability in unseen work conditions and future time periods. Considering the potential data leakage risk from overlapping windows in random partitioning (i.e., the sliding windows of the training and test sets might cover data from the same time period), direct random partitioning could result in data from the same time period appearing in both the training and test sets simultaneously, causing data leakage. Therefore, after random partitioning, the timestamps of all sample windows were checked one by one: if the start and end times of a sample window in the test set overlapped with any sample window in the training set, it was removed from the test set until the two sets had no overlap on the timeline. After this processing, the sample sizes of the training, validation, and test sets remained approximately in a 7:1:2 ratio, and the sample distribution of each subset was consistent with the original dataset.
[0039] To ensure the stable convergence of the SDAE-BiLSTM model (i.e., the pre-defined flow parameter prediction model) integrating a multi-head attention mechanism, refined parameter configuration is required for the denoising encoder, time-series extraction layer, and overall training process, based on the time-frequency characteristics of the gas-liquid two-phase flow signal and the functional attributes of each network module. The model input is the denoised DAS vibration time-series signal. To convert the time-series data into a format that meets the network input requirements, a sliding window method is used to construct the model input samples. The final time-series sequence length is determined to be T=200, and the sliding step size is 50, thus constructing a uniform model training and testing sample set.
[0040] In the hyperparameter optimization stage, a grid search method was chosen. Considering the low dimensionality of the parameters to be tuned and the strong physical and engineering coupling between them, grid search, by exhaustively searching quantitative indicators on the validation set, can intuitively eliminate combined interference between parameters. Compared with search strategies that rely on randomness, this method is less prone to getting trapped in local optima in this low-dimensional and strongly constrained engineering scenario, and can more reliably lock in the optimal parameter combination that adapts to the complex signal characteristics of downhole, providing a benchmark for subsequent comparative experiments and loss analysis. Table 1 below shows the candidate range of hyperparameter grid search: Table 1. Candidate Range for Hyperparameter Grid Search
[0041] Regarding the core module parameters determined by the grid search method, the SDAE encoder adopts a 3-layer hidden layer structure with 128, 64, and 32 neurons respectively, using PReLU as the activation function, a Dropout rate of 0.1, and L2 regularization. The BiLSTM temporal module, as the core of the model's temporal modeling, employs a bidirectional network structure to capture the bidirectional temporal dependence of signals. The number of LSTM units is set to 128, and the internal activation function follows the classic configuration of tanh (cell state) + sigmoid (gating). The Dropout rate is set to 0.2 to reduce the risk of overfitting. The input dimension is consistent with the output dimension of the SDAE encoder to ensure effective transmission of feature sequences. In the improved attention module, an 8-head parallel structure is adopted, with a single-head feature dimension of 16, a temporal neighborhood window size of 20, and a decay coefficient λ of 0.01.
[0042] Model training is considered in two parts: the model itself and the unified settings followed by all models participating in the comparison. The Adam optimizer is used in this model, with an initial learning rate of 0.0005, reduced to 0.0001 during joint fine-tuning, and a batch size of 64. This size is suitable for the sample size of the downhole dataset, avoiding training oscillations caused by small batches while ensuring the model fully learns the sample features. For the comparative experiments, all models share a completely identical dataset and partitioning results, uniformly splitting the training, validation, and test sets in a 7:1:2 ratio, and employing the same stratified sampling strategy to ensure that the sample distribution faced by each model is identical. Input preprocessing uniformly involves signal denoising, followed by sliding window partitioning with a fixed window length of 200 and a step size of 50, and then Z-score standardization. The optimization and training settings remain identical, consistently using the Adam optimizer with an initial learning rate of 0.0005, reduced to 0.0001 during fine-tuning. ReduceLROnPlateau is used for learning rate scheduling, with a patience value of 10 and a decay factor of 0.5. The batch size is 64, the maximum training epochs are 200, and early stopping is achieved when the validation set loss does not decrease for 15 consecutive epochs. The hyperparameters of each model are optimized individually within a candidate range using grid search, with the optimization objective being the minimization of the validation set MAE.
[0043] It should be noted that traditional Stacked Denoising AutoEncoder (SDAE) layers employ fixed noise injection, ReLU activation function, and a single reconstruction loss. When processing noisy, non-stationary, and abruptly changing signals like downhole DAS, they are prone to problems such as weak feature loss, training instability, and excessive smoothing of high-frequency details. To improve the noise-resistant feature extraction capability of SDAE for downhole DAS signals and make it more suitable for the non-stationary, noisy, and abruptly changing characteristics of two-phase flows, this application improves traditional SDAE in four aspects: network structure, activation function, normalization mechanism, and loss function. (Reference) Figure 3 , Figure 3 This is a structural diagram of the improved SDAE module in the first embodiment of the downhole gas-liquid two-phase flow parameter prediction method of the present invention. The improved SDAE adopts a symmetric encoding-decoding architecture, which consists of an adaptive noise injection layer, three encoding layers (encoding layer 1 has a dimension of 128, encoding layer 2 has a dimension of 64, and encoding layer 3 has a dimension of 32), three decoding layers, and a bottleneck layer. The encoding layers sequentially map high-dimensional noisy signals to low-dimensional robust features, while the decoding layers restore the bottleneck features to a reconstructed signal with the same dimension as the input. Each network layer adopts a combination structure of "linear transformation + PReLU activation function + hierarchical normalization". The PReLU activation function can alleviate the problem of inactivation of traditional ReLU neurons and preserve weak mutations and high-frequency details in the signal, while hierarchical normalization can suppress feature distribution shift, stabilize the deep network training process, and accelerate model convergence.
[0044] The training method of SDAE employs a layer-by-layer greedy training process. The hidden layer output of the previous denoising autoencoder (DAE) serves as the input of the next denoising autoencoder (DAE). Through layer-by-layer nonlinear transformation, the original high-dimensional noisy input data is mapped into low-dimensional, highly discriminative deep abstract features. Functionally, the stacked denoising autoencoder (SDAE) can be divided into an encoder module and a decoder module: The encoder module consists of the hidden layers of multiple stacked denoising autoencoders (DAEs) and is the core feature extraction part of the stacked denoising autoencoder (SDAE). It follows the principle of "layer-by-layer dimensionality reduction," with the number of neurons in each layer decreasing sequentially. The output of the previous layer serves as the input of the next layer. Each hidden layer further abstracts the features based on the previous layer, removing redundant information and noise interference, and gradually mapping the original high-dimensional input data into low-dimensional bottleneck layer features. These features are deep abstract features that can represent the essence of the data and can be directly used as the input of downstream models in engineering applications. The decoder module is structurally symmetrical with the encoder module and follows the principle of "layer-by-layer dimensionality increase," with the number of neurons in each layer increasing sequentially. It gradually restores the low-dimensional features of the bottleneck layer to reconstructed data consistent with the input dimension. The core function of the decoder is to optimize the weight parameters of the encoder by reconstructing the error during the unsupervised pre-training stage, so that the encoder can learn effective feature mapping rules. If only the denoising autoencoder SDAE is used for feature extraction, only the encoder module can be retained after training, which greatly reduces the computational complexity of the model.
[0045] It's also worth noting that, as a deep neural network, SDAEs are prone to problems like vanishing gradients, unreasonable weight initialization, and overfitting if trained directly end-to-end. Therefore, it employs a two-step training strategy: "layer-by-layer unsupervised pre-training + overall supervised fine-tuning." This is key to the good performance of stacked denoising autoencoder (DAE) layers in small-sample scenarios, ensuring effective learning of deep features while allowing the model to accurately adapt to specific downstream tasks. The first step is layer-by-layer unsupervised pre-training. A bottom-up training approach is used, with independent unsupervised training performed on the hidden layers of each stacked DAE layer. The training objective is to minimize the proposed improved joint loss function. This loss function integrates temporal reconstruction error, sparsity constraints, and frequency domain consistency loss, better preserving the temporal abrupt changes and frequency domain features of the two-phase flow signal while denoising. During training, the denoised preprocessed signal is first input into the first layer of the DAE, and adaptive noise injection is used to enhance the model's robustness. After reconstruction training, the optimal parameters of this layer are saved. Then, the output of the first hidden layer is used as the input to the second layer of the DAE, and the above training process is repeated, and so on, to complete the pre-training of all encoding layers. This process provides excellent initial weights for the entire deep network, alleviates the gradient vanishing problem caused by random initialization, and enables each layer to learn stable and physically meaningful feature mapping rules. The second step is overall supervised fine-tuning. Based on layer-by-layer pre-training, the encoding, bottleneck, and decoding layers of the entire stacked denoised autoencoder (SDAE) are concatenated into a complete deep network, connected to subsequent multi-head attention modules and BiLSTM layers. The joint loss function is used to minimize the loss through gradient descent, and all encoding, bottleneck, and decoder parameters are updated in reverse to obtain the optimal parameters. During the training phase, a complete symmetric encoder-bottleneck-decoder structure is used to guide feature learning through reconstruction error. In the actual prediction phase, only the encoder-bottleneck layer is retained to map the high-dimensional noisy signal into low-dimensional robust features (i.e., deep feature sequences), which are then fed into subsequent multi-head attention and BiLSTM layers.
[0046] The training of the denoising autoencoder (DAE) is as follows: First, a denoising operator is added to the original input x (i.e., the denoised DAS signal) to generate noisy samples. Then, the hidden layer features are obtained through the encoder:
[0047]
[0048]
[0049] Independent bottleneck layer feature mapping:
[0050] The decoder obtains the reconstructed data through mapping, g()=PRelU(LN()):
[0051] The improved joint loss function expression for the reconstruction error is as follows:
[0052] in, , , These are the encoding weight matrices for the first, second, and third layers, respectively. W l To decode the weight matrix, , , These are the encoding bias vectors for the first, second, and third layers, respectively. b l For decoding the bias vector, PRElU(LN()) is the activation function. This refers to the number of samples in a single batch. The total training loss for SDAE consists of three terms: the first is the temporal reconstruction loss, which ensures the denoised signal closely approximates the original signal in terms of temporal morphology; the second is the sparsity constraint, which encourages the coding layer to output sparser features, enhancing the expression of sensitive features related to flow rate and velocity; and the third is the frequency domain consistency loss, which uses FFT transformation to ensure that the reconstructed signal maintains consistency with the real signal in terms of dominant frequency and energy distribution, avoiding the loss of flow rate mutation features and high-frequency transient information. This is the balance coefficient.
[0053] It should also be noted that the core function of the improved multi-head attention mechanism is to achieve secondary screening and purification of deep features. This mechanism firstly, through dynamic weight allocation, adaptively enhances abrupt changes strongly correlated with flow parameters, suppressing redundant interference. Secondly, considering that standard global attention dilutes local transient change information among numerous distant nodes, a local neighborhood window constraint is adopted to allow the model to focus on strongly correlated transient segments, thereby restoring its sensitivity to downhole flow changes. Furthermore, a temporal distance attenuation factor of "near-strong, far-weak" is incorporated to avoid weight contention among invalid nodes within the window. This series of improvements addressing specific pain points completes the reconstruction from "equal features" to "high-purity key features," thereby significantly improving the accuracy, robustness, and responsiveness to sudden changes in operating conditions in downhole gas-liquid two-phase flow parameter prediction.
[0054] In its implementation, the pre-training process of the BiLSTM layer involves feeding attention-enhanced features into the BiLSTM layer for temporal modeling. This network, through the collaboration of forward and backward LSTMs, simultaneously backtracks historical dependencies and looks ahead to future contexts in the time dimension, extracting bidirectional long-distance temporal correlations layer by layer. Each layer concatenates and fuses the temporal information extracted from both directions, effectively alleviating the gradient vanishing problem in long sequence modeling and comprehensively depicting the continuous evolution of downhole flow from a global perspective. The high-dimensional features output by the BiLSTM undergo nonlinear mapping through fully connected layers, ultimately outputting the flow prediction result. The main function of the fully connected layers is to comprehensively process the temporal features output by the BiLSTM and convert them into the final flow prediction result. Simultaneously, the prediction result and the actual flow are used together through a physical constraint loss function to calculate the total loss, which is then used for backpropagation to optimize the parameters of the entire model (i.e., minimizing L). total To achieve this, the Adam optimizer is employed, and the gradient is backpropagated to the SDAE, improved MHA, BiLSTM, all weights and biases of the fully connected layer are updated synchronously.
[0055] Design of physical constraint loss function: The difference in flow rate between any time t and t+1 must be controlled within a reasonable range that is actually allowed in engineering. There should be no unfounded drastic jumps or false fluctuations that do not conform to the laws of fluid flow. This characteristic of flow continuity is the core basis for designing the physical constraint loss function.
[0056]
[0057] in This represents the physical constraint loss for smoothing the continuity of traffic flow over time. Let t be the predicted flow rate. The above regularization term applies to downhole flow patterns that are continuous flow forms such as bubbly flow, stratified flow, or regular slug flow for most of the time period. The flow curve exhibits a combination of "gradual change + intermittent abrupt change". When there is a violent slug flow or turbulent flow condition or when a valve is suddenly opened or closed, such large jumps that conform to physical laws will be suppressed if a continuous constraint is forcibly applied, resulting in a delayed prediction response and a lower amplitude.
[0058] Since the core optimization objective is a regression task for traffic prediction, we decided to use mean absolute error (MAE) plus physical constraints as the core loss function of the model.
[0059] in This represents the overall loss function of the model. This represents the mean absolute error fitting loss, responsible for ensuring the numerical accuracy between the predicted and actual values. The weighting coefficients are used to constrain the model. This fusion approach retains the fitting advantages of a pure data-driven model while standardizing the model output through physical constraints. This ensures that the prediction results conform to the statistical laws of the training data and strictly follow the physical principle of the continuity of downhole two-phase flow. It also complements the improved multi-head attention mechanism—attention captures abrupt changes in real operating conditions, while physical constraints suppress spurious jumps, further enhancing the model's predictive stability and engineering applicability.
[0060] Controlling the strength of physical constraints, if If the value is too large, the model will over-smooth the prediction results and lose its ability to capture sudden changes in traffic flow; if If the value is too small, the physical constraints have no effect. Optimization is achieved within the range of [0.01, 0.1] using a mesh search. Set it to 0.05. As the number of model iterations increases, observing the overall loss curve of the model, we can see that when the number of iterations reaches 100, the curve gradually flattens out, the model training loss converges, and the model training is complete.
[0061] Further, refer to Figure 4 , Figure 4 This is a model architecture diagram based on the improved SDAE-multi-head attention mechanism-BiLSTM in the first embodiment of the downhole gas-liquid two-phase flow parameter prediction method of the present invention. The processing method for inputting the denoised DAS signal into the preset flow parameter prediction model and outputting the downhole gas-liquid two-phase flow parameter prediction result is as follows: The denoised DAS signal is input into the preset flow parameter prediction model. Adaptive noise and feature mapping are superimposed on the denoised DAS signal through the improved SDAE module to obtain a deep feature sequence. The deep feature sequence is linearly projected through the multi-head attention module, and attention scores are calculated and multi-head attention weights are fused on the projected features based on neighborhood window constraints and time decay factors to obtain multi-head attention enhanced features. The multi-head attention enhanced features are bidirectionally extracted and spliced through the BiLSTM layer to obtain high-dimensional time features. The high-dimensional time features are nonlinearly mapped and dimensionally transformed through the fully connected layer to output the downhole gas-liquid two-phase flow parameter prediction result (i.e., the flow prediction sequence of the continuous physical law of downhole fluid). ).
[0062] Furthermore, after the preset flow parameter prediction model is trained, the improved SDAE module is used to superimpose adaptive noise and feature mapping on the denoised DAS signal to obtain the deep feature sequence. The processing method is as follows: the improved SDAE module is used to perform adaptive noise superposition on the denoised DAS signal to generate a noisy vibration signal; based on the three-layer coding layer and the bottleneck layer, the noisy vibration signal is linearly transformed, and the PReLU activation function and the hierarchical normalization function are used to perform layer-by-layer dimensionality reduction mapping on the linearly transformed noisy vibration signal to obtain the deep bottleneck features of each time step within the preset time window; the deep bottleneck features of each time step within the preset time window are spliced together in time dimension to obtain the deep feature sequence.
[0063] In the specific implementation, the weights of all trained layers are fixed, the three-layer decoder branch is deleted, and only the encoding + bottleneck forward operation is performed; the bottleneck output of each time step within the time window is... Concatenate the data along the time dimension to generate a two-dimensional temporal feature matrix:
[0064] T is the total length of the time window (which can be 200 in this embodiment), and d is the feature dimension of the bottleneck layer (which is 32 in this embodiment). H It is a two-dimensional time-series feature matrix (i.e., a deep feature sequence).
[0065] Furthermore, the processing method for calculating the attention score of the projected features and fusing multi-head attention weights based on the neighborhood window constraint and the temporal decay factor is as follows: the attention score of the projected features is calculated using the attention score formula based on the neighborhood window constraint and the temporal decay factor; the attention score is converted into projection weights using a normalization function; and the projection weights and projected features are fused using a multi-head parallel fusion formula to obtain the multi-head attention enhanced features.
[0066] It should be noted that although the deep feature sequence output by the SDAE encoder has filtered out most of the noise and retained the core information, it still suffers from problems such as equal distribution of feature weights, key features being obscured by redundant information, and insufficient characterization of the correlation between features at different time steps. The introduction of the multi-head attention mechanism can precisely address these pain points. The multi-head attention mechanism dynamically enhances the representation of features highly correlated with key parameters such as flow rate through adaptive weight calculation, while suppressing redundancy and noise interference. This effectively overcomes the limitation of SDAE's "equal treatment of features," significantly improving the purity and recognition accuracy of the feature sequence. The deep feature sequence H∈R output by SDAE... T×d(T is the time step, d is the feature dimension) This includes multi-dimensional information such as amplitude, frequency, and phase of the downhole vibration signal. However, it contains both effective features strongly correlated with flow velocity and flow rate, as well as redundant features derived from noise. The multi-head attention mechanism obtains the (Q / K / V) projected features through Q / K / V linear projection:
[0067] In the formula, (W Q / W K / W V ) is a dedicated projection weight matrix for query, key, and value.
[0068] It should be understood that this embodiment introduces a local neighborhood constraint mechanism, which strictly limits the field of view of attention calculation to a local window [t] centered at the current time t with a radius of k. Within the range of [k, t+k]. Setting the window length k to 20 structurally blocks interference from long-distance irrelevant noise, allowing the model to highly focus computational resources and attention weights on highly correlated local transient segments. This significantly reduces computational redundancy while effectively restoring the ability to keenly capture key changes in traffic.
[0069] Furthermore, even within a limited local window, the impact of each time-series node on the current prediction target is not equal. Inspired by the physical prior of the continuity of downhole flow evolution, signal states at adjacent times often have stronger propagation correlations. Therefore, this embodiment introduces a temporal distance attenuation factor into the basic attention score. This factor assigns higher weights to closer segments by nonlinearly mapping relative positions, ensuring that attention allocation strictly follows the evolutionary law of "stronger near, weaker far," effectively avoiding weight contention among ineffective nodes within the window. The improved attention score formula is:
[0070] In the formula, Let i be the query vector for the i-th row. Let j be the key vector in the j-th row of the window. This is the scaling factor for the single-head feature dimension. and Let λ be the time index for time i and time j, and λ be the time decay coefficient. This is the attention score after the attenuation is superimposed.
[0071] Normalization function:
[0072] In the formula, The normalization function converts the scores into weights of 0 to 1.
[0073] The multi-head parallel fusion formula is:
[0074]
[0075] In the formula, This is a feature of multi-head attention enhancement. ( ) represents vector concatenation. For the h-th independently parallel computation attention branch, For the first i The projection matrix of the head, This is a multi-head fusion weight.
[0076] Furthermore, the high-dimensional temporal features are obtained by bidirectional temporal feature extraction and concatenation of the multi-head attention enhancement features through the BilSTM layer. The processing method is as follows: the multi-head attention enhancement features are subjected to forward LSTM traversal and backward LSTM traversal respectively to obtain forward temporal features and backward temporal features; the forward temporal features and backward temporal features are concatenated to obtain high-dimensional temporal features.
[0077] This represents the hidden state of the forward LSTM at time t. This represents the hidden state of the backward LSTM at time t. The hidden state is the final output of the BiLSTM, and its calculation process is as follows: 1. Forward LSTM state update (ascending order propagation):
[0078] 2. Backward LSTM state update (reverse propagation):
[0079] 3. Bidirectional state fusion (splicing operation)
[0080] in For the feature vector concatenation operation, since BiLSTM fully inherits the cell state and three-gating mechanism of LSTM, retaining its core advantage of solving the gradient vanishing problem of long sequences, LSTM() represents the gating state update logic of standard LSTM.
[0081] BiLSTM, by introducing a bidirectional propagation mechanism, overcomes the limitation of unidirectional LSTM, which can only utilize historical information, and achieves complete contextual feature modeling of the sequence. This allows the feature representation at each time step to integrate global past and future information, thereby constructing a more complete and accurate representation of non-stationary, locally abrupt, and strongly correlated industrial time-series signals.
[0082] Concatenating all time steps yields the complete bidirectional feature sequence:
[0083] In the formula, It represents high-dimensional temporal features.
[0084] The fully connected layer outputs a single-moment predicted flow:
[0085] In the formula, This is the weight matrix of the fully connected layer. For the bias vector of the fully connected layer, For the model to predict the flow rate at time t, It is a linear activation mapping with no nonlinear activation (flow regression task, outputting continuous real flow). The output of the BiLSTM at time t is a fused bidirectional high-dimensional feature vector.
[0086] Reference Figure 5 , Figure 5 This is a structural block diagram of the first embodiment of the downhole gas-liquid two-phase flow parameter prediction system of the present invention.
[0087] like Figure 5 As shown, the downhole gas-liquid two-phase flow rate parameter prediction system proposed in this embodiment of the invention includes: The denoising module 5001 is used to denoise downhole DAS signals; The prediction module 5002 is used to input the denoised DAS signal into the preset flow parameter prediction model and output the predicted flow parameters of the downhole gas-liquid two-phase flow. The preset flow parameter model is constructed based on the combination of the improved SDAE module, the multi-head attention module, the BilSTM layer and the fully connected layer. Each layer of the network in the improved SDAE module is composed of a linear transformation, a PReLU activation function and a hierarchical normalization function.
[0088] Other embodiments or specific implementations of the downhole gas-liquid two-phase flow rate parameter prediction system of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0089] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0090] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0091] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0092] 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 predicting flow parameters of downhole gas-liquid two-phase flow, characterized in that, The method includes the following steps: Denoise the downhole DAS signal; The denoised DAS signal is input into the preset flow parameter prediction model, and the predicted flow parameters of the downhole gas-liquid two-phase flow are output. The preset flow parameter prediction model is constructed based on the combination of the improved SDAE module, the multi-head attention module, the BilSTM layer and the fully connected layer. Each layer of the network in the improved SDAE module consists of a linear transformation, the PReLU activation function and the hierarchical normalization function.
2. The method as described in claim 1, characterized in that, The step of inputting the denoised DAS signal into a preset flow parameter prediction model and outputting the predicted flow parameters of the downhole gas-liquid two-phase flow includes: The denoised DAS signal is input into a preset flow parameter prediction model. The improved SDAE module superimposes adaptive noise and feature mapping on the denoised DAS signal to obtain a deep feature sequence. The deep feature sequence is linearly projected using a multi-head attention module, and attention scores and multi-head attention weights are fused on the projected features based on neighborhood window constraints and temporal decay factors to obtain multi-head attention enhanced features. The multi-head attention enhancement features are bidirectionally extracted and concatenated using a BilSTM layer to obtain high-dimensional temporal features. The high-dimensional time-series features are nonlinearly mapped and dimensionally transformed by a fully connected layer, and the predicted flow rate parameters of the downhole gas-liquid two-phase flow are output.
3. The method as described in claim 2, characterized in that, The improved SDAE module superimposes adaptive noise and feature mapping onto the denoised DAS signal to obtain a deep feature sequence, including: The denoised DAS signal is adaptively superimposed with noise using an improved SDAE module to generate a noisy vibration signal. Based on a three-layer coding layer and a bottleneck layer, the noisy vibration signal is linearly transformed, and the linearly transformed noisy vibration signal is dimensionality-reduced layer by layer by the PReLU activation function and the hierarchical normalization function to obtain the deep bottleneck features of each time step within the preset time window. The deep bottleneck features at each time step within the preset time window are spliced together along the time dimension to obtain a deep feature sequence.
4. The method as described in claim 2, characterized in that, The process of calculating attention scores and fusing multi-head attention weights on the projected features based on neighborhood window constraints and temporal decay factors yields multi-head attention-enhanced features, including: Based on the neighborhood window constraint and the temporal decay factor, the attention score of the projected feature is calculated using the attention score formula. The attention score is converted into projected weights using a normalization function; The projected weights and the projected features are fused using a multi-head parallel fusion formula to obtain multi-head attention-enhanced features.
5. The method as described in claim 4, characterized in that, The attention score formula is as follows: ; In the formula, Let i be the query vector for the i-th row. Let j be the key vector in the j-th row of the window. This is the scaling factor for the single-head feature dimension. and Let λ be the time index for time i and time j, and λ be the time decay coefficient. This is the attention score after the attenuation is superimposed.
6. The method as described in claim 4, characterized in that, The multi-head parallel fusion formula is as follows: In the formula, This is a feature of multi-head attention enhancement. ( ) represents vector concatenation. For the h-th independently parallel computation attention branch, For the first i The projection matrix of the head, This is a multi-head fusion weight.
7. The method as described in claim 2, characterized in that, The process involves bidirectional temporal feature extraction and concatenation of the multi-head attention enhancement features using a BilSTM layer to obtain high-dimensional temporal features, including: The multi-head attention enhancement features are subjected to forward LSTM traversal and backward LSTM traversal respectively to obtain forward temporal features and backward temporal features; The forward and reverse time series features are concatenated to obtain high-dimensional time series features.
8. A downhole gas-liquid two-phase flow parameter prediction system, characterized in that, The system includes: The noise reduction module is used to denoise the downhole DAS signal; The prediction module is used to input the denoised DAS signal into the preset flow parameter prediction model and output the predicted flow parameters of the downhole gas-liquid two-phase flow. The preset flow parameter prediction model is constructed based on the combination of the improved SDAE module, the multi-head attention module, the BilSTM layer and the fully connected layer. Each layer of the network in the improved SDAE module consists of a linear transformation, the PReLU activation function and the hierarchical normalization function.
9. A downhole gas-liquid two-phase flow parameter prediction device, characterized in that, The device includes: a memory, a processor, and a downhole gas-liquid two-phase flow rate parameter prediction program stored in the memory and executable on the processor, the downhole gas-liquid two-phase flow rate parameter prediction program being configured to implement the steps of the downhole gas-liquid two-phase flow rate parameter prediction method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium stores a downhole gas-liquid two-phase flow rate parameter prediction program, which, when executed by a processor, implements the steps of the downhole gas-liquid two-phase flow rate parameter prediction method as described in any one of claims 1 to 7.