Introduction

Artificial intelligence (AI) has been frequently used in the prediction of physical and industrial processes1,2,3,4. They are also used as an assistance tool besides exact studies, either numerical or experimental, during optimization of processes, and they can mimic and then provide mathematical descriptions for processes5,6,7,8. Recently, AI has been combined with computational fluid dynamics to simulate the fluid flow pattern in different geometries, such as square cavity and the cylindrical bubble column reactors9,10,11. In this combination, the AI learns the process from the computational fluid dynamics (CFD) data set, specifically from each CFD node in the domain, and then represents the new data set for different conditions. The flow pattern in this condition is also based on the CFD data and is completely independent of boundary conditions, mesh sensitivity, and stability of numerical methods12,13,14,15. The AI shows the evolution of the flow pattern between the range of exact models, which is helpful to avoid exact modeling repetition with expensive computational expenses in the optimization process.

In the multiphase flow application, Pourtousi et al.16 employed the ANFIS method to learn CFD data from different heights of a bubble column reactor and predicted the new data set of the flow pattern for different heights and sparger (gas distributor) specifications. They also used this method to learn CFD data about formation, detachment and to raise the bubble at few CFD time steps, and after learning data, they predicted the interface between continuous and dispersed phase for the very small time step. Pourtousi et al.17 showed that the prediction of the interface between dispersed and continuous phase is not very accurate with the combination of ANFIS and CFD, and it requires a huge number of rules.

There are also several tuning parameters to accurately predict the shape of the pattern in the AI18. For instance, in the ANFIS technique, number of rules and membership functions can be changed for each input and results in improvement of the pattern6,19.

The selection of different datasets during the learning process enables us for better pattern recognition. One of the main advantages of this accurate fluid flow pattern prediction is the CFD method does not require to save each time step and then store the data. In this case, AI plays a role as an assistance tool to provide non-existing data, which sometimes needs large computational time and hard drive for storing data. This technique can be replaced with computational fluid dynamics, and it enables us to avoid storing data for a very small time step and replace smart modeling instead of CFD modeling.

Recently there are several machine learning (ML) tools that have been developed to predict the pattern of flow in a domain. They showed that the number of input parameters and the number of membership functions could significantly impact on accurate prediction of flow pattern. However, the selection of each model based on the learning time has not been fully considered. Additionally, the prediction of more futures in the pattern has not been fully investigated. In this work, we consider the prediction of flow pattern in the domain and represent new features of flow characteristics based on the predictions ability.

We use different patterns of fluid flow for different time steps as a data set, and with the ANFIS method, all time steps are learned. After training all patterns of fluid, the AI predicts missing times with the CFD method, which has not been used in the training method. We also compare prediction results with the existing model in literature called the genetic algorithm fuzzy inference system (GAFIS) to evaluate the capability of models in predicting flow patterns. For the first time, we present a new mathematical correlation based on AI for the flow pattern in the cavity domain. This correlation can represent the local values for the fluid flow when there is a shear flow.

Method

In this study, to build-up a large dataset for the fluid flow, we simulate the 3D cavity by the Lattice Boltzmann method (LBM). This dataset enables us to study the ability of ML prediction process in the simulation of fluid flow pattern recognition in a simple fluid problem. The AI is used to get several slices for various simulation time at the center of the cavity, in x–y coordinate. Then it tries to learn the process and predict many simulation times that are not simulated by the CFD method or saved on the computer. This ability enables us to visualize the fluid pattern in a short period of time.

Lattice Boltzmann Method (LBM)

For simulation of single-phase fluid flow in the 3D cavity, we use the lattice Boltzmann method, and the collision term is computed based on Bhatnagar-Gross-Krook (BGK). The model of D3Q19 is used to present the location of LB points. The LB equation, which represents the streaming and collision part, is written as:

$$f_{i} \left( {\vec{x} + c\vec{e}_{i} \Delta x,t + \Delta t} \right) - f_{i} \left( {\vec{x},t} \right) = \frac{1}{\tau }\left( {f_{i}^{ eq} \left( {\vec{x},t} \right) - f_{i} \left( {\vec{x},t} \right)} \right) + \Delta tF_{i}$$
(1)

where \(f_{i}\) is the density distribution and \(f_{i}^{{{ }eq}}\) is the equilibrium distribution for particles in the domain. \(c_{i} = ce_{i}\) is the discrete velocity in the domain of cavity, while \(e_{i}\) presents unit lattice velocity. \(F\) is also the external force in the direction of \(i\).

