A method for determining and closed-loop controlling the filling quantity of an inhibitor

By combining a multi-source interactive feature matrix and a fuzzy PID controller in the oil and gas gathering and transportation system, the problems of poor data fusion and response lag in the method for determining the amount of corrosion inhibitor added are solved. This enables real-time and accurate prediction and dynamic control of the amount of corrosion inhibitor added, improving the corrosion protection effect and reducing the consumption of the agent.

CN122219641APending Publication Date: 2026-06-16XI'AN PETROLEUM UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XI'AN PETROLEUM UNIVERSITY
Filing Date
2026-03-26
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Existing methods for determining the amount of corrosion inhibitor to be added suffer from poor data integration, insufficient algorithm optimization accuracy, and slow response, resulting in poor corrosion protection of oil and gas gathering and transportation systems and serious waste of agents.

Method used

By installing a pipeline full-parameter monitoring network in the oil and gas gathering and transportation system, time-series data is collected and processed to construct a multi-source interactive feature matrix. A corrosion inhibitor injection volume prediction model is used with covariance tensor transformation and dynamic graph attention mechanism, combined with a fuzzy PID controller to realize real-time injection volume correction, and multi-objective constraint optimization and online updates are performed.

Benefits of technology

It enables real-time and accurate prediction and dynamic control of corrosion inhibitor dosage, improving corrosion protection effectiveness and reducing agent consumption and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122219641A_ABST
    Figure CN122219641A_ABST
Patent Text Reader

Abstract

The application provides a method for determining and closed-loop controlling of an inhibitor injection amount, which comprises: collecting time series data of pipeline parameters through a pipeline full-parameter monitoring network in an oil and gas gathering and transportation system; processing the time series data to obtain target data; constructing a unified time series feature matrix based on the target data; taking the unified time series feature matrix as an input of an inhibitor injection amount prediction model to obtain an output inhibitor injection amount prediction value; taking the unified time series feature matrix and the inhibitor injection amount prediction value as inputs of an injection amount-corrosion rate response proxy model to obtain an expected corrosion rate; correcting the expected corrosion rate to obtain an inhibitor injection correction amount, and combining the inhibitor injection amount prediction value to obtain a target injection amount, and injecting the inhibitor into the pipeline of the oil and gas gathering and transportation system according to the target injection amount; through the above technical solution, real-time, accurate and dynamic regulation and control of the inhibitor injection amount can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of equipment corrosion protection technology, and in particular to a method for determining and controlling the amount of corrosion inhibitor added. Background Technology

[0002] Oil and gas gathering and transportation systems are constantly exposed to corrosive media such as chloride ions, carbon dioxide, and hydrogen sulfide. Corrosion-induced equipment failures and pipeline leaks are frequent accidents, accounting for more than 40% of production accidents. Traditional corrosion inhibitor application relies on manual experience, resulting in rigid strategies that cannot respond to fluctuations in operating conditions, easily leading to agent waste or insufficient protection.

[0003] Existing single-model prediction schemes suffer from three major drawbacks: ineffective fusion of multi-source heterogeneous data leading to input distortion, susceptibility to local optima, and lagging model response, making real-time dynamic adjustment difficult, with response delays often exceeding several minutes. Therefore, there is an urgent need for a method that can achieve high-quality fusion of multi-source data, coupling of prediction model mechanisms, efficient parameter training and optimization, and real-time feedback and self-updating capabilities for determining and controlling corrosion inhibitor dosage. Summary of the Invention

[0004] This application provides a method for determining and controlling the amount of corrosion inhibitor added, which solves the defects of poor data fusion, insufficient algorithm optimization accuracy, and response lag in the existing methods for determining the amount of corrosion inhibitor added. It achieves high-precision prediction, real-time closed-loop control, and online self-updating of the amount of corrosion inhibitor added.

[0005] To achieve the above objectives, this application provides a method for determining and closed-loop controlling the amount of corrosion inhibitor added, the method comprising: A pipeline full-parameter monitoring network is pre-installed in the oil and gas gathering and transportation system to collect time-series data of pipeline parameters; these parameters include, but are not limited to, flow rate, temperature, pressure, CO2 partial pressure, H2S partial pressure, and Cl. - Concentration and corrosion rate; A timestamp alignment algorithm is used to perform data alignment on the time series data; then, the aligned time series data is subjected to abnormal data removal, data completion, and normalization to obtain the target data. Based on the target data, core data is obtained by feature selection using the Pearson correlation coefficient; multiple interaction features are constructed using the core data, and a unified time-series feature matrix is ​​built based on these multiple interaction features. Its dimensions are , N This represents the total number of time-series samples. k These are the feature dimensions after filtering; The unified time series feature matrix The predicted corrosion inhibitor dosage is obtained by using the input of the corrosion inhibitor dosage prediction model as input; the corrosion inhibitor dosage prediction model is expressed as follows: ;in, This is the predicted value for the amount of corrosion inhibitor to be added. For the model parameter set, The physical mechanism constraint parameter set; the initial feature enhancement layer of the corrosion inhibitor injection amount prediction model is the covariance tensor transformation, the backbone network is a dual-path dense residual network, which is composed of two alternating dense blocks connected with custom physical residuals, and a dynamic graph attention mechanism based on spectral theory is introduced, and the output layer is a multi-expert hybrid layer. The unified time series feature matrix The predicted corrosion inhibitor dosage is used as input to the dosage-corrosion rate response proxy model to obtain the expected corrosion rate; and the expected corrosion rate is corrected by a fuzzy PID controller to obtain the corrected corrosion inhibitor dosage. The predicted amount of corrosion inhibitor to be injected is superimposed with the corrected amount of corrosion inhibitor to obtain the target amount of injection. The corrosion inhibitor is then injected into the pipeline of the oil and gas gathering and transportation system according to the target amount of injection.

