AI-based predictive approach via FFB propagation in a driven-cavity of Ostwald de-Waele fluid using CFD-ANN and Levenberg–Marquardt

The integration of Artificial Intelligence (AI) and Machine Learning (ML) techniques into computational science has ushered in a new era of innovation and efficiency in various fields, with particular significance in computational fluid dynamics (CFD). Several methods based on AI and Machine Learning (ML) have been standardized in many fields of computational science, including computational fluid dynamics (CFD). This study aims to couple CFD with artificial neural networks (ANNs) to predict the fluid forces that arise when a flowing fluid interacts with obstacles installed in the flow domain. The momentum equation elucidating the flow has been simulated by adopting the finite element method (FEM) for a range of rheological and kinematic conditions. Hydrodynamic forces, including pressure drop between the back and front of the obstacle, surface drag, and lift variations, are measured on the outer surface of the cylinder via CFD simulations. This data has subsequently been fed into a Feed-Forward Back (FFB) propagation neural network for the prediction of such forces with completely unknown data. For all cases, higher predictivity is achieved for the drag coefficient (CD) and lift coefficient (CL) since the mean square error (MSE) is within ± 2% and the coefficient of determination (R) is approximately 99% for all the cases. The influence of pertinent parameters like the power law index (n) and Reynolds number (Re) on velocity, pressure, and drag and lift coefficients is also presented for limited cases. Moreover, a significant reduction in computing time has been noticed while applying hybrid CFD-ANN approach as compared with CFD simulations only.

www.nature.com/scientificreports/velocity is given with a maximum value of U max that is the controlling parameter for Reynolds number.A choice of Re with magnitude of 20 and 100 was made to switch between the stationary and non-stationary regimes.
The following is an expression of the conservation laws that apply to 2D incompressible, isothermal and time dependent flows.
The relationship that represents a change in viscosity based on Ostwald de-Waele model aka Power Law (PL) fluid with the shear rate is written as follows: where m represents consistency coefficient; n is the power law index; γ is the magnitude of shear rate.The bound- ary conditions at various parts of the domain are given as At inlet: u = 4U max .y(H − y)/H 2 , v = 0, At outlet: p = 0, At Walls and on obstacle: The formula for determining the involved Re for the power law fluid model is as follows: meanings of all the parameters correspond to their standard assumptions.It should be noticed that the temporal derivative in Eq. ( 2) is set to zero for lower values of Re.The calculation of the drag and lift forces acting on the cylinder involves the following line integrals.
where σ is the Cauchy stress tensor, and n is the unit normal vector.Normalizing the drag and lift forces yields us to their corresponding dimensionless coefficients as where U mean represents the average velocity of the parabolic inflow profile.

Hybrid CFD-ANN scheme CFD simulations-generation of training data sets
The model partial differential equations along with the rheological law representing Ostwald de-Wale PL fluid (1-3) have been simulated using commercial finite element-based solver COMSOL by a suitable choice of elements from the available library to approximate the velocity and pressure values approximations.Newton's approach is utilized to solve discrete non-linear algebraic systems, and a direct solver PARDISO is adopted as inner linear solver.The following convergence condition is set for the nonlinear iteration.
(1) where indicates a component of the solution vector.Figure 2 depicts the coarse computational grid used for the present study.For the accurate computation of quantities of interest including the drag and lift coefficients, the grid is more refined near the obstacle.Although meshing is performed at many different levels to optimally divide the domain into enough finite elements, only the coarsest level is shown here.
Table 1 contains an enumeration of mesh statistics at various Refinement Levels (RL).The number of elements (EL) and related global degrees of freedom (DOF) for velocity and pressure data are shown.The table demonstrates that the minimum number of elements (769) and degrees of freedom ( 4032) are available at level 1, while the largest number of elements (52,844) and degrees of freedom (250,024) are available at level 9 for the collection of data.
Table 2 shows that code validation under same geometric and parametric settings as in 48 , which validates the existing code.
In Table 3, the variation in numerical data for C D and C L at all levels of refinements is shown to show the grid convergence and sufficiency of the underlying grid.Since the results at refinement levels 8 and 9 only differ by less than 1% so to save computational cost, all further simulations have been performed on level 8 of refinement.It is worth mentioning that a negative C L indicates upward lift forces are playing a more significant role that the downward forces.

