Learning goals¶
Explain how a gradient with respect to can flow through a numerical solver
Compare differentiable simulation with simulation-based least squares and inverse PINNs on the same data contract
State what the method does not fix: identifiability, model mismatch, and bound activity
Reading¶
Classical estimation, automatic differentiation, inverse PINN
Thuerey et al. (2021), differentiable physics and differentiable physics versus physics-informed training (method background with fluid examples)
The idea¶
Simulation-based least squares already puts the simulator in the loop: pick , simulate, compare with measurements. What it lacks is a cheap direction to move . A grid search simulates many candidates, and finite differences need extra simulations per parameter.
Differentiable simulation writes the integrator itself in an automatic-differentiation framework. Each solver step is an ordinary differentiable operation, so reverse-mode AD returns
from a single forward rollout and one backward pass, where is the simulated speed at sample .
How the gradient flows¶
For the classical SMIB of SMIB dynamics, one RK4 step maps the state to
where is the network reactance for the current stage (prefault, fault-on, postfault). The trajectory is a chain , and the loss gradient is the chain rule along that chain. Backpropagation computes it automatically, carrying the sensitivity of each state to and backward through every step.
Two practical conditions make this work in the teaching model:
Fault switching depends on time only. The reactance changes at fixed and , so put both on the step grid. Each step then sits inside one stage, and nothing non-differentiable happens inside a step. State-triggered events (protection acting on ) need event-aware solvers and are beyond this course.
Scales are comparable. Fit and , and compare speed deviation , as in gradient scaling.
Course helper: sciml_ps.smib_torch.rollout_smib (fixed-step RK4 in PyTorch, tensors (batch, time, 2)). parity_error checks it against the SciPy reference solver used in Lab 1.
Three estimators, one data contract¶
| Simulation LS (grid or derivative-free) | Differentiable simulation | Inverse PINN | |
|---|---|---|---|
| Unknowns | NN weights and | ||
| Trajectory obeys the model? | Exactly (solver) | Exactly (solver) | Approximately (residual penalty) |
| Gradient source | None or finite differences | AD through solver steps | AD through network and residual |
| Cost per iteration | One simulation per candidate | One rollout + backward pass | One network pass over collocation points |
| Needs | Any simulator | Differentiable solver | Network, collocation design, loss weights |
| Main failure mode | Coarse grid; many simulations | Long or stiff rollouts give poor gradients; solver must be rewritten in AD | Network absorbs model error; weighting shifts |
The comparison rule from Lab 3 still holds: same measurements, noise, window, and bounds for every estimator, and a held-out disturbance for every estimate.
What it does not fix¶
Identifiability. Exact gradients of a flat loss surface are still flat. Weak excitation leaves poorly informed whichever estimator you use (identifiability).
Model mismatch. The fitted is the best value for the model you differentiated. If the data come from a different model, become equivalent parameters (physical vs equivalent).
Bounds. Report the bounds and whether an estimate ended on one.
Where it leads¶
Differentiable simulators are also the basis of hybrid models: a neural term trained inside the solver, next to the known swing equation. See Neural ODE / hybrid. That is how SciML models can later plug into established simulation workflows instead of replacing them.
Lab¶
Lab 3 — Inertia and damping estimation, optional section “Differentiable simulation”
Honesty rule¶
Fast convergence is not recovery. Report the true or reference when known, the estimate, the bounds, and the held-out disturbance error, as for every other estimator.
Common misconceptions¶
“Exact gradients mean the estimate is exact.”
“Differentiable simulation is a kind of PINN.” It has no network and no residual penalty; the solver enforces the model.
Differentiating through a state-triggered switch as if it were smooth
- Thuerey, N., Holzschuh, B., Holl, P., Kohl, G., Lino, M., Liu, Q., Schnell, P., & Trost, F. (2021). Physics-based Deep Learning. arXiv. 10.48550/arXiv.2109.05237