[0006] In one possible implementation, the corrosion inhibitor dosage prediction model uses the initial feature enhancement layer to modify the unified temporal feature matrix. Perform covariance tensor transformation; construct node feature matrices based on the dynamic graph attention mechanism, and perform two-layer cascaded graph attention calculation and physical manifold projection on the node feature matrices; perform feature transformation on the projected matrix through the dual-path dense residual network; perform multi-expert mixing and tensor voting mechanism on the feature-transformed matrix through the multi-expert mixing layer, and perform multi-objective constraint optimization; and solve the constrained quadratic programming problem to obtain the predicted value of the corrosion inhibitor injection amount.

[0007] In one possible implementation, the physical constraint function based on the extended Butler-Volmer equations is defined in the physical manifold projection. : ;in, For the physical Jacobian matrix, The gradient matrix, F This represents the Frobenius norm.

[0008] In one possible implementation, the composite loss function constructed by the multi-objective constrained optimization is: ;in, For composite loss function, For data fitting loss term, This represents the loss term related to the consistency of physical mechanisms. This is an economic cost loss item. To correct the loss term for closed-loop feedback, , , This is a hyperparameter.

[0009] In one possible implementation, the constrained quadratic programming problem is: ;in, The output is the predicted value of the corrosion inhibitor dosage. The lower limit of the injection volume, This is the maximum amount that can be added. A and b This represents a linear constraint on the monotonicity of the corrosion rate.

[0010] In one possible implementation, the corrosion inhibitor dosage prediction model adjusts the weights based on an adaptive hybrid optimization algorithm; the adaptive hybrid optimization algorithm integrates chaotic Latin hypercube sampling, improved differential evolution, and Nesterov accelerated gradient descent, with the objective function being: ;in, For the model parameter set, For sample weights, This is the predicted value for the amount of corrosion inhibitor to be added. This is the best betting volume in history. For the first Measured corrosion rate values ​​for each sample. This represents the corrosion rate threshold allowed by the process.

[0011] In one possible implementation, the dosage-corrosion rate response proxy model is pre-trained based on electrochemical kinetics and historical operating data, and is used to establish a nonlinear mapping relationship between the dosage of corrosion inhibitor and the corrosion rate.

[0012] In one possible implementation, correcting the expected corrosion rate using a fuzzy PID controller to obtain the corrected amount of corrosion inhibitor dosage includes: Obtain the measured values ​​of corrosion rates for pipelines in oil and gas gathering and transportation systems; Based on the measured corrosion rate and the expected corrosion rate, the corrosion rate deviation is determined. Corrosion rate change rate ; The corrosion rate deviation Corrosion rate change rate Input the fuzzy PID controller; The fuzzy PID controller dynamically adjusts the proportional coefficient using a preset fuzzy rule table. K p Integral coefficientK i and differential coefficients K d This determines the correct amount of corrosion inhibitor to be added at the current moment.

[0013] In one possible implementation, the corrosion rate deviation Corrosion rate change rate Determined by the following formula: ;in, This is the measured corrosion rate. The expected corrosion rate; The process for determining the correction amount of the corrosion inhibitor is expressed by the following formula: ;in, Add a correction amount for the corrosion inhibitor. Due to corrosion rate deviation, For a moment The corrosion rate deviation This is the proportionality coefficient. The integral coefficient is... is the differential coefficient.

[0014] In one possible implementation, the method further includes: The corrosion inhibitor injection volume prediction model is updated online using an incremental learning loss function to adapt to long-term changes in operating conditions; the incremental learning loss function is a weighted sum of historical loss and new data loss. If the prediction error of the corrosion inhibitor injection volume prediction model exceeds the preset error threshold for 24 consecutive hours, the model is retrained and the above online update process is re-executed.

[0015] The technical solutions provided in this application embodiment have at least the following technical effects or advantages: By using a pre-built corrosion inhibitor dosage prediction model, the amount of corrosion inhibitor to be added is predicted, enabling real-time and accurate prediction. Furthermore, based on the dosage-corrosion rate response proxy model and fuzzy PID controller, a correction amount for the amount of corrosion inhibitor is obtained. This correction amount is then used to adjust the predicted amount of corrosion inhibitor to obtain the target dosage, achieving dynamic control of the amount of corrosion inhibitor added. This improves the accuracy of the amount of corrosion inhibitor added, thereby reducing agent consumption and maintenance costs while ensuring corrosion protection effectiveness. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments of this application or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 A flowchart illustrating a method for determining and controlling the amount of corrosion inhibitor added, as provided in this application embodiment; Figure 2 A flowchart illustrating another method for determining and controlling the amount of corrosion inhibitor added, as provided in this application embodiment. Detailed Implementation