Construction of ANN
To implement machine learning algorithms, an artificial neural network has been created using multilayers namely input, hidden and output layers.The schematic diagram of underlying ANN is presented in Fig. 3a,b.The underlying ANN model consists of 2 input layers (for n and Re), 2 output layers (for drag and lift coefficients) and 10 hidden layers for the stationary case while for the time dependent case the number of input layers is increased to 3 to include time-step size in the input parameters.For all cases, 70% data is used for training phases while 15% each for testing and validation phases respectively.To minimize the loss function Levenberg-Marquardt  optimization algorithm has been employed with suitable activation functions such as TANSIG (f(x)) and PURELIN (g(x)) in the hidden and output layers respectively.These activation functions can be represented mathematically as f (x) = 2 1+e −2x − 1 and g(x) = x .LM algorithms works based on feed-forward and back- propagation and computes the gradient of Loss function w.r.t the weights in the neural network.These gradients are then used to update the weights using some optimization algorithm in the training step.

Stationary case Re = 20
By performing line integration over the boundary of the obstacle as provided in Eq. ( 5), drag and lift forces have been computed and subsequently their non-dimensional analogue, the drag and lift coefficients C D and C L respectively.Table 4 display the fluctuations that occur in standard hydrodynamic quantities, such as the  www.nature.com/scientificreports/coefficients of C D and C L defined in Eq. ( 6).It is discovered that the C D and C L increase with the power law index.Furthermore, lift forces are shown with negative values of C L , which translates to a predominance of upward- directed lift force.When impediments are positioned directly above the cavity region, fluid is forced downward into the cavity, creating upward thrust on the obstruction, leading to negative values for the lift coefficient.The maximum C D and C L of 6.4225 and − 0.5996 are achieved, respectively, based on the computed values over the obstacle having its centre placed at (1.5, 1.5).For small values of n, the drag force decreases because of the fluid's viscosity decreasing with shear rate and the power law behaving as a shear thinning material, but for large values of n, the fluid's viscosity increasing with the rate of deformation leading to an increase in the drag coefficient.Change in pressure measured at the front and back of the obstacle as a function of n at Re = 20 is shown in Table 5.Based on the obtained numerical data, it is determined that the pressure drop increases as n grows larger.Because a power law fluid exhibits the characteristics of a shear-thinning fluid when n is less than one, a Newtonian fluid when n is equal to one, and elucidates the properties of a shear-thickening fluid, the viscosity of a power law fluid increases when the magnitude of n is increased.As a result, the fluid strikes the obstacle with more force, which causes the pressure drop to increase.
Table 6 explains the range of values for the C D and C L when encountering a square obstacle cantered at coordinates (1.5, 1.5).As the Re increases, the C D and C L drop.Furthermore, lift forces are shown with negative values of C L , which translates to a predominance of upward-directed lift force.When impediments are positioned directly above the cavity region, fluid is forced downward into the cavity, creating upward thrust on the obstruction, leading to negative values for the C L .
Table 7 illustrates the pressure drop as a function of rising Re.The largest pressure difference is observed at Re = 1, roughly 0.45548, while the smallest is observed at Re = 50, around 0.074106917.
The velocity distribution is brought into focus in Fig. 4 by adjusting the n between 0.3 and 1.5.The Power law flows with n = 0.5 exhibit shear thinning behaviour, while those with n = 1 behave like Newtonian fluids and for n = 1.3 and 1.5 behave like shear thickening fluids.Since the parabolic velocity is induced at the inlet, and the other boundaries are maintained at no slip conditions, the change in velocity that is only detected is near barriers and other parts of the channel driven cavity.During power law fluid flow in the cavity region, additional circulating flow is generated, and vortices occur.
Examining the effect of increasing n on the pressure gradient in a channel-driven cavity at Re = 20 is shown in Fig. 5.It is revealed that when n increases, the power law fluid transforms from a shear thinning state to a Newtonian state, and finally to a shear thickening state.Since the viscosity of the fluid increases and the velocity of the fluid decreases as n grows larger, less force is applied to the barrier as n grows larger.As a result, the injected   www.nature.com/scientificreports/fluid displays higher pressures for cases where n is greater than one, also known as shear thickening case.For shear-thinning cases stagnation pressure is reduced.Figure 6 depicts viscosity plots showing the yielded and unyielded zones for a variety of scenarios, which offers more comprehension of the flow behaviour activity.The shear thickening process results in the formation of small zones that are not yielding, which is an indication that the flow is weak because of the influence of fluid yield stress.Thus, liquid-like behaviour is promoted by decreasing values of n during shear thinning, whereas it is inhibited by the fluid yield stress.For the case n = 1, the viscosity is constant throughout the domain which confirms the Newtonian flow regime.Some islands of viscosity also revealed in the vicinity of obstacle for shear-thinning cases n < 1. Table 8 depicts the two-performance metrics Mean Square Error (MSE) and the coefficient of determination (R) for C D and C L at various stages of the developed neural network.The MSE for all cases is approaching zero and R value is close to 1 showing higher predictivity of fluid forces via the established net.
The goodness of fit is shown in Fig. 7 for training, testing and validation phases.This fitted regression line covers most of the data points as is evident from the R values.For the sake of brevity only one case for n = 0.7 has been shown here both for C D and C L .The convergence of Loss function i.e., MSE versus the number of epochs is presented in Fig. 7.It is observed that a smaller number of epochs required for the convergence of loss function for C D as compared with C L .
In Fig. 8, we see what happens to the flow's velocity at x = 1 (before obstacle) and at x = 5 (the outlet) by generating line graphs.Because of the generation of a completely developed flow in this stream, the perfectly parabolic behavior is observed at n = 1 and for other values of n the parabola is flattened and sharpened in the center of the channel representing the shear rate dependence of viscosity and consequently on velocity.

