## Abstract

Predicting the flow field around sluice gates is essential for controlling water levels and discharges in open channels and rivers. Smooth particle hydrodynamics (SPH) models can satisfactorily reproduce such free-surface flows, but they typically require long computational time and extensive computational resources. In this work, we propose a convolutional neural network (CNN) to predict the flow field around a sluice gate. A validated SPH model is used to carry out extensive simulations, and the generated data set is used to train and test CNN-based models. The results demonstrated that the developed CNN can accurately reproduce sluice gate flows, with *R*^{2} values exceeding 90% and significantly reducing the computational costs. Furthermore, various traditional machine learning algorithms comprising adaptive neuro-fuzzy inference system, genetic programing, multigene genetic programing, and one-dimensional CNN were also evaluated, and a comparison of the results showed that the developed CNN performed better than the traditional data-driven algorithms in predicting sluice gate flows. Therefore, the proposed method is a promising tool for providing rapid prediction of the spatial distribution of flow fields near the sluice, and potentially for predicting other spatially distributed hydrologic variables.

## HIGHLIGHTS

We developed a parameter-based convolutional neural network to predict the flow field around sluice gates.

Smooth particle hydrodynamics results were utilized to train, validate, and test the developed algorithm.

The developed model can accurately reproduce sluice gate flows and performed better than traditional data-driven algorithms.

## LIST OF SYMBOLS

*m*_{k}the mass corresponding to particle

*k*(evaluated at*a*or*b*)*ρ*_{k}the density corresponding to particle

*k*(evaluated at*a*or*b*)*t*time

*v*_{k}the position and velocity of the particles

*k*(evaluated at*a*or*b*)*W*the smoothing kernel function

the gradient of the kernel function with respect to the coordinates of the particle

the dissipation term

the acceleration due to gravity

*P*the pressure corresponding to the particle

the pressure corresponding to particle

*k*(evaluated at*a*or*b*)the position of the particles

*h*the smoothing kernel length

the viscosity term

_{c}the numerical speed of sound

*a*the artificial viscosity coefficient

*h*_{0}the gate opening

*h*_{w}the downstream overflow weir height

*U*_{0}average inlet velocity

*h*_{a}the inlet water level

*h*_{0}/*h*_{a}nondimensional sluice gate opening

*h*/_{w}*h*_{a}nondimensional overflow weir height

*u/U*_{0}the horizontal velocity

*v/U*_{0}the vertical velocity

- SPH
smooth particle hydrodynamics

- CNN
convolutional neural network

- DL
deep learning

- ML
machine learning

- RF
the random forest

- MLP
the multilayer perceptron

- ANFIS
adaptive neuro-fuzzy inference system

- GP
genetic programing

- 1D-CNN
one-dimensional convolutional neural network

- MGGP
the multigene genetic programing

- CUDA
compute unified device architecture

- CPUs
the central processing units

- GPUs
the graphics processing units

- dp
the model to the particle distance

- ANN
artificial neural network

## INTRODUCTION

Gates are one of the most widely used water regulation structures for controlling water levels and discharges in open channels, rivers, and lakes (Akoz *et al.* 2009; Ghorbani *et al.* 2020; Luo *et al.* 2021; Nikoli & Karamarkovi 2021; Peng *et al.* 2021; Salmasi & Abraham 2021). Examples of their applications in the field of hydrology and water resources include agricultural water canals, dams, and exits of lakes. Gates can be classified into many different types, and sluice gates have been extensively used in many water resources projects (Swamee 1992; Salmasi & Abraham 2021). Sluice gates are a type of underflow gate, where water flows beneath the gate and the flow is primarily governed by the gate opening. The flow discharge beneath a gate has been a topic of significant research because it is a fundamental problem in many water conservancy projects (Belaud *et al.* 2009; Yousif *et al.* 2019; Salmasi & Abraham 2021). The discharge under a gate can be typically estimated based on the discharge coefficient, and thus, many previous studies have focused on the estimations of the discharge coefficient (Rajaratnam & Subramanya 1967; Cassan & Belaud 2012; Salmasi & Abraham 2021).