[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0019] In the description of the embodiments of this application, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the embodiments of this application and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application. The terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, the terms "installed," "connected," and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; a mechanical connection or an electrical connection; a direct connection or an indirect connection through an intermediate medium; or a connection within two components. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of this application according to the specific circumstances.

[0020] Figure 1 This is a flowchart illustrating a method for determining and controlling the amount of corrosion inhibitor added, as provided in an embodiment of this application. Figure 1 As shown, the method may include the following steps.

[0021] S101. A pipeline full-parameter monitoring network is pre-installed in the oil and gas gathering and transportation system, and time-series data of pipeline parameters are collected through this pipeline full-parameter monitoring network.

[0022] The pipeline parameters include, but are not limited to, flow rate, temperature, pressure, CO2 partial pressure, H2S partial pressure, and Cl. - Concentration and corrosion rate.

[0023] S102. Use a timestamp alignment algorithm to perform data alignment on the time series data; and then perform abnormal data removal, data completion and normalization on the aligned time series data to obtain the target data.

[0024] In some embodiments, the process of obtaining the target data in S102 above may include the following steps. Since the pipeline parameters are multi-source data, exhibiting heterogeneity and asynchronicity, a timestamp alignment algorithm is used to perform data alignment. The data formula can be: , ;in, =10s, indicating the reference time granularity; n for The number of raw data points within the time slice; These are the original sampled values. This is the aligned aggregate value.

[0025] The outlier removal process can use the 3σ criterion to identify and remove outliers, with the outlier judgment formula being: In the case of data judgment These are outliers, where... For sample values, The mean, The standard deviation is denoted as .

[0026] The data completion process can utilize an improved K-nearest neighbor interpolation method, with the interpolation formula as follows: , ;in, Let K be the number of controllable nearest neighbors, where K is the number of missing points to be imputed. For weights determined by distance, Given sample points, Ensure the stability of numerical calculations.

[0027] Data normalization can be achieved using Min-Max normalization, which maps the data to the [0,1] interval to eliminate dimensional differences. The normalization formula is as follows: ;in, This represents the normalized data. , These are the maximum and minimum values ​​of the data sample, respectively.

[0028] S103. Based on the target data, core data is obtained by feature selection using the Pearson correlation coefficient; multiple interaction features are constructed using this core data, and a unified time-series feature matrix is ​​built based on these multiple interaction features. .

[0029] Its dimensions are , N This represents the total number of time-series samples. k These are the feature dimensions after filtering. Among them, matrix elements... Corresponding to the The time series sample of the th time series Normalized data of key features.

[0030] In some embodiments, obtaining core data through feature selection using the Pearson correlation coefficient may include the following steps: Selecting core features that significantly affect corrosion rate and injection volume based on the Pearson correlation coefficient, using the following formula: ;in, Indicates core features, n This represents the total number of data samples used for calculation. and The first Specific feature observations and target variable values ​​for each sample; and These are features x and target y In all n The arithmetic mean of the samples.

[0031] Next, interactive features such as temperature-pressure coupling characteristics and the partial pressure ratio of CO2 and H2S are constructed simultaneously, and finally a unified time-series feature matrix X is constructed, with the following formulas: , ;in, It exhibits temperature-pressure coupling characteristics. For temperature, For pressure, The characteristic of the partial pressure ratio of CO2 to H2S is shown. For CO2 partial pressure, For H2S voltage division.

[0032] S104. Calculate the unified time-series feature matrix. As input to the corrosion inhibitor dosage prediction model, the predicted corrosion inhibitor dosage is obtained as output.

[0033] The prediction model for the amount of corrosion inhibitor added is expressed as follows: ;in, This is the predicted value for the amount of corrosion inhibitor to be added. For the model parameter set, The model uses a set of physical mechanism constraint parameters. The initial feature enhancement layer of the corrosion inhibitor dosage prediction model is a covariance tensor transform, and the backbone network is a dual-path dense residual network, consisting of two alternating dense blocks connected to custom physical residuals. A dynamic graph attention mechanism based on spectral theory is introduced, and the output layer is a multi-expert hybrid layer. For example, a distributed optimization strategy can be used to train this corrosion inhibitor dosage prediction model.

[0034] S105, the unified time series feature matrix The predicted corrosion inhibitor dosage is used as input to the dosage-corrosion rate response proxy model to obtain the expected corrosion rate; and the expected corrosion rate is then corrected by a fuzzy PID controller to obtain the corrected amount of corrosion inhibitor dosage.

[0035] S106. The predicted value of the corrosion inhibitor injection amount is superimposed with the correction amount of the corrosion inhibitor injection to obtain the target injection amount, and the corrosion inhibitor is injected into the pipeline of the oil and gas gathering and transportation system according to the target injection amount.

