FEM Hex8 Elastodynamics Solver
A JAX Hex8 elastodynamics solver — and a retrospective that found and fixed two bugs in the submitted version.
My contribution
I derived the forward kinematics and Jacobian of a 4-joint arm, tested candidate strain energies for rotation invariance, and derived the Neo-Hookean stress by hand.
- Affiliation
- Computational Design of Cyber-Physical Systems
- Dates
- Spring 2026
- Role
- Individual assignment on course starter notebooks
- Topics
- Optimization and Simulation
- Tools
- JAX, Python
Contents
01
The problem
I wanted to predict how a compliant part bends and vibrates under load, which is the basis of virtual testing for soft robots and flexible structures. That meant connecting rigid-arm kinematics with continuum mechanics and building a finite element simulator from the energy density up.
02
My contribution
I derived the forward kinematics and Jacobian of a 4-joint arm, tested candidate strain energies for rotation invariance, and derived the Neo-Hookean stress by hand. In the JAX solver I implemented the energy density, Hex8 shape functions and their derivatives, the deformation gradient, element energy with vertex and Gauss quadrature, autodiff forces, lumped mass, clamped boundary conditions and the time step, then designed and ran five load scenarios. The course supplied the overall solver skeleton and the GIF export.
03
Constraints
Explicit time stepping is only stable below a CFL limit, so the step was tied to wave speed (Δt = 0.2h/√(E/ρ), 3.16 × 10⁻⁴ s at baseline). With a fixed 1,000 steps per run, stiffer scenarios covered only 0.1 s of physical time. The mesh was a modest 12 × 4 × 4 (325 nodes, 192 elements) to keep Colab runs fast.
04
Design decisions
I used autodiff to get forces as the gradient of total energy rather than hand-coding the stress divergence, which removes a whole class of derivation errors. Velocity Verlet was the integrator because its energy error stays bounded over long runs, unlike forward Euler. I compared vertex quadrature against 3-point Gauss quadrature to check the cheaper rule.
05
What was difficult
This is the project I learned the most from after the fact. My write-up said every scenario behaved as expected, but re-running the solver showed the beams stretching and curling upward under a downward load. Splitting the causes found two bugs. The main one: one line assigned the boundary-condition helper's position output to the velocity, so every node drifted at a speed equal to its own coordinate. The second: my implemented energy dropped the −μ ln J term, so the material was not stress-free at rest and, as I proved, preferred to collapse. My handwritten derivation had the correct form; the code did not.
06
Evidence
The four-way re-run isolates each defect: as submitted, the unloaded beam moved 0.26; fixing only the energy, 0.31; fixing only the velocity, it collapsed toward the wall (1.55); with both fixed it stayed exactly at rest (0.0000). With both fixes every loaded beam bends downward along its load, for example the soft beam overshoots to −1.43 at 0.40 s and the combined load also bends it sideways by +0.21.
07
Current status
Simulation. The submitted version is a completed assignment; the corrected version exists as a re-run for the retrospective paper.
08
What I would change next
I would add an unloaded zero-motion test before running any scenario, since it exposes both bugs in one step. I would also add a smaller time step or an inversion-safe energy for extreme loads: the softest, heaviest case still inverts elements and fails at 0.07 s even with both fixes.
Related work