However, recent studies showed that the construction and operation of gates can significantly affect the water quality, water ecology, and emission of greenhouse gases (Nakamura *et al.* 2019; Luo *et al.* 2021; Peng *et al.* 2021). A reasonable assessment of water quality, water ecology, and emission of greenhouse gases requires knowledge of the entire flow field, and the flow discharge under the sluice gate can be directly obtained based on the flow field data, so it is advantageous to model the entire flow field near a sluice gate. Numerical modeling is an important research method to simulate the flow field, which can provide a complete data set at a relatively low cost, but it has disadvantages such as inaccuracy, high computational requirements, and large disk storage space. Advances in modern artificial intelligence, especially deep learning (DL) algorithms, and the increasing amount of high-quality data provide a new way to establish the flow field distribution. To propose and evaluate the performance of the new method, we focus on a relatively simple test case: developing a convolutional neural network (CNN) model to model the flow field in a controlled gate system and compare it with a numerical model and traditional DL models.

Physical modeling and experimental methods are the most commonly used methods to study computational fluid dynamics. For example, Mohammad *et al.* (2022) investigate the flow resistance and velocity distribution in a smooth triangular channel under varying slope conditions in a laboratory environment. Parsamehr *et al.* (2022) evaluated the influence of roughness elements on the unfavorable riverbed slope on hydraulic jump characteristics. These experimental works deepen the understanding of computational fluid dynamics to reflect the real physical processes of fluid evolution. However, laboratory methods are often very time consuming and expensive, making it urgent to develop complementary methods.

With the development of computers, numerical models based on computational fluid dynamics are powerful tools for predicting free-surface flows subjected to the influence of hydraulic structures (Yan & Mohammadian 2017; Yan *et al.* 2020, 2021; Ahmadi *et al.* 2022). Numerical models can use computers to replace the natural environment, mechanical devices, and other physical simulations, compared with physical experiments, and reduce the simulation cost, and models can be used as a supplement to the experiment. The majority of the existing numerical studies have been carried out using mesh-based approaches (Vauclin *et al.* 2010), but it is challenging for these approaches to create good-quality grids for complex geometry and provide high-fidelity predictions for problems with large deformation and fluctuating free surfaces. More recently, advanced meshless numerical approaches, such as those based on smooth particle hydrodynamics (SPH), have been used to reproduce free-surface flows (Crespo *et al.* 2008; Razavitoosi *et al.* 2014). Gu *et al.* (2022) studied the application of DualSPHysics in the spillway hydraulic system and found that the DualSPHysics code based on the SPH method has a promising spillway flow in the engineering field. Nóbrega *et al.* (2022) used the SPH method, and the results show that the numerical results are in good agreement with the test data of wide crown weir and spillway chute. Therefore, SPH can better accommodate large deformation, free surface, and fluid–solid interaction problems (Xiong *et al.* 2006; Fei *et al.* 2021). However, these models typically require long computational time and extensive computing resources, limiting their wider usage in practical applications.

To make up for the shortcomings of numerical models regarding computational costs, data-driven models based on modern machine learning (ML) techniques have been recently employed to predict complex flows (Lui & Wolf 2019; Zhu *et al.* 2019; Hosseiny *et al.* 2020; Kabir *et al.* 2020; Zhao *et al.* 2020a, 2020b; Yan *et al.* 2021; Kumari *et al.* 2022; Zhang *et al.* 2022). For instance, Hosseiny *et al.* (2020) developed an efficient flood simulation model utilizing the random forest and multilayer perceptron (MLP) algorithms. Kabir *et al.* (2020) adopted an one-dimensional CNN (1D-CNN) to predict flood inundation. Yan *et al.* (2021) predicted the flow depths in a fluvial system using the multigene genetic programing (MGGP) approach. These studies showed that ML algorithms can successfully act as surrogates for hydraulic models and significantly reduce computational costs (Schmidt *et al.* 2020). In recent years, CNN algorithms have been widely applied in the field of water resources research and have been demonstrated to be promising tools for predicting complicated water-related processes (Zhang *et al.* 2022). Several recent studies have found CNN algorithms to be promising tools for predicting flow fields. For instance, Sekar *et al.* (2019) proposed a combined deep CNN and deep MLP approach and employed it to predict incompressible laminar steady flow fields over airfoils. Their study demonstrated that the proposed approach exhibited high efficiency and accuracy. Kreyenberg *et al.* (2019) estimated the velocity field using a CNN based on measured concentration distributions of density-driven solute transport. They demonstrated that the CNN algorithm can successfully represent the underlying mechanisms and thus can be used to close the information gap of missing system variables. Although the prior studies have made significant contributions, previous CNN-based ML studies have not focused on modeling the sluice gate flow, the prediction of which is essential for controlling water levels and discharges in open channels and rivers. This gap in the literature inhibits the adoption of ML techniques to modeling of free-surface flows subjected to the influence of hydraulic structures. The sluice gate is one of the most widely used hydraulic structures, and thus improving the practice of sluice gate flow modeling is of significant practical importance.

