A square falling onto a ground under gravity and then compressed by a ceiling is simulated with mass-spring elasticity potential and implicit Euler time integration. Each time step is solved by minimizing the Incremental Potential with the projected Newton method.
pip install numpy scipy pygame
python simulator.py