The equilibrium distribution (\(f_{i}^{eq}\)) with different weight factors (\(w\)) describes as:

$$f_{i}^{eq} = w_{i} \rho \left\{ {1 + \frac{{ _{{c_{i} u^{eq} }} }}{{C_{S}^{2} }} + \frac{{(c_{i} u^{eq} )^{2} }}{{2C_{S}^{2} }} - \frac{{u^{eq2} }}{{2C_{S}^{2} }}} \right\}$$
(2)

The weight factors are as w0 = 1/3, w1−6 = 1/18 and w5−9 = 1/36. The macroscopic density and velocity of fluid can be calculated based on:

$$\rho = \sum\limits_{i} {f_{i} }$$
(3)
$$\rho \vec{u} = \sum\limits_{i} {\vec{e}_{i} } f_{i}$$
(4)

\(\rho\) and \(u\) present the density and velocity of fluid flow, respectively.

ANFIS

ANFIS is a fuzzy implication structure that precisely forecasts the manners of nonlinear and complex systems20,21. Three various sorts of fuzzy reasoning are present, which Sugeno and Takagi suggested if–then rules applied in the ANFIS framework22. Herein x coordination (x), y coordination (y), and time (t) are engaged for the achievement of fluid velocity in place of output. The function of the ith rule is written as:

$$w_{i} = \mu_{Ai} \left( x \right) \mu_{Bi} \left( y \right)\mu_{ci} \left( t \right)$$
(5)

where wi is the signal coming out of the second layer's node and μAi, μBi and μCi are received signals from implemented MFs on inputs, x coordination (x), y coordination (y) and time (t), to the second layer's node. More details on ANFIS can be found elsewhere22.

Results and discussion

The analysis of liquid flow pattern by CFD methods in 3D geometries requires high computational time. Saving all fluid properties in the three dimensions for each time step is time-consuming and needs a very large hard drive for storing data. In this study, we specifically, simulate the 3D cavity and save data at the center of the domain for several time steps. Then we use some data in training ANFIS for prediction of the liquid pattern. During learning data, we examine different combinations of membership functions, rules, and the number of inputs to evaluate the best condition for the prediction of flow patterns with AI. After learning all data, we call ANFIS function to generate the liquid flow pattern for different time steps, and we compare them with some of the CFD data that has not been presented in the training process. This procedure enables us to facilitate fast visualization of the data in a short computational time.

The prediction of flow pattern recognition in the domain requires the high accuracy of the learning process in artificial intelligence algorithms. This accuracy called "intelligence of the method" can be achieved with all tuning parameters in the AI and way of processing and training data. In this study, to achieve the intelligence of the method, we start training with different numbers of inputs and outputs. At first, we train data with one input and output and observe the accuracy of the method. The results show that the accuracy of the method is very low when only one input is used in the training process. This accuracy can not increase by increasing the number of rules or the number of membership functions. To achieve better accuracy of the method, we can increase the number of inputs. Increasing the number of inputs causes an increment in the number of neural in the system. For clustering data in the ANFIS method, we select grid partition clustering and also select generalized bell-shaped membership function (Gbellmf) as a type of fuzzy membership functions (MFs). The percentage of data utilized for training is %60, the maximum iteration in ANFIS is 500, and the number of data is considered 65,000. With the above parameters and considering x coordinate as the first input and different number of MFs, the ANFIS learning is implemented. Figure 1 shows the regression (R) about 0.117 for the training, and 0.116 for the testing. This value of R shows %11 of ANFIS intelligence for reaching a high ANFIS intelligence, we consider y coordinate as the second input and repeat the ANFIS training/testing when the number of MFs = 2,3 and 4.

Figure 1
figure 1

ANFIS training and testing processes, one input, number of MFs = 2, 3, 4.

Results depicted in Fig. 2 reveal that the amount of R is drastically risen up, and when the number of MFs = 2, the value of R for training/testing is about 0.92. Changes in the number of MFs from 2 to 4 indicated an increase in the amount of R from 0.92 to 0.96, which had a great influence over achieving %96 of ANFIS intelligence which is depicted in Fig. 3.

Figure 2
figure 2

ANFIS training and testing processes, two inputs, number of MFs = 2, 3, 4.