The primary objective of this article was to develop a CNN for creating realizations of sluice gate flows. More specifically, we attempted to construct a new CNN to predict the flow field of free-surface flows subjected to the influence of sluice gates with downstream overflow weirs based on the governing parameters. A validated SPH model was employed to generate data for the training and validating of the CNN. To specify, we first developed a SPH model and validated it against experimental data for sluice gate flows, and then employed the validated numerical model to carry out additional computations for various scenarios with different arrangements of sluice gates and downstream weirs, i.e., the training and validating arrangements. Subsequently, the outcome of the numerical model was processed and utilized to train and validate the CNN. The trained and validated CNN was then used to predict the flow field for several new arrangements, i.e., the testing arrangements. The predictions for the testing cases obtained by the CNN were then compared against the results of separately performed SPH simulations for those arrangements. Various traditional ML algorithms comprising adaptive neuro-fuzzy inference system (ANFIS), genetic programing (GP), MGGP, and one-dimensional CNN (1D-CNN) were also evaluated and employed to construct ML-based models. The innovation of this study is mainly reflected in the following two aspects: (1) a CNN architecture for the flow field distribution near the sluice was developed; (2) CNN-based rapid simulation model of the flow field near the sluice, which can achieve the rapid high accurate reconstruction of the flow field near the sluic.

The rest of this article is organized as follows. The methodologies comprising the governing equations of the SPH model, the numerical model setup, and the details of the ML models are described in Section 2. The results are presented and discussed in Section 3. Finally, the research is summarized, and conclusions are drawn in Section 4.

## METHODOLOGY

### Mathematical representation

In the SPH approach, fluids and solids are described using particles, and the relevant quantities, such as mass, velocity, and pressure, are all related to these particles (Tartakovsky *et al.* 2007). By solving the dynamic equation of particle motions and tracking the trajectory of each particle, the mechanical behavior of the whole system can be obtained.

*et al.*2014):where and are the mass and density corresponding to particle

*k*(evaluated at

*a*or

*b*),

*t*is time, , represent the velocity of the particles

*k*(evaluated at

*a*or

*b*),

*W*represents the smoothing kernel function, and represents the gradient of the kernel function with respect to the coordinates of the particle.

*et al.*2015):where

*T*represents the dissipation term,

*g*represents the acceleration due to gravity, and

*P*is the pressure corresponding to the particle.

*et al.*2015; Domínguez

*et al.*2022):where is the pressure corresponding to particle

*k*(evaluated at a or b).

### Model setup

The governing equations were numerically solved using the open-source code based on the SPH model named DualSPHysics (Crespo *et al.* 2015; González *et al.* 2018; Zubeldia *et al.* 2018; Domínguez *et al.* 2022). DualSPHysics is implemented in C ++ and Compute Unified Device Architecture language, and it performs numerical simulations on either the central processing units or graphics processing units (GPUs). The SPH simulations in this work were all performed using the GPU mode on a desktop with a NVIDIA GeForce RTX 3060 device.

*et al.*(2009), and thus the arrangements for the first numerical run were set to be consistent with the experiment. The details about the model setup for this baseline simulation are summarized as follows. The gate opening

*h*was set as 0.012 m, and the downstream overflow weir height

_{0}*h*was set as 0. The

_{w}*x*coordinate of the sluice gate was