[0036] By using a pre-built corrosion inhibitor dosage prediction model, the amount of corrosion inhibitor to be added is predicted, enabling real-time and accurate prediction. Furthermore, based on the dosage-corrosion rate response proxy model and fuzzy PID controller, a correction amount for the amount of corrosion inhibitor is obtained. This correction amount is then used to adjust the predicted amount of corrosion inhibitor to obtain the target dosage, achieving dynamic control of the amount of corrosion inhibitor added. This improves the accuracy of the amount of corrosion inhibitor added, thereby reducing agent consumption and maintenance costs while ensuring corrosion protection effectiveness.

[0037] In one possible implementation, the corrosion inhibitor dosage prediction model uses the initial feature enhancement layer to analyze the unified time-series feature matrix. Perform covariance tensor transformation; construct node feature matrices based on the dynamic graph attention mechanism, and perform two-layer cascaded graph attention calculation and physical manifold projection on the node feature matrices; perform feature transformation on the projected matrix through the dual-path dense residual network; perform multi-expert mixing and tensor voting mechanism on the feature-transformed matrix through the multi-expert hybrid layer, and perform multi-objective constrained optimization; and solve the constrained quadratic programming problem to obtain the predicted value of the corrosion inhibitor injection amount.

[0038] In one possible implementation, the physical constraint functions based on the extended Butler-Volmer equations are defined in the projection of the physical manifold. : ;in, For the physical Jacobian matrix, The gradient matrix corresponding to the input features of the corrosion inhibitor dosage prediction model. F This represents the Frobenius norm.

[0039] In one possible implementation, the composite loss function constructed by this multi-objective constrained optimization is: ;in, For composite loss function, For data fitting loss term, This represents the loss term related to the consistency of physical mechanisms. This is an economic cost loss item. To correct the loss term for closed-loop feedback, , , This is a hyperparameter.

[0040] In one possible implementation, the constrained quadratic programming problem is: ;in, This is the predicted value for the final output corrosion inhibitor dosage. The lower limit of the injection volume, This is the maximum amount that can be added. A and b This represents a linear constraint on the monotonicity of the corrosion rate.

[0041] In some embodiments, a corrosion inhibitor dosage prediction model that couples physical mechanisms and data-driven approaches can be pre-built in the following manner to establish a nonlinear mapping relationship between multi-source features and corrosion inhibitor dosage, thereby achieving accurate prediction.

[0042] (1) Establish a unified time series feature matrix To the amount of corrosion inhibitor added Hybrid mapping function ,in For data-driven model parameter sets, This is a set of physical mechanism constraint parameters.

[0043] (2) Using covariance tensor transformation as the initial feature enhancement layer, the two-dimensional unified temporal feature matrix is ​​transformed. Mapped to a three-dimensional covariance tensor T To explicitly capture the higher-order statistical relationships between features, the transformation formula is as follows: ;in, For sample index, a and b These are the feature dimension indices, For the first a The mean of each feature, For the first b The mean of each feature, For small regularization constants, It is an identity matrix.

[0044] (3) Introduce a dynamic graph attention mechanism based on spectral graph theory to process the above tensors. First, construct a dynamic feature map for each sample. , where nodes Corresponding features, edge weights It is determined by the distance of the feature in the tensor space.

[0045] The graph attention coefficient is calculated as follows: ;in, W and a For learnable parameters, This indicates a splicing operation.

[0046] (4) Perform physical manifold projection.

[0047] Physical constraint functions are defined based on the extended Butler-Volmer equations. : Solving constrained optimization problems: .

[0048] (5) The backbone network consists of alternating dense blocks and custom physical residual connections.

[0049] No. l The layer output is: ;in, As an activation function with learnable parameters, the physical residual connection fuses the output of the physical manifold projection layer with the output of the data-driven path using adaptive weights.

[0050] (6) The final output module of the model is a multi-expert hybrid layer. This multi-expert hybrid layer consists of... K A network of "experts" and a gated network The network consists of several parts, each expert responsible for learning the mapping patterns of different regions of the input space. The final prediction is given by the weighted sum of the expert networks. ;in, This is the last hidden layer. For a gated network, the output satisfies , For expert network, K This indicates the number of expert networks.

[0051] (7) The model applies enhanced physical regularization and a multi-objective joint loss function to the output. The constructed composite loss function contains four terms: The definitions of each item are as follows: , , , .

[0052] In one possible implementation, the corrosion inhibitor dosage prediction model adjusts the weights based on an adaptive hybrid optimization algorithm; this adaptive hybrid optimization algorithm integrates chaotic Latin hypercube sampling, improved differential evolution, and Nesterov accelerated gradient descent, with the objective function being: ;in, For the model parameter set, For sample weights, This is the predicted value for the amount of corrosion inhibitor to be added. This is the best betting volume in history. For the first Measured corrosion rate values ​​for each sample. This represents the corrosion rate threshold allowed by the process.

[0053] In some embodiments, the adaptive hybrid optimization algorithm is determined through the following process.

[0054] (1) Chaotic mapping generates the initial population to enhance diversity, and the formula is: Where r=4 is a control parameter. For the first n Chaos value in the next iteration (0,1) represents a random initial value.

[0055] (2) The mutation operation in the global exploration phase adopts an adaptive scaling factor based on the population fitness distribution. The formula is: ;in, For individuals The scaling factor of variation Its loss function value, and These are the minimum fitness and average fitness of the current population, respectively. =0.4, =0.9 is the preset boundary.

