Big Theta Θ

Particle-Based Fluid Simulation


Fluid simulation is a popular topic in computer graphics that uses computational fluid dynamics to generate realistic animations of fluids such as water and smoke. Most of these simulation techniques are simply numerical approximations of the Navier-Stokes equations, which describe the motion of fluids.

There are two primary approaches when numerically approximating the Navier-Stokes equations (or any problem involving flow fields): Lagrangian, or so-called “particle-based” methods, and Eulerian, or “grid-based” methods. Taking a Lagrangian perspective, we observe an individual discretized fluid parcel as it moves through space and time. Contrastingly, Eulerian solvers focus on the motion of a fluid through specific locations in space as time passes. One can think of modeling these Lagrangian parcels as particles and these Eulerian fixed locations in space as grid cells.

Though both Lagrangian and Eulerian solvers are widely used in computer graphics and computational fluid dynamics to great effect, a notable property of particle-based solvers is that they are generally not as spatially restricted since they do not rely entirely on an underlying Eulerian simulation grid. This, as well as their comparative ease of implementation, makes Lagrangian solvers uniquely well suited for applications such as video games, which often involve large, dynamic environments.

One of the most popular methods for the simulation of particle-based fluids is Smoothed Particle Hydrodynamics (SPH), first developed by Gingold and Monaghan in 1977 for astrophysics simulations. Müller first applied this same technique to real-time fluid simulation for games, and SPH has since grown into the method of choice for simulators with applications in engineering, disaster prevention, high-fidelity computer animation, and, of course, video games and other real-time effects.

The Equations of Fluid Motion

Before discussing the Smoothed Particle Dynamics formulation of the Navier-Stokes equations in depth, it is necessary to build some amount of intuition by means of a derivation from more basic physics. I suggest a strong knowledge of multi-variable calculus, and a working familiarity with differential equations.

The Navier-Stokes equations are given by:

subject to the incompressibility constraint

where is the density of the fluid, is the velocity vector field, is the pressure, and is a vector of external forces (e.g. gravity).

A Brief Derivation…

This can easily be understood from a more reasonable foundation of Newtonian physics using the continuity of mass, momentum, and energy. First, recall the definition of the material or Lagrangian derivative, which, as opposed to the Eulerian derivative with respect to a fixed position in space, quantifies the change in a field following a moving parcel. The material derivative is defined as the nonlinear operator

where is the flow velocity.

Recall the time-dependent classical relation between force and acceleration . Applying the material derivative, we have

Which we can then expand to the forces acting on a particle

noting that the discretization of density limits to mass as

where the volume is approaching the size of the domain.

The contribution of the fluid to the total force on each particle is modeled in two parts: pressure and viscosity, with again representing any external force such as gravity. Modeling the force contribution of pressure as the gradient of the pressures, and the force contribution of viscosity proportional to the divergence of the gradient of the velocity field, we have

We wish to model incompressible fluids, or fluids in which the material density is constant within each infinitesimal volume that moves with the flow velocity. Examples of incompressible fluids include liquids such as water, which are of great interest in computer graphics and physics simulation.

Following from this statement, we constrain the volume change of any arbitrary “chunk” of fluid , motivated by the conservation of mass

This volume change can be measured by integrating the normal component of the fluid velocity field along the boundary of our “chunk”:

Gauss’ Theorem gives

While a formal derivation of the incompressible Navier-Stokes equations is much more involved, this should help to motivate some physical understanding of their origins and validity. Further reading could help show the fundamentals of pressure and viscosity forces, which can be better understood from the stress in the system (see the Stokes hypothesis or Cauchy’s equation of motion).

Smoothed Particle Hydrodynamics

The basic idea of SPH is derived from the integral interpolation, similar to Kernel Density Estimation. In essence, SPH is a discretization of the fluid into discrete elements, particles, over which properties are “smoothed” by a kernel function. This means that neighboring particles within the smoothing radius affect the properties of a given particle, such as pressure and density contributions—a surprisingly intuitive way of thinking about fluid dynamics simulation.

This cornerstone kernel function gives the approximation of any quantity at a point

where and are the mass and density of the jth particle, respectively, and is a radially symmetric smoothing kernel with length having the following properties:

Note that we are summing over all other particles . Applying this to the above discussed Navier-Stokes equations, we first must determine a way to define the fluid density based upon neighboring particles, though this follows trivially from the previous approximation, substituting for the arbitrary quantity

Due to the linearity of the derivative , the spatial derivtive (gradient) of any quantity can be easily obtained as follows

The same is true for the Laplacian

SPH and Navier-Stokes