*x*= 0.218 m, and its crest width was 0.002 m, and the

*x*coordinate of the overflow weir was located at

*x*= 0.398 m with a crest width of 0.002 m. The

*x*coordinate of the inlet patch was

*x*= 0.054 m, and the velocity profiles at the inlet patch were obtained from Akoz

*et al.*(2009) with an average inlet velocity

*U*= 0.098 m s

_{0}^{−1}. The approach flow depth

*h*was set as 0.107 m. The

_{a}*y*coordinate of the bed surface was set as 0. Preliminary simulations were performed to assess the sensitivity of the model to the particle distance (dp). Finally, a particle distance of 0.001 m was adopted, and the ratio value for

*h*/dp is 107. The minimum time step was set to be 0 s, and the actual transient time step was automatically determined by the code. The time of simulation was set to be 90 s. The Symplectic scheme was used for time integration, the Quintic Wendland kernel was used as the kernel function, and the artificial viscosity model with a viscosity value of 0.005 was employed for viscosity treatment.

_{a}### Numerical experiments

The validated SPH model was employed to perform numerical experiments to generate synthetic data. The experiments can be divided into two distinct sets: the first set was used to train and validate ML models, while the second set was used as unseen experiments to further test the developed models. Each numerical run had a distinct arrangement of the sluice gate and overflow weir. To ensure the general suitability of the developed models, the key quantities were converted into nondimensional parameters. More specifically, the lengths were divided by the approach water depth, and the velocities were divided by the average inlet velocity. At the upstream boundary, both the flow rate and the velocity were kept constant, to ensure that the velocity distributions for the numerical models were consistent with the measured velocities reported by Akoz *et al.* (2009). A total of 31 different cases were considered in the train-validation set, and 80% of the cases were used for model training and the remaining cases were used for model validation. For further testing of the developed CNN, eight different scenarios were considered in the numerical experiments. The averaged Froude number estimated based on the gate openings was 2.54.

### The convolutional neural network

CNN is a special type of the artificial neural network (ANN). A traditional ANN establishes a statistical connection between inputs and outputs using hierarchical connected layers of neurons (Wu *et al.* 2009; Kurtulus & Razack 2010), and the parameters and weights in the network are usually determined by minimizing the loss function. However, for data with multiple arrays (e.g., images), there is typically a higher correlation between neighboring components and lower correlation between farther components. However, a neuron in a traditional ANN is not connected to other neurons in the same layer, which makes the network inadequate in extracting local patterns, and is fully connected to all neurons in the previous layer, which makes the network redundant (Khosravi *et al.* 2020; Ellafi *et al.* 2021). CNNs typically utilize the convolution and pooling operators to overcome this drawback. A convolution layer employs trainable filters to generate a feature map and highlight local features, and a pooling layer reduces the image resolution without losing the key features (Kreyenberg *et al.* 2019; Zhao *et al.* 2020a, 2020b). Therefore, CNNs can better extract the major patterns in an image and eliminate unnecessary computational costs.

#### Features

The flow field of the sluice gate flow is primarily governed by the upstream and downstream boundary conditions, and the arrangement of the sluice gate. The upstream boundary condition mainly consists of the flow velocity and inlet water level (*h _{a}*) (Pahar & Dhar 2017). To eliminate the necessity of incorporating the upstream boundary condition as a feature for ML models and to enhance the generalization of the trained ML models, all of the dimensions were nondimensionalized by the inlet water level, and the velocity components were nondimensionalized by the inlet velocity. The downstream boundary condition can be represented by the downstream weir height (

*h*). Therefore, two dimensionless quantities, nondimensional sluice gate opening (

_{w}*h*

_{0}/

*h*) and nondimensional overflow weir height (

_{a}*h*/

_{w}*h*), were fed into the ML models to predict the water mask and nondimensional velocity components (

_{a}*u*/

*U*

_{0}and

*v*/

*U*

_{0}).

#### Overall architecture

*h*

_{0}/

*h*and

_{a}*h*/

_{w}*h*) were fed, and their values were mapped into the feature space through a few layers of dense, batch normalization, activation, and reshape. This process transformed the values of the two input variables into an input image, and the backpropagation approach was employed to train the network. The optimal parameters are obtained from the training set, such as learning_rate, batch_size, n_epochs, nkerns and poolsize, using the trained parameters to initialize the model and perform hyperparameter tuning through the validation set.