[0056] (3) The exponential crossover operation is used to generate new candidate solutions by mixing the parameters of the current individual with the mutation vector to promote population information exchange. Its formula is: ;in, For the newly generated individuals after crossover The parameter value of the dimension. The value of the corresponding dimension of the mutation vector. The value of the dimension corresponding to the original individual. CR The crossover probability (decreases linearly from 0.9 to 0.6 with each iteration). rand The numbers are uniformly random numbers in the range [0,1]. The dimension index is randomly selected, ensuring that at least one dimension parameter comes from the mutation vector.

[0057] (4) The fitness evaluation function in the global exploration phase is the sum of squared residuals between the predicted injection amount and the actual optimal injection amount, and the formula is: The global range of parameters is achieved by minimizing the function.

[0058] (5) After global exploration, local refinement is performed, selecting the top 20% of high-quality solutions, and updating them using adaptive momentum gradient descent, as shown in the following formula: , ;in, For the momentum term, the direction of the historical gradient has been accumulated; The adaptive momentum coefficient decreases nonlinearly from 0.9 to 0.4 with each iteration. The learning rate is decayed, with an initial value of 0.01, and it decays to 0.95 times the original value every 10 generations.

[0059] (6) Inertia weight A non-linear decreasing strategy is adopted, and the formula is: ;in, , These are the upper and lower limits of the inertia weight. t This represents the current iteration number. This represents the maximum number of iterations.

[0060] (7) In the local refinement stage, a learning rate decay and gradient clipping mechanism is introduced to avoid gradient explosion, accelerate parameter convergence and improve parameter accuracy.

[0061] In one possible implementation, the dosage-corrosion rate response proxy model is pre-trained based on electrochemical kinetics and historical operating data to establish a nonlinear mapping relationship between the dosage of corrosion inhibitor and the corrosion rate.

[0062] In some embodiments, the unified time-series feature matrix will be used. The predicted amount of corrosion inhibitor to be added By inputting the same amount of fuel added into the corrosion rate response surrogate model, the corresponding expected corrosion rate can be calculated. ,Right now: ;in, In response to the surrogate model function, a benchmark is provided for subsequent calculations of corrosion rate deviation.

[0063] In one possible implementation, S105 may include: obtaining a measured value of the corrosion rate of the pipeline in the oil and gas gathering and transportation system; and determining the corrosion rate deviation based on the measured corrosion rate and the expected corrosion rate. Corrosion rate change rate The corrosion rate deviation Corrosion rate change rate Input the fuzzy PID controller; the fuzzy PID controller dynamically adjusts the proportional coefficient according to the preset fuzzy rule table. K p Integral coefficient K i and differential coefficients K d This determines the correct amount of corrosion inhibitor to be added at the current moment.

[0064] In one possible implementation, this corrosion rate deviation Corrosion rate change rate Determined by the following formula: ;in, This is the measured corrosion rate. The expected corrosion rate.

[0065] The process for determining the correction amount of the corrosion inhibitor can be expressed by the following formula: ;in, Add a correction amount for the corrosion inhibitor. Due to corrosion rate deviation, For a moment The corrosion rate deviation This is the proportionality coefficient. The integral coefficient is... is the differential coefficient.

[0066] In some embodiments, the corrosion rate deviation can be... Corrosion rate change rate Input a fuzzy PID controller, which dynamically adjusts the proportional coefficient according to a preset fuzzy rule table. K p Integral coefficient K i and differential coefficients K d And calculate the required amount of corrosion inhibitor to be added at the current moment. Among them, if This indicates that the actual corrosion level of the pipeline is higher than expected, and the injection volume can be automatically increased in this case; if This indicates that the actual corrosion level of the pipeline is lower than expected, at which point the injection volume can be automatically reduced. Ultimately, the control system in the oil and gas gathering and transportation system can drive the injection pump to inject the corrosion inhibitor into the pipeline according to the target injection volume.

[0067] In one possible implementation, the method further includes: using an incremental learning loss function to update the corrosion inhibitor injection volume prediction model online to adapt to long-term changes in operating conditions; the incremental learning loss function is a weighted sum of historical loss and new data loss; if the prediction error of the corrosion inhibitor injection volume prediction model exceeds a preset error threshold for 24 consecutive hours, the model is retrained and the above online update process is re-executed.

[0068] In some embodiments, the incremental learning loss function can be expressed as: ;in, The loss of the original model, For incremental dataset loss, It is a forgetting factor used to balance new and old knowledge.

[0069] In other embodiments, model performance monitoring triggering retraining can be expressed as: ;in, and The first h The predicted betting amount per hour and the actual optimal betting amount.

[0070] The following is combined Figure 2 The workflow of the method provided in this application is introduced through an embodiment. In this embodiment, the data is taken from an oilfield gathering and transportation pipeline system.

[0071] S201, Multi-source data acquisition, fusion and feature engineering.

[0072] (1) In the oil and gas gathering and transportation system, a pipeline full parameter monitoring network is pre-built, and the time series data of pipeline parameters are collected within 1 hour. An example of the time series data is shown in Table 1 below.

