Channel flow inversion method
Through OpenFOAM, simulation data is generated and deep learning models are constructed. Based on the surface flow velocity distribution, the channel flow is inverted, and the existing open channel flow measurement is solved, and the existing open channel flow measurement is achieved quickly and accurately.
Patent Information
- Application Number
- CN202510575923.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-05-06
AI Technical Summary
The existing open channel flow measurement methods have problems such as low accuracy, high cost and limited application scope, making it difficult to achieve fast and accurate flow measurement.
The computational fluid mechanics software OpenFOAM is used to generate simulation data, modify river parameters in batches through scripts, build a deep learning model, and invert channel flow based on surface flow velocity distribution, reducing dependence on cross-sectional shape and water depth measurement.
It realizes low-cost and high-precision channel and river flow measurement, reduces equipment and labor costs, expands the scope of application of flow measurement, and improves measurement efficiency and accuracy.
Smart Images

Figure CN120493718A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of hydrology, water resources and water conservancy engineering, and in particular relates to a channel flow inversion method. Background Art
[0002] In the advancement of digital construction, real-time and accurate flow monitoring is crucial for water resource management and allocation. There are many existing methods for measuring open channel flow, but they all have certain limitations. The traditional flow meter measurement method requires the instrument to be placed directly in the water flow, which is not only cumbersome to operate, but also easy to damage the instrument in complex water flow environments (such as too fast flow rate, high sediment content, etc.), and the measurement accuracy will also be affected. The method of inferring flow based on water level is simple and efficient, but it relies on a large amount of data accumulation. For newly built channels or unexplored rivers, it is impossible to accurately measure the flow. The Acoustic Doppler Current Profiler (ADCP) has improved the measurement accuracy to a certain extent and does not require data accumulation. However, it is difficult to achieve real-time monitoring, and a large number of measurements have high manpower and time costs.
[0003] With the development of science and technology, especially image processing and computer vision, methods based on particle tracking velocimetry and large-scale particle image velocimetry (PIV) have made it easy to obtain surface velocity. Whether based on drones, fixed or handheld remote sensing technologies, including optical and microwave, have been proven to be able to provide instantaneous surface velocity quickly and cost-effectively during remote access. However, it is still necessary to give a proportional coefficient for converting depth-averaged flow velocity and river cross-sectional bathymetry data to complete flow calculations. Both are complex and difficult to obtain accurate results. Current methods require additional measurement costs after surface velocity measurements to obtain both.
[0004] Deep learning technology has been widely used in the field of data mining, and its influence continues to expand with advances in algorithms and increases in computing power. The most challenging aspect of deep learning calculations is obtaining high-quality training data. The quality of training data directly impacts the final model's performance, yet such data is often difficult to obtain. The flexibility of OpenFOAM (open-source software for computational fluid dynamics) allows for the generation of large amounts of simulation data to support model training. It is worth exploring the possibility of directly deriving average bathymetry and flow rate from surface velocity distributions through extensive data training. This would greatly facilitate flow measurement and provide technical support for the digital construction and management of irrigation districts and watersheds.
[0005] Therefore, there is an urgent need to develop a data-driven deep learning method that is expected to overcome the above limitations and provide continuous and reliable flow data support for water resource management and allocation. Summary of the Invention
[0006] In response to the above-mentioned deficiencies in the prior art, the present invention provides a channel flow inversion method to solve the problems of low precision, high cost, and limited scope of application of existing open channel flow measurement methods, and to achieve rapid and accurate measurement of open channel flow.
[0007] In order to achieve the above objectives, the present invention adopts a technical solution: a channel flow inversion method, comprising the following steps:
[0008] The computational fluid dynamics software OpenFOAM is used to debug the calculation cases, and the debugging results are used to ensure the correctness of the batch solution results;
[0009] Use scripts to batch copy and modify the river channel parameters of calculated cases;
[0010] Use scripts to call the computational fluid dynamics software OpenFOAM to batch solve all calculation cases and calculate the simulation structure to build a data set;
[0011] Build a deep learning model based on the data set;
[0012] Training deep learning models;
[0013] The time-averaged velocity distribution of the section is read from the velocity distribution cloud map, and the channel flow is inverted using the trained deep learning model.
[0014] The present invention has the beneficial effect of eliminating the need for radar or other equipment to measure cross-sectional shape and water depth. Instead, it utilizes algorithms to obtain flow data for channels and rivers at a lower cost. This enables low-cost, high-precision flow measurement for channels and rivers, reducing costs economically and providing a more powerful algorithm technically.
[0015] This paper aims to provide a method for more accurately inverting flow based on surface velocity using deep learning technology and how to use the computational fluid dynamics software OpenFOAM to generate training data, so as to solve the problems of low precision, high cost, and limited scope of application of existing open channel flow measurement methods, and realize rapid and accurate measurement of open channel flow.
[0016] Furthermore, the debugging of the calculation case is specifically as follows:
[0017] Using the computational fluid dynamics software OpenFOAM, a basic geometric model is selected and a computational mesh of a domain with a geometric shape is generated with a given mesh accuracy;
[0018] In the basic geometric model, the boundary conditions of the channel are set. The bottom and side walls of the channel are set as walls, and the Spalding wall function is used to simulate the near-wall flow dynamics. The free surface is regarded as a freely sliding rigid lid, the channel outlet is set as the far field, and backflow is not allowed.
[0019] Select and set the turbulence model and solution method to complete the debugging of the test case.
[0020] The beneficial effect of the above-mentioned further scheme is that, combined with the optimization solution of the turbulence model, it can effectively simulate the interaction between complex near-wall flow and free surface, significantly improve the accuracy and stability of turbulence simulation in the channel, and at the same time reduce the computing cost, providing reliable data support for engineering fluid analysis.
[0021] Furthermore, the script is used to batch copy and modify the calculated case river parameters, which is specifically as follows:
[0022] Modify the parameters that control the flow channel shape in the calculation case and save it as the initial calculation file;
[0023] Set the parameters that control the initial velocity and background grid size in the calculation case file;
[0024] The initial calculation file is copied through the script, and the river parameters to be modified are replaced with random values in the form of random numbers.
[0025] The beneficial effects of the above-mentioned further scheme are: batch generation of randomly parameterized river channel cases through scripts, automatic modification of flow channel shapes and creation of diversified calculation files, significantly improving the efficiency of parameter research, supporting the rapid construction of simulation sample libraries under different geometric conditions, providing a large-scale data foundation for optimized design or sensitivity analysis, and reducing errors caused by manual repetitive operations.
[0026] Furthermore, the computational simulation structure constructs a data set, which is specifically:
[0027] Use scripts to call the computational fluid dynamics software OpenFOAM to batch solve all calculation cases;
[0028] Based on the solution results, the calculation case file is read to obtain the surface velocity sampling points, and the randomly generated model geometry parameters are used to make a data set of water surface velocity distribution-water depth-cross-section average velocity.
[0029] The beneficial effects of the above-mentioned further solution are: automated batch solving of OpenFOAM cases and extraction of surface velocity data through scripts, efficient generation of parameterized data sets, significant improvement in computational efficiency and data consistency, providing structured water depth-velocity correlation data for machine learning or statistical analysis, and supporting rapid hydrodynamic characteristics research and engineering optimization design.
[0030] Furthermore, the construction of the deep learning model is specifically as follows:
[0031] Read the data set of water surface velocity distribution-water depth-cross-section average velocity, extract the surface velocity distribution data and preprocess it, use the preprocessing results as input data for the deep learning model, read the water depth and cross-section average velocity in the data set of water surface velocity distribution-water depth-cross-section average velocity, and use the water depth and cross-section average velocity as output data for the deep learning model;
[0032] Build an improved ResNet network model;
[0033] Define the loss function and use the Adam optimizer to optimize the parameters of the deep learning model to complete the construction of the deep learning model.
[0034] The beneficial effects of the above further scheme are: establishing a nonlinear mapping relationship between surface velocity distribution and water depth and cross-sectional average velocity through the improved ResNet network, using deep learning to automatically extract flow field characteristics, significantly improving prediction accuracy and generalization ability, providing an efficient data-driven method for rapid inversion of water depth and cross-sectional average velocity, and reducing the complexity and computational cost of traditional hydraulic calculations.
[0035] Furthermore, the improved ResNet network model includes:
[0036] The one-dimensional convolution layer is used to perform preliminary feature extraction on the input data and compress the feature dimension in combination with the maximum pooling operation. The input data is the preprocessed surface velocity distribution data.
[0037] A multi-stage bottleneck module is used to extract the dimensionally compressed features and obtain feature maps, where each bottleneck module is equipped with an adaptive residual connection path;
[0038] Global average pooling layer, used to compress the feature map into a vector of fixed length;
[0039] The fully connected layer is used to classify the compressed feature map to obtain output data, where the output data is water depth and cross-section average flow velocity.
[0040] The beneficial effects of the above further scheme are: the improved ResNet network efficiently extracts flow velocity distribution characteristics through one-dimensional convolutional layers and multi-stage bottleneck modules, combines adaptive residual connections to enhance gradient propagation and feature reuse capabilities, and significantly improves the model's ability to express complex flow field characteristics. At the same time, it uses global average pooling and fully connected layers to achieve high-precision water depth and cross-sectional average flow velocity prediction, improving generalization and robustness while ensuring computational efficiency.
[0041] Furthermore, the feature map is obtained by extracting the dimensionally compressed features, which is specifically:
[0042] Compress the number of input channels to the intermediate dimension through the 1x1 convolution kernel;
[0043] Based on the features after dimension compression, a 3x1 convolution kernel is used to extract local features, and a 1x1 convolution kernel is used through a dimensionality-increasing convolution layer to restore the feature dimension to the number of output channels to complete feature reconstruction. In this process, each convolution calculation requires a normalization and activation.
[0044] Downsampling is introduced to reduce the spatial resolution of the reconstructed feature map through convolution with a stride of 2.
[0045] The beneficial effects of the above further scheme are: reducing the amount of calculation by compressing the dimension through the 1x1 convolution kernel, combining the 3x1 convolution kernel to extract local features and reconstruct them by increasing the dimension, optimizing the calculation efficiency while ensuring the feature expression ability; introducing standardization, activation function and downsampling operations to enhance the model's nonlinear fitting ability and feature hierarchical extraction effect, so that the network can more efficiently learn the complex mapping relationship between flow velocity distribution and hydraulic parameters, further improving the prediction accuracy and generalization performance.
[0046] Furthermore, the loss function is expressed as follows:
[0047] loss=(((H p -H) / H) 2 +((V p -V) / V) 2 ) 0.5
[0048] Among them, loss represents the loss function, H p represents the predicted value of water depth, H represents the true value of water depth, V p It represents the predicted value of the average flow velocity of the section, and V represents the actual value of the average flow velocity of the section.
[0049] The beneficial effect of the above further scheme is that the loss function adopts the square root of the sum of squares of relative errors of water depth and cross-sectional average flow velocity, which can balance the prediction accuracy of the two key hydraulic parameters, avoid the training process being biased towards a single target due to dimensional differences, and at the same time enhance the model's sensitivity to small errors, improve the overall regression performance, and make the prediction results more stable and reliable.
[0050] Furthermore, the time-averaged velocity distribution of the cross section is read from the velocity cloud map, and the channel flow is inverted using the trained deep learning model, which is specifically as follows:
[0051] Obtain surface velocity distribution cloud map;
[0052] Based on the surface velocity distribution cloud map, Python software was used to read the data file, divide the river surface and extract the river centerline, and then extract the cross-sectional velocity 1D distribution along the perpendicular direction of the centerline;
[0053] The 1D distribution of cross-sectional flow velocity is preprocessed, and based on the preprocessing results, the trained deep learning model is input to obtain the channel flow prediction results, completing the inversion of channel flow.
[0054] The beneficial effect of the above-mentioned further scheme is: by automatically extracting cross-sectional 1D velocity data from the surface velocity distribution cloud map and using the pre-trained deep learning model for flow inversion, the efficiency and accuracy of channel flow monitoring are significantly improved, the manual intervention and uncertainty of traditional measurement methods are reduced, and efficient and reliable technical support is provided for real-time hydrological monitoring and water conservancy project management. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 Flow chart of the method of the present invention.
[0056] Figure 2 It is a technical flow chart of the present invention. DETAILED DESCRIPTION
[0057] The specific embodiments of the present invention are described below to facilitate understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the appended claims, these changes are obvious, and all inventions and creations utilizing the concepts of the present invention are protected.
[0058] Example
[0059] like Figure 1 As shown, the present invention provides a channel flow inversion method, which is implemented as follows:
[0060] S1. Use the computational fluid dynamics software OpenFOAM to debug the calculation case. The debugging results are used to ensure the correctness of the batch solution results. Specifically:
[0061] Using the computational fluid dynamics software OpenFOAM, a basic geometric model is selected and a computational mesh of a domain with a geometric shape is generated with a given mesh accuracy;
[0062] In the basic geometric model, the boundary conditions of the channel are set. The bottom and side walls of the channel are set as walls, and the Spalding wall function is used to simulate the near-wall flow dynamics. The free surface is regarded as a freely sliding rigid lid, the channel outlet is set as the far field, and backflow is not allowed.
[0063] Select and set the turbulence model and solution method to complete the debugging of the test case.
[0064] In this embodiment, a basic geometric model is selected, and a computational mesh of a domain with a geometric shape, such as a rectangular channel, is generated with a given mesh accuracy (eg, 0.05 m).
[0065] In this example, the channel boundary conditions are explicitly set in the model. The bottom and side wall boundaries of the channel are set as walls, and the Spalding wall function is applied to simulate the near-wall flow dynamics. The free surface is regarded as a rigid lid that slides freely. The channel outlet is set to the far field, and backflow is not allowed.
[0066] In this example, a turbulence model and solution method are selected and set. For example, the KOmegaSST turbulence model from the Reynolds time-averaged (RANS) method is used, and the SIMPLE algorithm is used to solve the steady-state flow for the pressure-velocity field. A reasonable time step size (e.g., 1 second) and the number of iterations required to fully develop the calculation (e.g., 5000) are set.
[0067] S2. Use scripts to batch copy and modify the river channel parameters of the calculated cases, specifically:
[0068] Modify the parameters that control the flow channel shape in the calculation case and save it as the initial calculation file;
[0069] Set the parameters that control the initial velocity and background grid size in the calculation case file;
[0070] The initial calculation file is copied through the script, and the river parameters to be modified are replaced with random values in the form of random numbers.
[0071] In this embodiment, the parameters controlling the flow channel shape in the calculation case, such as the river width, are modified by changing the given values to the special symbol $B. The other parameters that need to be modified are processed in the same way and saved as the initial calculation file.
[0072] In this embodiment, the parameters in the calculation case file are set, the surface position is located through parameters such as $B and $H, and a sampling point for reading the surface velocity result is given, such as 1000 sampling points.
[0073] In this example, the initial calculation file is copied via a script, and the river channel parameters that need to be modified are replaced with random values. For example, in a rectangular channel, these include key parameters such as water depth (e.g., randomly set to a value between 0.3m and 5m), bottom width (e.g., randomly set to a value between 1m and 10m), and average inflow velocity (e.g., randomly set to a value between 0.1m / s and 3m / s). The script automatically modifies parameters and generates batches of cases to obtain diverse simulation scenarios, providing a rich data source for subsequent dataset construction, such as generating 5,000 sets of cases.
[0074] S3. Use scripts to call the computational fluid dynamics software OpenFOAM to batch solve all calculation cases and calculate the simulation structure to build a data set. Specifically:
[0075] Use scripts to call the computational fluid dynamics software OpenFOAM to batch solve all calculation cases;
[0076] Based on the solution results, the calculation case file is read to obtain the surface velocity sampling points, and the randomly generated model geometry parameters are used to make a data set of water surface velocity distribution-water depth-cross-section average velocity.
[0077] In this embodiment, OpenFOAM is called by script to batch solve all cases, and the velocity distribution results of all cases can be quickly calculated by parallel multi-machine method.
[0078] In this embodiment, the surface velocity sampling points obtained in the smpleLines calculation case file are read and combined with the randomly generated model geometry parameters to create a data set of "water surface velocity distribution-water depth-cross-section average velocity" for subsequent deep learning model training.
[0079] S4. Build a deep learning model based on the dataset, specifically:
[0080] Read the data set of water surface velocity distribution-water depth-cross-section average velocity, extract the surface velocity distribution data and preprocess it, use the preprocessing results as input data for the deep learning model, read the water depth and cross-section average velocity in the data set of water surface velocity distribution-water depth-cross-section average velocity, and use the water depth and cross-section average velocity as output data for the deep learning model;
[0081] Build an improved ResNet network model, which includes:
[0082] The one-dimensional convolution layer is used to perform preliminary feature extraction on the input data and compress the feature dimension in combination with the maximum pooling operation. The input data is the preprocessed surface velocity distribution data.
[0083] A multi-stage bottleneck module is used to extract the features after dimension compression and obtain the feature map. Each bottleneck module is equipped with an adaptive residual connection path. Specifically, the number of input channels is compressed to the intermediate dimension through a 1x1 convolution kernel; based on the dimensionally compressed features, a 3x1 convolution kernel is used for local feature extraction, and the feature dimension is restored to the number of output channels using a 1x1 convolution kernel through a dimensionality-enhanced convolution layer to complete feature reconstruction. In this process, each convolution calculation requires a normalization and activation; downsampling is introduced to reduce the spatial resolution of the reconstructed feature map through a convolution with a stride of 2;
[0084] Global average pooling layer, used to compress the feature map into a vector of fixed length;
[0085] The fully connected layer is used to classify the compressed feature map to obtain output data, where the output data is water depth and cross-section average flow velocity;
[0086] Define the loss function and use the Adam optimizer to optimize the parameters of the deep learning model to complete the construction of the deep learning model.
[0087] In this example, a data input iterator is constructed. First, the training dataset is read. The surface velocity distribution data is extracted and preprocessed, including reselection of discrete intervals, data gradient enhancement, and recalculation of the average velocity and distance within each discrete interval. This serves as the input data for the deep learning model. The water depth H and cross-sectional average velocity V from the dataset are read as the output data of the deep learning model. The input and output are packaged for backpropagation learning training of the network model.
[0088] In this embodiment, an improved ResNet network model is built. First, a one-dimensional convolutional layer (kernel_size=7, stride=2) is used to perform preliminary feature extraction on the input data, and the feature dimension is further compressed in combination with the maximum pooling operation (MaxPool1d). Secondly, a multi-stage bottleneck module (BottleneckGELU) is established, which includes a normalization (BN) layer, a GELU activation layer, and a convolutional layer (Conv). The number of input channels is compressed to an intermediate dimension through a 1x1 convolution kernel to reduce the computational overhead, which is the dimensionality reduction convolution layer; a 3x1 convolution kernel is used for local feature extraction, and then a 1x1 convolution kernel is used through a dimensionality increase convolution layer to restore the feature dimension to the number of output channels, thereby completing feature reconstruction. During this process, each convolution calculation requires a standardization and activation. A downsampling (downsample=True) operation is introduced at a specific stage, and a convolution with a stride of 2 is used to reduce the spatial resolution of the feature map, thereby gradually expanding the receptive field and extracting higher-level abstract features. Each bottleneck module (BottleneckGELU) is equipped with an adaptive residual connection path to alleviate the gradient vanishing problem and accelerate the training process. When the number of input channels does not match the number of output channels, the dimension is adjusted through an additional 1x1 convolution layer to ensure that the output of the residual branch and the backbone network can be seamlessly added, thereby effectively transmitting low-level feature information. After the feature extraction in the last stage is completed, the deep learning model compresses the feature map into a fixed-length vector through global average pooling (AdaptiveAvgPool1d), and then connects to the fully connected layer (Linear Layer) for the final classification task. The design of the fully connected layer fully considers the number of categories required and supports flexible expansion to multi-classification scenarios.
[0089] In this embodiment, the mean squared error (MSE) is used as the loss function, where the two prediction quantities are loss = (((H p -H) / H) 2 +((V p -V) / V) 2 ) 0.5 , use Adam optimizer to optimize the parameters of the model, where loss represents the loss function, H p represents the predicted value of water depth, H represents the true value of water depth, V p It represents the predicted value of the average flow velocity of the section, and V represents the actual value of the average flow velocity of the section.
[0090] S5. Train the deep learning model;
[0091] In this example, when setting up the data iterator, 20% of the data is randomly extracted from the dataset as the validation set, and the remaining 80% is used as the training set. The deep learning model is trained and optimized. The hyperparameters of the neural network are set to 200 training rounds, 20 batch sizes, and a learning rate that decreases every 200 rounds, respectively. -4 , 10 -4 , 10 -5 , 10 -6 , 10 -7 A total of 1000 rounds of training were performed. During the training process, the model parameters were continuously adjusted to improve the accuracy of the model in flow inversion and complete the model training.
[0092] S6. Read the cross-section time-averaged velocity distribution from the velocity distribution cloud map and use the trained deep learning model to invert the channel flow. Specifically:
[0093] Obtain surface velocity distribution cloud map;
[0094] Based on the surface velocity distribution cloud map, Python software was used to read the data file, divide the river surface and extract the river centerline, and then extract the cross-sectional velocity 1D distribution along the perpendicular direction of the centerline;
[0095] The 1D distribution of cross-sectional flow velocity is preprocessed, and based on the preprocessing results, the trained deep learning model is used to invert the channel flow.
[0096] In this embodiment, taking video PIV flow measurement as an example, after obtaining the surface velocity distribution cloud map, python software is used to read the data file, divide the river surface and extract the river centerline, and extract the cross-sectional velocity 1D distribution along the perpendicular direction of the centerline.
[0097] In this embodiment, data input construction is completed according to the model preprocessing method, and the trained model parameter file is brought in to complete the river and channel flow prediction.
[0098] In this embodiment, different models can be established in S1 to cope with different artificial channels, and a rectangular cross-section is used as an approximation for natural rivers. More factors can also be added. For example, when using actual river channel cross-section materials, the roughness of the sidewalls can be appropriately modified to obtain more accurate training data. Interference factors such as fluctuations can also be added to increase the robustness of the training model. Other simpler or more complex network models can be selected in S4 and S5 to achieve faster training speeds or more accurate estimation results. In tests, MLP (Multi-Layer Perceptron) can also effectively predict river flow as a simpler neural network model after gradient enhancement. AlexNet (AlexNet) has some improvement after adding convolution, and the training time can be significantly reduced, but both are less accurate than ResNet. Alternatively, a deeper and wider network architecture can be used to improve accuracy. At the same time, to ensure optimal training results, the training hyperparameters should also be adjusted according to the model. In S6, it should be noted that when selecting a river channel, the flow should be fully developed, the cross-sectional width should be as unchanged as possible, and there should be no obvious river bends in the actual river. At the same time, the model prediction has a certain scope of application. Since the depth is inverted by the influence of the river bottom on the surface velocity, the influence of depth on the surface is very small in the case of large rivers. However, it is still challenging to predict the depth of deeper rivers.
[0099] In this embodiment, Figure 2 As shown, Figure 2 This paper demonstrates the entire process of estimating open channel flow by generating data through simulation using OpenFOAM software, and then using a neural network to learn and predict the processed data. Parameters such as water depth, bottom width, and average velocity are randomly generated. A mesh model with free surface and wall conditions is constructed in OpenFOAM using the K-ωSST (shear stress transport turbulence model). The SimpleFoam solver calculates the velocity distribution, and then calculates the flow rate and surface velocity distribution to establish a basic data set. The surface velocity distribution data is then preprocessed by calculating the average value, velocity gradient, and distance difference. This processed data is then fed into a network model (i.e., a ResNet network model) consisting of an input layer, a batch normalization layer, a Gaussian error linear unit activation function, and a convolutional layer. Finally, a convolutional neural network layer outputs the average velocity and water depth change to calculate the flow rate, completing the flow prediction.
[0100] In this embodiment, the computational fluid dynamics (CFD) software OpenFOAM is used to model and solve the rectangular open channel flow. Figure 2The OpenFOAM grid model in the channel is used to establish a rectangular coordinate system at the bottom of the channel center, and the blockMesh (block structured grid generator) in OpenFOAM is used to generate a structured grid with a grid accuracy of 0.05m. The boundary conditions are set, the bottom and side wall boundaries of the channel are set as walls, and the Spalding wall function is applied to simulate the near-wall flow dynamics; the free surface is regarded as a rigid lid that slides freely; the channel outlet is set as the far field, and backflow is not allowed. The KOmegaSST turbulence model in the Reynolds time-averaged (RANS) method is selected, and the SIMPLE (semi-implicit pressure coupled equation algorithm) algorithm is used to solve the steady-state flow of the pressure-velocity field. The time step is set to 1S and the number of iterations is set to 5000 times. Through the above settings, the cross-sectional velocity distribution of the rectangular open channel flow at different water depths is solved to generate a "water surface velocity distribution-water depth-cross-sectional average velocity" data set.
[0101] In this embodiment, random numbers are generated within a suitable range to change the state of the river, including the river depth, river width and cross-sectional average velocity. The computational fluid dynamics software OpenFOAM is used to perform batch calculations and solve the problems, and simulation results of river flows in different states are obtained. The cross-sectional velocity distribution is extracted to obtain a data set of "surface velocity distribution-water depth-cross-sectional average velocity". After the surface velocity distribution of the river is obtained, the surface width of the river is easy to obtain, and it will usually be measured when measuring the surface velocity distribution. It will be used as a known variable and converted into a model input corresponding to a discrete data point interval. By actively calculating the lateral velocity gradient of the surface velocity distribution and using it as part of the input of the deep learning model, the calculation uses a one-sided difference quotient instead of a derivative, which is called gradient data enhancement. This will improve training efficiency and, to a certain extent, improve the prediction accuracy and generalization ability of the model. After preprocessing, the 1D data of the surface velocity distribution will constitute 3×(n-1) input data, which are the standardized velocity u in the discrete interval. * i , transverse velocity gradient g i and discrete interval width b i , n is the number of discrete data points, calculated as Figure 2 As shown in the figure, u i is the discrete data of surface velocity distribution, y i For the corresponding position coordinates, the average flow velocity u in the discrete interval can be calculated i * , discrete interval cross-section velocity gradient g i , and the discrete interval b i .
[0102] In this embodiment, a deep learning model is built based on the Pytorch framework. The surface velocity distribution of the open channel is used as input data, and the water depth and cross-section average velocity are used as output. The data set is obtained by OpenFOAM calculation for the neural network to calculate the loss value for back propagation learning. The present invention builds a one-dimensional convolutional neural network (1D-CNN) based on an improved bottleneck structure (Bottleneck Structure) and GELU (Gaussian Error Linear Unit) activation function. The model significantly improves the learning ability of complex data patterns by optimizing the feature extraction module and the residual connection mechanism, while maintaining a high computational efficiency. The model consists of the following core parts:
[0103] (1) Input feature extraction layer (i.e., one-dimensional convolutional layer): The deep learning model first performs preliminary feature extraction on the input data through a one-dimensional convolutional layer (kernel_size = 7, stride = 2), and further compresses the feature dimension by combining a maximum pooling operation (MaxPool1d). This step aims to reduce data redundancy while retaining key spatial information, laying the foundation for efficient learning of subsequent deep networks.
[0104] (2) Multi-stage bottleneck module (BottleneckGELU): The core feature extraction part consists of multiple improved bottleneck modules, each of which contains three main operations:
[0105] 1) Dimensionality reduction convolution layer: The number of input channels is compressed to the intermediate dimension through a 1x1 convolution kernel to reduce computational overhead; 2) Deep feature extraction layer: A 3x1 convolution kernel is used for local feature extraction, combined with batch normalization (BatchNormalization) and GELU activation function to enhance nonlinear expression capabilities; 3) Dimensionality increase convolution layer: The 1x1 convolution kernel is used again to restore the feature dimension to the number of output channels, thereby completing feature reconstruction.
[0106] In addition, a downsampling (downsample=True) operation is introduced at a specific stage to reduce the spatial resolution of the feature map through convolution with a stride of 2, thereby gradually expanding the receptive field and extracting higher-level abstract features.
[0107] 2) Residual Connection Mechanism: To alleviate the vanishing gradient problem and accelerate training, each bottleneck module is equipped with an adaptive residual connection path. When the number of input channels does not match the number of output channels, an additional 1x1 convolutional layer is used to adjust the dimensions, ensuring that the residual branch and the output of the backbone network can be seamlessly added, effectively transferring low-level feature information.
[0108] (3) Global Average Pooling and Classifier: After the final stage of feature extraction, the deep learning model compresses the feature map into a fixed-length vector through global average pooling (AdaptiveAvgPool1d), which is then connected to the fully connected layer (Linear Layer) for the final classification task. The design of the fully connected layer fully considers the number of categories required and supports flexible expansion to multi-classification scenarios.
[0109] Compared with traditional ReLU or other activation functions, the construction of deep learning models using GELU can better capture subtle changes in data distribution, and is especially suitable for signal processing tasks in high-noise environments. By stacking multiple bottleneck modules to achieve progressive feature extraction, the scalability of the model is guaranteed, and the parameter scale is greatly reduced. The residual branch structure is dynamically adjusted according to the differences in feature dimensions at different stages, which enhances the robustness and generalization ability of the model. When setting the data iterator, 20% of the data is randomly extracted from the dataset as a validation set, and the remaining 80% is used as a training set. The deep learning model is trained and optimized, the hyperparameters of the neural network are set, and the Adam optimizer is selected. The training rounds are 200, the batch size is 20, and the learning rate decreases every 200 rounds, respectively, by 10 -4 , 10 -4 , 10 -5 , 10 -6 and 10 -7 A total of 1000 rounds of training were conducted. During the training process, the model parameters were continuously adjusted to improve the accuracy of the deep learning model in flow inversion. The trained deep learning model was used for flow inversion. The surface velocity distribution data of the open channel obtained by actual measurement was input into the trained deep learning model. The model output predicted water depth and average cross-sectional velocity, and then the open channel flow was calculated. The method of the present invention can achieve rapid inversion of the open channel flow by measuring only the surface velocity. In the test, for the flow inversion under a simple rectangular channel, the deep learning model has the highest flow inversion accuracy, and the mean square error of the test set predicted flow is 10 -1 (m 3 / s) 2 , coefficient of determination R 2 is 0.988; this shows that the present invention can accurately invert open channel flow and provide reliable data support for hydrological monitoring. The present invention combines CFD simulation technology to generate a large amount of data, solves the problem that the initial data set of the deep learning model is difficult to obtain, and reduces the cost of data acquisition. At the same time, the application of deep learning models reduces dependence on expensive measuring equipment (such as ADCP) and reduces measurement costs. The present invention is not limited by geographical conditions. In the face of different channels, flow inversion can be performed only by measuring the surface velocity distribution data of the open channel, which expands the scope of application of flow measurement.
[0110] This invention leverages the variability of OpenFOAM and its deep learning technology for data mining in the field of hydrological monitoring to achieve the goal of more accurately inverting flow based on surface velocity. This involves the cross-integration of multiple disciplines and aims to improve water resource management and allocation, especially in the modernization of artificial water channels and agricultural irrigation water channels. In summary, the present invention has the following technical effects:
[0111] Significantly Improved Accuracy: Compared to traditional measurement methods (such as current meters and buoys), this method, based on deep learning technology, can exploit the underlying features of surface velocity data to more accurately infer flow, significantly improving measurement accuracy. Compared to methods that infer flow based on water level, this method eliminates the need for design and historical measurement data, enabling high-precision measurements in new areas.
[0112] Significant cost reduction: Reliance on complex measurement equipment is reduced, reducing equipment acquisition and maintenance costs, as well as labor and time costs. Using CFD simulation to generate data avoids the extensive repetitive operations and cross-sectional measurement processes required in actual testing, saving time and money.
[0113] Wide adaptability: The deep learning model has strong generalization ability and can adapt to different open channel conditions (such as different water depths, bottom widths, etc.) and complex water flow environments. It can be widely used in most water transfer channels and has certain flow measurement capabilities for some rivers.
[0114] Innovative technology integration: Combining CFD simulation with deep learning is an innovative approach. CFD simulation provides rich initial data, while deep learning models conduct in-depth data mining and analysis. The two complement each other and bring new solutions to open channel flow measurement.
Claims
1. A channel flow inversion method, characterized in that: The following steps are involved: The computational fluid dynamics software OpenFOAM is used to debug the calculation cases, and the debugging results are used to ensure the correctness of the batch solution results; Use scripts to batch copy and modify the river channel parameters of calculated cases; Use scripts to call the computational fluid dynamics software OpenFOAM to batch solve all calculation cases and calculate the simulation structure to build a data set; Build a deep learning model based on the data set; Training deep learning models; The time-averaged velocity distribution of the section is read from the velocity distribution cloud map, and the channel flow is inverted using the trained deep learning model.
2. The channel flow inversion method according to claim 1, characterized in that: The debugging of the calculation case is specifically as follows: Using the computational fluid dynamics software OpenFOAM, a basic geometric model is selected and a computational mesh of a domain with a geometric shape is generated with a given mesh accuracy; In the basic geometric model, the boundary conditions of the channel are set. The bottom and side walls of the channel are set as walls, and the Spalding wall function is used to simulate the near-wall flow dynamics. The free surface is regarded as a freely sliding rigid lid, the channel outlet is set as the far field, and backflow is not allowed. Select and set the turbulence model and solution method to complete the debugging of the test case.
3. The channel flow inversion method according to claim 1, characterized in that: The script is used to batch copy and modify the calculated case river parameters, which are specifically as follows: Modify the parameters that control the flow channel shape in the calculation case and save it as the initial calculation file; Set the parameters that control the initial velocity and background grid size in the calculation case file; The initial calculation file is copied through the script, and the river parameters to be modified are replaced with random values in the form of random numbers.
4. The channel flow inversion method according to claim 1, characterized in that: The computational simulation structure constructs a data set, which is specifically: Use scripts to call the computational fluid dynamics software OpenFOAM to batch solve all calculation cases; Based on the solution results, the calculation case file is read to obtain the surface velocity sampling points, and the randomly generated model geometry parameters are used to make a data set of water surface velocity distribution-water depth-cross-section average velocity.
5. The channel flow inversion method according to claim 4, characterized in that: The construction of the deep learning model is specifically as follows: Read the data set of water surface velocity distribution-water depth-cross-section average velocity, extract the surface velocity distribution data and preprocess it, use the preprocessing results as input data for the deep learning model, read the water depth and cross-section average velocity in the data set of water surface velocity distribution-water depth-cross-section average velocity, and use the water depth and cross-section average velocity as output data for the deep learning model; Build an improved ResNet network model; Define the loss function and use the Adam optimizer to optimize the parameters of the deep learning model to complete the construction of the deep learning model.
6. The channel flow inversion method according to claim 5, characterized in that: The improved ResNet network model includes: The one-dimensional convolution layer is used to perform preliminary feature extraction on the input data and compress the feature dimension in combination with the maximum pooling operation. The input data is the preprocessed surface velocity distribution data. A multi-stage bottleneck module is used to extract the dimensionally compressed features and obtain feature maps, where each bottleneck module is equipped with an adaptive residual connection path; Global average pooling layer, used to compress the feature map into a vector of fixed length; The fully connected layer is used to classify the compressed feature map to obtain output data, where the output data is water depth and cross-section average flow velocity.
7. The channel flow inversion method according to claim 6, characterized in that: The feature map obtained by extracting the dimensionally compressed features is specifically: Compress the number of input channels to the intermediate dimension through the 1x1 convolution kernel; Based on the features after dimension compression, a 3x1 convolution kernel is used to extract local features, and a 1x1 convolution kernel is used through a dimensionality-increasing convolution layer to restore the feature dimension to the number of output channels to complete feature reconstruction. In this process, each convolution calculation requires a normalization and activation. Downsampling is introduced to reduce the spatial resolution of the reconstructed feature map through convolution with a stride of 2.
8. The channel flow inversion method according to claim 5, characterized in that: The expression of the loss function is as follows: loss=(((H p -H) / H) 2 +((V p -V) / V) 2 ) 0.5 Among them, loss represents the loss function, H p represents the predicted value of water depth, H represents the true value of water depth, V p It represents the predicted value of the average flow velocity of the section, and V represents the actual value of the average flow velocity of the section.
9. The channel flow inversion method according to claim 1, characterized in that: The method of reading the cross-section time-averaged velocity distribution from the velocity cloud map and inverting the channel flow using the trained deep learning model is as follows: Obtain surface velocity distribution cloud map; Based on the surface velocity distribution cloud map, Python software was used to read the data file, divide the river surface and extract the river centerline, and then extract the cross-sectional velocity 1D distribution along the perpendicular direction of the centerline; The 1D distribution of cross-sectional flow velocity is preprocessed, and based on the preprocessing results, the trained deep learning model is input to obtain the channel flow prediction results, completing the inversion of channel flow.
Citation Information
Patent Citations
Flow rate level prediction method based on convolutional neural network deep learning
CN108875161A
Mean flow velocity calculation method based on channel cross section
CN113887142A
Open channel flow measurement method, device and equipment and storage medium
CN114169258A
Method and system for monitoring sand content of suspended load of river channel system based on video image
CN117788961A
Channel flow measuring method and device based on bionic eagle eye vision
CN118570700A
Cited By
Drop flow measuring method based on machine vision
CN121089828A