_{a}#### Regularization

To suppress the problem of overfitting and to make the network generalize well to unseen data, we used batch-normalization modules (Ioffe & Szegedy 2015; Pan *et al.* 2019) as the regularization strategy to improve the performance of the network. This approach changed the distribution of the inputs in each layer during the training process and performed normalization of the output in the hidden layers (Ioffe & Szegedy 2015; Pan *et al.* 2019). Therefore, this approach can eliminate the issue of internal covariate shift, which in turn addresses the issue of overfitting.

#### Downsampling, activation function, and loss function

The pooling operations were one of the most popular downsample operations; however, considering that the network was sufficiently large for the dataset and thus the downsampling was performed using convolutional layers, these convolutional layers can be regarded as trainable pooling layers. The ReLU function was used as the activation function (Khosravi *et al.* 2020) because it is one of the most widely used activation functions with high efficiency. The mean squared error between the ground truths and predictions was used as the loss function. The algorithm first calculated the partial derivation of the loss function with respect to the parameters and subsequently tuned each parameter along the gradient descent direction to minimize prediction errors.

#### Training

Three CNNs were separately trained, including water masks, dimensionless streamwise velocity components, and dimensionless vertical velocity components. The validation set is used to estimate the generalization error during or after training and to update the hyperparameters. We tuned the hyperparameters including learning_rate, batch_size, and n_epochs using the validation set. Finally, the Adam optimization algorithm was employed for model training, and the learning rate was set as 0.001. The epoch was set as 1,000, the batch size was set to 4, and the kernel size was set as 3.

### Reference machine learning algorithms

In this work, various traditional ML algorithms comprising ANFIS, GP, MGGP, and 1D-CNN were also evaluated and employed to construct ML-based models (Rezaali *et al.* 2021), which were used as reference models. A major difference between these algorithms and the CNN was that they cannot perform 2D convolutional or downsampling operations, and thus, they cannot directly extract 2D spatial features. A common practice to apply these algorithms to predict the spatial distribution of variables is to predict output variables at each point and then merge the predictions together to construct the spatial distribution of the target variable (Kabir *et al.* 2020; Yan *et al.* 2021). However, training separate models for each point is not practical. In this study, we added two additional input variables into the training data sets, namely, the indices for the rows and columns of the pixels. Incorporating these additional variables can help traditional ML algorithms to extract spatial patterns and provide predictions using a single model. The 1D-CNN model was constructed on the same platform as the 2D-CNN model. The ANFIS model was developed using the fuzzy logic toolbox in MATLAB. The GP and MGGP models were implemented primarily using an adapted version of the MATLAB code GPTIPS2 (Yan *et al.* 2021).

### Data processing

All of the numerical simulations reached statistically steady states after 60 s, and thus, the data pertaining to the last 30 steps were extracted and averaged to obtain the time-averaged velocity fields. For each case, the water mask, the streamwise velocity component *u*, and vertical velocity component *v* were determined. The water mask was not a direct output of the numerical model and was defined to indicate whether a point contains water (water mask = 1) or not (water mask = 0). The velocity data together with the sluice gate opening and weir height were nondimensionalized by the inlet velocity and inlet water level. The nondimensionalized data were further normalized to fall between 0 and 1. Subsequently, a virtual mesh was created, and the processed data were mapped onto the mesh to construct three image-like matrices, which were matrices for water mask, normalized *u*, and normalized *v*.

For CNNs, the matrices were converted into grayscale images, which were the maps showing the spatial distribution of the water mask and flow velocities. For postprocessing, the predicted images were converted back to matrices. The velocity maps were corrected by the water mask maps to remove unphysically based values created by spatial interpolations. To specify, if the water mask at a grid was 0, then the velocity at the same grid was set as 0. Finally, the values in the matrices were denormalized to obtain actual values.