[0073] Table 1: (2) Perform timestamp alignment to unify all data to a 10-second granularity. Taking the original sampling point t=60s as an example, its aligned timestamp is: For corrosion rate data at t=62s (high sampling frequency), the average value is taken within the time slice of t=60s.

[0074] (3) Anomalies are detected using the 3σ criterion.

[0075] Determine the mean and standard deviation of the traffic data: .

[0076] Judgment threshold: If If the flow rate is 115.0 at t=300s, it is considered abnormal. Assuming the flow rate is 115.0 at t=300s, which is below the threshold, it is retained.

[0077] (4) For missing temperature data caused by sensor failure, K-nearest neighbor interpolation is used to complete the data. The Euclidean distances between the five complete samples before and after the missing point are determined (based on time and operating condition characteristics): Corresponding temperature value Calculate the weights: ; interpolation value; .

[0078] (5) Perform Min-Max normalization on all features. Taking temperature as an example, assuming the minimum value is 64.0℃ and the maximum value is 66.0℃, then... The time-normalized value is: .

[0079] (6) Determine the Pearson correlation coefficient for feature screening. Taking the correlation coefficient calculation between temperature and corrosion rate as an example, take 10 samples: , .

[0080] Determine the mean: , .

[0081] Determine the covariance and variance: , .

[0082] Determine the Pearson correlation coefficient: Because its absolute value is much greater than 0.3, temperature is retained as the core feature.

[0083] (7) Constructing interactive features. Taking t=0s as an example, the temperature-pressure coupling feature and the CO2 / H2S partial pressure ratio formula are as follows: , The final unified time-series feature matrix is ​​constructed. The dimensions are 360×8.

[0084] S202. Construction and training of a model for predicting the amount of corrosion inhibitor added.

[0085] (1) Obtain the unified time series feature matrix constructed by S201 A sample submatrix was constructed by selecting data from 10 consecutive time points. This is used to demonstrate the forward propagation process of the model.

[0086] (2) Perform covariance tensor transformation. First, determine the eigenvalue vector. and centralized matrix : ;in, It is a 10-dimensional column vector of all 1s.

[0087] Determine the sample covariance matrix And add regularization terms: ;in, , It is an 8th-order identity matrix.

[0088] (3) Construct the node feature matrix of the dynamic graph attention mechanism For each feature dimension j ,from Corresponding column Extracting 8-dimensional statistical feature vectors : Among them, the trend item This was obtained by solving the least squares problem: , By concatenating the statistical feature vector with the original feature mean, we obtain... The j OK: .

[0089] (4) Perform attention calculation for the two-level cascaded graph. The first-level attention calculation calculates the attention coefficient matrix between nodes. Its elements are: , ;in, , These are learnable parameters.

[0090] Second-level attention is applied to the updated node features. The above calculation yields the final attention weight matrix. and output features .

[0091] (5) Perform physical manifold projection. Define physical constraint functions based on the extended Butler-Volmer equations. : ;in, The physical Jacobian matrix has the following elements: , .

[0092] By solving constrained optimization problems The augmented Lagrange method is used for iterative solution. k The iterative update formula is: , .

[0093] (6) Construct a dual-path dense residual network. The data-driven path consists of two dense blocks, each containing three transformation layers. The first dense block... l The layer output is: ;in, This is the Mish activation function.

[0094] The physical path will project the features By adapting the network Transformed into a tensor of the same dimension as the data path, the final fused features are: Among them, weight Generated through a learnable Sigmoid gating mechanism: .

[0095] (7) Implement a multi-expert hybrid and tensor voting mechanism. (Set up...) K =4 expert networks, each expert is a three-layer MLP. Tensor voting matrix is ​​introduced. This is used to capture the collaborative and competitive relationships among experts. The final prediction is obtained through tensor shrinkage computation: Among them, gating weights Generated by the gated network G, and satisfying .

[0096] (8) Perform multi-objective constrained optimization to obtain the final output. The constructed composite loss function contains four terms: ; Each item is defined as follows: , , , .

[0097] (9) Obtain the final fueling amount by solving a constrained quadratic programming problem: ;in, A and b This represents a linear constraint on the monotonicity of the corrosion rate.

[0098] (10) The model is trained using a distributed optimization strategy. The total parameters are... Divided into and Alternating updates: , Gradient clipping and adaptive learning rate scheduling are used during training.

[0099] S203, Adaptive Hybrid Optimization Algorithm Parameter Optimization.

[0100] (1) A hybrid optimization algorithm is designed, which integrates chaotic Latin hypercube sampling, improved differential evolution, and Nesterov accelerated gradient descent, with the objective of minimizing the weighted mean square error between the predicted and actual betting amounts. The objective function is: ; in, For the model parameter set, For sample weights, This is the best betting volume in history.

[0101] (2) In the algorithm initialization phase, chaotic mapping combined with Latin hypercube sampling is used to generate the initial population. This ensures both population diversity and avoids uneven distribution. The formula for generating the initial population is: , ; Where m=50 is the number of Latin hypercube sampling partitions. Population size The initial parameters cover the entire search space.

