IISPH fluid simulation calculation method based on lstm neural network
By using the IISPH fluid simulation method based on LSTM neural network, the pressure acceleration of particles in the next frame can be directly predicted, which solves the problem of low efficiency in pressure acceleration calculation in the existing technology, and realizes high efficiency and accuracy in fluid simulation. It is suitable for real-time fluid simulation in games and film special effects.
Patent Information
- Application Number
- CN202210641076.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-08
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-06-08
AI Technical Summary
Existing fluid simulation methods suffer from low efficiency in solving pressure acceleration while ensuring fluid incompressibility, resulting in complex and time-consuming calculations, especially in large-scale simulations where the simulation time increases exponentially.
The IISPH fluid simulation calculation method based on LSTM neural network is adopted. By constructing a training set and building an LSTM neural network regression model, the pressure acceleration of particles in the next frame can be directly predicted, replacing the pressure term solution module in the traditional method and simplifying the calculation process.
While ensuring fluid incompressibility and accuracy, it significantly improves calculation speed and reduces computational resource consumption, achieving high efficiency and accuracy in fluid simulation. It is suitable for small-scale fluid simulation to achieve real-time simulation effects.
Smart Images

Figure CN114896913B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of IISPH fluid simulation calculation, and particularly relates to an IISPH fluid simulation calculation method based on an LSTM neural network. BACKGROUND
[0002] Fluid simulation has always been a popular research topic in computer graphics. How to simulate fluid effects realistically and efficiently, simulation methods based on physical models have been proposed. Among them, the methods basically used at home and abroad are the Euler method based on grid and the Lagrangian method. Compared with the Euler method, the Lagrangian method has more advantages in the treatment of fluid details, and therefore is widely used.
[0003] Smoothed Particle Hydrodynamics (SPH) is the most widely used fluid simulation method in the Lagrangian method. Because the SPH method has many shortcomings, many improved methods have appeared. The Weakly Compressible SPH (WCSPH) method well solves the incompressibility problem of the traditional SPH method, but needs a smaller time step to maintain the stability of the simulation. The Predictive Corrective Incompressible SPH (PCISPH) method has a longer time step and more stable numerical solution than the WCSPH method. The Local Poisson SPH (LPSPH) method reduces the time for solving the Poisson equation to improve the computational efficiency of each frame according to the large density error of WCSPH and the large time-consuming of global solution of Poisson equation of PCISPH. The Implicit Incompressible SPH (IISPH) method can effectively improve the time step in large scenes by discretizing the pressure Poisson equation. The Divergence-Free SPH (DFSPH) method adjusts the density twice using pressure to make the fluid incompressible.
[0004] In the above fluid simulation methods, in order to ensure the incompressibility of the fluid, the solution of the pressure acceleration in a single time step does not effectively improve the low computational efficiency, but rather makes the calculation process more complex and time-consuming. When simulating hundreds of millions of particles in a large scene, the simulation time increases geometrically. SUMMARY
[0005] In view of the above deficiencies in the prior art, the application provides an IISPH fluid simulation calculation method based on an LSTM neural network, which can effectively solve the problem of low efficiency of pressure acceleration solving in the prior art while ensuring high accuracy of incompressible fluid calculation results.
[0006] In order to achieve the above object, the technical scheme adopted by the application is:
[0007] The application provides an IISPH fluid simulation calculation method based on an LSTM neural network, comprising the following steps:
[0008] S1, defining a particle scene file, and outputting attribute values of particles in a certain frame of fluid by using an IISPH fluid simulation method;
[0009] S2, constructing a training set by using the particle attribute values;
[0010] S3, building an LSTM neural network regression model, learning fluid simulation by using the training set, and training the LSTM neural network regression model;
[0011] S4, replacing the original particle pressure acceleration solving module by using the trained LSTM neural network regression model, and calculating the velocity and position of the next frame of particles to perform continuous fluid simulation.
[0012] Further, the step S2 comprises the following steps:
[0013] S201, setting a maximum threshold of the number of field particles within a smooth kernel radius, and supplementing 0 to positions with insufficient number, so that each attribute value of the particles is constructed into a fixed-length feature vector;
[0014] S202, constructing a training set by using the feature vector.
[0015] Further, the expression of the feature vector is:
[0016]
[0017] Wherein, β i represents the feature vector at , x i represents the position of the particle i, x j represents the position of the particle j, represents the input pressure of the particle i, represents the input pressure of the particle j, represents the intermediate density of the particle, ρ i represents the density of the particle i, ρ j represents the density of the particle j, is the position of the particle.
[0018] Further, the expression of the LSTM neural network regression model in step S3 is:
[0019]
[0020] wherein, represents the pressure acceleration of the i th particle in a frame, Reg(·) represents the LSTM neural network regression model, β i represents the feature vector of the particle i
[0021] Further, the expression of the velocity and position of the next frame of the particle in step S4 is:
[0022]
[0023]
[0024]
[0025] wherein, v i (t) represents the velocity of the i th particle in the current frame, v i (t+Δt) represents the velocity of the i th particle in the next frame, Δt represents the time step between two frames, represents the intermediate velocity of the particle, represents the pressure acceleration of the i th particle in a frame, x i (t+Δt) represents the position of the i th particle in the next frame, x i (t) represents the position of the i th particle in the current frame.
[0026] The beneficial effects of the present application are:
[0027] (1) According to the present application, the properties of each particle in a frame output in the IISPH first fluid simulation process are used as a training set, the training set includes the position, density, intermediate density and input pressure of the current particle and the particles within the smooth kernel radius, the correlation of the multivariate data is processed by using the LSTM neural network regression model, the relationship between the input properties of the particles and the output pressure acceleration is fully extracted, the calculation speed is effectively improved under the condition of ensuring the incompressibility of the fluid and the accuracy of the pressure acceleration, the pressure acceleration is directly solved without calculating the pressure received by the current particle, the velocity and position of the next frame of the particle are calculated, the calculation resources consumed are reduced, and the accuracy of the model prediction is effectively improved.
[0028] (2) the application can improve the calculation efficiency of fluid simulation in a single time step, the original method needs to traverse all current particles for each iteration calculation, and the calculation consumption increases with the increase of the number of iterations, the regression model in the application only needs to traverse all current particles once to complete the calculation of the pressure term and update the particle properties. Meanwhile, the application updates the particle position to perform the next frame of fluid simulation. BRIEF DESCRIPTION OF DRAWINGS
[0029] Figure 1 The method flowchart of the application.
[0030] Figure 2 The LSTM neural network regression model structure diagram in the embodiment.
[0031] Figure 3 The liquid simulation effect diagram in the embodiment. DETAILED DESCRIPTION
[0032] The specific embodiments of the application are described below to facilitate those skilled in the art to understand the application, but it should be clear that the application is not limited to the scope of the specific embodiments, and for those skilled in the art, it is obvious that various changes are within the spirit and scope of the application defined and determined by the appended claims, and all applications utilizing the concept of the application are within the scope of protection.
[0033] EMBODIMENT
[0034] As shown in the drawings, the application provides an IISPH fluid simulation calculation method based on LSTM neural network, and the implementation method is as follows: Figure 1
[0035] S1, define a particle scene file, and output the attribute value of a particle in a certain frame of fluid by using the IISPH fluid simulation method;
[0036] In the IISPH algorithm, the particle velocity at t+Δt can be expressed as:
[0037]
[0038] Where, v i (t+Δt) represents the velocity of the next frame of particle i, Δt represents the time step between frames, m i represents the mass of particle i, F i adv (t) represents other forces except pressure, such as gravity, viscosity, etc., F i p (t) represents the pressure to be calculated. Similar to PCISPH, LPSPH and other methods, the IISPH method first calculates the pressure according to other forces Fi adv (t) update the velocity, compute an intermediate velocity:
[0039]
[0040] where v i (t) denotes the velocity of particle i in the current frame.
[0041] Based on the continuity equation, the rate of change of density can be expressed as:
[0042]
[0043] where, denotes the divergence of particle velocity, denotes the change of density of particle i over time, p i denotes the density of particle i, p i (t+Δt) denotes the density of particle i in the next frame, p i (t) denotes the density of particle i in the current frame.
[0044] Its calculation formula is:
[0045]
[0046] where, denotes the smoothing kernel function, v ij (t+Δt) = v i (t+Δt) - v j (t+Δt) is expressed as the relative velocity between particle i and particle j, which depends on the pressure F i p (t) at time t. Substitute equation (4) into equation (3) to obtain an intermediate density
[0047]
[0048] For incompressible fluid, its density should be maintained at the static density p0, so p i (t+Δt) = p0. After obtaining the intermediate density, all the density increments in the later stage are caused by the pressure, so the rate of change of the intermediate density and the density of the next time step is:
[0049]
[0050]
[0051] where, denotes the particle pressure acceleration, denotes the pressure acceleration of the neighboring particle j.
[0052] where the pressure acceleration is calculated by
[0053]
[0054] Substituting equation (8) into equation (6) gives a linear equation system:
[0055]
[0056] The particle pressure p i (t) is solved by using the relaxation Jacobi iteration:
[0057]
[0058] where l denotes the iteration number, ω is the relaxation coefficient, A ij is calculated by
[0059]
[0060] According to the above formula calculation, the steps of the existing IISPH method are summarized as follows:
[0061] 1) Prediction
[0062] Traverse all particles:
[0063] a. Calculate the density p i (t) at time t;
[0064] b. Calculate the intermediate velocity
[0065] Traverse all particles:
[0066] a. Calculate the intermediate density according to the intermediate velocity
[0067] b. Initialize the pressure at time t as half of the pressure at the previous time step t-Δt;
[0068] c. Calculate the parameter A ii .
[0069] 2) Pressure solution
[0070] a. Initialize the iteration number l = 0;
[0071] b. Iteratively execute until the density error is less than the specified threshold;
[0072] Traverse all particles
[0073] a. Calculate pressure
[0074] b. Update pressure value
[0075] c. Iteration number l+1.
[0076] 3) Update position
[0077] Update the velocity and position at the next time t+Δt.
[0078] The density and external force of the particle can be calculated by a smoothing kernel function:
[0079]
[0080] where A j represents a physical quantity that needs to be accumulated (such as density, viscosity, pressure), m j and ρ j are the mass and density of the particles within the smoothing kernel radius h, is the position of the particle, is a suitable smoothing kernel function that can be selected.
[0081] S2, construct a training set using the particle attribute values, the implementation method is as follows:
[0082] S201, set a maximum threshold for the number of particles in the neighborhood within the smoothing kernel radius, and supplement 0 to the positions with insufficient number, so that the attribute values of the particles are constructed into a fixed-length feature vector;
[0083] S202, construct a training set using the feature vector.
[0084] In this embodiment, for the calculation process in step one, the attribute values of a particle in a frame can be calculated, based on the values of the numerical solvers in the IISPH method, the present application randomly selects different scenes in fluid simulation, each scene includes some water and some collidable objects including spheres, cuboids, statues, etc., a total of more than 100 frames of data are selected, and a quarter of the number of particles in each frame of data is randomly selected to ensure the generalization ability of the neural network.
[0085] These attribute values are constructed into a fixed-length feature vector as the input training set of the neural network in the present application. To ensure the consistency of the length of the feature vector, the present application sets that the number of particles in the neighborhood within the smoothing kernel radius is at most 50, and 0 is supplemented to the positions with insufficient number. The input features include: position x, density ρ, intermediate density ρ adv , input pressure The output feature is pressure acceleration a p , and the feature vector β at the final point isi is:
[0086]
[0087] wherein, β i represents the eigenvector at , x i represents the position of particle i, x j represents the position of particle j, represents the input pressure of particle i, represents the input pressure of particle j, represents the intermediate density of particle, ρ i represents the density of particle i, ρ j represents the density of particle j.
[0088] The eigenvector can accurately predict the state of the next frame of particles in subsequent work, calculate the acceleration, and perform continuous fluid simulation.
[0089] S3, build an LSTM neural network regression model, and learn fluid simulation by using the training set to train the LSTM neural network regression model;
[0090] In this embodiment, the LSTM neural network regression model comprises: an input layer, a hidden layer and an output layer. The input layer and the output layer are only one layer, and the hidden layer is two layers. The number of neurons of the input layer is consistent with the input eigenvector, the number of neurons of the hidden layer is 256, 128 and 32 respectively, the number of neurons of the output layer is 1, representing the output pressure acceleration, and the neurons of each layer are connected to each other.
[0091] The training process is forward propagation, and the formula is as follows:
[0092] f t = σ (W f · [h t-1 , x t ] + b f )
[0093] i t = σ (W i · [h t-1 , x t ] + b i )
[0094] C′ t = tanh (W c · [h t-1 , x t ] + b c )
[0095] C t = C t-1 · ft +i t ·C′ t
[0096] o t =σ(W o ·[h t-1 ,x t ]+b o )
[0097] h t =o t ·tanh(C t )
[0098] Among them, f t This is represented as the output of the forget gate. The forget gate stores the output h from the previous time point. t-1 and the input x at the current time point t f is obtained through the sigmoid activation function. t The process; i t and C' t This is represented as input gate output. The input gate has the same structure as the forget gate, uses the sigmoid activation function, and outputs C′. t The first part indicates how much input information is retained at the current time point; the second part involves processing the input information using the tanh function, with the output being C′. t C t This represents the cell state update in the network structure; h t Represented as the output gate, the output gate determines the degree to which the cell state at the current moment is filtered. It initially has the same structure as the input gate, and then uses the sigmoid activation function to calculate the output filtering probability o. t Then cell state C t Activate using the tanh function, and finally use o. t The filter activation result yields the current output h. t Cellular state C of LSTM t Slow change indicates long-term memory; h t Rapid changes indicate short-term memory. W in each layer... f b f W i b i W c b c W o b o All weights are shared within the layer. This network uses mean squared error (MSE) as the loss function:
[0099]
[0100] Wherein, y represents the output value, n is the sample number.
[0101] In the learning stage, the purpose of the present application is to establish an LSTM neural network regression model, which can use the feature vector to predict the pressure acceleration of each particle in the next frame. Through the feature vector, the present application can formulate the regression problem as:
[0102]
[0103] Wherein, represents the pressure acceleration of the i-th particle in a certain frame, Reg(·) represents the LSTM neural network regression model, β i represents the feature vector of particle i, which is calculated by The velocity and position of the particle in the next frame can be calculated as:
[0104]
[0105]
[0106] Wherein, v i (t) represents the velocity of particle i in the current frame, v i (t+Δt) represents the velocity of particle i in the next frame, Δt represents the time step between two frames, represents the intermediate velocity of the particle, represents the pressure acceleration of the i-th particle in a certain frame, x i (t+Δt) represents the position of particle i in the next frame, x i (t) represents the position of particle i in the current frame.
[0107] In this embodiment, the method can directly learn the calculation method of the pressure term solver in IISPH, and directly calculate the pressure acceleration according to the current state of the particle.
[0108] S4, replace the original particle pressure acceleration solver module with the trained LSTM neural network regression model, and calculate the velocity and position of the particle in the next frame to perform continuous fluid simulation.
[0109] In this embodiment, the original pressure solving term is replaced, and the neural network model is used to calculate the input particle attribute values, including the positions, densities, intermediate densities and input pressures of the current particle and the particles within the smoothing kernel radius, and the output is the pressure acceleration. The velocity and position of the current particle in the next frame are calculated according to formula (13) and formula (14) to perform continuous fluid simulation.
[0110] The method is aimed at the problem of large calculation overhead and long time consumption in a single time step in the traditional method, adopts deep learning neural network regression learning IISPH method in fluid simulation, and is used to replace the calculation of the pressure term in the traditional model as a new data driver, so that the time required for calculation is reduced under the condition of ensuring data accuracy, and the purpose of real-time simulation can be achieved for small-scale fluid simulation.
[0111] The application can be applied to game scenes and film special effects, and with the improvement of computer performance, various large games emerge in an endless stream, how to simulate realistic fluid special effects in real time has become a hot spot in the field. Due to the fine details of fluid in the traditional method, the overall calculation is time-consuming and inefficient, which cannot meet the real-time generation of game development and film special effects. In view of the existing problems, the application proposes a neural network regression method according to the fitting effect of the neural network, replaces the construction of complex nonlinear relationship in the IISPH method steps, and can efficiently improve the overall efficiency of fluid simulation under the condition of ensuring accurate calculation. The specific method is as follows:
[0112] A1, define a particle game scene file, and output the attribute value of a particle in a certain frame of fluid in the game scene by using the IISPH fluid simulation method;
[0113] A2, construct a training set by using the particle attribute value;
[0114] A3, build an LSTM neural network regression model, and learn fluid simulation by using the training set, and train the LSTM neural network regression model;
[0115] A4, replace the original particle pressure acceleration solving module by using the trained LSTM neural network regression model, and calculate the velocity and position of the next frame of particles to perform continuous fluid simulation.
[0116] By replacing the solution of the pressure term in the original method, the neural network can be used to predict the pressure acceleration of the particle, so as to calculate the velocity and position of the next frame of particles, reduce the time consumed for calculation, finally form a complete fluid animation, realize high-quality real-time fluid simulation, and thus bring better game experience and film viewing experience to users.
Claims
1. A method for IISPH fluid simulation calculation based on LSTM neural network, characterized in that, Includes the following steps: S1. Define the particle scene file and use the IISPH fluid simulation method to output the attribute values of particles in a certain frame of fluid. S2. Construct a training set using particle attribute values, specifically as follows: S201. Set a maximum threshold for the number of particles in the radius of the smooth kernel, and pad the positions with insufficient number with 0, so that the attribute values of each particle are constructed as a feature vector of fixed length. S202. Construct a training set using the feature vectors; the training set includes the position, density, intermediate density, and input pressure of the current particle and particles within the radius of the surrounding smooth kernel. ,in, Indicates the input pressure. This indicates the time step between two frames. t Indicates time, express t - The pressure of time; S3. Build an LSTM neural network regression model and use the training set to learn fluid simulation to train the LSTM neural network regression model. The expression for the LSTM neural network regression model is: in, Indicates the first [frame] in a certain frame Pressure acceleration of individual particles This represents an LSTM neural network regression model. Represents particles eigenvectors; S4. Replace the original particle pressure acceleration solution module with the trained LSTM neural network regression model, and calculate the particle velocity and position in the next frame to perform continuous fluid simulation.
2. The IISPH fluid simulation calculation method based on LSTM neural network according to claim 1, characterized in that, The expression for the feature vector is: in, Indicates in The feature vector at that location, Represents particles Location, Represents particles Location, Represents particles Input pressure, Represents particles Input pressure, This represents the intermediate density of the particles. Represents particles density, Represents particles density, It is the position of the particle.
3. The IISPH fluid simulation calculation method based on LSTM neural network according to claim 1, characterized in that, The expression for the particle's velocity and position in the next frame in step S4 is as follows: in, Indicates the particles of the current frame speed, Indicates particles in the next frame speed, This indicates the time step between two frames. This represents the intermediate velocity of the particle. Indicates the first [frame] in a certain frame Pressure acceleration of individual particles Indicates particles in the next frame Location, Indicates particles in the current frame The location.
Citation Information
Patent Citations
Server performance prediction method based on particle swarm optimization nerve network
CN103164742A
Fluid simulation data prediction model based on LSTM
CN112182954A
Graph neural network simulation method and system for fluid simulation
CN114580252A