For the traditional ML algorithms, the matrices were not converted into images as they are not designed to process image-like data. Instead, the matrices were reshaped into datasets with multiple arrays, with each array containing one variable. The indices for the rows and columns of the virtual grids were added into the datasets as additional input variables. For postprocessing, the predictions obtained from the traditional ML models were reorganized and reshaped, based on the indices, to form the final matrices.

### Assessment metrices

## RESULTS AND DISCUSSION

### Validation of the SPH model

*u/U*and

_{0}*v/U*, at different locations. The magnitude of the vertical velocities was quite small in most of the regions except for near the gate, and thus only two measured velocity distributions located near the gate were provided and considered. As seen, the SPH predictions for both the horizontal and vertical velocities were in good agreement with the experimental data. The difference between the measurements and numerical predictions for the vertical velocity at

_{0}*x/h*= 1.626 was more apparent relative to the other locations. Our results for this location were very similar to the numerical data provided by Akoz

_{a}*et al.*(2009), which also overpredicted the vertical velocity magnitude. A possible fact that led to this discrepancy was that we set the vertical velocity as zero at the inlet boundary in the numerical model, while there might be a small vertical velocity component in the experiment. However, for the other locations, the SPH model reproduced the flow field satisfactorily well. The RMSE and

*R*

^{2}values were also calculated and indicated on the plots, and the RMSE values were comparably low, while

*R*

^{2}values were high. Therefore, it is reasonable to conclude that the SPH model can satisfactorily represent the underlying processes of the sluice gate flow and is thus qualified to perform numerical experiments for generating synthetic data.

### Numerical experiments

The validated SPH model was employed to carry out additional computations for different arrangements of the sluice gates and overflow weirs. The considered sluice gate openings (*h _{0}*/

*h*) ranged from 0.112 to 0.224. Preliminary simulations were conducted, and the results showed that the flow became fully unconfined flow with larger gate openings. The height of the downstream weir (

_{a}*h*/

_{w}*h*) ranged from 0 to 0.187. The incorporation of the overflow weir can further increase the complexity of the problem by considering the influence of an additional hydraulic structure and can also be seen as a way of considering different downstream boundary conditions. For each case, the numerical data were extracted and randomly divided into three parts by MATLAB: 60% of the data were used for model training, 20% of the data were used for validation, and the remaining 20% of the data were used for model testing.

_{a}*u*/

*U*, and

_{0}*v*/

*U*, respectively. Note that these maps were actually grayscale, and pseudo color was used here to better visualize the results. The water profiles can be seen from the water mask maps. For the free-flow-outlet cases (

_{0}*h*/

_{w}*h*= 0), the upstream water level generally decreased with the gate opening. In the last case (

_{a}*h*/

_{0}*h*= 0.224), the flow became almost fully unconfined flow, so the upstream water level was quite similar to the downstream water level. For the cases where the outflow was obstructed by the downstream weir, the downstream water level was apparently governed by the downstream weir height: the water level increased with the height of the overflow weir.

_{a}The map for the horizontal velocity (*u/U _{0}*) clearly shows that a jet-like flow was formed due to the influence of the sluice gate. The downstream velocity was significantly higher than the upstream water velocity due to the contraction caused by the sluice gate. However, the difference in horizontal velocities between the regions upstream and downstream of the sluice gate generally decreased with larger gate openings. It was also apparent that the downstream weir directed the flow toward upward and created an overflow with a void region near the bottom of the weir.

The map for the vertical velocity (*v/U _{0}*) showed that there was a significant increase in vertical velocity near the sluice gate opening, as the water level suddenly decreased through this region. Without the downstream weir, the horizontal distribution of the vertical velocity was quite uniform, since the jet-like flow primarily moved horizontally in the downstream direction. However, the vertical velocity substantially increased due to the placement of the downstream weir, which caused the formation of the weir overflow.

These observations were consistent with existing knowledge and general engineering judgments. Therefore, the quality of the synthetic data was believed satisfactory. Eight of these cases were then used as unseen test cases (indicated using red outlines), and the remaining cases were used for training and validating the ML models.

### Performance of the CNN model

*h*= 0.168 and

