Giter Club home page Giter Club logo

sph_taichi's Introduction

SPH Taichi

A high-performance implementation of Smooth Particle Hydrodynamics (SPH) simulator in Taichi. (working in progress)

Examples

  • Dragon Bath (~420 K particles, ~280 FPS on RTX 3090 GPU, with timestep 4e-4)

  • Armadillo Bath (~1.74 M particles, ~80 FPS on RTX 3090 GPU, with timestep 4e-4)

Features

Currently, the following features have been implemented:

  • Cross-platform: Windows, Linux
  • Support massively parallel GPU computing
  • Weakly Compressible SPH (WCSPH)[1]
  • One-way/two-way fluid-solid coupling[2]
  • Shape-matching based rigid-body simulator[3]
  • Neighborhood search accelerated by GPU parallel prefix sum + counting sort

Note

The GPU parallel prefix sum is only supported by cuda/vulkan backend currently.

Install

python -m pip install -r requirements.txt

To reproduce the demos show above:

python run_simulation.py --scene_file ./data/scenes/dragon_bath.json
python run_simulation.py --scene_file ./data/scenes/armadillo_bath_dynamic.json

Reference

  1. M. Becker and M. Teschner (2007). "Weakly compressible SPH for free surface flows". In:Proceedings of the 2007 ACM SIGGRAPH/Eurographics symposium on Computer animation. Eurographics Association, pp. 209–217.
  2. N. Akinci, M. Ihmsen, G. Akinci, B. Solenthaler, and M. Teschner. 2012. Versatile rigid-fluid coupling for incompressible SPH. ACM Transactions on Graphics 31, 4 (2012), 62:1–62:8.
  3. Miles Macklin, Matthias Müller, Nuttapong Chentanez, and Tae-Yong Kim. 2014. Unified particle physics for real-time applications. ACM Trans. Graph. 33, 4, Article 153 (July 2014), 12 pages.

Acknowledgement

Implementation is largely inspired by SPlisHSPlasH.

sph_taichi's People

Contributors

afutured avatar erizmr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sph_taichi's Issues

bug in particle_system.py

the for_all_neighbors function has bug in particle_system.py.
the loop: for p_j in range(self.grid_particles_num[ti.max(0, grid_index-1)], self.grid_particles_num[grid_index]):
does not works properly. If grid_index is zero and the loop is skipped, which will result in particles getting squeezed into the (0,0,0) grid.

bug in counting_sort!

The “grid_ids_new” obtained from running “counting_sort” is different each time. Do you have this problem?

Adding ”ti.loop_config(serialize=True)“ before the first for loop can yield the correct result, but it is inefficient.

Is there any other solution?

Taichi version

Hi, thanks for sharing your interesting work.
I have tried to run your code, while failed due to the restricted taichi version installed by PIP.
Should I build the taichi from source other than with pip installation?
Thanks

compute pressure force error?

Hi, thanks for your greak work, it really inspires me a lot . However, i'm wondering whether it is correct to compute two pressure force while computing pressure acceleration between two fluid particles.
屏幕截图 2024-06-20 210046
In "Versatile Rigid-Fluid Coupling for Incompressible SPH", it only use one pressure force.
In "Versatile Rigid-Fluid Coupling for Incompressible SPH":
image
I'm wondering if you take interaction force into consideration. But i think that it should not be correct?
Looking forward to your reply!

How to visualize like the gif shown?

Thank you for your implementation! I have successfully run your code and the result which is in .ply file. How to visualize it like the gif shown in the respo?

WCPSH dynamic rigid body may be error

        elif self.ps.material[p_j] == self.ps.material_solid:
            boundary_viscosity = 0.0
            # Boundary neighbors
            ## Akinci2012
            f_v = d * boundary_viscosity * (self.density_0 * self.ps.m_V[p_j] / (self.ps.density[p_i])) * v_xy / (
                r.norm()**2 + 0.01 * self.ps.support_radius**2) * self.cubic_kernel_derivative(r)
            ret += f_v

If boundary_viscosity is zero, the f_v will be zero too.....

Spell error in the particle_system.py

line 19 and 20, domain is misspelled as domian, which lead to wrong domain size
self.domain_end = np.array([1.0, 1.0, 1.0])
self.domian_end = np.array(self.cfg.get_cfg("domainEnd"))

wrong when set exportObj to true

hello, thank you so much for sharing.
I got an error when set armadillo_bath_dynamic.json "Configuration" "exportObj" to true

[E 01/14/23 19:13:58.414 20808] [taichi/rhi/cuda/cuda_driver.h:operator()@88] CUDA Error CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered while calling stream_synchronize (cuStreamSynchronize)

Traceback (most recent call last):
File "E:\Taichi\SPH_Taichi-master\run_simulation.py", line 101, in
obj_data = ps.dump(obj_id=obj_id)
File "E:\Taichi\SPH_Taichi-master\particle_system.py", line 461, in dump
self.copy_to_numpy_nd(obj_id, np_x, self.x)
File "D:\Users\m1503\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py", line 1006, in call
return self.primal(self.kernel_owner, *args, **kwargs)
File "D:\Users\m1503\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py", line 872, in call
return self.runtime.compiled_functionskey
File "D:\Users\m1503\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py", line 797, in func

raise e from None
File "D:\Users\m1503\AppData\Local\Programs\Python\Python39\lib\site-packages\taichi\lang\kernel_impl.py", line 794, in func__
t_kernel(launch_ctx)
RuntimeError: [taichi/rhi/cuda/cuda_driver.h:operator()@88] CUDA Error CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered while calling stream_synchronize (cuStreamSynchronize)
GLFW Error 65537: The GLFW library is not initialized
[E 01/14/23 19:13:59.363 20808] [taichi/rhi/cuda/cuda_driver.h:operator()@88] CUDA Error CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered while calling stream_synchronize (cuStreamSynchronize)

scene.py giving very low fps

the provided demo runs in a very low fps, around 0.75-0.85 fps.
I tried both cpu and gpu, also tried disabling the saving frames but still very slow.
also tried disabling output sim_info

IISPH的实现

请问iisph算法的实现参考的是哪一篇论文?和Markus Ihmsen的原文Implicit Incompressible SPH中的算法实现好像有点不太一样。

Support for custom geometry?

Does this package allow defining a custom geometry that contains the flow (for example, particles moving through pipes), and if so are there any examples of how to do this? Thanks!

Demo video reproduction

Hi, Thanks for your lovely project.
Anyway I've runned python run_simulation.py --scene_file ./data/scenes/dragon_bath.json and what I saw was

capture

I was expecting like the video you've uploaded(with realistic water and objects).
Is it somewhat related to the GLFW Error 65537: The GLFW library is not initialized? Which I got while running the code.

Thanks.

GPU跑不了是为啥?

CPU算的太慢了,不知道为啥改成GPU就跑不了了。是因为代码里用了什么东西吗?

Add option for disable GPU prefix sum

The current implementation of neighborhood relies on cuda prefix sum, which prevents the program running on CPU.
There should be an option to disable the GPU only prefix sum.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.