Examples#

Run these scripts from the repository root so they can find the included bunny meshes. CUDA is used automatically where it helps.

Drop a bunny#

python examples/demo_bunny.py

This is the quickest visual demo. A soft bunny falls onto the standard solver’s projected ground plane, deforms on impact, and settles in Polyscope.

Suspend a bunny#

python examples/suspended_bunny.py

The bunny is held by its ear tips while gravity stretches the rest of its body. Polyscope shows von Mises stress by default and also provides equivalent Green strain as an alternate view.

Train a neural controller#

python examples/train_neural_controller.py --plot neural_bunny.png

A small MLP learns feedback by backpropagating through the FEM rollout. The saved plot compares it with the best constant actuator on a held-out task; --show opens the trained result in Polyscope. CUDA is recommended for the default training run.

Try IPC contact#

pip install -e ".[ipc]"
python examples/ipc_bunny.py

This drops a small bunny collision mesh onto the ground with the full IPC solver. The trajectory is checked for penetration, intersection, and inverted tetrahedra before it is played back.

Identify material parameters#

python examples/demo_diff_material.py

This example makes Young’s modulus and Poisson’s ratio learnable, then fits them to a synthetic deformation by differentiating through the simulation. It writes the optimization history to material_identification.png.

Render a material grid#

python examples/bunny_material_grid.py

This is the long batch example. After you choose a camera, it renders 25 bunny drops with different material settings and writes a video for each one. It requires FFmpeg and considerably more time and disk space than the other examples.

For the underlying mechanics, see Simulation. For the gradient paths, see Differentiation.