Open Advanced Search
Get 20M+ Full-Text Papers For Less Than $1.50/day.
Start a 14-Day Trial for You or Your Team.
Learn More →
Towards real-time fluid dynamics simulation: a data-driven NN-MPS method and its implementation
Towards real-time fluid dynamics simulation: a data-driven NN-MPS method and its implementation
Yao, Qinghe; Wang, Zhuolin; Zhang, Yi; Li, Zijie; Jiang, Junyang
MATHEMATICAL AND COMPUTER MODELLING OF DYNAMICAL SYSTEMS 2023, VOL. 29, NO. 1, 95–115 https://doi.org/10.1080/13873954.2023.2184835 Towards real-time fluid dynamics simulation: a data-driven NN-MPS method and its implementation Qinghe Yao, Zhuolin Wang, Yi Zhang, Zijie Li and Junyang Jiang Sun Yat-Sen University, School of Aeronautics and Astronautics, Shenzhen, China ABSTRACT ARTICLE HISTORY Received 18 July 2022 In this work, we construct a data-driven model to address the Accepted 21 February 2023 computing performance problem of the moving particle semi- implicit method by combining the physics intuition of the method KEYWORDS with a machine-learning algorithm. A fully connected artificial Data-driven; Lagrangian neural network is implemented to solve the pressure Poisson equa- particle method; edge tion, which is reformulated as a regression problem. We design computing context-based feature vectors for particle-based on the Poisson equation. The neural network maintains the original particle meth- od’s accuracy and stability, while drastically accelerates the pres- sure calculation. It is very suitable for GPU parallelization, edge computing scenarios and real-time simulations. 1. Introduction The moving particle semi-implicit (MPS) method, initially proposed by Koshizuka and Oka , was developed to solve the Navier–Stokes equations in the Lagrangian framework for incompressible viscous flows. It is essentially a fractional step method that consists of the split of each time step into two steps of prediction and the correction. The MPS method improves the accuracy and stability of the pressure calculation compared to many other particle methods that calculate pressure explicitly, like the smooth particle hydrodynamics (SPH) . Giving the stability of the pressure calculation and the convenience of dealing with free-surface boundary conditions, MPS are widely implemented to address problems like haemodynamics simulations , large-scale simulations on geographical phenomena  and analysis on material processing . However, accuracy comes at the cost of computational resources and time. In the MPS scheme, the pressure of the next frame is derived from solving the pressure Poisson equation. The preconditioned conjugate gra- dient (PCG) method or the incomplete Cholesky conjugate gradient (ICCG) method is usually used to solve the discrete pressure Poisson equation and requires enormous computational resources as the number of particles is large. This is also discussed in . Generally speaking, these iterative methods are not suitable for the GPU parallelization. Hence, large-scale simulations using MPS are difficult without high-performance CPU clusters; it prohibits MPS from being widely employed as a desktop tool for engineers. A modified method, the explicit MPS method , has been proposed to make the solving CONTACT Qinghe Yao firstname.lastname@example.org School of Aeronautics and Astronautics, Sun Yat-Sen University, Shenzhen, China © 2023 The Author(s). Published by Informa UK Limited, trading as Taylor & Francis Group. This is an Open Access article distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/ licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. 96 Q. YAO ET AL. process more suitable for the GPU parallelization and to reduce the computational cost. It calculates the pressure explicitly; the calculation of each particle is independent and, thus, can be carried out on different threads simultaneously. However, the explicit calculation mode is susceptible to the time step value and is less stable compared to the implicit mode. With excellent computing power (especially in GPU) and sophisticated AI hardware technologies, data-driven methods are now gaining more and more attention. In areas like computer vision, natural language processing and machine learning, they have been proven to be very effective. Apart from these well-known implementations, machine learning can also be employed to address the physics problem. Many data-driven models are used in fluid dynamics where most of them manage to reduce the computational cost. A common idea is the model reduction techniques, for example see [8–12]. They project the Navier–Stokes equations into the low-dimensional space. With a decrease in the representation completeness, they can bring considerable speed-up to the problem. For Lagrangian particle fluid simulations, the random forest technique  is implemented to predict each particle’s acceleration with a context-based feature vector as the input. It does not require an iterative solver and attains a real-time calculation speed. In , an efficient and lightweight cheap neural network architecture is used to predict fluid dynamics and to generate realistic animations. In , the physics-informed neural network (PINN) is used for the neural particle method. For Eulerian grid-based simulations, neural networks  and convolutional neural networks  have been implemented to replace traditional pressure projection methods. These data-driven methods significantly reduce the compu- tational cost, produce a realistic fluid-like effect and shed light on building high-fidelity data-driven models for fluid simulations. We are interested in gaining the physics intuition from MPS such that the constructed data-driven model can accelerate the calculation, save computational resources, and generate reliable results for engineering problems. In this paper, we employ an artificial neural network (NN) to address the computa- tional cost problem in the original MPS method. We reformulate the pressure Poisson equation as a regression problem depending on the context-based feature vector we designed. The training data are generated using the original MPS method with a conjugate gradient (CG) solver. The MPS method with a neural network (NN-MPS) we proposed can significantly improve the efficiency of the pressure calculation as it is free of iterations used, for example, in the CG method. Also, the calculation of each particle is independent; the computation can be easily parallelized. We compare the performance of NN-MPS and MPS using a dam collapse problem with experimental results from Martin and Moyce , which demonstrates the accuracy of NN-MPS. We also test NN-MPS on several other scenes. These results show that NN-MPS has a robust performance and can significantly improve the calculation speed. At the same time, we also deploy NN-MPS on edge computing devices with AI chips to verify the possibility of achieving higher performance on AI devices and to demonstrate its potential for real-time applications. 2. Moving particle semi-implicit method 2.1. Governing equation In the MPS scheme, the governing equations for incompressible viscous flow simulations are the continuity and the Navier–Stokes equations: MATHEMATICAL AND COMPUTER MODELLING OF DYNAMICAL SYSTEMS 97 Dρ ¼ 0; Dt Du ∇p ¼ þ ν∇ uþ g; Dt ρ where is the material derivative for time, u is velocity, g is the external body force per Dt unit mass, ρ and ν are the density and kinematic viscosity, respectively. 2.2. Kernel function and particle number density The kernel function describes how a particle interacts with others in its vicinity. In this work, we adopt the same kernel function from the original MPS method, see . The radius of the interaction area is determined by the parameter r , 1; ð0 � r< r Þ wðrÞ ¼ : 0 ðr � rÞ Particle number density at coordinate r , where the particle i is located, is defined by N ¼ wðjr r jÞ: i j i j� i If the incompressible condition is satisfied, the particle number density should be constant N . 2.3. Discrete differential operators A gradient vector between two particles i and j having scalar quantities ϕ and ϕ at i j coordinates r and r is defined  as i j " # ϕ minðϕÞ j i h∇ϕi ¼ ðr r Þwðjr r jÞ ; j i j i i 2 jr r j j i j� i where d is the dimension of the space, minðϕÞ denotes the minimum value of a scalar quantity ϕ among the neighbouring particles of particle i. Similarly, a divergence scalar quantity between two particles i and j having vector ~ ~ quantities ϕ and ϕ at coordinates r and r can be defined as i j i j " # D E ~ ~ ϕ ϕ j i ∇� ϕ ¼ ðr r Þwðjr r jÞ : j i j i i N jr r j j i j� i The Laplacian model is derived from solving a diffusion equation, i.e. � � 2d ∇ ϕ ¼ ðϕ ϕÞwðjr r jÞ; j i j i i 0 N λ j� i where the normalization parameter λ is given by 98 Q. YAO ET AL. wðrÞr dv λ ¼ ; wðrÞdv where V denotes the neighbourhood of particle i. 2.4. Boundary condition and searching neighbour particles In the MPS method, dynamic boundary conditions are imposed to deal with the free- surface. The particle number density is smaller for particles in the vicinity of free-surface because their neighbourhoods include empty air regions. Particles satisfying the follow- ing criteria are considered as on the free-surface. � 0 N < βN ; where β in this work is selected to be β ¼ 0:97. In the pressure calculation, the dynamic free-surface condition is satisfied by setting the pressure of free-surface particles to be zero, which equals the atmospheric pressure. For the wall boundary condition, as shown in Figure 1, two layers of wall particles are placed along the solid boundary, surrounded by two layers of ghost particles. For the pressure calculation, the wall particles are used; they interact with nearby fluid particles, while their positions keep stationary. The ghost particles are only taken into considera- tion for calculating the particle number density to avoid that wall particles are identified to free-surface particles. Many steps of the MPS method requires neighbour particles searching. Three search- ing techniques are commonly used in particle methods. They are the linear scanning, the linked-list searching , and the tree searching . In this work, we use the linked-list searching technique. The linked-list searching places a temporary grid on the calculation region, and particles are assigned to different cells. Particles in the same or adjacent cells are considered. Figure 1. The arrangement of particles near the wall. MATHEMATICAL AND COMPUTER MODELLING OF DYNAMICAL SYSTEMS 99 2.5. Velocity update scheme The MPS method is a predictor-corrector method for the velocity, which includes three main steps . Firstly, it transits particles using viscosity force, body forces, and applies then collision detection. � n 2 n u ¼u þðν∇ u þgÞΔt; i i � n � r ¼r þ u : i i i Secondly, it calculates the source term and the coefficient matrix using the temporary � � location r and the temporary velocity u and solves the pressure Poisson equation. We i i use the modified source term from Lee et al. , 0 � ρ ρ N N 2 nþ1 � i ∇ p ¼ ð1 γÞ ∇� u þ γ ; i i 2 0 Δt Δt N � � where u denotes the temporary velocity of particle i, N is the temporary particle i i number density of particle i, γ is a blending parameter ranging from 0.0 to 1.0. Based on our numerical tests, we set γ ¼ 0:2. nþ1 � Finally, it uses the predicted pressure p to update the temporary velocity u and temporary location r , i.e. Δt nþ1 � nþ1 u ¼ u ∇p ; i i i nþ1 � � nþ1 r ¼ r þ ðu þ u ÞΔt: i i i i 3. A data driven pressure model 3.1. Modelling of incompressibility using a data-driven pressure projection In the MPS method, the calculation of pressure uses the continuity equation and the � 0 method keeps the particle number density N to be constant N . The discrete Poisson equation of pressure for particle i is ( ) � � 0 0 � 1 N λ ρ ρ N N � i p ¼ p wðjr r jÞ ð1 γÞ ∇� u þ γ : i j j j � 2 0 N 2d Δt Δt N j� i Since it is based on the interaction between the particle and it neighbour particles, it has to be solved globally (simultaneously for all particles), which brings challenges to the parallelization. Also, for large-scale problems, solving large sparse systems can be expen- sive. To address this problem, we design a data-driven model to efficiently carry out the pressure calculation while maintaining the robustness and stability. We reformulate the pressure projection step as a data-driven regression problem. The machine learning model used in this work is the neural network. However, it relies on the initialization of weight parameters, and many of its mechanism is still not so well understood. Yet, its capability of extracting, transforming low-level features and fitting nonlinear function makes it an excellent choice to serve as a regressor. 100 Q. YAO ET AL. To ensure the robustness and accuracy of the neural network, choosing an appropriate representation for the model’s input is very important. In traditional data-driven model- ling problems, techniques like principle components analysis (PCA) are implemented to derive representative feature of the input data. Since the issue addressed here is physics- informed, the construction of the feature vector can be referred to the original MPS method. In the pressure Poisson equation, we have " # 0 � X X 2d ρ ρ N N � i ðp wðjr r jÞÞ