[0102] (3) In the global exploration phase, an improved DE algorithm is used. The mutation operation introduces global and local optima of the population as guidance, and the adaptive scaling factor is dynamically adjusted according to population diversity. The formula is: , ; in, For generation t population diversity, For initial diversity, , , The globally optimal individual. For individuals The local optimum (the optimum of the last 10 generations). , Index for random individuals ( ).

[0103] (4) The crossover operation employs an adaptive crossover probability, dynamically adjusted based on individual fitness and population diversity. The formula is: , ;in, , , Use random dimension indexes to ensure that at least one dimension comes from the mutated vector.

[0104] (5) In the local refinement stage (generations 81-200), Nesterov acceleration gradient descent combined with gradient covariance adjustment is used. The parameter update formula is: , , ; in, This is the amount of data updated in the previous round. =0.95, =0.3, =0.012, c =10, Let be the gradient covariance matrix. For regularization terms, It is an identity matrix.

[0105] S204, Real-time injection volume decision and closed-loop feedback correction.

[0106] (1) Perform moving average filtering on the measured corrosion rate data to eliminate high-frequency noise. The formula is: Where M=5 is the size of the sliding window. These are linear weighting coefficients. =10s is the monitoring interval, substituting... Real-time measured data.

[0107] (2) Determine the corrosion rate deviation Deviation change rate and the cumulative term of the integral of deviation To enhance sensitivity to small deviations, a nonlinear transformation of the deviation is introduced. The formula is: , ; in, It is a nonlinear factor. =0.1 is the upper limit of integral saturation. =0.1 is the inhibition coefficient. It is a saturation function.

[0108] (3) The fuzzification process uses a Gaussian-triangular mixed membership function. Deviation The fuzzy sets are {NB, NM, NS, ZO, PS, PM, PB}. Gaussian membership functions are used for the intermediate fuzzy sets (ZO, PS, PM), and triangular membership functions are used for the edge fuzzy sets (NB, NM, NS, PB). Taking the PS set as an example, the formula for the mixed membership function is: .

[0109] (4) The fuzzy inference method uses the Mamdani inference method, and the defuzzification method uses the dynamic weighting method. The PID parameter update formula is: , ; in, =0.7, =0.15, =0.04 is the initial parameter, and L=12 is the number of valid triggering rules. For rule weights, =50 is the adjustment factor. For rule trigger strength, This is the parameter increment for the rule output.

[0110] S205, Online Model Updates and Performance Maintenance.

[0111] (1) An incremental learning strategy enhanced by meta-learning is adopted. Combined with Bayesian optimization to dynamically adjust the forgetting factor, efficient fusion of new and old knowledge is achieved. The incremental learning loss function is: , ; in, The loss of the original model on the historical dataset ( =0.08), Loss on the new dataset ( =0.11), For matrix trace, =0.05 is the meta-learning gradient coupling coefficient. For the Bayesian optimization process, =0.6, =0.8 represents the forgetting factor range.

[0112] (2) The model parameters are updated using a layered fine-tuning strategy. The learning rate for the attention layer and gating layer parameters is 0.3 times the base learning rate, while the learning rate for the hidden layer and output layer parameters is the base learning rate. The learning rate decay formula is as follows: .

[0113] (3) Model performance monitoring adopts a dual-threshold triggering retraining mechanism of "mean relative error + error variance". The monitoring indicators are calculated as follows: The trigger condition is: and By inputting 24-hour monitoring data and meeting the dual threshold conditions, retraining is automatically triggered. Data from the past three months is retrieved from the cloud database, and the S203 hybrid optimization algorithm is re-executed to update the parameter set. This ensures the long-term adaptability of the model.

[0114] (4) Finally, high-precision prediction of corrosion inhibitor dosage is achieved. As shown in Table 2, the relative error between the actual data and the calibration data is controlled within 1%, which proves that the model has high accuracy and can simulate errors to calibrate it.

[0115] Table 2: The above technical solutions enable accurate prediction of injection volume through multi-source data fusion and physical mechanism coupling. Combined with adaptive optimization and real-time closed-loop control, accuracy and response speed are significantly improved, and online learning capabilities are available. This ensures protective effectiveness while significantly reducing drug consumption, achieving long-term, economical, and safe operation.

[0116] The various embodiments in this specification are described in a progressive manner. For the same or similar parts between the various embodiments, please refer to each other. Each embodiment focuses on describing the differences from other embodiments.

[0117] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of this application.

Claims

