CS 283 Advanced Computer Graphics

Project - Fluid and Mass-Spring Simulation


Stable Fluid Simulation (click to enlarge)
Mass-Spring Simulation (click to enlarge)

Stable Fluid Demo Video

Mass-Spring Demo Video


Stable Fluid Simulation

Mass-Spring Simulation


I have implemented stable fluid simulator with semi-Lagrangian advection and basic mass-spring simulator. I consult mostly Robert Bridson’s Fluid Simulation for Computer Graphics for fluid simulation and Andrew Witkin’s SIGGRAPH 1997 course note, Physically Based Modeling: Principles and Practice, for mass-spring simulation.

Fluid Simulation

Simulation Steps

  1. Calculate an optimal time step
  2. Self-advection (semi-Lagrangian)
  3. Apply body forces including gravity
  4. Projection
  5. Update velocities by pressures
  6. Trace marker particles’ new positions

I used MAC (marker-and-cell) method, a staggered grid, for storing velocities and calculating divergence. This enables me to calculate unbiased and correct, i.e. having trivial null space, finite differences. Also, I used one of the Jos Stam’s stable fluid techniques, semi-Lagrangian advection, in order to achieve unconditionally stable simulation. In the Projection stage, I used plain conjugate gradient method to solve the linear system of pressures and divergence, and subsequently to make the fluid incompressible. Since I didn’t use any preconditioner, for example Robert Bridson mentioned modified incomplete Cholesky preconditioner in his book, my implementation may be improved a lot just by changing CG to PCG.

Thus, if I have more time to work on my simulator, I’d like to implement a level set method in order to get more precise interface between air and water, and also want to introduce preconditioners to improve the performance.


After unzip that file, please run 0_install.sh first.


You can run demos like below.

# Fluid simulation demo
$ cd prj
$ python -m fluidsim

# Mass-spring simulation demo
$ cd prj
$ python -m particlesim

Development Environment

  1. OS: Mac OS X 10.8.3
  2. Python 2.7.2, numpy 1.7.1, scipy 0.12.0, Matplotlib 1.3

* Woojong Koh, 2013