top of page

BASIC 2D AND 3D EULERIAN PARTICLE FLUID SIMULATOR

ABOUT

The aim of this project was to familiarise myself with CFD, establish a basic understanding of the fundamental building blocks of famous Fluid Simulation Softwares, and implement a basic Fluid Solver from the ground up in MATLAB. I chose MATLAB because it provides a straightforward, easy-to-use environment and tools to take on the required math efficiently while keeping the code fairly readable.

The Solver I present here will hopefully provide a friendly starting point for new comers to take a dive into CFD and see how it works under the hood. I also hope that the code is readable enough and will invite people to improve and expand on it in their own way to try out new features.

Key Features

01 / Eulerian Method

The properties of the fluid are observed as a function of Time and Space. Unlike the Lagrangian Method, it is easy to track the fluid surface in the Eulerian Method.

02 / MAC Grid

MAC Grids are a good way to discretise space. The staggered arrangement solves the inherit "null-space" problem of Central Differences.

03 / Particle Method Fluid Tracer

The fluid or quantity is traced at each Time Step to determine which grid cells are occupied. Furthermore, cells are classified as Inner Cells or Surface Cells.

04 / Semi-Lagrangian Advection

An intuitive, physically-based, unconditionally-stable Lagrangian approach which solves the advection problem. Coupled with RK2 Method for improved accuracy.

05 / Two Pressure Solvers

One assumes that every non-solid cell contains fluid, the particles then trace another quantity being convected, such as ink. The second solves pressure only for cells containing particles.

06 / Particle Diffusion

Naive attempt at Volume Conservation. Particle Diffusion is equivalent to the explicit discretisation of the Heat Equation, it aims to uniformly distribute particles throughout the fluid/quantity volume.

07 / Velocity Extrapolation

Basic Iterative Velocity Extrapolation Method through Averaging.

08 / Collision System

Basic Physically-based Collision Detection and Correction System. Deals with particles escaping the Grid or going into Obstacles.

09 / Emitters and Obstacles

Up to 4 Particle Emitters and 4 Rectangular/Cubic Obstacles.

10 / Export Data to Houdini

Export Particle and Obstacle data for further manipulation and rendering in Houdini.

Product

GALLERY

About

DEMO VIDEO

Featured

DOWNLOAD

Minimum Requirements:

​

Source Code, Full Report and other references:

Click here to download the full source code as well as the report(User Guide in section 16) and other references.

​

Running the Demo:

Run Matlab file Demo.m, Note that I’m running Matlab on a MACOSX... WINDOWS users might need to replace forward slashes with back slashes in functions: InitDirectories, ExportFrame2D, ExportFrame3D, ExportObs2D and ExportObs3D.

Demo
bottom of page