/taichi_elements

High-performance multi-material continuum physics engine in Taichi

Primary LanguagePythonMIT LicenseMIT

Taichi Elements Build Status Code Coverage

High-Performance Multi-Material Continuum Physics Engine (work in progress).

The solver is being developed using Taichi, therefore it is cross-platform and supports multithreaded CPUs and massively parallel GPUs.

The plan is

  • To build a reusable MLS-MPM multimaterial (water/elastic/snow/sand/mud) simulator
  • To integrate the simulator into Blender

Using taichi_elements in Python

  • Install taichi with pip: python3 -m pip install taichi
  • Go to demo folder
  • python3 demo_2d.py and you will see

  • python3 demo_3d.py and you will see a 3D simulation visualized in 2D.

To simulate and render an example 3D scene with Python

  • Make sure you have a modern NVIDIA GPU (e.g. GTX 1080 Ti)
  • Download taichi.ply and run python3 demo_3d_letters.py (wait for at least 10 frames)
    • A binary particle folder with a timestamp in its time (e.g., sim_2020-07-27_20-55-48) will be created under the current folder.
  • python3 ../renderer/render_particles [particle_input_folder] [begin] [end] [step] [render_output_folder]
    • E.g., ../renderer/render_particles.py sim_2020-07-27_20-55-48/ 0 100 1 frames
  • Images are in the rendered folder. For example, 100 million MPM particles simulated in 8 hours on a V100 GPU:

[Watch on YouTube]

Using taichi_elements in Blender

Installing Taichi for Blender

(Not sure if it is the standard approach, but it works for now.)

  • Find the Python3 executable bundled in Blender. Open a console in Blender and type in
import sys
print(sys.exec_prefix)

The output looks like /XXX/blender-2.81a-linux-glibc217-x86_64/2.81, which means python3 is located at /XXX/blender-2.81a-linux-glibc217-x86_64/2.81/python/bin/python3.7

  • Install pip using that Python executable
  • Install Taichi: ./python3.7m -m pip install --upgrade taichi (Note: as of July 28 2020, Taichi version is v0.6.22. Please use the latest version.)

Installing taichi_elements (experimental) for Blender

  • Set the environment variable BLENDER_USER_ADDON_PATH, e.g. /home/XXX/.config/blender/2.81/scripts/addons
  • Go to utils folder
  • Execute python3 install_blender_addon.py to install the addon
    • If you are doing development and wish to keep refreshing the installed addon, add argument -k.
  • Restart Blender to reload the addon