Differentiable Simulation
A differentiable simulator computes gradients of its outputs with respect to its inputs, enabling gradient-based design, control, and learning.
Simulation you can differentiate
A differentiable simulator is a physics solver written so that automatic differentiation can propagate derivatives through every step of the computation. Beyond producing an output, it produces the sensitivity of that output to every input parameter. This turns simulation from a forward-only black box into a component that fits directly inside gradient-based optimization and learning.
Automatic differentiation
Automatic differentiation records the elementary operations a program performs and applies the chain rule to compute exact derivatives, up to floating-point precision. Reverse mode, the same mechanism as backpropagation, is efficient when there are few outputs and many inputs, which is the usual situation in design optimization where a single objective depends on thousands of parameters.
What gradients unlock
- Design optimization: adjust geometry or material parameters to minimize an objective
- Inverse problems: recover unknown inputs that reproduce observed outputs
- Control: tune actuation to steer a system toward a target trajectory
- Hybrid learning: train a neural network embedded inside the physics loop
A tiny example
import torch
# differentiate a simple explicit time step
def step(u, dt, alpha):
lap = torch.roll(u,1) - 2*u + torch.roll(u,-1)
return u + dt*alpha*lap
u = torch.zeros(64, requires_grad=True); u.data[32]=1.0
out = step(u, 0.1, 0.5).sum()
out.backward() # du_out/du available in u.grad
Costs and cautions
Reverse-mode differentiation stores intermediate states, so memory grows with the number of time steps; checkpointing trades recomputation for memory. Long unrolled simulations can produce exploding or vanishing gradients, and chaotic systems make gradients meaningless beyond a short horizon. Used within its limits, differentiable simulation is a bridge between classical solvers and machine learning.