Abstract
Accurately obtaining the distribution of the open-channel velocity field in hydraulic engineering is extremely important, which is helpful for better calculation of open-channel flow and analysis of open-channel water flow characteristics. In recent years, machine learning has been used for open-channel velocity field prediction. However, effective training of data-driven models in machine learning heavily depends on the diversity and quantity of data. In this paper, a CFD-based pre-training neural network model (CFD–PNN) is proposed for accurate open-channel velocity field prediction, allowing the adaption to the task with small sample data. Also, a cross-sectional velocity field prediction method combining the computational fluid dynamics (CFD) and machine learning is established. By comparing CFD–PNN with six other neural network algorithm models and the CFD model, the results show that, in the case of small sample data, the CFD–PNN model can predict a more reasonable open-channel velocity field with higher prediction accuracy than other models. The average error of the velocity calculation for the trapezoidal open-channel cross-section is about 3.62%. Compared with other models, the accuracy is improved by 0.3–2.8%.
HIGHLIGHTS
A velocity field prediction model based on CFD and machine learning.
The model adapts to tasks with small sample data.
Experimental verification using the measured data of trapezoidal open channels.
Graphical Abstract
INTRODUCTION
Accurate calculation of velocity distribution has a wide range of applications in flow measurement, sediment transport, river restoration, and power plant design. Since the 1980s, some scholars have studied the laws of flow velocity distribution in open channels based on mathematical formulas. Nezu et al. (1989) classified open channels into two categories: narrow channels and wide channels. In a narrow open channel with a width-to-height ratio <5, the maximum flow velocity occurs below the free surface. Chiu (1989) derived and compared the velocity distribution equation of open-channel water flow based on the principle of maximum entropy. Chiu & Tung (2002) studied the maximum velocity and regularity in open-channel flow. Chiu & Hsu (2006) present a synthesis of a probability-based approach to modeling and predicting velocity distributions in fluid flows. Based on the Shannon entropy concept and the principle of maximum entropy, Marini et al. (2011) proposed a new method for calculating the two-dimensional velocity distribution of open-channel water flow. Luo & Singh (2011) derived two-dimensional distribution of velocity in open channels based on the Tsallis entropy concept. Fontana et al. (2013) developed a 2D entropy-based model providing a reliable estimation of the velocity distribution for open-channel flow with a rectangular cross-section. Bonakdari & Moazamnia (2015) developed an equation to predict the velocity field in narrow open channels based on Tsallis entropy. Luo et al. (2018) analyzed the differences and connections between four commonly used flow velocity laws and two theoretically and quantitatively entropy-based flow velocity distributions.
In recent years, some researchers have applied artificial neural network (ANN) and computational fluid dynamics (CFD) to predict flow velocity distribution in open channels. Yang & Chang (2005) applied an ANN to predict the velocity distribution in open channels by using the flow velocity profile measured by the acoustic Doppler velocimeter, and the results showed that the constructed ANN could fit the flow velocity profile. Sahu et al. (2011) proposed an ANN model to predict the point form velocity in meandering open channels. Baghalian et al. (2012) used artificial intelligence, analytical, experimental, and numerical methods to study the velocity field in a 90° bend. The results show that ANN model and numerical method have better performance than an analytical solution in most cases. Sun et al. (2014) studied the ability of the ANN model to describe and model the complex flow structure of combined open-channel water flow based on a large amount of data output by the CFD model. Pektas (2015) predicted the velocity distribution parameter by using the stepwise multilinear regression models, classification and regression tree (C&RT) models, and ANN models. The results show that the prediction performance of an ANN is the best. Bonakdari et al. (2011, 2020), Gholami et al. (2015, 2016), and Zaji & Bonakdari (2015, 2019) successively compared CFD and ANN methods in the prediction of the open-channel velocity field. They tried the traditional feedforward neural network, radial basis function neural network (RBFNN), multi-layer perceptron model based on decision trees (DT-MLP), radial basis function based on decision trees (DT-RBF), extreme learning machine (ELM), and other methods to predict velocity fields in open channels. The results show that the ANN method can more effectively predict the velocity distribution in open channels than CFD.
The current literature on the open-channel velocity field is mainly carried out in the hydraulic laboratory, where more flow velocity measurement data can be obtained, which benefits the analysis of open channels. However, in practical engineering applications, it is difficult to obtain more flow velocity point measurement data in the case of large open channels or unfavorable measurement environments, which will greatly affect the accuracy of the prediction results of the machine learning model. Therefore, the velocity field analysis of open channels with few data is difficult and remains to be researched.
This paper proposes a CFD-based pre-training neural network model (CFD–PNN) to predict the open-channel velocity field. This model combines the numerical modeling ability of CFD with the prediction ability of an ANN to solve the calculation problem of the open-channel velocity field with small sample data, and fills the shortage in this field. Taking an open channel in Dujiangyan, Sichuan Province, China, as an example, the ability of the CFD–PNN model to predict channel velocity field was studied. When the measured data of cross-sectional velocity points are few, CFD–PNN can improve the prediction accuracy and obtain a more reasonable profile distribution of the open-channel velocity field, which is more suitable for engineering applications.
EXPERIMENTAL OPEN-CHANNEL MODEL
Suppose the water level height is H and set a vertical line at the channel section. The one-point method is to measure the single-point flow velocity at the vertical line from the bottom of the channel and use the flow velocity at this point as the average velocity of the vertical line. The two-point method is to measure the flow velocity at two points at and from the vertical line to the bottom of the channel and take the average velocity of the two points as the average flow velocity of the vertical line. The three-point method is to measure the three-point flow velocity at , , and from the vertical line to the bottom of the channel and take the average flow velocity of the three points as the vertical average flow velocity. The three-point flow measurement model is shown in Figure 2(b), where the red dots indicate the location of the measurement points. This measurement method is often used to estimate flow through channel profiles. In this paper, the measurement data obtained by this method are used to analyze the flow velocity distribution. Due to the limitations of the actual engineering measurement of the channel, it can be seen from the three-point flow measurement model that the vertical lines in the x-coordinate direction are arranged at wide intervals, and there are only three points of flow velocity values on each vertical line. The distribution of flow velocity at the side slope of the channel is also unclear. Therefore, for this experimental channel, the spatial distribution of such measuring points is relatively sparse and the measurement data of profile velocity points are less, which makes it difficult to reflect the complete velocity field of this channel. Since the trapezoidal open channel in this paper is a wide and shallow open channel with a width-to-height ratio > 5, the maximum velocity appears at the water surface, so the secondary flow phenomenon can be ignored. The study selected 266 data (70%) of 19 water levels as the training set. The 112 data (30%) of the remaining eight water levels are used as the test set. The statistical information of measured velocity is shown in Table 1.
. | Mean (m/s) . | Max (m/s) . | Min (m/s) . | σ . |
---|---|---|---|---|
Train | 1.43 | 2.19 | 0.44 | 0.43 |
Test | 1.40 | 2.14 | 0.54 | 0.41 |
. | Mean (m/s) . | Max (m/s) . | Min (m/s) . | σ . |
---|---|---|---|---|
Train | 1.43 | 2.19 | 0.44 | 0.43 |
Test | 1.40 | 2.14 | 0.54 | 0.41 |
PRINCIPLE OF THE CFD–PNN MODEL
CFD pre-training module
This module is mainly composed of CFD numerical model and SSA-BP (Guo & Wang 2022) model. Firstly, the velocity field of the open channel is modeled and simulated by the CFD numerical model to obtain the simulated velocity data. Usually, simulated velocity data are sufficient to reflect the flow velocity distribution of the open channel in the hydraulic theory under ideal conditions. Then the CFD simulation data are fed into the SSA-BP model for training so that the pre-training network, net1 can learn the distribution of CFD data and predict the velocity field under ideal conditions. This module can alleviate the problem of over-fitting caused by sparse data and avoid the final model from predicting an overly cluttered velocity field. After that, net1 can be used for retraining with the fine-tuning module.
CFD numerical model
Boundary . | Boundary conditions . | Specifications . |
---|---|---|
Inlet | Velocity-inlet | Magnitude, normal to boundary |
Outlet | Outflow | – |
Surface | Symmetry | – |
Wall | Wall | No slip |
Boundary . | Boundary conditions . | Specifications . |
---|---|---|
Inlet | Velocity-inlet | Magnitude, normal to boundary |
Outlet | Outflow | – |
Surface | Symmetry | – |
Wall | Wall | No slip |
Since the study is about the flow in a wide and shallow open channel under a steady state, the rigid-lid hypothesis method is used for the free water surface. In this experiment, CFD simulated the ideal profile velocity field of the trapezoidal open channel under 27 water levels, with a total of 35,617 velocity data.
SSA-BP model
Back propagation neural network
The basic idea of a back propagation neural network (BPNN) is the gradient descent method and its implementation steps are:
- 1.
Determine the network structure through the pre-selected network topology and activation function;
- 2.
Use the back propagation algorithm to iteratively correct the connection weights and biases of the neuron nodes in the network;
- 3.
Finally, the neural network learns the characteristics of the training samples and is used for data classification or regression.
The training is stopped with an artificially set target loss value and the maximum number of epochs.
Sparrow search algorithm
The sparrow search algorithm is a new heuristic algorithm to find the optimal solution by simulating the process of the foraging and anti-predation behavior of sparrows, which was first proposed by Xue & Shen (2020). The principle is as follows:
Individual sparrows in a population are divided into three categories: producers, scroungers, and danger perceivers. The producers usually have a higher fitness value and are responsible for searching for the position of the optimal fitness value and providing the search area and direction for the scroungers. The scroungers will follow the producer with the best fitness value to search while monitoring the producers. The danger perceivers are responsible for judging whether the environment is dangerous, and if it is dangerous, an alarm signal will be sent out to guide the group to move to a safe area. The proportion of producers and scroungers in the population is constant and is transformed into each other with the iterative calculation process of the algorithm.
- 1.The position update formula of the producer is shown in the following equation:where t is the current number of iterations and is the parameter value of the -th dimension of the th sparrow at the th iteration. is the maximum number of iterations. is a random number of (0, 1). is the alarm value, is the safety threshold, Q is a random number that obeys the normal distribution, and L is a all-one matrix.
- 2.
where is the position of the best fitness among the discoverers and is the position of the global worst fitness. , where A is a matrix with internal elements randomly assigned to 1 or −1.
- 3.
is the position of the global optimum fitness. is the step size control parameter, which is a random number obeying the standard normal distribution. K is a random number of [−1, 1], is the fitness value of the current sparrow individual, is the global best fitness value, and is the global worst fitness value. is a small constant, avoiding a denominator of 0.
Principle of the SSA-BP model
Fine-tuning module
This module mainly retrains the net1 obtained from the CFD pre-training module based on the measurement data.
The model net1, which has undergone the CFD pre-training module, learns the ideal velocity field distribution for CFD simulation. However, since there is still a certain degree of error between the CFD data and the measured data, it is difficult for net1 to get rid of this ‘error dilemma’ and to characterize the real velocity field well. Therefore, it is necessary to add a fine-tuning module.
The fine-tuning module adjusts the model parameters by retraining the pre-trained network with the measured data to improve the model's prediction accuracy. Compared with the neural network algorithm without the pre-training module, the fine-tuning module does not need to consider the initialization of network parameters because it uses the pre-trained model parameters obtained in the previous step as initialization parameters for training. This can also alleviate the problem of unstable training results caused by differences in parameter initialization. And because it is fine-tuned based on the model net1 that has learned the CFD features, the fine-tuned model net2 can not only effectively reduce the prediction error, but also retain the features of the CFD to avoid the predicted velocity field from deviating too much from the theoretical value.
There are currently two common training methods for fine-tuning: (1) All weights and biases are trained and updated; (2) Some weights and biases are fixed, and the remaining weights and biases are trained. After the previous experimental comparison, it is found that the model obtained by the first training method has higher prediction accuracy and can retain the distribution characteristics of CFD to a greater extent. Therefore, the CFD–PNN model in this paper adopts the method of training and updating all the weights and biases of the network in the fine-tuning module.
Model settings
In this paper, CFD, BPNN, SSA-BP, RBFNN, ELM, DT-RBF, and DT-MLP are used as benchmarks to compare with the CFD–PNN model. The purpose of the experiment is to predict the velocity field at an unknown water level.
In order to ensure that the predicted velocity value is not negative, nonnegative processing of data is added after inverse normalization, i.e., the velocity value <0 is set to 0. Since only the velocity magnitude in the axial direction of the channel profile can be measured, and according to the CFD simulation results, the radial velocity of the section is approximately equal to 0, this experiment only considers the axial velocity of the section not the radial velocity. 25,189 CFD simulation flow velocity data at the same water level as the training set are selected to construct the CFD–PNN model. In order to improve the training speed, 2,519 (10%) of the 25,189 data are selected by equal interval sampling to train the SSA-BP network to obtain the transferable network net1.
DATA NORMALIZATION AND PERFORMANCE EVALUATION METRICS
The advantage of using data normalization is that it can make the data dimensionless. It facilitates the training of the neural network, accelerates the speed of convergence, and makes the training result more stable.
In the above equations, m is the number of samples in the test set, is the ith measured value in the test set, is the ith predicted value, is the average value of the test set data, and is the average value of the predicted data.
The closer the values of RMSE, MAE, and MAPE are to 0 and the closer the values of R and R2 are to 1, the better the prediction performance of the model is.
EXPERIMENTAL RESULTS
Error analysis between CFD simulation results and measured values
RMSE . | MAE . | MAPE (%) . | R . | R2 . |
---|---|---|---|---|
0.1093 | 0.0873 | 6.2424 | 0.9711 | 0.9339 |
RMSE . | MAE . | MAPE (%) . | R . | R2 . |
---|---|---|---|---|
0.1093 | 0.0873 | 6.2424 | 0.9711 | 0.9339 |
Since the measured data in this paper are obtained from the open channel in the irrigation area, they will be affected by various influences in the natural environment, such as terrain, wind speed, air humidity, wall roughness, and part of the sediment at the bottom of the channel. Therefore, there will be a certain deviation between the real velocity field and the simulation results.
Comparison of prediction results of different algorithm models
It can be seen from Table 4 that the prediction error of each neural network model for flow velocity is lower than that of CFD. The CFD–PNN model achieves the optimum in all five evaluation indicators. Therefore, the CFD–PNN model can effectively reduce the prediction error. The CFD–PNN model has an RMSE of 0.0596, MAE of 0.0451, MAPE of 3.6216%, R of 0.9894, and R2 of 0.9786.
Model . | RMSE . | MAE . | MAPE (%) . | R . | R2 . |
---|---|---|---|---|---|
CFD | 0.1047 | 0.0883 | 6.4214 | 0.9709 | 0.9340 |
BPNN | 0.0636 | 0.0515 | 4.2557 | 0.9878 | 0.9756 |
SSA-BP | 0.0625 | 0.0478 | 3.9315 | 0.9883 | 0.9764 |
RBFNN | 0.0665 | 0.0508 | 4.1356 | 0.9867 | 0.9734 |
ELM | 0.0674 | 0.0492 | 4.0249 | 0.9863 | 0.9726 |
DT-RBF | 0.0882 | 0.0574 | 4.6802 | 0.9763 | 0.9532 |
DT-MLP | 0.0729 | 0.0560 | 4.4385 | 0.9839 | 0.9680 |
CFD–PNN | 0.0596 | 0.0451 | 3.6216 | 0.9894 | 0.9786 |
Model . | RMSE . | MAE . | MAPE (%) . | R . | R2 . |
---|---|---|---|---|---|
CFD | 0.1047 | 0.0883 | 6.4214 | 0.9709 | 0.9340 |
BPNN | 0.0636 | 0.0515 | 4.2557 | 0.9878 | 0.9756 |
SSA-BP | 0.0625 | 0.0478 | 3.9315 | 0.9883 | 0.9764 |
RBFNN | 0.0665 | 0.0508 | 4.1356 | 0.9867 | 0.9734 |
ELM | 0.0674 | 0.0492 | 4.0249 | 0.9863 | 0.9726 |
DT-RBF | 0.0882 | 0.0574 | 4.6802 | 0.9763 | 0.9532 |
DT-MLP | 0.0729 | 0.0560 | 4.4385 | 0.9839 | 0.9680 |
CFD–PNN | 0.0596 | 0.0451 | 3.6216 | 0.9894 | 0.9786 |
- 1.
The LM algorithm is used for training with a small number of epochs set. Because over-training will make the velocity field predicted by the final model net2 forget the characteristics of CFD, which will easily lead to over-fitting and reduce the robustness. In this experiment, the number of epochs of model fine-tuning is set to 1, so that the velocity field predicted by the final model net2 largely retains the distribution of the CFD calculation results. The experimental comparison results are shown in Figure 12. It can be seen that with the increase in the number of training epochs, the CFD–PNN model deviates more and more from the distribution of the CFD calculation, and the predicted velocity field becomes more and more chaotic, which is inconsistent with the actual situation. And it can be seen from Table 5 that when the number of epochs is small (1 and 10), the prediction error is relatively lower, and the two cases have their own advantages in different evaluation indicators.
- 2.
The gradient descent with momentum (GDM) algorithm is selected for training with a large number of epochs set. Compared with the first method, although this will take longer for fine-tuning, it can stop the training after the model reaches convergence, avoiding the problem of over-fitting caused by over-training. Figure 13 and Table 6 show the results of training the model with different epoch numbers using the GDM algorithm in the fine-tuning module. It can be seen from Figure 13 that with the increase in the number of epochs, the difference in the velocity field predicted by CFD–PNN is getting smaller and smaller, and it can be determined that the model has converged at this time. And it can be seen from Table 6 that the prediction accuracy of the model is improved under a large number of epochs.
Number of epochs . | RMSE . | MAE . | MAPE (%) . | R . | R2 . |
---|---|---|---|---|---|
1 | 0.0597 | 0.0447 | 3.6240 | 0.9893 | 0.9785 |
10 | 0.0578 | 0.0454 | 3.6480 | 0.9901 | 0.9799 |
100 | 0.0614 | 0.0480 | 3.8135 | 0.9887 | 0.9773 |
1000 | 0.0615 | 0.0484 | 3.9270 | 0.9887 | 0.9772 |
Number of epochs . | RMSE . | MAE . | MAPE (%) . | R . | R2 . |
---|---|---|---|---|---|
1 | 0.0597 | 0.0447 | 3.6240 | 0.9893 | 0.9785 |
10 | 0.0578 | 0.0454 | 3.6480 | 0.9901 | 0.9799 |
100 | 0.0614 | 0.0480 | 3.8135 | 0.9887 | 0.9773 |
1000 | 0.0615 | 0.0484 | 3.9270 | 0.9887 | 0.9772 |
Number of Epochs . | RMSE . | MAE . | MAPE (%) . | R . | R2 . |
---|---|---|---|---|---|
100 | 0.0742 | 0.0563 | 4.4725 | 0.9837 | 0.9669 |
1000 | 0.0632 | 0.0486 | 3.9219 | 0.9882 | 0.9760 |
10000 | 0.0612 | 0.0465 | 3.7411 | 0.9888 | 0.9774 |
100000 | 0.0596 | 0.0451 | 3.6216 | 0.9894 | 0.9786 |
Number of Epochs . | RMSE . | MAE . | MAPE (%) . | R . | R2 . |
---|---|---|---|---|---|
100 | 0.0742 | 0.0563 | 4.4725 | 0.9837 | 0.9669 |
1000 | 0.0632 | 0.0486 | 3.9219 | 0.9882 | 0.9760 |
10000 | 0.0612 | 0.0465 | 3.7411 | 0.9888 | 0.9774 |
100000 | 0.0596 | 0.0451 | 3.6216 | 0.9894 | 0.9786 |
Evaluation of the consistency of the CFD–PNN model with distribution characteristics of the CFD numerical solution
According to Figure 8, it can be known that, ideally, the maximum velocity of the velocity field of the trapezoidal open channel is located on the water surface, the flow velocity at the channel wall is 0, and the distribution of velocity contours has annular characteristics. Taking the 2.8 m water level as an example, it can be seen from Figure 10 that the velocity fields predicted by the RBFNN, ELM, DT-RBF, and CFD–PNN have annular distribution characteristics, and the position of the maximum velocity is on the water surface. However, RBFNN, ELM, and DT-RBF failed to show the trend of velocity dropping to 0 near the channel wall. To better prove that CFD–PNN still retains the characteristics of CFD after parameter transfer training, the seven neural network models are compared with the simulation results of CFD. Since there are data with a velocity value of 0 in the CFD data, MAPE is not applicable in this case, so the remaining four evaluation indicators are adopted. The experiment selected 10,428 CFD simulation data of eight water levels in the test set.
Model . | RMSE . | MAE . | R . | R2 . |
---|---|---|---|---|
BPNN | 0.4057 | 0.2769 | 0.6656 | 0.3485 |
SSA-BP | 0.4588 | 0.3115 | 0.6890 | 0.1668 |
RBFNN | 0.3244 | 0.1800 | 0.7975 | 0.5833 |
ELM | 0.3265 | 0.1944 | 0.8013 | 0.5779 |
DT-RBF | 0.3330 | 0.1946 | 0.7878 | 0.5611 |
DT-MLP | 0.3680 | 0.2224 | 0.7360 | 0.4640 |
CFD–PNN | 0.1387 | 0.1128 | 0.9677 | 0.9238 |
Model . | RMSE . | MAE . | R . | R2 . |
---|---|---|---|---|
BPNN | 0.4057 | 0.2769 | 0.6656 | 0.3485 |
SSA-BP | 0.4588 | 0.3115 | 0.6890 | 0.1668 |
RBFNN | 0.3244 | 0.1800 | 0.7975 | 0.5833 |
ELM | 0.3265 | 0.1944 | 0.8013 | 0.5779 |
DT-RBF | 0.3330 | 0.1946 | 0.7878 | 0.5611 |
DT-MLP | 0.3680 | 0.2224 | 0.7360 | 0.4640 |
CFD–PNN | 0.1387 | 0.1128 | 0.9677 | 0.9238 |
CONCLUSION
In this paper, a CFD-based pre-training neural network model (CFD–PNN) is proposed and applied to the numerical simulation and prediction of the profile velocity field of a straight trapezoidal open channel, using 378 velocity data measured by the Renmin Channel Hydrological Station in Dujiangyan, Sichuan Province. The CFD–PNN model is experimentally compared with CFD simulation results and six other neural network prediction results. The conclusion is as below:
- 1.
In the case of less measured data, the CFD–PNN model can effectively reduce the prediction error, improve the prediction accuracy, and the predicted velocity field is also more reasonable. Compared with the measured flow velocity values, the CFD–PNN model has an RMSE of 0.0596, MAE of 0.0451, MAPE of 3.6216%, R of 0.9894, and R2 of 0.9786. It outperforms six other neural network algorithm models and the CFD model in all five evaluation indicators. Compared with other models, the accuracy is improved by 0.3–2.8%.
- 2.
In order to make the final prediction model retain the distribution characteristics of the CFD model as much as possible, an appropriate training method needs to be adopted in the fine-tuning module. The LM algorithm with a small number of epochs can be used for training when time-saving is needed, and the GDM algorithm can be used for training until the model converges when time cost is not considered.
ACKNOWLEDGEMENTS
The authors would like to reveal their appreciation and gratitude to the Renmin Channel Hydrological Station for the flow velocity measurement data. In addition, we are grateful to the editor and anonymous reviewers for their constructive comments on the manuscript.
FUNDING
This research was supported by Sichuan Science and Technology Program (NO: 2021YFG0121, NO: 2022ZHCG0042).
DATA AVAILABILITY STATEMENT
Data cannot be made publicly available; readers should contact the corresponding author for details.
CONFLICT OF INTEREST
The authors declare there is no conflict.