_{0}/h_{a}*h*= 0. To evaluate the performance of the constructed model in reproducing the actual flow field, all of the results were converted back to the dimensional form. Generally, the maps generated based on the CNN model were impressively similar to those for the ground truths. In terms of the water mask, the CNN model successfully reproduced the sudden drop in the water level around the sluice gate. There was a small unrealistic discontinuity in the upstream region, but it was only caused by errors in a few pixels and did not significantly affect the overall performance. In general, the predicted upstream and downstream water levels were satisfactorily close to the ground truths. The CNN model also reproduced the patterns of the velocity field very well. It is very impressive that the high-velocity regions in both the upstream and downstream areas have been successfully captured. There were more oscillations in the predicted maps. A possible approach to resolving these imperfections is to increase the data set size, which requires more computing resources. At most pixels, the predicted velocities matched the actual velocities very well.

_{w}/h_{a}*R*

^{2}values for all cases in the training, validation, and test datasets. It is apparent that the model predicted the scenarios with median values of the input quantities better than those with extreme values (i.e., the numbers located farthest from the average of the data set), which was partially attributed to the relatively few samples of extreme cases for model training. For the scenario with the largest gate opening and a free outflow, the network performed the worst. The flow in this extreme scenario was almost fully unconfined flow, and thus, the flow characteristics were different from other scenarios. Overall, the RMSE values were satisfactorily low and the

*R*

^{2}values were comparably high, indicating that the developed CNN model can provide acceptable predictions for sluice gate flows.

### Performance of different ML algorithms

This work has already demonstrated that the developed CNN-based model can provide reasonable predictions for the flow field near a sluice gate. To better assess the performance of various ML algorithms, it is necessary to compare the errors between different models. Previous studies on ML, such as those by Feng *et al.* (2020), Sekar *et al.* (2019), and Kreyenberg *et al.* (2019), utilized the train and validation sets to compare models, demonstrating the feasibility of this approach. In this work, the model performance was compared by analyzing the errors of the training and validation sets.

*R*

^{2}values corresponding to the reference algorithms for the train-validation data sets were computed and shown in box plots (Figures 13 and 14). In this example, the compared variable was

*u/U*

_{0}, and error indices were calculated based on the grayscale values. It can be seen in Figure 8 that the CNN model generally provided lower RMSE and higher

*R*

^{2}values than the other tested models, demonstrating the good performance of the proposed algorithm. If both the training and validation performances are inferior to CNN, it is unlikely for the test performance to surpass that of the training and validation datasets in normal circumstances. The better generalization capability of the proposed CNN compared to the traditional ML algorithms should be primarily attributed to the 2D convolutional layers, which can better extract spatial features.

### Reconstruction of the complete flow field

*h*= 0.168 and

_{0}/h_{a}*h*= 0) in the test data sets. These flow fields were reconstructed using

_{w}/h_{a}*U*and

*V*values. The comparison in Figure 15 demonstrates that the final flow field predicted by the developed CNN was very similar to the ground truth flow field, further confirming that the proposed approach can reasonably reproduce the flow field of sluice gate flows.

### Key contributions and limitations

Numerical modeling of gate flows using the SPH approach receives relatively less attention compared to those using mesh-based models, and the current study incorporated an overflow weir. The established SPH model is believed more promising than mesh-based models, and the simulations with an additional overflow weir highlight the merits of SPH approaches. In addition, the validated SPH model was utilized to perform synthetic experiments, which provide high-fidelity data for the development and evaluation of ML-based models.

The key contribution of this work is that it demonstrated the potential of the proposed CNN for predicting sluice gate flows. Modeling sluice gate flows has many practical applications in the field of hydrology and water resources, so the development of such a suitable ML algorithm and a novel type of model is very beneficial for researchers and engineers in this field. In this study, the training and validation sets were used to determine the generalization ability of different MLs, demonstrating the stronger ability of CNN. Furthermore, two sets of tests were done to demonstrate the risk of no overfitting of the CNN model. This study showed that the developed CNN models can satisfactorily reproduce the sluice gate flows and outperformed the traditional ML algorithms. A major reason for the good performance of the proposed network was that it contains convolutional layers and is thus more capable of extracting spatial features. Predicting the sluice gate flows using computational fluid dynamics models would take several hours (even days for larger domains), while reproducing the sluice gate flows using the developed CNNs would only take a few minutes. Therefore, the contribution made in this study is significant for reducing the computational costs of modeling flow fields.

