Pattern recognition of the fluid flow in a 3D domain by combination of Lattice Boltzmann and ANFIS methods

Many numerical methods have been used to simulate the fluid flow pattern in different industrial devices. However, they are limited with modeling of complex geometries, numerical stability and expensive computational time for computing, and large hard drive. The evolution of artificial intelligence (AI) methods in learning large datasets with massive inputs and outputs of CFD results enables us to present completely artificial CFD results without existing numerical method problems. As AI methods can not feel barriers in numerical methods, they can be used as an assistance tool beside numerical methods to predict the process in complex geometries and unstable numerical regions within the short computational time. In this study, we use an adaptive neuro-fuzzy inference system (ANFIS) in the prediction of fluid flow pattern recognition in the 3D cavity. This prediction overview can reduce the computational time for visualization of fluid in the 3D domain. The method of ANFIS is used to predict the flow in the cavity and illustrates some artificial cavities for a different time. This method is also compared with the genetic algorithm fuzzy inference system (GAFIS) method for the assessment of numerical accuracy and prediction capability. The result shows that the ANFIS method is very successful in the estimation of flow compared with the GAFIS method. However, the GAFIS can provide faster training and prediction platform compared with the ANFIS method.


Scientific RepoRtS
| (2020) 10:15908 | https://doi.org/10.1038/s41598-020-72926-3 www.nature.com/scientificreports/ There are also several tuning parameters to accurately predict the shape of the pattern in the AI 18 . For instance, in the ANFIS technique, number of rules and membership functions can be changed for each input and results in improvement of the pattern 6,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: where f i is the density distribution and f eq i 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 eq i ) with different weight factors ( w ) describes as: The weight factors are as w 0 = 1/3, w 1−6 = 1/18 and w 5−9 = 1/36. The macroscopic density and velocity of fluid can be calculated based on: ρ 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 systems 20,21 . Three various sorts of fuzzy reasoning are present, which Sugeno and Takagi suggested if-then rules applied in the ANFIS framework 22 . 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: where w i 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 elsewhere 22 . (1)

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  www.nature.com/scientificreports/ 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. 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.
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,  www.nature.com/scientificreports/ 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). 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.
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  www.nature.com/scientificreports/ are depicted in Fig. 12. Results show that there is a good adaptation between the prediction velocity lines and the CFD velocity lines. 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: µ 1i , µ 1j and µ 1k are written in Eq. 6, as:  www.nature.com/scientificreports/ 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).
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    www.nature.com/scientificreports/ 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 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 www.nature.com/scientificreports/ 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. 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.
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  www.nature.com/scientificreports/ 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 www.nature.com/scientificreports/ 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.
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.