Complete
Inverse Heat Transfer with PINNs
Recovering unknown heat flux and material properties with a physics-informed neural network.
- Accuracy (time-invariant flux)99%
- Accuracy (time-variant flux)97%
- Convergence vs. paper~10× faster
What it does
A re-implementation, with improvements, of a research paper that solves a 1D inverse heat transfer problem with Physics-Informed Neural Networks (Billah et al., 2023), done with Keshav Kumar.
- Synthetic training data generated with Green's functions.
- A PINN with a custom learning-rate scheduler that co-optimises the network weights and the thermophysical parameters.
- 99% accuracy for time-invariant flux and 97% for time-variant flux.
- Converges ~10× faster than the original paper.
- The repo has the data generation (
GT.ipynb), the training (iht_with_pinn.ipynb) and a full report (report.pdf).
The cell below computes the problem's exact solution live: a slab heating up, and the points a PINN would be trained on. Change the heat-flux case, or α to see how fast heat spreads.
The problem
A slab of length m starts at (temperatures are measured from the starting temperature). A heat flux enters at the left face and the right face is insulated:
The forward problem is to find when and the thermal diffusivity are known. The inverse problem goes the other way: from measured temperatures, find and . It is ill-posed (many parameter sets fit noisy data almost equally well), and it is what a PINN can do that an ordinary neural network can't: the unknown parameters sit inside the loss, next to the network's weights, and are learned with them.
Three cases, as in the paper:
- Constant flux: W/m², for s. Here both and are unknown.
- Linear flux: W/m², for s.
- Sinusoidal flux: W/m², one period in 1600 s ().
In the time-varying cases is known and is recovered at 9 times.
Ground truth from Green's functions
The training data comes from the exact solution, found with Green's functions. For the constant flux:
The time-varying fluxes add their own terms. For :
and for :
Each sum is cut at terms. The first part is the heat that has come in, spread evenly; the series describes how it is distributed along the slab.
The paper gives m²/s but not the conductivity . It can be recovered from the paper's plot of at s, where °C: at that time is negligible from on, and with the series at can be summed by hand. That gives W/(m·K), so throughout.
Training data
The solution is sampled every m (201 points) and every 15 s (constant case, a grid) or 1 s (the other two).
- Constant flux: 2,200 points chosen at random out of the 48,441.
- Time-varying flux: all 201 points at each of 9 times, so 1,809 points in all.
- Noisy variants: each temperature gets added, where is the spread of over time at that position: 10% noise.
The PINN
A fully connected network takes and predicts . The thermophysical parameters and are two extra trainable numbers. The loss has three parts:
The data term fits the measurements; the governing-equation term makes the network obey the heat equation at the training points (this is where is learned); the boundary term ties the slope at to the flux (this is where is learned). The derivatives come from automatic differentiation in PyTorch.
Time is scaled to , and for the time-varying cases the temperature to . The equations then hold with and , so all the learned numbers are of order 1.
For the time-varying cases, one network is trained per time (on that time's 201 points) and the governing-equation term is dropped, as in the paper: each network gives at its time.
Faster convergence
The paper uses one learning rate, 0.001, for everything. Its training took about 11.2 hours (an estimate from the paper's table for 2,000 points). Re-created exactly, it took 12 hours here. The improved training gives each part its own learning rate and schedule:
| Case | Network | Schedule |
|---|---|---|
| Constant | 8 × 20 tanh | (warming up from 0.1 over 2,000 epochs), ; , , |
| Time-varying | 3 × 30 SiLU | epochs 0–20k: fit the data only (); 20k–30k: network frozen () while learns from its slope; then both fine-tune (, 6.5 → 5.2 at 40k) |
Every run starts from (and in the constant case).
Results
Constant flux, true values W/m² and m²/s:
| Data | Paper: | Paper: | This work: | This work: | Training time |
|---|---|---|---|---|---|
| No noise | 9,989 | 9,999.7 | 0.53 h (paper ~11.2) | ||
| 10% noise | 9,968 | 10,042 | 0.48 h (paper ~11.2) |
For the linear and sinusoidal fluxes (no noise), the recovered at the 9 times is within 1.2% of the truth on average, after about 1.5 hours of training each.
The cell below replays those training runs from the values the notebook logged every 1,000 epochs: and walking towards the truth, and, for the time-varying cases, the 9 recovered fluxes rising onto the true once the boundary term is switched on.
References
- M. M. Billah, A. I. Khan, J. Liu and P. Dutta, Physics-informed deep neural network for inverse heat transfer problems in materials, Materials Today Communications 35, 106336, 2023.