Figure 3
figure 3

ANFIS training and testing processes, three inputs, number of MFs = 2, 3, 4.

To reach a high percentage of ANFIS intelligence, we add time as the third input, and the learning step for the number of MFs = 2, 3, and 4 are done. By comparing R when the number of inputs is three and two, which indicates an increase in R in the testing and training, particularly when the number MFs = 4, percentage of ANFIS intelligence is %99.5, which is a significant achievement in the ANFIS intelligence.

According to Fig. 4, ANFIS prediction points have good adaptation with the CFD points; eventually, we predict surfaces that indicate velocity as the ANFIS output based on different inputs. By using predicted surfaces, there is a suitable capability to achieve more points in the cavity, which most of them have not been present in the ANFIS learning processes (see Fig. 5).

Figure 4
figure 4

ANFIS prediction validation by the CFD outputs, three inputs, number of MFs = 4.

Figure 5
figure 5

ANFIS prediction surfaces, three inputs, number of MFs = 4.

The highest intelligence is achieved when the number of inputs equals three and the number of MFs = 4. The degree of MFs is illustrated in Fig. 6; furthermore, Figs. 7 and 8 indicate MSE error and RMSE error for the training and testing processes in the highest level of ANFIS intelligence. In the following section, the velocity prediction patterns are depicted for the times that its data are present in the ANFIS learning processes, the velocity prediction patterns are depicted on the left side of Fig. 9, also the velocity prediction patterns for the times that are absent in the learning processes are depicted on the right side of Fig. 9.

Figure 6
figure 6

Degree of membership function, three inputs, number of MFs = 4.

Figure 7
figure 7

ANFIS training errors, three inputs, number of MFs = 4.

Figure 8
figure 8

ANFIS testing errors, three inputs, number of MFs = 4.

Figure 9
figure 9

Velocity prediction pattern for absent and present times in learning processes by the obtained ANFIS intelligence when the number of inputs is three, and the number of MFs is 4.

Furthermore, in Fig. 10, the velocity prediction patterns for the different times are illustrated. In the following section of this study, we select five points that are highlighted in Fig. 11, and their velocity are predicted at different times, also we compare the predicted velocity of five points with the CFD velocity of five points that are depicted in Fig. 12. Results show that there is a good adaptation between the prediction velocity lines and the CFD velocity lines.

Figure 10
figure 10

Velocity prediction 3D pattern, three inputs, number of MFs = 4.

Figure 11
figure 11

Five selected points in the cavity to evaluate velocity at different times.

Figure 12
figure 12

Prediction of the velocity patterns at different times.

Table 1 The equation of MF.

Generalized Bell-shaped membership function (Gbellmf) from different types of MFs, and its equation can be seen in Table 1. Gbellmf is selected for prediction of velocity that is obtained from the following equation:

$$V = \frac{{\sum\nolimits_{i = 1}^{4} {\sum\nolimits_{j = 1}^{4} {\sum\nolimits_{k = 1}^{4} {\left( {\mu_{1i} \times \mu_{2j} \times \mu_{3k} } \right) \times \left( {p_{m} x + q_{m} y + r_{m} z + s_{m} } \right)} } } }}{{\sum\nolimits_{i = 1}^{4} {\sum\nolimits_{j = 1}^{4} {\sum\nolimits_{k = 1}^{4} {\left( {\mu_{1i} \times \mu_{2j} \times \mu_{3k} } \right)} } } }}$$
(6)

\(\mu_{1i} , \mu_{1j}\) and \(\mu_{1k}\) are written in Eq. 6, as:

$$\mu_{1i} = \frac{1}{{\left( {1 + \left| {\frac{{x - c_{i} }}{{a_{i} }} } \right|^{{2b_{i} }} } \right)}}$$
(7)
$$\mu_{1j} = \frac{1}{{\left( {1 + \left| {\frac{{x - c_{j} }}{{a_{j} }} } \right|^{{2b_{j} }} } \right)}}$$
(8)
$$\mu_{1k} = \frac{1}{{\left( {1 + \left| {\frac{{x - c_{k} }}{{a_{k} }} } \right|^{{2b_{k} }} } \right)}}$$
(9)

Table 2 shows membership function parameters for each input separately in the first layer of ANFIS structure. Also, Table 3 shows Eq. (6) parameters that are extracted from the bottom layer of ANFIS structure, using these parameters in Eq. (6) we can predict fluid velocity based on ANFIS inputs (x and y coordinates and time).

