- Notifications
You must be signed in to change notification settings - Fork12
SPH Realization of Fluid Simulation. Featuring Large Scale Simulation, Rigid-Fluid Coupling and High Viscosity Fluid.
jason-huang03/SPH_Project
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A unified framework of SPH fluid simulation implemented inTaichi. You can find thefull demo on bilibili and thereport on arxiv.
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 andimplicit) and pressure (WCSPH,PCISPH andDFSPH) management. The final "Post-Processing" phase involves surface reconstruction of fluid particles usingSplashSurf and rendering the scene inBlender, utilizing Blender's rich community resources for scene creation. We faced challenges in correctly implementingIISPH and integratingPBF into our unified framework.
- Weakly compressible SPH for free surface flows (WCSPH)
- Predictive-Corrective Incompressible SPH (PCISPH)
- Divergence-Free Smoothed Particle Hydrodynamics (DFSPH)
git clone https://github.com/jason-huang03/SPH_Project.gitcd SPH_Projectconda create --name SPH python=3.9conda activate SPHpip install -r requirements.txt
The code is tested on Ubuntu 22.04, Python 3.9.12, CUDA 12.2 with NVIDIA A100 GPU.
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.gzsudo mkdir -p /opt/vulkan-sdksudo 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 valueexport VULKAN_SDK=/opt/vulkan-sdk/$VULKAN_SDK_VERSION/x86_64export PATH="$PATH:$VULKAN_SDK/bin"export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$VULKAN_SDK/lib"# possibly you will need this lineexport VK_LAYER_PATH="$VULKAN_SDK/etc/vulkan/explicit_layer.d"
After that, you can check if you have successfully installed Vulkan SDK by runningsource ~/.bashrc
followed byvulkaninfo
in your terminal.
You can refer to theofficial document of splashsurf for more detail. Here we provide a way to install splashsurf on Linux without admin permission.
# install rust toolchaincurl --proto'=https' --tlsv1.2 -sSf https://sh.rustup.rs| sh# install splashsurfcargo install splashsurf
You can refer to theofficial 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 filetar -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 fileexport PATH=$PATH:~/blender-3.6.7-linux-x64/
The rendering script is tested with blender 3.6.7 and blender 4.0 seems uncompatible.
For a quick start, try the following command and make sure you turn on the export settings in thejson
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 opennum_workers
processes to do surface reconstruction withsplashsurf.
Then you can do rendering withblender. 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 setCUDA_VISIBLE_DEVICES
andnum_workers
according to your available devices.
- Correct implementation ofImplicit Incompressible SPH
- Integration ofPosition Based Fluids
- Strong rigid-fluid coupling followingInterlinked SPH Pressure Solvers for Strong Fluid-Rigid Coupling
This project is built upon the following repositories:
We thank all contributors of these repositories for their great work and open source spirit.
If you use this code or find our work valuable, please cite:
@misc{huang2024journeysphsimulationcomprehensive, title={Journey into SPH Simulation: A Comprehensive Framework and Showcase}, author={Haofeng Huang and Li Yi}, year={2024}, eprint={2403.11156}, archivePrefix={arXiv}, primaryClass={physics.flu-dyn}, url={https://arxiv.org/abs/2403.11156}, }