Thermodynamics Numerical Schemes Materials Pipeline & Output
Academic Technical Documentation

Mathematical & Physical Foundations of 2D Heat Conduction

A comprehensive guide covering Fourier's law of thermal conduction, the parabolic heat diffusion PDE, explicit FTCS stability criteria, and dual-solver verification against steady-state SOR relaxation.

C++17 & Python Engine Explicit FTCS Transient Solver SOR Steady-State Benchmark

1. Physics Foundations

Fourier's law, conservation of thermal energy, and the 2D Heat Equation

1.1 Fourier's Law of Heat Conduction

Fourier's law states that the local conductive heat flux density $\mathbf{q}$ ($\text{W/m}^2$) in an isotropic medium is directly proportional to the negative local temperature gradient $\nabla T$:

$$\mathbf{q} = -k \nabla T = -k \left( \frac{\partial T}{\partial x}\hat{\mathbf{i}} + \frac{\partial T}{\partial y}\hat{\mathbf{j}} \right)$$

Here, $k$ ($\text{W/m}\cdot\text{K}$) denotes the material's thermal conductivity. The negative sign ensures thermal energy flows spontaneously from regions of higher temperature toward regions of lower temperature in accordance with the Second Law of Thermodynamics.

1.2 Conservation of Energy & The 2D Heat PDE

For an infinitesimal control volume with mass density $\rho_m$ ($\text{kg/m}^3$) and specific heat capacity $c_p$ ($\text{J/kg}\cdot\text{K}$) without internal heat generation, the rate of internal thermal energy change equals the net conductive heat flux entering the volume:

$$\rho_m c_p \frac{\partial T}{\partial t} = -\nabla \cdot \mathbf{q} = -\nabla \cdot (-k \nabla T) = k \nabla^2 T$$

Dividing by volumetric heat capacity $\rho_m c_p$ defines the thermal diffusivity $\alpha = \frac{k}{\rho_m c_p}$ ($\text{m}^2/\text{s}$), yielding the 2D transient parabolic heat equation:

$$\frac{\partial T}{\partial t} = \alpha \nabla^2 T = \alpha \left( \frac{\partial^2 T}{\partial x^2} + \frac{\partial^2 T}{\partial y^2} \right)$$

Steady-State Limit: As $t \to \infty$, thermal equilibrium is reached ($\frac{\partial T}{\partial t} = 0$). The parabolic PDE collapses into Laplace's Elliptic Equation ($\nabla^2 T = 0$), which becomes strictly independent of material properties $\alpha$.

Dirichlet Boundary Conditions

The $L \times L$ ($0.1\text{ m} \times 0.1\text{ m}$) plate is initialized at uniform temperature $T(x,y,0) = T_0$, while the four edges are clamped to fixed isothermal reservoirs:

  • Top ($y = L$): $T_{N-1, j} = T_{\text{top}}$
  • Bottom ($y = 0$): $T_{0, j} = T_{\text{bottom}}$
  • Left ($x = 0$): $T_{i, 0} = T_{\text{left}}$
  • Right ($x = L$): $T_{i, N-1} = T_{\text{right}}$

Perceptually Uniform Heat Maps

The Python visualizer maps the discrete $100 \times 100$ scalar temperature matrix $T_{i,j}$ using Matplotlib's perceptually uniform Inferno colormap:

Peak High Temperature $\rightarrow$ Bright Yellow / White
Intermediate Thermal Gradient $\rightarrow$ Fiery Orange / Crimson
Cold Sink / Ambient Low $\rightarrow$ Deep Violet / Black

2. Numerical Schemes & Stability

FTCS explicit time-stepping, Courant-Friedrichs-Lewy (CFL) stability, and SOR verification

2.1 Forward-Time Central-Space (FTCS) Discretization

Discretizing time with step $\Delta t$ ($t^n = n\Delta t$) using a first-order forward difference $\mathcal{O}(\Delta t)$, and space with uniform grid spacing $h = \Delta x = \Delta y = \frac{L}{N-1}$ using second-order central differences $\mathcal{O}(h^2)$:

$$\frac{T_{i,j}^{n+1} - T_{i,j}^{n}}{\Delta t} = \alpha \left( \frac{T_{i+1,j}^{n} - 2T_{i,j}^{n} + T_{i-1,j}^{n}}{h^2} + \frac{T_{i,j+1}^{n} - 2T_{i,j}^{n} + T_{i,j-1}^{n}}{h^2} \right)$$

Defining the dimensionless mesh Fourier number $r = \frac{\alpha \Delta t}{h^2}$, we isolate the next timestep temperature $T_{i,j}^{n+1}$:

$$T_{i,j}^{n+1} = T_{i,j}^{n} + r \left( T_{i-1,j}^{n} + T_{i+1,j}^{n} + T_{i,j-1}^{n} + T_{i,j+1}^{n} - 4T_{i,j}^{n} \right)$$

2.2 Von Neumann Stability & Critical Timestep

Explicit time-marching schemes are conditionally stable. Rewriting the FTCS update at the center node gives a coefficient of $(1 - 4r)$ on $T_{i,j}^n$. To prevent non-physical checkerboard oscillations and exponential error amplification, the coefficient must remain non-negative:

$$1 - 4r \ge 0 \quad \implies \quad r = \frac{\alpha \Delta t}{h^2} \le \frac{1}{4} \quad \implies \quad \Delta t_{\max} = \frac{h^2}{4\alpha}$$

