Physics-Enhanced Neural Networks for Rigid Body Dynamics: From Pendulums to Linkage Mechanisms
The Problem with Pure Data-Driven Dynamics
Drop a ball. A neural network trained on enough trajectories will learn that things fall. But change the ball’s mass, the air density, or the planet — and it fails. It learned the pattern, not the physics.
Physics-enhanced neural networks (PENNs) take a different approach: embed the equations of motion directly into the network architecture, and let the network learn only what the physics doesn’t cover. Friction coefficients. Damping. Contact forces. The messy stuff that’s hard to model analytically but easy to measure.
This isn’t new for fluid dynamics and PDEs. But rigid body dynamics — pendulums, linkages, robotic arms, mechanical mechanisms — has its own family of approaches, and they’re maturing fast.
The Hamiltonian Approach: Energy Conservation by Construction
Hamiltonian Neural Networks (Greydanus et al., NeurIPS 2019) started the modern wave. The idea is elegant: instead of learning trajectories directly, learn the Hamiltonian H(q, p) — the total energy of the system — and derive the equations of motion from it.
Hamilton’s equations guarantee energy conservation:
dq/dt = ∂H/∂p , dp/dt = −∂H/∂q
A standard neural network trained on pendulum data will eventually violate energy conservation — the pendulum spirals inward or outward over long rollouts. An HNN physically cannot do this. The Hamiltonian structure acts as an inductive bias that makes the network respect thermodynamics by construction.
The catch: You need position-momentum pairs (q, p), which means you’re working in phase space. For simple systems (mass-spring, pendulum, two-body), this is fine. For a 12-link mechanism with joints and contacts? The coordinate bookkeeping gets painful.
The Lagrangian Alternative: Generalized Coordinates
Lagrangian Neural Networks (Cranmer et al., ICLR 2020) sidestep the momentum problem. Instead of H(q, p), they learn the Lagrangian L(q, q̇) = T − V directly and derive motion from the Euler-Lagrange equations.
Why does this matter for mechanical systems? Lagrangian mechanics works in generalized coordinates. A four-bar linkage has one degree of freedom regardless of how many Cartesian coordinates describe it. The Lagrangian formulation naturally handles this reduction.
Deep Lagrangian Networks (DeLaN, Lutter et al. 2019) took this further for robotics: instead of learning the full Lagrangian, learn the mass matrix and potential energy separately. The neural network replaces specific terms in the Euler-Lagrange equation while keeping the physical structure intact. This was demonstrated on real robot arms — learning dynamics from 100 seconds of motion data.
Adding Constraints: The Key to Mechanisms
Pendulums and mass-springs are beautiful pedagogical examples, but real mechanical systems have constraints. A linkage has rigid bars. A cam follower must stay on the cam surface. Joints restrict relative motion.
Constrained Hamiltonian Neural Networks (CHNN, Finzi et al., NeurIPS 2020) solve this by embedding rigid-body constraints explicitly. Instead of using generalized coordinates (which require careful derivation for each mechanism), CHNN works directly in Cartesian space and enforces constraints like fixed distances between connected bodies.
This means you can model a chain pendulum, a gyroscope, or a rigid rotor without ever deriving its Lagrangian by hand. The network learns the dynamics in the full coordinate space while the constraints keep the solution physically consistent.
For mechanical linkages, this is a game-changer. A four-bar linkage is just four rigid bars with four distance constraints. Feed that structure to CHNN, add some trajectory data, and the network learns the dynamics while respecting the geometry.
Scaling Up: Graph Neural Networks for Articulated Bodies
Single pendulums are solved problems. The real challenge is multi-body systems — chains, trusses, articulated robots, complex linkage trains.
Lagrangian Graph Neural Networks (LGNN, Bhattoo et al., NeurIPS 2022 Spotlight) combine Lagrangian mechanics with graph neural networks. Each body is a node, each joint or connection is an edge, and message passing computes the interactions.
The breakthrough: generalization across system sizes. Train on a 5-link chain, and the model predicts the dynamics of a 20-link chain it’s never seen. This is because the Lagrangian structure + graph topology encode the physics at the local interaction level, not the system level.
LGNN has been demonstrated on:
- Rope and chain dynamics
- Bar-chain hybrid systems
- Tensegrity structures (rigid bars + cables)
The same architecture could model complex linkage mechanisms where multiple bars interact through joints and constraints.
The State of the Art: Higher-Order Topology
HOPNet (Wei & Fink, Nature Communications 2025) represents the current frontier. Instead of treating multi-body systems as simple graphs (nodes + edges), HOPNet uses combinatorial complexes — higher-order topological structures that can represent faces, volumes, and higher-dimensional relationships.
This matters for collision dynamics. When two rigid bodies collide, the interaction isn’t just between two nodes — it involves surfaces, normals, contact patches. Higher-order representations capture this naturally.
HOPNet achieves superior accuracy in long rollouts and generalizes to unseen collision scenarios. It’s currently the benchmark for learned rigid body dynamics.
Caveat: The license is non-commercial research only. For practical applications, the permissively licensed alternatives (HNN, LNN, CHNN, LGNN, DeLaN) are the way to go.
Differentiable Simulators: The Complementary Approach
While PENNs learn physics from data, differentiable simulators provide physics as computation — with gradients.
- Brax (Google) — JAX-based massively parallel rigid body simulation on GPU/TPU
- Tiny Differentiable Simulator — Header-only C++ from the creator of PyBullet
- DiffTaichi — 10 differentiable physics examples in the Taichi language
- NVIDIA PhysicsNeMo — Production physics-ML framework
These aren’t competitors to PENNs — they’re complements. Use a differentiable simulator to generate training data, then train a PENN for fast inference. Or use the simulator’s gradients for system identification, then switch to a PENN for real-time prediction.
The Gap Nobody Has Filled
Here’s what’s surprising: nobody has published a PINN specifically for classical mechanism design.
Four-bar linkages. Slider-crank mechanisms. Cam-follower systems. The 507 mechanical movements from Henry T. Brown’s 1868 catalog. These are some of the most well-understood mechanical systems in engineering — deterministic trajectories governed by geometry, inertia, and contact constraints.
MIT’s LINKS dataset provides 100 million planar linkage mechanisms with kinematic trajectories. MotionGen from Stony Brook University offers interactive mechanism simulation. The data infrastructure exists.
The approaches exist too: CHNN handles rigid constraints natively. LGNN generalizes across system sizes. DeLaN learns manipulator dynamics from seconds of data.
What’s missing is the connection. A PINN that takes a linkage topology (which bars connect where, what joints are used) and predicts its full dynamics — including friction, backlash, contact forces — without solving the Euler-Lagrange equations from scratch for each new design.
This would be a genuine contribution. Design engineers could evaluate mechanism candidates in milliseconds instead of setting up a multibody dynamics simulation for each one. Parametric sweeps that currently take hours on a workstation could run in seconds on a laptop.
Where to Start
If you want to explore this space, here’s a practical roadmap:
-
HNN — Start here. Clean PyTorch code, great visualizations, well-documented. Run the pendulum and two-body experiments to build intuition.
-
LNN — Compare with HNN. Same problems, Lagrangian formulation. Understand the trade-offs.
-
CHNN — The bridge to real mechanisms. Run the chain pendulum and gyroscope examples.
-
LGNN — Multi-body systems. See how graph structure enables generalization.
-
DeLaN — Robotics angle. Learn how to decompose the Lagrangian into learnable components.
All five are permissively licensed (Apache 2.0 or MIT). We’ve collected them with working examples in the physics-enhanced-neural-networks repository, alongside flow simulation notebooks and linkage mechanism references.
The Takeaway
Physics-enhanced neural networks aren’t replacing analytical mechanics. They’re augmenting it. The key insight across all approaches — Hamiltonian, Lagrangian, graph-based, topological — is the same: embed what you know, learn what you don’t.
For rigid body dynamics, that means encoding Newton’s laws, conservation principles, and geometric constraints into the network architecture, then letting data fill in the gaps. The result is models that generalize better, conserve physical quantities by construction, and need orders of magnitude less training data than pure data-driven approaches.
The classical mechanism design gap is real and waiting to be filled. The tools are open source. The datasets exist. Someone just needs to connect the dots.