Multiphase Smoothed-Particle Hydrodynamics

Smoothed-Particle Hydrodynamics (SPH) is a method of simulating fluid flow. It is based on representing a fluid by a large number of discreet (individual) particles. Each particle has properties like position, pressure, density, mass, etc. The particles are fed through a bunch of equations that make them move in a fluid like flow.

If you are a maths nerd then one of the better and recommended papers for SPH fluids is Particle-based Viscoelastic Fluid Simulation.

Multiphase SPH is when you have 2 or more fluids with different densities etc (think oil and water) that flow around each other and clump together.

I have always had a fascination with simulating fluids. Over the years I have tried to understand SPH and have had many failed attempts at writing programs to do it (the basic formulas seem relatively simple, but getting the code to run stable without explosions and crashes is far from simple). Then I found this blog post by Tom Madams that had sample source code. With that I was finally able to get SPH working. It can still be fiddly to find a nice set of parameters to make a nice looking movie, but Tom’s code seems to be a great start. Thanks Tom!!

Multiphase SPH is now available in Visions Of Chaos.

A future release will include 3D support.


4 responses to “Multiphase Smoothed-Particle Hydrodynamics

  1. i have some basic questions regarding sph for my own program in python. ive read a ton of papers but there are some little problems i just cant seem to solve by myself – can i send you an email?

    • JP, I am by no means an expert with SPH. Take a look at the linked Tom Madams blog post and his source code. That really helped me get my movies working. I also read a heap of SPH papers and books without luck prior to that.


      • thats the page i came from in the first place. sadly Tom Madams blog post doesnt stick to the “normal” formulas supplyed in most papers at all! maybe just for me because it is written in an unfamiliar programming language…

        for example the first thing you do – calculate the density the normal way:
        (1)density.i = sum(1-n) m.j * W (r.ij,h)

        Tom is using:
        (2)density += pj.m * a*a*a * kNorm;
        with kNorm beeing “kNorm (20/(2*kPi*kH*kH))”

        i dont even see a coincidence there 😀
        So i´d like to follow the “usual” way (1) with the kernel function but i dont really get how i can compute a density by adding weighted masses together.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s