Thermalism enforces a $10\%$ safety margin ($\Delta t = 0.9 \, \Delta t_{\max}$, yielding $r = 0.225$), guaranteeing monotonic stability across all materials while maximizing step size.

FTCS Update Weights
NORTH$+r$
WEST$+r$
SELF$1 - 4r$
EAST$+r$
SOUTH$+r$
At $r = 0.225$: Center weight $= 0.10$

2.3 Dual-Solver Cross-Verification (FTCS vs. SOR)

1. Transient FTCS Time-Marching

Time-Accurate

Advances physical time $t$ step-by-step until the maximum instantaneous heating/cooling rate across the entire plate drops below tolerance $\epsilon = 10^{-5}\text{ K/s}$:

$$\max_{i,j} \left| \frac{T_{i,j}^{n+1} - T_{i,j}^{n}}{\Delta t} \right| < 10^{-5}$$
Captures physical snapshots $T(x,y,t_k)$

2. Steady-State SOR Solver

$\omega = 1.85$

Independently solves Laplace's equation ($\nabla^2 S = 0$) using Successive Over-Relaxation to verify that the asymptotic transient state $T(t_{\text{final}})$ matches exact equilibrium $S$:

$$S_{i,j}^{(k+1)} = (1-\omega)S_{i,j}^{(k)} + \frac{\omega}{4}\left(S_{i-1,j}^{(k+1)} + S_{i+1,j}^{(k)} + S_{i,j-1}^{(k+1)} + S_{i,j+1}^{(k)}\right)$$
Computes residual error map $E_{i,j} = T_{i,j} - S_{i,j}$

3. Material Properties & Characteristic Timescale

Built-in thermophysical constants and Fourier mode snapshot scheduling

3.1 Characteristic Thermal Diffusion Time ($\tau$)

By separation of variables on a square plate of side $L = 0.1\text{ m}$, the fundamental $(1,1)$ spatial Fourier eigenmode decays exponentially as $e^{-t/\tau}$. Thermalism uses $\tau$ to dynamically schedule non-uniform snapshot timestamps regardless of whether the plate is fast-conducting Copper or slow-conducting Stainless Steel:

$$\tau = \frac{L^2}{2\pi^2 \alpha}, \qquad t_{\text{snaps}} \in \{ 0,\; 0.1\tau,\; 0.5\tau,\; 1.0\tau,\; 2.0\tau,\; 4.0\tau,\; t_{\text{final}} \}$$

Because $\tau \propto \alpha^{-1}$, snapshots cluster densely during early boundary-layer penetration ($0.1\tau, 0.5\tau$) and space out exponentially as the plate approaches asymptotic equilibrium ($4.0\tau \rightarrow t_{\text{final}}$).

3.2 Built-in Engineering Materials ($L = 0.1\text{ m}, \; 100 \times 100$ Grid)

Material $k$ ($\text{W/m}\cdot\text{K}$) $\rho_m$ ($\text{kg/m}^3$) $c_p$ ($\text{J/kg}\cdot\text{K}$) $\alpha$ ($\text{m}^2/\text{s}$) $\tau$ (s)
Copper 401.0 8960 385 $1.162 \times 10^{-4}$ 4.36 s
Aluminium 237.0 2700 897 $9.786 \times 10^{-5}$ 5.18 s
Brass 109.0 8500 380 $3.375 \times 10^{-5}$ 15.01 s
Iron 80.0 7870 447 $2.274 \times 10^{-5}$ 22.28 s
Stainless Steel 16.0 8000 500 $4.000 \times 10^{-6}$ 126.65 s

4. Computational Pipeline & Sample Output

End-to-end execution workflow and multi-timestamp plate evolution

1

Domain & Dirichlet Boundary Setup

Initialize $100 \times 100$ mesh nodes to $T_0$ and enforce isothermal boundary temperatures $(T_{\text{top}}, T_{\text{bottom}}, T_{\text{left}}, T_{\text{right}})$ on outer matrix edges.

2

FTCS Transient Marching & Snapshot Capture

Advance time using $\Delta t = 0.9 \frac{h^2}{4\alpha}$, recording full temperature grids at $t = \{0, 0.1\tau, 0.5\tau, 1.0\tau, 2.0\tau, 4.0\tau\}$ until $\max |\partial T/\partial t| < 10^{-5}$.

3

SOR Steady-State Cross-Check & CSV Export

Solve $\nabla^2 S = 0$ via SOR ($\omega = 1.85$), verify maximum discrepancy $\max |T_{\text{final}} - S|$, and write node coordinates plus all time-series snapshots to output.csv.

4

Automated Matplotlib Diagnostic Grid

Invoke visualizer.py automatically via system call to render the multi-panel heatmap evolution, SOR comparison, residual error map, and vertical centerline temperature profiles.

Sample Simulation Output (sample.png)

Multi-panel diagnostic plot showing transient plate evolution across timestamps ($t=0 \rightarrow t_{\text{final}}$), SOR steady-state benchmark, residual difference map, and centerline thermal profiles.

130 DPI GridSpec Render
Thermalism 2D heat conduction simulation output showing temperature evolution across timestamps, SOR steady-state comparison, residual error heatmap, and centerline temperature curves
Figure 1: Temporal evolution of the $100 \times 100$ plate from initial state ($t = 0\text{ s}$) through intermediate $\tau$-multiples to steady-state convergence. Generated by visualizer.py

Explore Code Implementation

View thermalsim.cpp, visualizer.py, and sample datasets on GitHub.

anuz-912/thermalism