Skip to content

Smoothed Particle Hydrodynamics simulation in CUDA

Notifications You must be signed in to change notification settings

iwoplaza/cuda-sph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

The CUDA-SPH project aims to provide a set of tools for simulating fluids, as well as for visualizing the generated data. To simulate fluid we used the SPH technique. This approach assumes that a fluid is a set of particles that interact with each other and move around according to Navier-Stokes equations.

We saw an opportunity to parallelize it, so we used GPU programming with CUDA to implement it. To make production relatively faster and easier for us, we used the Python programming language.

Setup

Tested with Python 3.9

Simulator workspace

Install CUDA Toolkit: https://developer.nvidia.com/cuda-toolkit-archive

cd sim
./venv/Scripts/activate
pip install -r ./requirements.txt

Visualization workspace

Download PyOpenGL manualy from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl.

cd vis
./venv/Scripts/activate
pip install ./PyOpenGL-3.1.5-cp39-cp39-win_amd64.whl # cp39 <==> Python 3.9
pip install ./PyOpenGL_accelerate-3.1.5-cp39-cp39-win_amd64.whl # cp39 <==> Python 3.9
pip install -r ./requirements.txt

Usage

Software we made is divided into two programs, simulator and visualizer. Simulator is able to produce a simulation (to a chosen directory), and visualizer displays it.

Simulator

Two types of enclosure are available:

  • inside a box
  • inside a pipe

The config.py file is used to set numerous simulation parameters such as the mode (enclosure type), particle count and the initial state of the simulation.

Running the simulator:

python ./sim/src/main.py

Visualizer

Running the visualizer:

python ./vis/src/main.py

Movement

  • W,A,S,D - Move forward, left, back and right (relative to the camera)
  • Q, E - Move down and up (relative to the camera)
  • Space - Increase the speed of moving around twofold
  • Click and drag - Rotate the camera

Demo

Box 1 Box 2 Pipe

Read more

Full documentation of the project is available in Polish: Dokumentacja Projektu

About

Smoothed Particle Hydrodynamics simulation in CUDA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published