1. A method for determining and controlling the dosage of corrosion inhibitor in a closed-loop manner, characterized in that, The method includes: A pipeline full-parameter monitoring network is pre-installed in the oil and gas gathering and transportation system to collect time-series data of pipeline parameters; these parameters include, but are not limited to, flow rate, temperature, pressure, CO2 partial pressure, H2S partial pressure, and Cl. - Concentration and corrosion rate; A timestamp alignment algorithm is used to perform data alignment on the time series data; then, the aligned time series data is subjected to abnormal data removal, data completion, and normalization to obtain the target data. Based on the target data, core data is obtained by feature selection using the Pearson correlation coefficient; multiple interaction features are constructed using the core data, and a unified time-series feature matrix is ​​built based on these multiple interaction features. Its dimensions are , N This represents the total number of time-series samples. k These are the feature dimensions after filtering; The unified time series feature matrix The predicted corrosion inhibitor dosage is obtained by using the input of the corrosion inhibitor dosage prediction model as input; the corrosion inhibitor dosage prediction model is expressed as follows: ;in, This is the predicted value for the amount of corrosion inhibitor to be added. For the model parameter set, The physical mechanism constraint parameter set; the initial feature enhancement layer of the corrosion inhibitor injection amount prediction model is the covariance tensor transformation, the backbone network is a dual-path dense residual network, which is composed of two alternating dense blocks connected with custom physical residuals, and a dynamic graph attention mechanism based on spectral theory is introduced, and the output layer is a multi-expert hybrid layer. The unified time series feature matrix The predicted corrosion inhibitor dosage is used as input to the dosage-corrosion rate response proxy model to obtain the expected corrosion rate; and the expected corrosion rate is corrected by a fuzzy PID controller to obtain the corrected corrosion inhibitor dosage. The predicted amount of corrosion inhibitor to be injected is superimposed with the corrected amount of corrosion inhibitor to obtain the target amount of injection. The corrosion inhibitor is then injected into the pipeline of the oil and gas gathering and transportation system according to the target amount of injection.

2. The method according to claim 1, characterized in that, The corrosion inhibitor dosage prediction model uses the initial feature enhancement layer to modify the unified temporal feature matrix. Perform covariance tensor transformation; Based on the dynamic graph attention mechanism, a node feature matrix is ​​constructed, and a two-layer cascaded graph attention calculation and physical manifold projection are performed on the node feature matrix; the projected matrix is ​​transformed using the dual-path dense residual network; the transformed matrix is ​​subjected to multi-expert mixing and tensor voting mechanism through the multi-expert hybrid layer, and multi-objective constraint optimization is performed; and the constrained quadratic programming problem is solved to obtain the predicted value of the corrosion inhibitor injection amount.

3. The method according to claim 2, characterized in that, The physical constraint functions defined in the physical manifold projection are based on the extended Butler-Volmer equations. : ;in, For the physical Jacobian matrix, The gradient matrix, F This represents the Frobenius norm.

4. The method according to claim 2, characterized in that, The composite loss function constructed by the multi-objective constraint optimization is: ;in, For composite loss function, For data fitting loss term, This represents the loss term related to the consistency of physical mechanisms. This is an economic cost loss item. To correct the loss term for closed-loop feedback, , , This is a hyperparameter.

5. The method according to claim 2, characterized in that, The constrained quadratic programming problem is as follows: ;in, The output is the predicted value of the corrosion inhibitor dosage. The lower limit of the injection volume, This is the maximum amount that can be added. A and b This represents a linear constraint on the monotonicity of the corrosion rate.

6. The method according to claim 1, characterized in that, The corrosion inhibitor dosage prediction model adjusts the weights based on an adaptive hybrid optimization algorithm; the adaptive hybrid optimization algorithm integrates chaotic Latin hypercube sampling, improved differential evolution, and Nesterov accelerated gradient descent, with the objective function being: ;in, For the model parameter set, For sample weights, This is the predicted value for the amount of corrosion inhibitor to be added. This is the best betting volume in history. For the first Measured corrosion rate values ​​for each sample. This represents the corrosion rate threshold allowed by the process.

7. The method according to claim 1, characterized in that, The injection amount-corrosion rate response proxy model is pre-trained based on electrochemical kinetics and historical operating data, and is used to establish a nonlinear mapping relationship between the injection amount of corrosion inhibitor and the corrosion rate.

8. The method according to claim 7, characterized in that, The step of correcting the expected corrosion rate using a fuzzy PID controller to obtain the corrected amount of corrosion inhibitor dosage includes: Obtain the measured values ​​of corrosion rates for pipelines in oil and gas gathering and transportation systems; Based on the measured corrosion rate and the expected corrosion rate, the corrosion rate deviation is determined. Corrosion rate change rate ; The corrosion rate deviation Corrosion rate change rate Input the fuzzy PID controller; The fuzzy PID controller dynamically adjusts the proportional coefficient using a preset fuzzy rule table. K p Integral coefficient K i and differential coefficients K d This determines the correct amount of corrosion inhibitor to be added at the current moment.

9. The method according to claim 8, characterized in that, The corrosion rate deviation Corrosion rate change rate Determined by the following formula: ;in, This is the measured corrosion rate. The expected corrosion rate; The process for determining the correction amount of the corrosion inhibitor is expressed by the following formula: ;in, Add a correction amount for the corrosion inhibitor. Due to corrosion rate deviation, For a moment The corrosion rate deviation This is the proportionality coefficient. The integral coefficient is... is the differential coefficient.

10. The method according to any one of claims 1 to 9, characterized in that, The method further includes: The corrosion inhibitor injection volume prediction model is updated online using an incremental learning loss function to adapt to long-term changes in operating conditions; the incremental learning loss function is a weighted sum of historical loss and new data loss. If the prediction error of the corrosion inhibitor injection volume prediction model exceeds the preset error threshold for 24 consecutive hours, the model is retrained and the above online update process is re-executed.