Numerical Study of Rectangular Tank with Sloshing Fluid and Simulation of the Model Using a Machine Learning Method

This paper presents a ﬂ uid sloshing model using the arti ﬁ cial neural network method (ANN). Determining the ﬂ uid sloshing model in the tank is a challenging task due to its nonlinearity and complexity of behavior to its environmental and operational conditions. Due to the problems of laboratory modeling, the use of numerical modeling to analyze this phenomenon can be justi ﬁ ed. In this paper, ﬁ rst, the ﬂ uid sloshing in the tank is simulated by the smooth particle hydrodynamics method (SPH). The input-output data for training the arti ﬁ cial neural network is based on the obtained results. Finally, the maximum force due to the ﬂ uid sloshing is obtained by changing di ﬀ erent parameters.


Introduction
Sloshing refers to a fluid's free surface oscillations in a partly filled tank. The presence of a free surface in the liquid is needed for slosh, presenting a dynamic fluid-structure interaction challenge [1]. Many studies of liquid sloshing in tanks have been conducted using model tests for various excitations, fillings, compartment shapes, and internal configurations ( [2][3][4], as well as liquid sloshing effects for ship motions [5]. The majority of existing laboratory experiments, on the other hand, is for multiscale models rather than real ships. A series of numerical approaches are implemented to tackle the problem of liquid sloshing based on the constraints of theoretical and laboratory studies. However, most studies focused on the grid-based technique, which could necessitate special algorithms when tracking the motion of a free surface. Numerical methods for solving engineering problems involve several steps. The first step is to choose the proper governing equations that can model the problem with a certain level of accuracy. The next step is to discrete these governing partial differential equations. The most common discretization techniques are finite difference, finite volume, and finite element methods. All these methods discretize a continuum into elements connected by a topological mesh grid. However, when modeling problems like an explosion, impact, or fluid-structure interaction with large deformations, these methods require an adaptive remeshing process (Liu, 2010). Because fluid sloshing in tanks is associated with large deformations, numerical methods such as finite element and other techniques have many problems such as numerical distribution due to the expression transfer, continuity, and inflexibility of fluid free surface the use of these methods. In the last decade, meshfree methods have been used for simulation and various applications.
One of the nonlattice methods is the smooth particle hydrodynamics method. Sloshing flow has been studied using the SPH process ( [6][7][8][9]. This study was aimed at improving the SPH method's ability to simulate sloshing flow correctly and calculating impact pressure by using a more precise time-stepping integration and a simplified boundary state treatment. Qiao et al. [10] developed a new coupled model based on wavelet transform to predict short-term PM10 concentrations [10]. Peng et.al [11] have examined how metering performance is affected by the presence of rectifiers when shale gas is extracted. Lind et al. [12] used a weakly compressible assumption to apply the SPH simulation principle to incompressible flows with the free surface. The density was linked to the pressure field using an equation of state, a typical weakly compressible SPH (WCSPH) approach. Gómez-Gesteira and Dalrymple [13] used a 3D WCSPH model to simulate the effect of a dambreak flow on a tall structure. Qiao et al. [14] have studied a real-time and accurate underwater target classifier that can be created by combining Local Wavelet Acoustic Patterns (LWAPs) and multilayer perceptron (MLP) neural networks. They first improve the Whale Optimization Algorithm (WOA) and then optimize the classifier's parameters [14]. Extensive research has been done on fluid sloshing modeling. [15] Fluid sloshing modeling in a carrier tank has been performed in two ways: mechanical model (pendulum) and simulation based on the SPH method. In this research, the issue of fluid tanker overturning has been investigated. Simulation of sloshing behavior in the tank has been performed by two methods, CFD and SPH [16]. The results of the two methods are compared [17], and the SPH method is used to model fluid sloshing phenomena. The algorithm used in this method to solve Poisson and momentum pressure equations includes various subalgorithms such as core gradient correction, particle displacement algorithms, sloshing viscosity calculators, and free surface detectors. Also, the size of the baffles in the tank to reduce sloshing has been studied and evaluated. As seen in all previous research, constant volume simulations have been considered. In spatial applications, the change in fluid volume in the reservoir will lead to changes in sloshing behavior. On the other hand, different modes of movement in the tank and fluid displacement relative to the tank and its effects on the amount of force created to investigate the maximum pressure are another important point of the present study.
Furthermore, even though the SPH modeling technique is commonly used in the scientific community, few engineering implementations have been published due to its relatively high computational cost. Determining a completely accurate model of the behavior of a physical phenomenon is a challenging task. However, today, using computational expressions, especially artificial intelligence, it is possible to obtain a model close to the behavior of that phenomenon. A model is a mathematical representation of a real system that can be constructed based on various methods [18]. Given that most systems have nonlinear and complex behavior, modeling should be based on an approach based on physical mechanisms governing system behavior. The models thus obtained have a sufficient approximation of the actual process [19]. Many methods have been proposed to identify the system. Among the available methods, the artificial neural network method can be used as one of the important tools for determining to model. A combination model based on wavelet transform for predicting the natural gas based on machine learning method was studied in some papers in recent year [20,21]. Much research has been done on using simulation data to train neural networks [22]. A neural network is used to predict aerodynamic coefficients. Training data for the neural network are derived from wind tunnel test measurements and numerical simulations. A comparative study of neural network prediction performance is also presented based on different transmission functions and educational data set sizes. Peng et al. [23] have implemented a model that forecasts the natural gas load daily using long short term memories, local mean decompositions, and wavelet threshold denoising algorithms. [24] A common modeling method using machine learning based on simulation data is used. In this research, a hypothetical model is created through a simulation model, and the necessary parameters and functions for modeling are presented using an artificial neural network model (machine learning) [25]. The neural network is used to predict the parameters of a diesel engine such as braking power, output torque, brake specific fuel consumption, brake thermal efficiency, and volumetric efficiency. Input data for network training were obtained from laboratory and simulation results. Data training was based on the backpropagation algorithm. Noghrehabadi et al. (2020) have examined how different heat fluxes affect the melting behavior of phase transition materials when they are surrounded by metal foam. To do this, a two-dimensional numerical model was utilized that took into account the nonequilibrium thermal component, the non-Darcy effect, and local natural convection [26]. Liu et al. [27] used a CFD model of the blowdown valve erosion issue to study the erosion simulation and improvement strategy for the separator blowdown system. A flow field analysis program called FLUENT is used to simulate and evaluate the erosion of the blowdown valve under various pressures, sand particle size and form factor, sand particle density, and sewage sediment concentration, and the major erosion issue of the blowdown system is determined [27]. Schmid et al. [28] present the optimal machine settings in polymer processing using a simulation-based machine learning model. In this research, different supervised machine learning algorithms are compared, and the best approach in experiments on a real machine is predicted using the initial settings of the device. Behbahan et al. [29] have used a metal foam/phase change PCM combination in the study, which has been demonstrated to be one of the most promising techniques for increasing thermal conductivity on PCMs. Findings show that selecting an aspect ratio that facilitates both conduction and convection heat transfer is extremely important [29]. Peng et al. [30] have analyzed the role of computational fluid dynamic tools in studying pathogen transmission. Using CFD models, they have studied airborne pathogens [30]. In another study, using the neural network method, the behavior of sloshing in a tank containing liquid under harmonic motion, and using the coordinates of the sloshing wave curve based on the results of the SPH method, the sloshing behavior was predicted [31].
In the previous study, the sloshing behavior of the fluid was investigated based on the prediction of the fluid wave curve and the input data of the neural network included the position, speed and acceleration of the tank and the result of the neural network was the model of the sloshing wave curve. But in this new paper, sloshing behavior is considered based on changes in the physical parameters of the 2 Geofluids fluid and the tank. This paper simulates changes in parameters such as fluid volume, fluid position, tank position, and range of motion for different inputs. Then, based on the values obtained, the sloshing model is determined using the neural network method. The neural network to predict the fluid wave curve in the reservoir and other sloshing behavior based on the wave has been evaluated. Tank and fluid conditions were considered constant in the previous paper. This study was aimed at determining the fluid sloshing model in the tank based on different inputs. Changes in fluid volume, tank velocity, and tank motion amplitude can cause different results in fluid sloshing behavior. For this purpose, first, the smooth particle hydrodynamic method is used to simulate the fluid in the tank. Various states are considered based on their variable inputs, and the forces due to fluid sloshing are determined. An artificial neural network is used to model the fluid sloshing in the next step. This network is trained based on input and output data (SPH simulation results). Input data include changes in fluid volume, displacement rate, and tank velocity, and output data include the maximum force generated by fluid sloshing.

Mathematical Model.
Since the fluid is believed to be incompressible, irrational, and inviscid water, the sloshing in tanks is defined using the potential flow theory. The surface tension is ignored. As seen in Figure 1, the domain is a rigid rectangular container with and without baffle configuration that is partly filled with liquid. The free surface is believed never to get overturned or broken through the sloshing operation. The rectangular tank's length and water depths are L and h, respectively. Consider the case of a rectangular rigid tank that has been exposed to lateral sinusoidal excitation x (t) [32]. The linearized fluid field equations for a two-dimensional fluid motion, assuming a small excitation amplitude and a small fluid response, are as follows: ∂φ ∂x where z is the vertical axis direction, x is the horizontal axis direction, t denotes time, x ″ is the vector of acceleration, g represents the vector of gravity acceleration, and η is the wave height. Combining the dynamic and kinematic freesurface conditions (3) and (4) yields a single state: The total potential function is the sum of fluid perturbed function Φ, which is the solution of Laplace's Equation (1) that satisfies the boundary conditions (3 and 4) plus the tank potential function Φ 0 = −X 0 x Ω cos ðΩ tÞ. Nevertheless, the expression x must be expressed in the Fourier series: The steps for determining the velocity potential function are the same as for a tank, with the same outcome: where Ω is the excitation frequency and ω n 2 = ð2n + 1Þπg/ Ltanhðð2n + 1Þπh/LÞ is the square of the natural frequency of a fluid-free surface; replacing Equation (7) into Equation (3) yields the free-surface wave height.
The first term in Equation (8) describes a simple wave, and a set of symmetric sine waves make up the surface waves. The pressure inside the fluid domain at every point (ignoring the hydrostatic pressure, ρgz) is

Geofluids
The hydrodynamic pressure at any point on the wall The net wall pressure distribution parameter, ðΔP w /ρg x 0 Þ, is shown in Figure 2 for various values of the excitation frequency parameter, ðΩ 2 LÞ/g. A similar situation to the phase change mentioned in the previous segment can also be observed.

Analytical Results.
Infinite series describe possible expressions, and they must be shortened. Here, we conduct a convergence analysis concerning series number N. The tank's dimensions and parameters are h = 0:18, 0:28, and 0:38. The external excitation frequency is Ω = 3:116r ad/s, and the motion can be expressed as X = x 0 sin ðΩ tÞ . Figures 3, 4, and 5 display the findings of N = 10, which show that they agree. To plot pressure value based on Equation (10), the value of the parameters of the above relation is as follows: L = 1:3, h = 0:18, 0:28, and 0:38 , x 0 = 0:1.

Numerical Analysis
3.1. SPH Theory. The SPH procedure is used to numerically simulate the sloshing effect in this article. A short overview of the approach is presented below and several key implementation problems. For a more detailed summary, the reader is directed to [33]. The interpolation principle underpins the SPH system. Using a kernel function, any function can express its values at a set of disordered points representing particle positions. The kernel function is a weighting function that specifies the input of a general field vector, A ðrÞ, at a given location, r. An ðrÞ ′ s kernel estimate is defined as follows ( [12,33]. The smoothing length d defines the efficient kernel width in which r is the position of vector, V is the space for the solution, and d is the length for the smoothing. The particle approximation of the function at a particle i can be described as follows using discretization of approximation (11): where m is the mass of the particle and ρ is the density of each particle. Index i represents the central particle, and j represents each particle in the area of influence of the central particle (neighboring particle). The smooth length in this study is equal to 1/2 of the initial distance between the particles. All particles inside the kernel function's compact support region must be considered at the summation.

Geofluids
W ij = Wðr i − r j , dÞ is the weight function or kernel, and m j and ρ j denote the mass and density, respectively. One of the kernel functions used in this work is the one introduced initially by Nyugen et al. [34] as in where α d is the 10/7πd2 in 2D and q = r/d. r is the distance between two points, i and j.

Discretization of Governing Equations in SPH
Formulation. To model fluid motions, the SPH formalism is extended to the Navier Stokes equations. This method is briefly explained here. Detailed descriptions are provided by [33]. The governing equations are the continuity and Navier-Stokes equations: where v refers to the vector velocity of the particles, t denotes time, ρ denotes fluid density, p denotes the pressure, g denotes the vector of gravity acceleration, and ν refers to the viscosity of the laminar. As the actual state equation is carried out, the time stage is very small due to the finite compressibility of real fluids. Consequently, the fluid is usually considered weakly compressible in real measurement. The pressure field is calculated by solving the P = P ðρ, eÞ equation. When the fluid pressure is below 1GPa, the entropy impact on the pressure field can be neglected ( [12,33]. The density of a fluid is solely determined by its pressure. The SPH equations consist of the mass conservation equation, the energy conservation equation, and the energy conservation equation. When the pressure of the flow field is low, it is said that the fluid is barotropic, and energy does not affect the pressure field. The energy equation is still unresolved. The SPH method's kernel and particle approximation define the density equations and the momentum equation [12] as follows: where ρ is the density of each particle v refers to the vector velocity of the particles, p denotes the pressure, g denotes the vector of gravity acceleration, and smoothing length h defines the efficient kernel width in which r is the position of vector, r ij = r ir j . Besides, W is the function of the kernel, and the enhanced Gaussian kernel is selected (mentioned in Section 2.2). The subscripts i and j describe a pair of interacting particles. In the preceding simulations, the coefficient α is set to 0.03.

Weakly Compressible SPH.
The WCSPH assumes a compressible fluid with a higher sound speed, a Mach number of M~0:1, and a density variation of less than 1%. The pressure is then measured using a state equation. The most famous state equation used in SPH is of the type ( [33,34] Here, we study the accuracy of the traditional WCSPH method using the Tait equation of state: where P denotes the fluid's nominal density (1000 kg/m3), γ denotes a fixed set to 7, and c s denotes the numerical sound speed utilized in the measurement. In SPH, the sound speed is normally set to 10 times the predicted maximum velocity of the fluid ðV max Þ [12]. Since density changes with the square of the Mach number, it is likely to be about 1% of the fluid's nominal density. Therefore, the numerical sound speed is kept low enough to allow for appropriate time measures. The calculations were performed with a Reynolds number of Re = 1000 and Re = ðρ ð2gÞ 1/2 D 3/2 Þ/μ, where D is the depth of water in the tank and g = 9:81m/s2 is the gravitational acceleration.

Results and Discussion
4.1. Results of SPH Modeling. This section contains the results of the SPH simulation. In this study, Fortran code is used for the simulated model. To execute the simulation, the required parameters based on the SPH method are shown in Table 1. These values include selecting the kernel function, tank dimensions, fluid height, and more. The simulation results using the SPH method are shown in Figures 6 and 7. Figure 6 shows the pressure on the tank wall on the right and left. This sloshing behavior has been performed in response to a sinusoidal stimulus. Figure 7

Results of SPH Simulation.
A schematic representation of the fluid tank is shown in Figure 8. As can be seen, changes are intended for the four parameters. These parameters are fluid volume, fluid displacement, tank displacement, and displacement amplitude value. The fluid sloshing model is simulated for each of these parameters, and the maximum force due to the fluid sloshing is obtained. As mentioned, it is considered three modes of each parameter earlier. Parameter changes can be done more in smaller steps but will take a lot of time and volume to simulate. Therefore, by combining three modes for the four parameters, 81 modes are created and the maximum force is determined. According to the results obtained from the simulation of fluid sloshing with the SPH method, the next step will be the neural network method to model the fluid sloshing behavior. The results are shown in Table 2.

Modeling Artificial Neural Network.
As mentioned earlier, the most important part of this research is using data related to sloshing simulation in the tank for modeling. Therefore, the artificial neural network has been used to achieve a suitable model of sloshing behavior. Artificial neural networks are an alternative way to solve and predict complex problems and are used in various programs such as control, production, and optimization. [35]. The neural network is a multilayered feed-forward type with an error propagation algorithm. Multilayered feed-forward (MLFF) neural networks comprise two or more layers of neurons. The output of each layer is simply fed to the next layer, hence the name of the feed-forward networks.
MLFF neural network is a robust network used in many applications. It is easy to implement and can give good results. For approximation problems, the function as a general model has good accuracy. The training process is easy compared to the RBF network [36]. MLFF neural network is more popular than other methods due to its wide application in most issues. Compared to other methods available in neural networks, its simple structure is another reason for its use (Fung, 2005). The ability of online training to adjust network control parameters is another advantage of this method. One of the important issues in using neural networks is determining the number of neurons, which is one of the main challenges of neural networks. Many scientists have recently worked to determine the optimal number of neurons needed to build a neural network (Yotov, 2020). If the number of neurons is too much, it will over-fit, resulting in a complicated neural network and other problems in the training process. It dramatically reduces generalizability, which leads to significant deviations in forecasts.
On the other hand, an insufficient number of neurons reduces prediction accuracy. From this point of view, determining the appropriate number of hidden layer neurons to prevent over-fitting plays an essential role in approximating the function. There are several methods, but the most common are determining the appropriate and sufficient number of hidden layer neurons, cross-validation, and initial stop [37]. The available data is divided into two independent sets in these methods: an educational set and a validation or test set. Only the training set participates in neural network learning, and the test set is used to calculate the test error.

Data Collection, Normalization, and Determination of
Neurons. The data obtained from the simulation of the SPH method were performed with Fortran software, and then, the data were collected in MATLAB software. The data collection process is such that for each mode of simulation, for example, a tank with a volume of fluid with a height of 0.18 can be considered in 10 seconds. The maximum force is determined based on the generated wave. For all similar cases, this process is repeated, and finally, a set of data obtained from the simulation is used to train the neural 7 Geofluids network. One of the ways to reduce the difference between the simulation results based on the SPH method and the neural network method is to collect simulation data, which can be strengthened and improved by examining different modes of change of existing parameters.
According to the status of the measurement parameters to normalize the sloshing behavior, normalization is used to standardize the data range. Data normalization is a database design technique. This method is to uniform the range of values related to different research variables and is also known as data scaling. If the unit of measurement of the studied variables is diverse, the data can be scaled using normalization methods [31]. The following formula is used to use this technique: where X max and X min are the maximum and minimum values of X, respectively, and X n is the X normalization value.
Regarding the process of determining the neural network results based on the output layer, since the only output simulates the maximum amount of force generated by the fluid sloshing, the final layer neurons are a number. Regarding the number of hidden layer neurons, the appropriate number can be reached based on different methods. If the number of neurons is too much, it will over-fit, resulting in a complicated neural network and other problems in the training process. It dramatically reduces generalizability, which leads to significant deviations in forecasts. On the other hand, an insufficient number of neurons reduces prediction accuracy.

Neural Network Structure, Training, and Data Testing.
The neural network structure used in this study is based on the neural network shown in Figure 9. The network used is a multilayer perceptron. The data training in this network is based on the backpropagation algorithm. This algorithm is a learning method with more than one hidden layer in artificial neural networks that calculates the gradient of network weights. Wc1 is the weight connected between the input and hidden layers, and Wc2 is the weight combined between the hidden and the output layers. The activation function used here is of the sigmoid function type.
Its derivative is as follows: For network training, the data obtained from the SPH model are randomly divided into three sets: 80% for network training, 10% to confirm that the network is being generalized, and to stop training before installation, and the remaining 10% is used as a network test that is completely independent of network generalization. The ANN training process obtains the optimal values for the adjustable weights   Geofluids and bias parameters to achieve the best fit between the input-output data. This is essentially a nonlinear optimization problem, and the cost function includes minimizing  Figure 9: Schematic diagram of neural networks.   4.6. Neural Network Simulation Results. In this network, the number of hidden layer neurons is considered to be 10. Regression graphs are widely used to predict and identify the relationship between independent and dependent variables. Here, R is represented as the regression symbol. Several hidden layer neurons were assigned based on the result of network convergence and with several repetitions. Based on the regression graph, the accuracy of the data training is acceptable (Figure 11). Figure 12 shows a    comparison between actual results and network results. The application of this modeling is in control systems to evaluate and investigate the effects of fluid sloshing in fuel carrier tanks, such as spacecraft, ships, or vehicles. In artificial neural network modeling, simulation data is based on modes in motion.
The data used in the neural network, which are the actual data, are shown in Section 4.3 according to Table 2. The neural network consists of 4 inputs and one output. The results of neural network prediction are shown in Figure 12. The critical point in neural network training is to use pervasive data in this process. However, due to the conditions of numerical simulations that take a long time to implement, there is this limitation in data collection. Therefore, this training has been done with the minimum data obtained from the simulation based on the SPH method.
Given that the accuracy of neural network prediction results is acceptable, it may encounter issues such as falling in local minimums, over-fitting, or under-training. While a multilayer network with sufficient neurons can perform almost any function, training algorithms such as backpropagation algorithms may not find the optimal weights. Therefore, to find a suitable option, a neural network can be placed in the repetition of the educational process to form this problem in the best way. Neural networks used to predict loads created by fluid sloshing based on input and output data for neural network training are more accessible than other numerical methods, making them superior.

Geofluids
The actual results with the results obtained from the neural network are shown in Figure 13. As can be seen, the neural network prediction is close to the actual values and the network has acceptable accuracy. Output values and actual data are based on normalized status. Figure 14 shows the neural network results for the test data. As mentioned earlier, 10% of the simulation data is used to evaluate the performance of the neural network to predict the actual data.

Conclusion
The behavior of the fluid sloshing phenomenon was investigated in a rectangular tank. Fluid sloshing was simulated using the SPH method. Different modes were considered based on fluid volume, amount of range of motion, and fluid displacement. Based on changes in existing parameters, the maximum force on the tank wall was obtained. In the next step, the model of fluid sloshing behavior was determined using an artificial neural network. Fluid sloshing in the tank is a nonlinear phenomenon, so one of the tools that can help predict its behavior is the use of artificial neural networks. The main and important reason for us to use this approach is to achieve a predictive block because we want to couple in the next step with a dynamic case. Extensive research in the field of fluid sloshing in the tank usually uses mechanical models equivalent to mass-spring or pendulum. This data plays an important role in neural network training. The obtained data have the ability to determine the appropriate results in exchange for changing various parameters. Limitations in simulating fluid sloshing in the tank and coupling all data to the dynamic system have led to the use of the neural network as a predictive block to apply force and load to the system. Simulation data were used to train the neural network. In this process, the network input consisted of 4 parameters and the output of one parameter. The purpose of fluid sloshing modeling using neural networks is to achieve an alternative model instead of mechanical equivalent models such as the mass-spring or pendulum models. This model can be used in control systems and induce the effects of fluid sloshing in liquid carrier tanks to the dynamic system.

Data Availability
Data is available and can be provided over the emails querying directly to the corresponding author (hosseinchegini@ phd.guilan.ac.ir).  Geofluids