Simplified Smooth Particle Hydrodynamics Fluid Simulation

Matthew O'Neil
CPE 471 Spring 2016

This project is an implementation of a fluid simulation using a simplified version of the smooth paritcle hydrodynamic model. Using an array of particles, the simulation applies forces on each of the particles according to their position relative to predefined boundaries, and the relative positions of nearby particles. While the canonical SPH model is physically accurate, my model sacrifices realism for speed. The pictures below show the simulation's capability to model the fluid's ability to fall, slosh, and create a breaking wave. The simulation is able to run smoothly in real time.

The fluid falling, sloshing to the left, and moving back

The simulation is capable of running approximately two thousand paricles, which would require 4 million computations at every time step using a naive O(n2) algorithm. Because a particle on two opposite sides of the simulation will have no affect on each other, I am able to drastically reduce the number of necessary computations by separating the simulation area into four cells, or buckets. Each particle only needs to compute forces acting within its own bucket, allowing the simulation to handle a much higher number of particles. The buckets are computed by comparing each particle's position to the center of the simulation space, as shown in the pictures below.

The four buckets dynamically moving with the simulation

The simulation is also capable of interacting with defined boundaries and applying arbitrary forces. In the following screenshots, the fluid is constrained within a box and slowly rotated. The simulation realistically creates vortices aas the fluid flows to fill in the container and is pushed by the fluid above and behind it.

The fluid flows in a rotating box

Initially, I dealt with particles going out of bounds by putting them back at the boundary. This resulting in unexpected behavior with a stack of particles balancing on each other at the sides of the container. Without an external force, the particles were perfectly balanced at the boundary and would not fall. I resolved this issue by introducing a very small variation when putting particles back in bounds. This variation was enough to disrupt the balance and produce more expected results.

If I work on the simulation to improve the realism, I will alter the method of assigning particles to buckets. By creating more buckets with fewer particles, I will be able to apply more rules while reducing the number of necessary computations. My current implementation is capable of simulating a three dimensional fluid, but the number of particles required to make a good looking fluid is too high for my computer to handle. In the previous screenshots all particles are perfectly balanced at z=0, but any variation in the z position of a particle is enough to disrupt the balance and spread the fluid out along the z axis. More buckets would allow the simulation to handle more particles and apply more physically rules.

References