Time dependent case Re = 100
Having obtained promising results for the stationary case, we extended the study to a time dependent case while increasing the Reynolds number to 100.Simulations have been run for t ∈ [0, 10] with t = 0.001[0, 10] with t = 0.001 producing 1000 data points for each case.From the obtained values, 70% data was used for training phase, 15% for testing and 15% for validation phase.Figure 9 shows the Levenberg-Marquardt neural  Extensive epochs for n = 0.7 and n = 1.3 are included in the analysis, which includes validation, testing, and training stages.Appropriate models for error analysis displayed were shown in Fig. 10.The neural network is led by this graph, which is responsible for orchestrating the process of learning patterns and relationships within the data that is presented.These graphs reduce the discrepancy between the outcomes that were predicted and those that really occurred by altering the parameters of the network in an iterative manner.This helps to improve the model's ability to generalize data that has not been seen before.Regression plots measure the degree of association between outcomes and objectives.A stronger relationship is indicated by a value of R that is close to 1, while a value of R that is close to 0 indicates that the association is arbitrary.In Fig. 11, plots of FEM-Net are displayed in comparison to the reference CFD solution for a value of n equal to 0.5.Finally, we show the efficiency of hybrid FEM-ANN approach by comparing the computational time for the calculation of drag and lift coefficients using CFD first and then predicting these force coefficients through ANN approach without CFD.Table 9 represents such a comparison.One can notice a drastic reduction in the computational time while predicting drag and lift through ANN approach.This data is collected by running CFD and ANN tool using a system with Intel ® Core™ i5 processors.

Conclusions
To forecast drag and lift coefficients with fully unknown data, a neural network has been trained and validated using findings from Finite Element based CFD simulations.As a first phase of this hybrid approach, the training and validation data sets for drag and lift coefficients have been generated by CFD and then are fed through ANN with optimal number of neurons and inner layers.A well-known feed-forward back-propagation LM algorithm, which offers second order training speed, was utilized to train the network.
We have shown that a coupled CFD-ANN approach can lead to a drastic reduction in computational resources in terms of memory and time considerations.This hybrid approach can accelerate the convergence of overall scheme.Numerical test cases have been performed in a channel driven cavity domain containing an obstacle    iv.C L with negative values are achieved when upward pressures are greater than those acting downward, while C L with positive values are achieved when downward forces are greater.v.In the case of a Power law fluid with shear thinning, the C D and C L have a smaller magnitude in contrast to the shear thickening version of the fluid.vi.The Re has a characteristic that decreases when applied to the pressure constraint difference in the vicinity of a square obstruction.vii.As the n rises, the velocity profile becomes peaky in the center, and flattening otherwise that truly reflects the features of PL fluids.
It has been shown that data-driven techniques are appropriate for fluid dynamics problems, and it has been determined that ANN is a trustworthy instrument that efficiently lowers the cost of CFD simulations.This approach in future will be applied to 3D and turbulent flows where advantages would be more prominent.

Figure 2 .
Figure 2. The computational grid at coarse level.

Table 3 .Figure 3 .
Figure 3. (a) Neural network block diagram for stationary case.(b) Neural network block diagram for time dependent case.

Figure 4 .
Figure 4. velocity profile at Re = 20 for various n.

Figure 5 .
Figure 5. Pressure distribution for several n.

Figure 7 .
Figure 7. MSE for C D (left) and C L (right) for n = 0.7.

Figure 8 .
Figure 8. Line graphs of velocity for various n.

Figure 9 .
Figure 9. MSE analysis of C D for = 0.7 and 1.3.

Figure 10 .
Figure 10.Fitness analysis of C D for n = 0.5.

Figure 11 .
Figure 11.Fitness analysis of C D for n = 0.5.
Schematic representation of the flow domain.

Table 1 .
Number of degrees of freedom for different refinement levels.

Table 2 .
Code validation for C D and C L at Re = 20.Drag and

Table 5 .
Pressure drop with Re = 20 for various n.

Table 7 .
Pressure gradient with n = 1 for various Re.

Table 9 .
Computational time comparison of CFD versus ANN approach for Re = 100.