Skip to content

Conversation

@zzigak
Copy link
Contributor

@zzigak zzigak commented Nov 1, 2025

Added the following examples:

  • XPBD cloth (bending and stretching constraints)
  • XPBD mesh (volumetric constraints, edge constraints, and hash skinning for speedup).
  • PBF fluid simulation
  • MPM viscoplastic model

- Add PBD cloth simulation (12_pbd_cloth)
- Add PBD mesh simulation (13_pbd_mesh)
- Add PBF fluids simulation (14_pbf)
- Add viscoplastic MPM material model (11_mpm_plastic)
- Rename substep function to p2g2p in viscoplastic simulator
@liminchen
Copy link
Collaborator

When I try to run the pbf example, I got

[Taichi] version 1.7.2, llvm 15.0.5, commit 0131dce9, osx, python 3.11.9
[Taichi] Starting on arch=metal
Traceback (most recent call last):
  File "/Users/minchen/Desktop/solidSimBook/code/14_pbf/simulator.py", line 519, in <module>
    main()
  File "/Users/minchen/Desktop/solidSimBook/code/14_pbf/simulator.py", line 506, in main
    scene.lines(np.array([start_corner, end_corner], dtype=np.float32), color=(0.6, 0.6, 0.6), width=1)
  File "/Users/minchen/Library/Python/3.11/lib/python/site-packages/taichi/ui/scene.py", line 166, in lines
    copy_all_to_vbo(vbo, vertices, 0, 0, per_vertex_color if has_per_vertex_color else 0)
  File "/Users/minchen/Library/Python/3.11/lib/python/site-packages/taichi/lang/kernel_impl.py", line 1113, in wrapped
    return primal(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/minchen/Library/Python/3.11/lib/python/site-packages/taichi/lang/kernel_impl.py", line 1043, in __call__
    key = self.ensure_compiled(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/minchen/Library/Python/3.11/lib/python/site-packages/taichi/lang/kernel_impl.py", line 1009, in ensure_compiled
    instance_id, arg_features = self.mapper.lookup(args)
                                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/minchen/Library/Python/3.11/lib/python/site-packages/taichi/lang/kernel_impl.py", line 513, in lookup
    if key not in self.mapping:
       ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'numpy.ndarray'

I guess this might be a python version issue. Which python are you using?

@zzigak
Copy link
Contributor Author

zzigak commented Dec 6, 2025

Hi Minchen, sorry, I should have specified the version! Just created a new environment with python 3.10.17 from scratch and this works for me:

(test_pb) ➜ zzigak @ mbp ~/test_pb uv pip list                                                                                                                               git:(main)
Package        Version
-------------- -------
colorama       0.4.6
dill           0.4.0
markdown-it-py 4.0.0
mdurl          0.1.2
numpy          2.2.6
pygments       2.19.2
rich           14.2.0
taichi         1.7.4

I think the crash occurs because Taichi v1.7.2 fails to recognize the NumPy array as a data container (runtime argument), incorrectly treating it as a template argument that requires hashing

For visualization i recommend putting the window into full screen for proper rendering of particles. Please do tell if this works for you!

@zzigak
Copy link
Contributor Author

zzigak commented Dec 7, 2025

The same version works for pbd_cloth (need to add warp-lang) example and viscoplastic mpm example too. For pbd_cloth you need to enable animation first before moving the control point, but it should be a simple fix to only allow that button to work when animation is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants