Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Case Study: Hanging Square*

We use a simple case study to end this lecture. Based on the mass-spring system developed in a previous section, we implement gravitational energy and sticky Dirichlet boundary conditions to simulate a hanging square. The excutable Python project for this section can be found at https://github.com/phys-sim-book/solid-sim-tutorial under the 2_dirichlet folder. MUDA GPU implementations can be found at https://github.com/phys-sim-book/solid-sim-tutorial-gpu under the simulators/2_dirichlet folder.

Gravitational energy has which can be trivially implemented:

Implementation 5.3.1 (GravityEnergy.py).

{{#include solid-sim-tutorial/2_dirichlet/GravityEnergy.py}}

Then we just need to make sure the gravitational energy is added into the Incremental Potential (IP):

Implementation 5.3.2 (Adding gravity to IP, time_integrator.py).

{{#include solid-sim-tutorial/2_dirichlet/time_integrator.py:ADDING_GRAVITY}}

For the sticky Dirichlet boundary condition, we modify the system accordingly when computing search direction:

Implementation 5.3.3 (DOF elimination, time_integrator.py).

{{#include solid-sim-tutorial/2_dirichlet/time_integrator.py:search_dir}}

Here is_DBC is an array marking whether a node is Dirichlet or not as we store the Dirichlet node indices in DBC:

Implementation 5.3.4 (DBC definition, simulator.py).

{{#include solid-sim-tutorial/2_dirichlet/simulator.py:DBC_def}}

# ...

{{#include solid-sim-tutorial/2_dirichlet/simulator.py:DBC_mask}}

Finally, after making sure is_DBC is passed to the time integrator, we can simulate an energetic hanging square (no initial stretching) with a smaller spring stiffness k=1e3 at framerate time step size h=0.02 (Figure 5.3.1).

Figure 5.3.1. From left to right: initial, intermediate, and final static frame of the hanging square simulation.