Smoothed Particle Hydrodynamics

The smoothed particle hydrodynamics (SPH) method has received a lot of attention recently but many people don’t have a good understanding of how it works under the hood. In this article I will help you understand what makes it different from a traditional finite volume (FV) approach and why it is commonly used.

To understand any method it is always helpful to understand the problem it was created to solve, the history can make it obvious what advantages and disadvantages a method has. SPH was originally developed in the 80’s to solve problems in astrophysics, a discipline with very different requirements than the typical CFD of the time. These scientists were interested in understanding things like star mergers as pictured below or solar system formation where a large cloud of dust coalesces into stars, planets, and asteroids At this scale the dust can be approximated as a highly compressible fluid but attempting to model such a system with FV would be quite challenging. SPH was introduced to provide a more natural way to describe these systems.

Smoothed Particle Hydrodynamics White Dwarf DensityFigure 1: Density during white dwarf merger (1)

SPH is a lagrangian method, attaching calculation nodes or particles to some region of gas and allowing it to move and interact with other particles dynamically as the system evolves. Each particle represents a distribution of mass, think of a cloud of dust which is dense at the center and becomes sparse farther away. By allowing particles to overlap it becomes clear that this is an intuitive way to describe a highly compressible fluid. It is also computationally efficient because no calculation nodes are wasted in regions that aren’t interesting, ie empty space.

Particles interact with each other by the same principle, with the strength of some interaction (ie gravity or surface tension) increasing as particles get closer. To solve for some property of interest the superposition of kernel functions is taken to derive a value at some point in space.

To formalize this understanding a 2D example is helpful. Each particle is a point in space with an associated kernel function describing its mass distribution or any other field of interest. In the image below we can see the overlapping kernel functions and the resulting summation of them.

Smoothed Particle Hydrodynamics Overlapping Kernal Function

In 3D the same operation is done but is difficult to display on a webpage.

To summarize some of the advantages of SPH over FV include:

  • A naturally transient method
  • Perfect mass, momentum, and energy conservation
  • Perfect advection
  • Resolution that follows mass instead of volume

Most of these points should be clear from the above description but the third point may not be so obvious. Unlike a finite volume code mass flux does not need to be evaluated between nodes because mass itself is fixed to a particle. Therefore, as a particle moves from point A to point B advection is an emergent property rather than a calculated one.

SPH vs. FV

These advantages have caught the attention of folks interested in other CFD applications; free surface problems in particular struggle with many of the same problems as astro-physics. To understand why SPH has become popular relatively recently it pays to understand some of its limitations. The method is quite easy to program, at least to start, but requires more computation time per node than finite volume. In FV each node will have ~10 neighbors with which it can interact while SPH particles will have ~100 neighbors as shown below with a 2D slice.

Smoothed Particle Hydrodynamics neighbors of a given particle in 2DFigure 2: Neighbors of a given particle in 2D

This was an issue in the past but it is easy to parallelize and can therefore take advantage of GPUs which are really massively parallel math machines. As GPUs have gotten better SPH has become much faster for a certain class of CFD problems.

Now that SPH can be faster where should it be used? This again requires discussion of its advantages and disadvantages relative to FV. Boundary conditions are much more complex to apply to a lagrangian or discrete method which becomes clear when thinking about a standard pressure boundary condition. In FV the boundary will be “communicated” via a continuous pressure gradient across the domain, in SPH there isn’t a guarantee that particles will be continuously present from the boundary to another region in the domain so that information will not be communicated. On the other hand moving boundaries which are complex to apply in FV become very natural in SPH. Particles are simply able to move out of the way as a wall approaches making particle methods a favorite in gearbox applications.

Clearly SPH is not a replacement for FV, it is just another tool in the toolbox of CFD analysts. With a full toolbox the analyst is able to choose the best tool for the job and deliver the best results in the shortest time possible.

MPS

Finally when discussing SPH it makes sense to discuss a derivative method called the Moving Particle Simulation (MPS) method. It was developed to address some shortcomings of SPH for liquid, free-surface, problems. SPH inherently deals with compressible fluids, to handle liquid problems many commercial codes apply a weakly compressible addition to SPH so density is relatively constant. Rather than a smooth (continuously differentiable) kernel function MPS uses an asymptotic function to describe particle to particle interactions which is a natural description of incompressible liquids.

Gearbox application for Moving Particle SimulationFigure 3: Typical gearbox application for MPS

The other major difference is the way walls are handled. Most SPH codes discretize walls as particles with limited degrees of freedom. This is an easy way to add walls to SPH but can introduce discretization error and slow down the simulation. MPS instead uses a Distance Function which is best thought of as a flat particle. During a preprocessing stage each triangle in a tessellated geometry is used to generate a function propagating away from the wall and all of these functions are combined into a single distance function that interacts with neighboring particles. By taking this approach geometry can be included in a simulation without additional particles or computational load.

Citations

Lorén-Aguilar, P. & Isern, J. & Garcia-Berro, Enrique. (2009). High-resolution Smoothed Particle Hydrodynamics simulations of the merger of binary white dwarfs. Astronomy and Astrophysics. 500. 10.1051/0004-6361/200811060.
Engineer to Engineer - Click here to schedule free time with a CAE expert