Physics-informed neural networks, explained
A network recovered a full cooling curve from six noisy points, refused to predict the impossible, and read a physical constant from the data. How PINNs work.
Most neural networks learn from data and nothing else. A physics-informed neural network (PINN) learns from data and from a law of physics, and the difference is startling. Give it six noisy measurements and the equation those measurements obey, and it will reconstruct an entire curve it was never shown, refuse to predict a physically impossible answer, and even read a physical constant straight out of the data.
This is the first of six ways to put physics into machine learning (the full map is here). It is the one that injects the physics into the loss function, and it is the easiest to understand from a single worked example.
The idea: punish the model for breaking the law
In science we often know something stronger than any dataset: a governing equation. A PINN writes that equation directly into the loss, so the network is punished for two things at once, disagreeing with the data it has seen, and violating the physics it must obey everywhere else.
Take a simple materials example from heat treatment: a hot component quenched into cooler surroundings. Newton’s law of cooling says the rate of cooling is proportional to how far above ambient the part still is. Writing theta for the temperature above ambient, so it decays to zero:
d(theta)/dt = -k * theta, theta(0) = 1, solution: theta(t) = exp(-k*t)
with a real cooling constant k = 1.5.
The trick that makes it work
A network N(t) predicts the temperature at time t. Because a neural network is a differentiable function, we can ask automatic differentiation for its exact derivative dN/dt and plug it straight into the law:
residual(t) = dN/dt + k * N(t)
A true solution makes this residual zero everywhere. So we penalise any nonzero residual at a couple of hundred points spread across the whole timeline, points where we have no measured data at all. The physics acts as free supervision in every empty region, and evaluating it only needs the derivative of the network, which autograd hands us for nothing.
One practical detail: PINNs use smooth activation functions like tanh rather than ReLU. We are differentiating the network, and ReLU’s slope is flat, so it carries no useful gradient information for a physics residual.
Act one: physics fills the gap the data left empty
Here is the experiment. Give two models the same six noisy measurements, all from the early part of the cooling (times up to 1.3), and ask what happens across the full timeline (out to 4). Only one of them has the physics in its loss.
- The plain network fits the six points, then in the region it never saw it plunges straight down and crosses below zero. That is not just wrong, it is impossible: a temperature below ambient means the part became colder than its surroundings while cooling toward them. With nothing to constrain it, the network invented a forbidden answer.
- The PINN traces the true curve across the entire no-data region. It cannot cross zero the way the plain network did, because the law in its loss forbids it.
The error in the region where there was no data at all:
| Model | Mean absolute error (no-data region) |
|---|---|
| Plain network (data only) | 0.599 |
| PINN (data and physics) | 0.001 |
The physics cut the error by roughly 500 times. Same six points. The only difference is that the PINN was also told the law. This is the first promise of PINNs: they need far less data, because physics supervises every empty region for free.
Act two: reading a constant out of the data
Now the stranger trick. Suppose we do not know the cooling constant k. We let the PINN treat k as an unknown to be learned alongside the network’s weights, starting from a deliberately wrong guess of 0.5.
- True k: 1.500
- Recovered by the PINN: 1.380, from six noisy readings, starting at 0.5
It does not land exactly on 1.5, and it should not. Six noisy points from only the early cooling carry limited information, and the honest recovered value reflects that. But the network read a physical constant out of raw measurements. This is the second promise of PINNs, the inverse problem, and it is how they are used to identify material properties such as diffusivities, rate constants and moduli from sparse experimental data.
Why this matters for materials
Real experiments give you few data points, noisy and expensive to collect. Pure data-driven models are hungry for data and, worse, will happily extrapolate into the physically impossible. A law in the loss changes both. A model can generalise from a handful of measurements, and it stays fenced inside what physics allows.
For materials science, where we usually have deep theory and shallow data, that trade is often exactly the right one. You do not have to choose between a model that respects physics and a model that learns from data. A PINN is both, and the whole idea is just one extra term in the loss.
If you want to see where this sits among the other approaches, from graph networks that bake in symmetry to diffusion models that invent new materials, start with the map of the six methods.
Found a mistake? Good, tell me. This publication flags its own suspect values. Reach me on LinkedIn.