Table 2 Membership functions parameters of ANFIS prediction.
Table 3 ANFIS prediction parameters in Eq. (6).

For better evaluation of the ANFIS method, we compare this method of prediction with the GAFIS method. Similar to the previous analysis, again, we start with training assessment, and after learning data set in both ANFIS and GAFIS, we compare then with R evaluation criteria. The results in Fig. 13 show that the ANFIS method is more capable in the training of CFD dataset, and the ratio of \(\frac{{R^{ANFIS} }}{{R^{GAFIS} }} > 1\) that shows the high ability of training data for the ANFIS method. In another assessment, we included more datasets in the process of the assessment called “testing process”. In this stage of evaluation, we observe similar behavior as the training process, and the ANFIS method shows a higher ability with regards to accuracy.

Figure 13
figure 13

Accuracy comparison of ANFIS and GAFIS methods for the best learning processes.

In addition to the accuracy criteria, we compare these methods with regards to error, \({R}^{2}\), STD, and computational time (training and testing times). Table 4 shows that the ANFIS method contains less error than GAFIS when both methods have the same number of iterations, inputs, and percentage of training data set. Both methods reach the best level of accuracy. However, the training time for the ANFIS method is almost two times more than the GAFIS method. In the prediction process, the GAFIS method is even much faster, and the speed of the prediction process is almost 7 times more than the ANFIS method.

Table 4 Model parameters, error evaluation, and computational time for ANFIS and GAFIS.

For the better comparison between the ANFIS and GAFIS method, the artificial flow characteristics (velocity distributions) should be compared at local computing points with CFD local dataset. Figure 14a,b shows the flow distribution for the ANFIS and GAFIS method, respectively, and then all velocity distributions are compared with CFD flow distributions in the cavity. The prediction results for the ANFIS method shows that this method can fully predict the flow distribution in the cavity with the minimal difference with CFD dataset, particularly near boundary conditions. However, the prediction results for the GAFIS method show that this method is unable to predict the flow at many local points. The low capability of prediction for some of the local points can be modified with consideration of data filtration near all boundary conditions or introducing boundary conditions as a numerical restriction into the learning algorithms. Another alternative method can be a dense CFD mesh near the boundary condition to have more datasets at those particular locations. We also predict the flow distribution for a different time, and we compare the ANFIS, GAFIS, and CFD methods at the time that the machine learning method does not have training sessions. Figure 15 shows the velocity for ANFIS, GAFIS, and CFD at different points in the cavity domain. Two velocity profiles for ANFIS and GAFIS are completely artificial and based on the prediction ability of machine learning. The results for the ANFIS results are comparable with CFD calculations at different time frames. However, the GAFIS is not as accurate as the ANFIS in the prediction of the flow pattern as a function of time.

Figure 14
figure 14

(a) Pattern recognition for liquid flow using the ANFIS method. (b) Pattern recognition for liquid flow using the GAFIS method.

Figure 15
figure 15

Comparison between ANFIS and GAFIS methods in three different local points in the cavity.

For future study, changes in a type of clusterings such as subtractive clustering and fuzzy c-means clustering, and their variable parameters such as the number of cluster in fuzzy c-means clustering and cluster influence range (CIR) in subtractive clustering are worth studying and evaluation.

Conclusion

In this study, a type of AI called ANFIS method is considered. For ANFIS learning processes, we considered data as inputs and outputs that were extracted from the CFD simulations. In the CFD method, we simulated a cavity and extracted data such as x and y direction and fluid velocity at different times. After making some changes in ANFIS variable parameters to achieve the highest percentage of ANFIS intelligence, ANFIS intelligence became conscious eventually. Fluid velocity as an ANFIS output is predicted in many points of the cavity in comparison with cavity points that are simulated via the CFD method. Particularly, in this study, we considered five points of the cavity at different times and predicted these points at any time in the CFD method period of time. By using this capability of the ANFIS method, we predicted the velocity of the fluid in times that no data existed in the learning processes. For the assessment of prediction capability in the ANFIS method, we compared this method with the GAFIS algorithm. The result shows that the prediction capability in the ANFIS method is higher than the GAFIS method. The ANFIS method can even better predict the flow patter at all local computing points. However, training and prediction time for the ANFIS method is much higher than the GAFIS method.