2026-02-05 · 4 min read · Physics · Neural Networks · Deep Learning · Thermodynamics
Heat Diffusion with Physics-Informed Neural Networks
How physics-informed neural networks learn heat diffusion by embedding the heat equation, boundary conditions, and initial conditions into training.
Heat is everywhere in engines, buildings, electronics, and even our bodies. Understanding how it moves through materials is a classic problem in physics and engineering. Traditionally, scientists use numerical methods like finite differences or finite elements to simulate heat flow. But these methods can be computationally expensive, especially for complex systems.
What if a neural network could learn heat diffusion directly from physics itself? That's exactly what Physics-Informed Neural Networks (PINNs) do.
What Are Physics-Informed Neural Networks (PINNs)?
Neural networks usually learn from data. If you want a network to predict temperatures, you feed it thousands of examples of input (position and time) and output (temperature).
PINNs take a different approach: instead of relying on data, they embed the laws of physics directly into the network. For heat diffusion, the network is penalized whenever its predictions violate the heat equation. This way, the network learns the solution while respecting physics.
In other words:
- Input: position (x) and time (t)
- Output: temperature (u(x,t))
- Loss function: combination of PDE residual, boundary conditions, and initial conditions
The network doesn't just memorize; it learns a continuous function that obeys thermodynamics.
The Heat Equation
For a simple 1D rod, heat diffusion is governed by:
∂u/∂t = α ∂²u/∂x²
Where:
- u(x,t) = temperature at position (x) and time (t)
- α = thermal diffusivity
- Boundary conditions specify the temperature at the ends of the rod
- Initial conditions define the starting temperature
PINNs approximate u(x,t) using a neural network:
u(x,t) ≈ uθ(x,t)
How the PINN Learns
Instead of training on thousands of examples, we generate random collocation points in the space-time domain. At each point, the network is evaluated for:
- PDE residual: is the heat equation satisfied?
- Boundary conditions: does the temperature match at the edges?
- Initial condition: does the temperature match the starting distribution?
The PDE residual loss is calculated from:
fθ(x,t) = ∂uθ/∂t − α ∂²uθ/∂x²
And the total loss function guiding the network is:
Ltotal = LPDE + LBC + LIC
Automatic differentiation computes derivatives of the network with respect to space and time, enabling the PDE residual to be evaluated efficiently.
Why This Matters
- Continuous solution: PINNs produce smooth predictions over space and time, unlike traditional grid-based methods.
- Fewer data requirements: Physics, not data, supervises the learning.
- Inverse problems: PINNs can also estimate unknown parameters like thermal diffusivity.
- Real-world applications: energy systems, electronics cooling, climate modeling, material science.
From 1D to 2D and Beyond
Starting with a 1D rod is straightforward, but PINNs scale naturally:
- 2D plates or 3D solids
- Complex geometries and heterogeneous materials
- Learning unknown thermal properties
- Combining physics with real sensor data
Visualizing the Results
You can create stunning visualizations:
- Heatmaps showing temperature distribution over a plate
- Line plots of temperature along the rod at different times
- Animations showing how heat propagates
These visuals make PINNs intuitive, even for non-experts.
Tools Used
- Python — main programming language
- PyTorch — deep learning framework
- NumPy & Matplotlib — computation and visualization
- Optional: GPU acceleration for faster training
Conclusion
Physics-Informed Neural Networks offer a fresh way to solve classical problems. By combining the power of neural networks with the rigor of physics, they allow us to learn continuous solutions with fewer data and greater flexibility.
For heat diffusion, PINNs are not just an experiment — they're a bridge between traditional numerical simulation and modern AI-driven modeling.
This project demonstrates how machine learning can respect the laws of nature, opening doors to applications in energy, engineering, and beyond.
Acknowledgements
I would like to thank the following sources and communities for inspiring and guiding this project:
- Raissi, M., Perdikaris, P., & Karniadakis, G. E. (2019) — for introducing Physics-Informed Neural Networks
- PyTorch community for excellent tools and tutorials on neural networks and automatic differentiation
- Medium authors and AI research bloggers who have shared accessible explanations of PINNs
- Friends and mentors in computational physics and machine learning communities for discussion and feedback
References
- Raissi, M., Perdikaris, P., & Karniadakis, G. E. (2019). Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational Physics, 378, 686–707. https://doi.org/10.1016/j.jcp.2018.10.045 (opens in a new tab)
- Karniadakis, G. E., Kevrekidis, I. G., Lu, L., Perdikaris, P., Wang, S., & Yang, L. (2021). Physics-informed machine learning. Nature Reviews Physics, 3, 422–440. https://doi.org/10.1038/s42254-021-00314-5 (opens in a new tab)
- Raissi, M., & Karniadakis, G. E. (2018). Hidden physics models: Machine learning of nonlinear partial differential equations. Journal of Computational Physics, 357, 686–707. https://doi.org/10.1016/j.jcp.2017.11.039 (opens in a new tab)
- Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press. https://www.deeplearningbook.org (opens in a new tab)