Following from the previous discussion of the Navier-Stokes equations, it is evident that the sum of the force density fields on the right hand side of the equation (pressure, viscosity, and external) give the change in momentum of the particles on the left hand side. From this change in momentum, we can compute the acceleration of particle

We are therefore interested in approximating the force terms of the Navier-Stokes equations for pressure and viscosity with SPH as follows

The pressure at a particle is calculated using some equation of state relating density to a defined rest density, usually the Tait equation or the ideal gas equation, such as

where is the rest density and is some defined gas constant dependent on the temperature of the system.

Note that these formulations can change between different methodologies of implementation and more advanced techniques. For example, the direct application of SPH to the pressure term gives

which is not symmetric. Consider the case of two particles, wherein particle would use the pressure only of particle to compute its pressure force and vice versa. The pressures at two particle locations are not equal in general, therefore the force is not symmetric. The above SPH pressure force equation uses what has become a canonical symmetrization (weighted sum). In Müller’s original paper, for reference, the symmetrization is performed using an arithmetic mean

This again has to be addressed in the viscosity term, which naively yields the asymmetric relation

This is addressed using velocity differences as a natural approach due to the viscosity force’s dependence only on velocity differences and not absolute velocity which can be thought of as looking at the neighbors of particle from ’s own moving frame of reference.

Surface Tension

So far, we have given a brief justification for the Navier-Stokes from basic physical principles and have discussed the use of SPH as a Lagrangian discretization scheme, allowing us to model pressure and viscosity forces. A crucial missing component for a believable simulation, however, is surface tension. Surface tension is the result of attractive forces between neighboring molecules in a fluid. On the interior of a fluid, these attractive forces are balanced, and cancel out, whereas on the surface of a fluid, they are unbalanced, creating a net force acting in the direction of the surface normal towards the fluid, usually minimizing the curvature of the fluid surface. The magnitude of this force depends on the magnitude of the current curvature of the surface as well as a constant depending on the two fluids that form the boundary.

Surface tension forces, while not present in the incompressible Naiver-Stokes equations, can be explicitly modeled in a number of different ways. Again, the most common and perhaps easiest to grasp approach is presented by Müller et al., which revises the Navier-Stokes equations by adding another term based upon the above physical principles for surface tension

where is a color field at particle locations and everywhere else, given in a smoothed form by

note that the gradient of the smoothed color field yields the surface normal field pointing into the fluid and the divergence of measures the curvature of the surface

Thus, we have the following force density

formed by distributing the surface traction among particles near the surface by multiplying a normalized scalar field which is non-zero only near the surface.

Kernel Functions

SPH Kernels

Müller states “(s)tability, accuracy and speed of the SPH method highly depend on the choice of the smoothing kernels.” The design of kernels for use in SPH is an area of active research and varies widely by implementation, but there are a number of core principles which are generally adhered to, well exemplified by Müller’s original proposed kernels: poly6, spiky, and viscosity. The figure above shows these kernels (in order), with the thick line corresponding to their value, the thin line to their gradient towards the center, and the dashed line to their Laplacian.

Kernels with second-order interpolation errors can be constructed as even and normalized. Kernels that are with vanishing derivatives at the boundary are conductive to stability. Justification of this is left as an exercise to the reader.

Müller’s poly6 kernel

satisfies the design constraints and can be evaluated without computing square roots in distance computations since only appears squared.

The spiky kernel

originally proposed by Desburn for use in SPH deformable body simulation solves the problem of particle clumping when poly6 is used for pressure force computation by necessitating a non-zero gradient near the center.

Finally, the viscosity kernel

has the following properties

We desire a viscosity kernel with a smoothing effect only on the velocity field. For other kernels, there can be a non-zero negative Laplacian of the smoothed velocity field for two close particles, creating forces that increase particle relative velocities, creating artifacts and instability especially when the number of particles is low. The given viscosity kernel has a positive Laplacian everywhere and satisfies the desired constraints.


As discussed, vanilla (i.e. Müller-like) SPH formulations have a number of limitations, notably in the calculation of pressure and viscosity, artificial surface tension, and the relatively arbitrary choice of kernel functions. Most importantly, but beyond the scope of this brief introduction, are the problems with enforcing incompressibility and maintaining simulation stability with large timesteps with techniques such as PCISPH. Further extensions include using different equations of state for pressure calculation (see WCSPH), a discussion of applicable numerical integration methods, adaptive timestepping, and a myriad of performance optimizations (the astute reader might already see a need for sorting particles into a grid based upon the kernel support radius).

We plan to release a number of tutorials in the near future detailing both basic and advanced SPH implementations, as well as discussions of the mathematics behind some of the techniques used in bleeding-edge particle-based fluid solvers.

— Lucas Schuermann