The CNN-based surrogate for the SPH model also has some other merits: (1) It is easy to use because it only requires a modeler to update the input data for simulations of new scenarios and does not require the installation of the complicated SPH modeling software. (2) It can significantly reduce the requirement for storage disk space. The network can provide predictions for arbitrary cases in a few seconds, so it becomes unnecessary to store the numerical outputs; thus, the disk space required for storing the network was less than 450 MB, while the storage size for the numerical data obtained in this study was more than 75 GB. (3) It may outperform numerical models in the future. ML algorithms can elucidate unseen mechanisms and eliminate errors due to assumptions or improper predefined relationships between variables. Therefore, when more high-fidelity observational data are available for model training, an ML-based model may eventually outperform a numerical model. Furthermore, the developed CNN can predict the complete flow field using a few governing parameters, implying that the proposed CNN approach is potentially a powerful tool for predicting the flow fields for any cases with the fluid–solid coupling process.

However, it is acknowledged that this work also has some limitations. The developed CNNs can only accommodate a single target variable, and hence, the three CNNs were trained separately in this study instead of using one CNN to predict all the three variables. In the map for the horizontal velocity (*u/U*_{0}), the downstream weir directed the flow upward and created an overflow with a void region near the bottom of the weir. This void region does not have a clear physical meaning, and it seems to be a limitation of the model. A hydraulic jump seems to be observed in some test cases. Some test cases, primarily due to the presence of the tailgates. In this article, we mainly propose the method of CNN reconstruction of the gate flow field. In the future work, we will further study whether hydraulic jump has limitations to the ML model and further evaluate the applicability of ML in highly turbulent and two-phase (air–water) cases. Besides, the developed models performed relatively worse for the cases with extreme values and became almost invalid for fully unconfined flows. Therefore, further studies should be conducted to improve the prediction capability of the models for extreme values and to develop general models that are suitable for both sluice gate flows and fully unconfined flows.

## CONCLUSIONS

This study proposed a CNN to predict the flow fields near sluice gates, and the performance of the developed network was compared with those of 1D-CNN, ANFIS, GP, and MGGP models. The developed CNN-based models can directly reproduce, based on the sluice gate and downstream overflow weir configurations, the spatial distribution of water masks, and dimensionless horizontal and vertical velocity components, which can in turn reconstruct the complete flow fields near sluice gates. The results showed that the developed CNN models can satisfactorily reproduce the sluice gate flows, and outperformed the traditional ML algorithms. The better performance exhibited by the proposed network can be primarily attributed to the 2D convolutional layers, which can better extract spatial features. The comparisons between the SPH results (ground truths) and CNN predictions, as well as those between the performance of the CNN algorithm and traditional ML algorithms, showed that the developed CNNs can accurately reproduce the flow field near sluice gates and significantly reduce the computational cost, and it performed better than the traditional data-driven algorithms in predicting sluice gate flows. These findings also implied that the CNN approach was potentially a powerful tool for predicting the flow fields for any cases under the influence of solid structures. Future studies are recommended to improve the prediction capability of the models for extreme values. In the future, the data set can be further extended to include more data, especially for the flow field distribution near different types of sluice gates, to further improve the generalization ability of the ML models. Future works can also be conducted to develop general models that are suitable for both sluice gate flows and fully unconfined flows. It is also meaningful to conduct future studies to evaluate whether the ML models are subjected to limitations regarding the predictions of hydraulic jumps and to further evaluate the applicability of ML in predicting highly turbulent and two-phase (air–water) cases.

## ACKNOWLEDGEMENTS

This work was supported by the Open Research Fund of State Environmental Protection Key Laboratory of Drinking Water Source Protection, Chinese Research Academy of Environmental Sciences (2022YYSYKFYB05), the Open Fund from Engineering Research Center for Seismic Disaster Prevention and Engineering Geological Disaster Detection of Jiangxi Province (SDGD202202), and Natural Sciences and Engineering Research Council of Canada (NSERC Discovery Grants).

## 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.

Journal of Hydrodynamics34(5), 917–933.