CN117034759A - Natural gas pipeline transient flow calculation method based on convolutional neural network - Google Patents

Natural gas pipeline transient flow calculation method based on convolutional neural network Download PDF

Info

Publication number
CN117034759A
CN117034759A CN202310992941.7A CN202310992941A CN117034759A CN 117034759 A CN117034759 A CN 117034759A CN 202310992941 A CN202310992941 A CN 202310992941A CN 117034759 A CN117034759 A CN 117034759A
Authority
CN
China
Prior art keywords
model
neural network
natural gas
convolutional neural
prediction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310992941.7A
Other languages
Chinese (zh)
Inventor
马鹏岳
周凯
赵阳
吴昀
章文恺
王云龙
王涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Energy And Natural Gas Group Co ltd
Zhejiang University ZJU
Original Assignee
Zhejiang Energy And Natural Gas Group Co ltd
Zhejiang University ZJU
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Energy And Natural Gas Group Co ltd, Zhejiang University ZJU filed Critical Zhejiang Energy And Natural Gas Group Co ltd
Priority to CN202310992941.7A priority Critical patent/CN117034759A/en
Publication of CN117034759A publication Critical patent/CN117034759A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/20Design optimisation, verification or simulation
    • G06F30/27Design optimisation, verification or simulation using machine learning, e.g. artificial intelligence, neural networks, support vector machines [SVM] or training a model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/20Design optimisation, verification or simulation
    • G06F30/28Design optimisation, verification or simulation using fluid dynamics, e.g. using Navier-Stokes equations or computational fluid dynamics [CFD]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2113/00Details relating to the application field
    • G06F2113/08Fluids
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2113/00Details relating to the application field
    • G06F2113/14Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2119/00Details relating to the type or aim of the analysis or the optimisation
    • G06F2119/14Force analysis or force optimisation, e.g. static or dynamic forces

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Biomedical Technology (AREA)
  • Computational Linguistics (AREA)
  • Molecular Biology (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Geometry (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Medical Informatics (AREA)
  • Mathematical Optimization (AREA)
  • Mathematical Analysis (AREA)
  • Fluid Mechanics (AREA)
  • Algebra (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention provides a natural gas pipeline transient flow calculation method based on a convolutional neural network, which can be used for calculating pressure change in the process of fluid transient flow in a pipeline. According to the method, the pipeline space information is extracted through the convolution layer, the operation parameter information is embedded through the full connection layer, the data dimension is changed through the convergence layer and the up-sampling layer, and the training difficulty is reduced. Meanwhile, the method introduces time step packing and rolling prediction errors, so that the computing capacity of transient time sequence data is enhanced, the divergence problem of rolling calculation is effectively solved, and the prediction precision is improved. The invention provides a general method for solving transient flow of a fluid pipeline by utilizing a neural network model, does not make any assumption on data distribution of a sample, and can be theoretically used for pressure calculation in any one-dimensional transient natural gas flow process.

Description

Natural gas pipeline transient flow calculation method based on convolutional neural network
Technical Field
The invention belongs to the field of natural gas hydraulic calculation, relates to natural gas flow simulation calculation based on a neural network, and particularly relates to a natural gas pipeline transient flow calculation technology based on a convolutional neural network.
Background
Transient flow of natural gas is a highly complex and nonlinear physical phenomenon, typically described by a set of differential equations, the solution of which is critical to simulating fluid flow. The traditional solving method is a numerical solution, namely, a differential equation is converted into a differential equation and then solved, the development time of the method is long, the theoretical results are rich, and good effects are obtained in various simulation calculation tasks. However, the method requires iterative trial computation in the solving process, has high calculation cost, and particularly needs to consume a large amount of calculation resources when facing to large-scale flow simulation tasks.
In recent years, neural networks have exhibited good effects in the task of solving partial differential equations, such as feed-forward neural networks, graph neural networks, convolutional neural networks, and the like. By means of strong nonlinear fitting capacity and efficient calculation efficiency of the neural network, the trained neural network model can rapidly output a solution of a set of differential equations on the premise of keeping high precision, and solving efficiency is greatly improved.
The transient flow of the natural gas pipeline needs to be subjected to global calculation, and has the characteristic of large dimension, so that the convolutional neural network capable of performing global convolutional operation has greater potential. However, research on transient flow calculation of the convolutional neural network in the natural gas pipeline is still lacking at present, so that research on a transient flow calculation method of the natural gas pipeline based on the convolutional neural network has important significance.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a natural gas pipeline transient flow calculation method with high performance and high precision based on a convolutional neural network.
In view of this, the technical scheme adopted in the invention is as follows:
a natural gas pipeline transient flow calculation method based on a convolutional neural network comprises the following steps:
s1, performing computational fluid dynamics simulation on target natural gas pipelines under different working conditions to obtain transient simulation data under each working condition; each group of transient simulation data consists of in-tube pressure distribution data of each time step between the initial time and the end time of the simulation, and is subjected to normalization processing in advance; constructing a training sample based on different transient simulation data obtained by simulation, extracting in-tube pressure distribution data at an initial moment and pipeline operation parameters as model input, and outputting a corresponding truth value label by taking in-tube pressure distribution data of at least 1 time step from the initial moment to an end moment as a model, thereby constructing a training sample set; the pipeline operation parameters are pipeline length, pipeline diameter, initial moment inlet pressure and end moment outlet speed corresponding to the transient simulation data;
s2, training a convolutional neural network model by using the training sample set and taking a minimum total loss function as a target to obtain a natural gas pipeline transient flow calculation model;
the convolutional neural network model is formed by cascading a convolutional layer, a convergence layer, a full-connection layer, an up-sampling layer and a deconvolution lamination layer; the intra-tube pressure distribution data at the initial moment in the model input is input into a convolution layer in a 1-dimensional vector form; inputting the output result of the convolution layer into a convergence layer, and reducing the dimension through the maximum pooling operation; splicing the output result of the convergence layer with the pipeline operation parameters in the model input, and then inputting the spliced result into the full-connection layer; the output result of the full-connection layer is input into the deconvolution layer after the characteristic dimension is restored through the up-sampling layer, and the in-tube pressure distribution data of at least 1 time step between the initial time and the end time is output;
the total loss function is formed by weighting a first loss term and a second loss term, wherein the first loss term is the mean square error between the actual output of the model and the truth value label, and the second loss term is the rolling prediction error obtained by taking the actual output of the model as the model input again for secondary prediction;
s3, inputting the in-pipe pressure distribution data at the initial moment and the pipeline operation parameters into a natural gas pipeline transient flow calculation model according to the required prediction starting moment aiming at the target natural gas pipeline, and performing rolling prediction on the in-pipe pressure distribution data at different time steps from the initial moment to the ending moment in a recursion mode by the natural gas pipeline transient flow calculation model.
Preferably, when the computational fluid dynamics simulation is performed on the target natural gas pipeline, a series of working conditions are formed by sampling from the value range of each simulation parameter, and then the working conditions are respectively simulated.
Preferably, both the convolution layer and the deconvolution layer are output by a ReLU activation function.
Preferably, in the convolutional neural network model, N data points are uniformly selected along the central axis of the pipeline to form a 1-dimensional vector as the input of the convolutional layer based on the intra-tube pressure distribution data at the initial moment in the model input.
Preferably, the form of the total loss function is as follows:
wherein: k is the prediction step length of the convolutional neural network model, phi (y t ) The pressure distribution data in the tube with k prediction steps and output for the convolution neural network model phi, y t+1~t+k For the truth value label of the in-tube pressure distribution data corresponding to the k future prediction step sizes with the t moment as the initial moment, n is the dimension of the output result of the convolution neural network model phi (y) t ) k The final prediction step of the pressure distribution data in the tube, y, is output for the convolution neural network model phi t+k+1~t+2k And the truth value label is true value label of the in-pipe pressure distribution data corresponding to the next k prediction steps taking the time t+k as the initial time.
Preferably, the super-parameters in the convolutional neural network model are optimized in advance, the model is trained on the training set by dividing the training set and the verification set in advance, and the super-parameters of the model are optimized with the aim of minimizing the total loss function value of the verification set, so that a group of optimal super-parameters are obtained.
Preferably, the super-parameters include neuron number, learning rate, and learning cycle.
Preferably, the convolutional neural network model adopts a multi-step prediction mode, and a single prediction step length is 5, namely, the intra-tube pressure distribution data of 5 time steps from an initial time to an end time are output.
Preferably, the normalization process uses maximum and minimum normalization.
Preferably, in the step S3, if the time step required to be calculated from the initial time to the end time is greater than the single prediction step of the convolutional neural network model, rolling prediction is performed in a recursive manner, and the in-tube pressure distribution data of the last prediction step in the model output during the last prediction is continuously input as the model input during the next prediction until the prediction results of all the prediction time steps are obtained.
Compared with the prior art, the natural gas pipeline transient flow calculation method based on the convolutional neural network has the advantages that:
compared with the traditional numerical solution method, the method has higher calculation efficiency, namely, the calculation amount can be reduced in a specific solving task. Compared with the traditional data driving method, the method improves the rolling calculation performance of the data driving method by packing a plurality of time steps and introducing rolling prediction errors in the training process, so that the rolling calculation task which cannot be finished by the traditional data driving method can be finished, and the calculation precision is improved. Compared with the traditional convolutional neural network model, the method improves the convolutional neural network structure, and the model can learn the influence of the operation parameters on the output better by arranging the full-connection layer in the middle of the convolutional layer, so that the improved model structure has better applicability to the type of calculation task.
Drawings
Fig. 1 is a flowchart of an implementation of a method for calculating transient flow of a natural gas pipeline. .
Fig. 2 is a schematic diagram of a network structure of a convolutional neural network model.
FIG. 3 is a graph showing the comparison of actual values and calculated values of the model of the variation of the outlet pressure of the pipeline under different methods according to the embodiment of the invention.
Fig. 4 is a comparison of the calculated pressure distribution in the pipeline at t=1s according to the different methods of the present invention.
Detailed Description
The following describes embodiments of the present invention in detail with reference to the accompanying drawings, and the embodiments and specific operation procedures are given in the present invention on the premise of the technical solution of the present invention, but the scope of the present invention is not limited to the following embodiments.
The invention aims to train a convolutional neural network model to replace the traditional CFD method simulation which needs to consume a large amount of computation resources, so that the model can rapidly calculate the in-pipe pressure distribution data of each time step from the initial time to the end time under the condition that the pipeline length, the pipeline diameter, the initial time inlet pressure and the end time outlet speed of the target natural gas pipeline are known. The convolutional neural network model can greatly reduce the consumption of computational resources by CFD simulation, for example, the convolutional neural network model can be coupled with CFD simulation, and after a simulation result with a large step size is obtained by the CFD simulation, the convolutional neural network model is used for completing data of finer time steps. As shown in FIG. 1, the method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network comprises two steps of training generation data and model training.
The training data generation step aims at generating a large amount of simulation case data through simulation software, so as to provide data basis for training of the neural network model. Firstly, by reasonably setting simulation parameters, a large amount of sample data is generated by using simulation software. The raw data is then arranged in a specific format to simplify the training model process, e.g., arranging the model inputs and outputs in sequence, with the dimensions determined by the number of operating parameters and the number of time steps of a calculation. And finally, carrying out maximum and minimum normalization processing on the data.
The model training stage aims at training a model based on a convolutional neural network by using processed data, and the trained model can be used for verification and deployment. Firstly, a network framework of a model is built, wherein the network framework comprises a convolution layer, a convergence layer, a full connection layer, an up-sampling layer and a deconvolution layer. Each network layer needs to set super parameters, and the selection of the super parameters needs to be determined through the model verification effect. Finally, a loss function in the model is written, wherein the loss function comprises a mean square error and a rolling prediction error of an output value and an actual value. The final model is trained by weight through a back propagation algorithm, and the trained model can be subjected to effect verification through actual task data or a test set in an actual application or test stage.
The following describes a specific implementation manner of each step in the natural gas pipeline transient flow calculation method based on the convolutional neural network according to a preferred embodiment of the present invention.
Step 1, training data generation
Performing computational fluid dynamics simulation on target natural gas pipelines under different working conditions to obtain transient simulation data under each working condition; each group of transient simulation data consists of in-tube pressure distribution data of each time step between the initial time and the end time of the simulation, and is subjected to normalization processing in advance; and constructing training samples based on different transient simulation data obtained by simulation, extracting in-tube pressure distribution data at the initial moment and pipeline operation parameters as model input, and outputting corresponding truth labels by taking in-tube pressure distribution data of at least 1 time step from the initial moment to the end moment as a model, thereby constructing a training sample set. The pipeline operation parameters are pipeline length, pipeline diameter, initial inlet pressure and final outlet speed corresponding to the transient simulation data.
It should be noted that when the computational fluid dynamics simulation is performed on the target natural gas pipeline, a series of working conditions are required to be formed by sampling from the value ranges of the simulation parameters, and then the working conditions are respectively simulated, so that the training sample set covers all possible operation working conditions as much as possible.
It should be noted that for each training sample, the intra-tube pressure distribution data in which the truth labels are output as a model may be 1 time step or a plurality of time steps, which is related to the prediction modes employed by the subsequently trained convolutional neural network model. That is, if the convolutional neural network model adopts a single-step prediction mode, the intra-tube pressure distribution data as the model output truth label only contains 1 time step, and if the convolutional neural network model adopts a multi-step prediction mode, the intra-tube pressure distribution data as the model output truth label also needs to contain a plurality of time steps.
In addition, in order to ensure that the difference of the data value ranges input by the model is not excessive, normalization processing is needed when the simulation data are constructed into training samples, and the method is preferably realized by adopting a maximum and minimum normalization mode.
Thus, as an implementation manner of the embodiment of the present invention, the specific sub-steps of training data generation described in the above step 1 are as follows:
step 1-1, obtaining common operation parameters of a target natural gas pipeline, including parameters such as pipe diameter, length, materials, flow rate, pressure grade and the like, and performing simulation. The sources of these parameter acquisitions are not limited and may be obtained, for example, from data acquisition and supervisory control Systems (SCADA) and Geographic Information Systems (GIS).
Step 1-2, determining the value range of each parameter according to common operating parameters of a natural gas pipeline, sampling each parameter to form different operating conditions, performing simulation calculation on each operating condition by using a CFD method, or testing on an actual pipeline, generating or acquiring pipeline transient simulation pressure distribution data under a plurality of different operating conditions, and summarizing to obtain a pipeline simulation data set;
and step 1-3, carrying out normalization operation on the pipeline simulation data set to obtain a normalized pipeline simulation data set. The normalization may be performed using maximum and minimum normalization, and the formula is as follows:
wherein z is i For the variable to be normalized, z' i Is the normalized variable. z min 、z max Is the minimum and maximum value of the variable.
Step 1-4, constructing training samples based on the normalized data set, wherein each training sample takes in-tube pressure distribution data at an initial moment and pipeline operation parameters as model input, and takes in-tube pressure distribution data of at least 1 time step from the initial moment to an end moment as model output corresponding truth labels, wherein the pipeline operation parameters are pipeline length, pipeline diameter, initial moment inlet pressure and end moment outlet speed corresponding to transient simulation data. And forming a training sample data set by all training samples, and dividing the training samples in the training sample data set into a training set, a verification set and a test set according to a certain proportion by referring to a conventional model training mode. The specific model structure and training mode will be described later by step 2.
Step 2, model training
And training a convolutional neural network model by using the training sample set and taking the minimum total loss function as a target to obtain a natural gas pipeline transient flow calculation model.
In the present invention, as shown in fig. 2, the convolutional neural network model is formed by cascading a convolutional layer, a convergence layer, a full connection layer, an up-sampling layer and a deconvolution layer; the intra-tube pressure distribution data at the initial moment in the model input is input into a convolution layer in a 1-dimensional vector form; inputting the output result of the convolution layer into a convergence layer, and reducing the dimension through the maximum pooling operation; splicing the output result of the convergence layer with the pipeline operation parameters in the model input, and then inputting the spliced result into the full-connection layer; the output result of the full-connection layer is input into the deconvolution layer after the characteristic dimension is restored through the up-sampling layer, and the in-tube pressure distribution data of at least 1 time step between the initial time and the end time is output;
in the invention, the total loss function is weighted by a first loss term and a second loss term, wherein the first loss term is the mean square error between the actual output of the model and the truth value label, and the second loss term is the rolling prediction error obtained by taking the actual output of the model as the model input again for secondary prediction.
It should be noted that both the convolutional layer and the deconvolution layer have an activation function, i.e., both are output via the ReLU activation function.
In addition, theoretically, the in-tube pressure distribution data may be a continuous distribution, but the actual CFD simulation results in generally discrete in-tube pressure distribution data. While the convolutional neural network model is input, it is not necessary to input all data points as a model. Therefore, N data points can be uniformly selected along the central axis of the pipeline to form a 1-dimensional vector input as a convolution layer based on the pressure distribution data in the pipe at the initial moment in the model input. The specific value of N can be optimally adjusted according to practical situations, for example, the value is preferably 100.
In addition, in the model training process, the rolling prediction error is specially introduced in the total loss function adopted by the model training method besides the conventional mean square error, and the model training method is as follows:
wherein: k is the prediction step length of the convolutional neural network model, phi (y t ) The pressure distribution data in the tube with k prediction steps and output for the convolution neural network model phi, y t+1~t+k For the truth value label of the in-tube pressure distribution data corresponding to the k future prediction step sizes with the t moment as the initial moment, n is the dimension of the output result of the convolution neural network model phi (y) t ) k The final prediction step of the pressure distribution data in the tube, y, is output for the convolution neural network model phi t+k+1~t+2k And the truth value label is true value label of the in-tube pressure distribution data corresponding to the next k prediction steps taking the time t+k+1 as the initial time.
The first term LOSS in the total LOSS function LOSS is a conventional mean square error, and the second term LOSS is a rolling prediction error, and from the form, it can be seen that the first term LOSS is essentially a rolling prediction of a single output of the model, the intra-tube pressure distribution data from time t+k+1 to time t+2k is further predicted, and then the mean square error of the second term prediction is also calculated. The special loss function form is optimized for the prediction scene of transient flow calculation of the natural gas pipeline, and the follow-up embodiment proves that the model and the loss function form can accurately grasp the pressure change condition of the node, so that the problem that rolling prediction is easy to diverge in the prediction process is avoided, and the transient flow prediction accuracy of the long-sequence natural gas pipeline can be improved.
In addition, similar to the traditional model training method, the invention needs to optimize the model super-parameters besides the learnable parameters of the model. The super-parameters include neuron number, learning rate, learning round, etc. When the super-parameters in the convolutional neural network model are optimized in advance, the model can be trained on the training set by dividing the training set and the verification set in advance, and the super-parameters of the model are optimized with the aim of minimizing the total loss function value of the verification set, so that a group of optimal super-parameters are obtained. The learnable parameters of the model may then be trained and optimized based on the optimal superparameter.
It should be noted that, as mentioned above, the convolutional neural network model may be a single-step prediction method or a multi-step prediction method. In the invention, considering the problem of the predicted time length, a multi-step prediction mode is preferably adopted, and the specific prediction steps can be optimized according to actual needs. In a subsequent embodiment of the invention, the single prediction step is preferably 5, i.e. the in-tube pressure profile data is output for 5 time steps between the initial time and the end time, after optimization.
Thus, as an implementation manner of the embodiment of the present invention, the specific sub-steps of model training described in the above step 1 are as follows:
step 2-1, uniformly selecting 100 points on the central axis of each sample pipeline as data extraction points, taking the pressure of the data extraction points as raw data, and splicing into a 1-dimensional vector with 100 dataThe convolution layer calculation process taken on this vector is as follows:
where K is the size of the convolution kernel, ω k The k weight of the convolution kernel is that i ranges from 1 to 100, zero padding is performed when the x subscript is not within this range, l is the vector length, where 100, x is the input, y is the output, and σ is the ReLU activation function.
Step 2-2, after the convolution operation is completed, the vector is processed by using the convergence layer to reduce the feature dimension:
where i= (1, 3,5,) l-1,) l is the vector length.
Step 2-3, after the calculation of a plurality of convolution layers and a convergence layer, splicing the output of the convolution layers and the operation parameters, and performing full-connection layer calculation, wherein the calculation formula is as follows:
x' =σ (W (x u c) +b formula (5)
Wherein W is a parameter matrix to be trained, b is a bias term, and c is an operation parameter vector;
and 2-4, after the calculation of the full connection layer is completed, performing up-sampling layer and deconvolution layer operation, wherein the calculation formulas of the up-sampling layer and the deconvolution layer are as follows:
y=σ (ω×up (x')) formula (6)
Wherein up is an up sampling layer, and the calculation process is y 2i-1,2i =(x' i ,x' i )=up(x' i ) Wherein x' i Represents the ith element in x', y 2i-1,2i The 2i-1 and 2i elements after upsampling layer, i= (1, 2,., l) is the vector length, x is the deconvolution operation, ω is the deconvolution kernel;
step 2-5, combining the convolution layer, the convergence layer, the up-sampling layer, the full-connection layer and the deconvolution layer according to the figure 2 to form the convolution neural network model, wherein the model is input into pressure distribution and operation parameters at the moment t, and the pressure distribution at the moment t+1 to the moment t+k is output, wherein k is the number of a plurality of time steps;
in the 2 nd-6 th steps, the model loss function is the sum of the mean square error of the output value and the actual value and the rolling prediction error, the rolling prediction error is the mean square error of the real value after two continuous calculation by using the model, and the calculation formula is shown in the formula (2).
And 2-7, training the model on a training set, optimizing the super parameters of the model with the aim of minimizing the loss shown in the formula (2) of the verification set, wherein the super parameters comprise the number of neurons, the learning rate and the learning rounds, and finally obtaining a group of optimal super parameters.
After model training is finished, the model prediction accuracy can be verified by using a test set, and the model prediction accuracy can also be tested in an actual scene, namely, the in-pipe pressure distribution data at the initial moment and the pipeline operation parameters are input into a natural gas pipeline transient flow calculation model according to the required prediction starting moment aiming at a target natural gas pipeline, and the in-pipe pressure distribution data at different time steps from the initial moment to the ending moment are predicted by the natural gas pipeline transient flow calculation model.
However, it should be noted that if the time step to be calculated between the initial time and the end time is greater than the single prediction step of the convolutional neural network model, the rolling prediction is required to be performed in a recursive manner, and the intra-tube pressure distribution data of the last prediction step in the model output during the previous prediction is continuously used as the model input during the next prediction until the prediction results of all the prediction time steps are obtained. For example, the time steps required for prediction between the initial time and the end time are 100 steps, and the multi-step prediction is 5 steps at a time, so that 20 recursions are required to obtain the prediction results of all 100 steps.
In order to further demonstrate the advantages of the natural gas pipeline transient flow calculation method based on the convolutional neural network, the method is applied to a specific scene example below to demonstrate the technical effects.
Examples
In this embodiment, the COMSOL software is used to generate sample data, the flow model is transient flow, the physical field is pipeline flow in the fluid-solid coupling model, and the geometry of the simulation model is a section of straight pipeline. The operating parameters, including pipeline length, pipeline diameter, gas flow rate, pressure rating and natural gas composition, are set according to common operating conditions of the natural gas distribution system. Wherein, the length of the pipeline, the diameter of the pipeline, the gas flow rate and the pressure grade are valued in a certain range, the valued range is shown in table 1, and 400 samples are obtained for training and testing. The boundary condition in this embodiment is that the pipeline outlet flow rate smoothly transits from 0 to a certain fixed value in 1 second so as to simulate the situation when the tail end starts to use gas in an actual system. Since natural gas is a compressible gas, the boundary conditions will cause the pressure in the tube to drop and then rise, thereby generating 100 time steps of pressure distribution data, the purpose of the model trained in this embodiment is to roll the time sequence process in a state with only initial values.
Table 1 ranges of values of parameters used in simulation
And carrying out processes such as generating original data, processing data format, data normalization and the like according to the step of generating data in the S1 by utilizing the joint debugging of MATLAB and COMSOL, so as to obtain the processed training data. The training data is divided into a training set, a verification set and a test set according to the proportion of 8:1:1. The training set is a data set for training the neural network model, the verification set is a data set for evaluating whether the model performance in the training process reaches the expectation or not and performing parameter adjustment, and the test set is a data set for evaluating the final model performance.
In this embodiment, a model adopted by the natural gas pipeline transient flow calculation method based on Convolutional Neural Network (CNN) is shown in fig. 2. The convolution layer is used for extracting global features, the convergence layer and the upsampling layer are used for preserving important features and changing vector dimensions, and the full connection layer is used for introducing operation parameters and improving nonlinear fitting capacity of the model. The loss function of the model comprises two parts, including a mean square error of the output value and the actual value and a rolling prediction error, as shown in formula (2). Wherein the rolling prediction error is used to introduce a single-step rolling calculation during model training, thereby enhancing the rolling calculation capability of the model.
In this embodiment, the model hyper-parameters are adjusted based on the principle that the total loss function value of the verification set is minimum, so as to obtain a set of optimal hyper-parameters, as shown in table 2.
Table 2 super parameter optimizing results
In this example, three common indices are used to measure the accuracy of the predictive model, including the mean absolute error (Mean Absolute Error, MAE), the decision coefficients (coefficient of determination, R 2 ) And average absolute percent error (Mean Absolute Percentage Error, MAPE). Wherein, the closer the MAE and MAPE index values are to 0,the more accurate the prediction result. And when R is 2 The closer to 1, the better the model prediction effect is represented.
And performing open-loop training on the model on a training set, and performing closed-loop rolling calculation on a testing set after training is finished. The open loop training refers to that the model inputs a real value at different moments, the closed loop calculation refers to that the model inputs an output value calculated last time, and under the condition of closed loop calculation, the model only receives an initial pressure state and an operation parameter and realizes rolling simulation calculation at all time steps by inputting the output value calculated last time.
The model is applied to the test set for effect, and the actual value of the pressure change at the outlet of the pipeline and the calculated value of the model are shown in figure 3. The solid line in the graph is a true value, indicating that the pressure change at this point is decreasing followed by increasing as the line outlet flow rate transitions from 0 to a certain value. The long dashed line in the graph is the predicted value of the model for the process, and the graph shows that the model and the improved training method designed by the invention can accurately grasp the pressure change condition of the node, and the problems of easy divergence of rolling prediction and the like are avoided. Fig. 4 shows the calculation of the pressure distribution in the pipeline at t=1s, and it can be seen from the graph that the calculated pressure values are all near the true value, and the calculation accuracy is high.
The superiority of the method proposed by the invention is demonstrated by comparison with the conventional method, which refers to a common data-driven model and does not perform multi-time-step packing and modification of the loss function operation. FIGS. 3 and 4 also show that no time step packing is performed and thatThe calculation results of the traditional CNN method, the feedforward neural network (ANN) and the extreme gradient boost tree (xgboost) which introduce a rolling error (i.e. the formula 2 only has the 1 st loss term and no 2 nd loss term) can be seen from the figure that the calculation accuracy is inferior to the method proposed by the invention no matter what the pipeline outlet pressure changes and the pressure distribution condition is when t=1s. At the same time, table 3 also shows the different models in MAPE, R 2 And MAE, the table shows that the method of the invention achieves the best effect.
Table 4 shows the time required for calculation by the convolutional neural network-based calculation method and the conventional numerical solution method, and it can be seen that the calculation time can be greatly reduced by 3.8% compared with the conventional numerical solution method.
Table 3 evaluation index of different models in test set
TABLE 4 calculation of the time required by the method and the conventional method according to the present invention
The invention can predict the time sequence change of the pressure in the pipeline and does not limit the boundary condition and the working state of the pipeline. For example, in this embodiment, the working conditions of constant inlet pressure and variable outlet flow are adopted for verification, and in the working conditions of constant outlet pressure and variable inlet flow, the time sequence change rule of pressure is similar to that of the working conditions in this embodiment, so the invention is still applicable.
The above embodiment is only a preferred embodiment of the present invention, but it is not intended to limit the present invention. Various changes and modifications may be made by one of ordinary skill in the pertinent art without departing from the spirit and scope of the present invention. Therefore, all the technical schemes obtained by adopting the equivalent substitution or equivalent transformation are within the protection scope of the invention.

Claims (10)

1. The natural gas pipeline transient flow calculation method based on the convolutional neural network is characterized by comprising the following steps of:
s1, performing computational fluid dynamics simulation on target natural gas pipelines under different working conditions to obtain transient simulation data under each working condition; each group of transient simulation data consists of in-tube pressure distribution data of each time step between the initial time and the end time of the simulation, and is subjected to normalization processing in advance; constructing a training sample based on different transient simulation data obtained by simulation, extracting in-tube pressure distribution data at an initial moment and pipeline operation parameters as model input, and outputting a corresponding truth value label by taking in-tube pressure distribution data of at least 1 time step from the initial moment to an end moment as a model, thereby constructing a training sample set; the pipeline operation parameters are pipeline length, pipeline diameter, initial moment inlet pressure and end moment outlet speed corresponding to the transient simulation data;
s2, training a convolutional neural network model by using the training sample set and taking a minimum total loss function as a target to obtain a natural gas pipeline transient flow calculation model;
the convolutional neural network model is formed by cascading a convolutional layer, a convergence layer, a full-connection layer, an up-sampling layer and a deconvolution lamination layer; the intra-tube pressure distribution data at the initial moment in the model input is input into a convolution layer in a 1-dimensional vector form; inputting the output result of the convolution layer into a convergence layer, and reducing the dimension through the maximum pooling operation; splicing the output result of the convergence layer with the pipeline operation parameters in the model input, and then inputting the spliced result into the full-connection layer; the output result of the full-connection layer is input into the deconvolution layer after the characteristic dimension is restored through the up-sampling layer, and the in-tube pressure distribution data of at least 1 time step between the initial time and the end time is output;
the total loss function is formed by weighting a first loss term and a second loss term, wherein the first loss term is the mean square error between the actual output of the model and the truth value label, and the second loss term is the rolling prediction error obtained by taking the actual output of the model as the model input again for secondary prediction;
s3, inputting the in-pipe pressure distribution data at the initial moment and the pipeline operation parameters into a natural gas pipeline transient flow calculation model according to the required prediction starting moment aiming at the target natural gas pipeline, and predicting the in-pipe pressure distribution data at different time steps from the initial moment to the ending moment by the natural gas pipeline transient flow calculation model.
2. The method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network according to claim 1, wherein when the computational fluid dynamics simulation is carried out on the target natural gas pipeline, a series of working conditions are formed by sampling from the value range of each simulation parameter, and then each working condition is simulated respectively.
3. The method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network as recited in claim 1, wherein the convolutional layer and the deconvolution layer are output through a ReLU activation function.
4. The method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network according to claim 1, wherein in the convolutional neural network model, N data points are uniformly selected along the central axis of the pipeline to form a 1-dimensional vector serving as the input of the convolutional layer on the basis of the pressure distribution data of the pipeline at the initial moment in the input of the model.
5. The method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network as set forth in claim 1, wherein the form of the total loss function is as follows:
wherein: k is the prediction step length of the convolutional neural network model, phi (y t ) The pressure distribution data in the tube with k prediction steps and output for the convolution neural network model phi, y t+1~t+k For the truth value label of the in-tube pressure distribution data corresponding to the k future prediction step sizes with the t moment as the initial moment, n is the dimension of the output result of the convolution neural network model phi (y) t ) k The final prediction step of the pressure distribution data in the tube, y, is output for the convolution neural network model phi t+k+1~t+2k And the truth value label is true value label of the in-pipe pressure distribution data corresponding to the next k prediction steps taking the time t+k as the initial time.
6. The method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network according to claim 1, wherein the super parameters in the convolutional neural network model are optimized in advance, the model is trained on a training set by dividing the training set and a verification set in advance, and the super parameters of the model are optimized with the aim of minimizing the total loss function value of the verification set, so that a group of optimal super parameters are obtained.
7. The method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network according to claim 6, wherein the super parameters comprise the number of neurons, the learning rate and the learning rounds.
8. The method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network according to claim 1, wherein the convolutional neural network model adopts a multi-step prediction mode, and a single prediction step length is 5, namely, the intra-pipe pressure distribution data of 5 time steps from an initial time to an end time is output.
9. A natural gas pipeline transient flow calculation method based on a convolutional neural network as recited in claim 1, wherein the normalization process employs maximum and minimum normalization.
10. The method for calculating the transient flow of the natural gas pipeline based on the convolutional neural network according to claim 1, wherein in the step S3, if the time step required to be calculated between the initial time and the end time is longer than the single prediction step of the convolutional neural network model, rolling prediction is performed in a recursive manner, and the intra-pipe pressure distribution data of the last prediction step in the model output during the last prediction is continuously used as the model input during the next prediction until the prediction results of all the prediction time steps are obtained.
CN202310992941.7A 2023-08-08 2023-08-08 Natural gas pipeline transient flow calculation method based on convolutional neural network Pending CN117034759A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310992941.7A CN117034759A (en) 2023-08-08 2023-08-08 Natural gas pipeline transient flow calculation method based on convolutional neural network

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310992941.7A CN117034759A (en) 2023-08-08 2023-08-08 Natural gas pipeline transient flow calculation method based on convolutional neural network

Publications (1)

Publication Number Publication Date
CN117034759A true CN117034759A (en) 2023-11-10

Family

ID=88625620

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310992941.7A Pending CN117034759A (en) 2023-08-08 2023-08-08 Natural gas pipeline transient flow calculation method based on convolutional neural network

Country Status (1)

Country Link
CN (1) CN117034759A (en)

Similar Documents

Publication Publication Date Title
Chen et al. Gated recurrent unit based recurrent neural network for remaining useful life prediction of nonlinear deterioration process
CN110119854B (en) Voltage stabilizer water level prediction method based on cost-sensitive LSTM (least squares) cyclic neural network
CN111860982A (en) Wind power plant short-term wind power prediction method based on VMD-FCM-GRU
Pan et al. A multi-head attention network with adaptive meta-transfer learning for RUL prediction of rocket engines
Ayodeji et al. Causal augmented ConvNet: A temporal memory dilated convolution model for long-sequence time series prediction
CN111190429B (en) Unmanned aerial vehicle active fault-tolerant control method based on reinforcement learning
CN111723914A (en) Neural network architecture searching method based on convolution kernel prediction
CN112578089B (en) Air pollutant concentration prediction method based on improved TCN
CN109412161A (en) A kind of Probabilistic Load calculation method and system
CN114492211A (en) Residual oil distribution prediction method based on autoregressive network model
CN115310536A (en) Reservoir water level prediction early warning method based on neural network and GCN deep learning model
CN117034808A (en) Natural gas pipe network pressure estimation method based on graph attention network
Yao et al. Model-based deep transfer learning method to fault detection and diagnosis in nuclear power plants
Tao et al. A digital twin-based fault diagnostic method for subsea control systems
CN110263990B (en) Neural network-based flow torque prediction method and system for vortex type compound machine
CN112232570A (en) Forward active total electric quantity prediction method and device and readable storage medium
CN117034759A (en) Natural gas pipeline transient flow calculation method based on convolutional neural network
Tabib et al. Hybrid deep-learning POD-based parametric reduced order model for flow around wind-turbine blade
CN110829434B (en) Method for improving expansibility of deep neural network tidal current model
CN113887026A (en) Oil pipeline hydraulic prediction method based on ensemble learning
Shloof et al. A highly accurate artificial neural networks scheme for solving higher multi‐order fractal‐fractional differential equations based on generalized Caputo derivative
Marepally et al. Data Puncturing and Training Strategies for Cost-Efficient Surrogate Modeling of Airfoil Aerodynamics
Ma et al. A prediction-based cycle life test optimization method for cross-formula batteries using instance transfer and variable-length-input deep learning model
Zhao et al. Industrial fault diagnosis based on few shot learning
Chu et al. Modeling method for performance prediction of centrifugal compressor based on broad learning system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination