Skip to content

SPH Realization of Fluid Simulation. Featuring Large Scale Simulation, Rigid-Fluid Coupling and High Viscosity Fluid.

Notifications You must be signed in to change notification settings

jason-huang03/SPH_Project

Repository files navigation

SPH Fluid Simulation

[paper] [video]

A unified framework of SPH fluid simulation implemented in Taichi. You can find the full demo on bilibili and the report on arxiv.

pipeline of our framework

Detailed workflow of our SPH simulation framework.

This diagram illustrates the step-by-step process of our SPH simulation pipeline. It begins with the "Prepare Scene" phase, where users define fluid and rigid body properties, along with simulation parameters. The "Simulation" phase is next, showcasing the sequential application of gravitational, viscous, and pressure forces, followed by the dynamic updates of fluid and rigid bodies, incorporating various solvers for viscosity (standard and implicit) and pressure (WCSPH, PCISPH and DFSPH) management. The final "Post-Processing" phase involves surface reconstruction of fluid particles using SplashSurf and rendering the scene in Blender, utilizing Blender's rich community resources for scene creation. We faced challenges in correctly implementing IISPH and integrating PBF into our unified framework.

Features

✨ SPH Algorithm

✨ Fluid-Rigid Interaction Force

✨ Viscosity

✨ Rigid Solver

✨ SPH Surface Reconstruction

✨ Rendering

Heighlights

Large Scale Fluid Simulation

Large scale fluid simulation with over a million particles

Large scale fluid simulation of fluid consisting of 1.23M particles.

Rigid-Fluid Coupling

Rigid-fluid coupling=

Simulation of one fluid object and nine rigid objects in a confined space.

High Viscosity Fluid

Fluid with extremely high viscosity

Simulation of fluid with extremely high viscosity.

Buckling Effect

Realistic simulation of buckling effect

Simulation of buckling effect.

Coiling Effect

Realistic simulation of coiling effect

Simulation of coiling effect.

Installation on Linux

Python Environment

git clone https://github.com/jason-huang03/SPH_Project.git
cd SPH_Project
conda create --name SPH python=3.9
conda activate SPH
pip install -r requirements.txt

The code is tested on Ubuntu 22.04, Python 3.9.12, CUDA 12.2 with NVIDIA A100 GPU.

Install Vulkan SDK (Optional)

You may need Vulkan SDK to run the code. Here we provide a way to install Vulkan SDK on Linux without admin permission.

wget https://sdk.lunarg.com/sdk/download/latest/linux/vulkan-sdk.tar.gz -O vulkan-sdk.tar.gz


sudo mkdir -p /opt/vulkan-sdk
sudo tar -xvf vulkan-sdk.tar.gz -C /opt/vulkan-sdk # You can extract to your customized place. Change following lines accordingly.

VULKAN_SDK_VERSION=$(ls /opt/vulkan-sdk/ | grep -v "tar.gz")

echo "VULKAN_SDK_VERSION: $VULKAN_SDK_VERSION" # should be something like 1.3.268.0

Then you can add the following lines in your ~/.bashrc file.

# add following line in your ~/.bashrc
# suppose VULKAN_SDK_VERSION has a value

export VULKAN_SDK=/opt/vulkan-sdk/$VULKAN_SDK_VERSION/x86_64
export PATH="$PATH:$VULKAN_SDK/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$VULKAN_SDK/lib"

# possibly you will need this line
export VK_LAYER_PATH="$VULKAN_SDK/etc/vulkan/explicit_layer.d"

After that, you can check if you have successfully installed Vulkan SDK by running source ~/.bashrc followed by vulkaninfo in your terminal.

Install Splash Surf (Optional)

You can refer to the official document of splashsurf for more detail. Here we provide a way to install splashsurf on Linux without admin permission.

# install rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# install splashsurf
cargo install splashsurf

Install Blender (Optional)

You can refer to the official website of blender for more detail. Here we provide a way to install blender on LInux without admin permission.

# download blender 3.6 Linux package from https://www.blender.org/download/lts/3-6/

# uncompressed the .tar.gz file
tar -xf blender-3.6.7-linux-x64.tar.xz

Add the following line in your ~/.bashrc file.

# update the $PATH variable
# add the following line in ~/.bashrc file
export PATH=$PATH:~/blender-3.6.7-linux-x64/

The rendering script is tested with blender 3.6.7 and blender 4.0 seems uncompatible.

Usage

For a quick start, try the following command and make sure you turn on the export settings in the json scene configuration.

python run_simulation.py --scene ./data/scenes/dragon_bath_dfsph.json

To visualize the results, you can run the following command to make the images into a video. Those raw images is derived from Taichi GGUI API.

python make_video.py --input_dir ./dragon_bath_dfsph_output \
--image_name raw_view.png --output_path --video.mp4 --fps 30

To make the .ply particle file into .obj file for rendering, you can do surface reconstruction with the following command:

python surface_reconstruction.py --input_dir ./dragon_bath_dfsph_output --num_workers 2

This will open num_workers processes to do surface reconstruction with splashsurf.

Then you can do rendering with blender. We suggest you to first make a scene with a graphical user interface, setting materials, lighting, camera, rendering parameters and add other static objects. Then you can save the scene as a .blend file. With this, you can render the whole simulation process by running

CUDA_VISIBLE_DEVICES=0 python render.py --scene_file ./scene.blend \
--input_dir ./dragon_bath_dfsph_output --num_workers=1 --device_type OPTIX

The rendering script can put rendering jobs on multiple gpus. You can set CUDA_VISIBLE_DEVICES and num_workers according to your available devices.

Future Work

Acknowledgements

This project is built upon the following repositories:

We thank all contributors of these repositories for their great work and open source spirit.

About

SPH Realization of Fluid Simulation. Featuring Large Scale Simulation, Rigid-Fluid Coupling and High Viscosity Fluid.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages