PDE Numerical Methods
Discretizing partial differential equations on spatial grids: finite differences, finite elements, and spectral methods for the heat equation, wave equation, and Laplace's equation.
PDE Classification
The three canonical types of second-order PDEs, each with distinct physical behavior and numerical requirements:
Parabolic (Heat)
\(u_t = \alpha u_{xx}\)
Diffusion, smoothing. Information propagates at infinite speed.
Hyperbolic (Wave)
\(u_{tt} = c^2 u_{xx}\)
Waves, propagation. Finite speed, characteristics.
Elliptic (Laplace)
\(u_{xx} + u_{yy} = 0\)
Steady-state, boundary value problem. No time dependence.
1. Finite Difference Approximations
Replace derivatives with differences on a discrete grid. From Taylor expansion:
Forward: \(u'(x) \approx \frac{u(x+h) - u(x)}{h} + O(h)\)
Central: \(u'(x) \approx \frac{u(x+h) - u(x-h)}{2h} + O(h^2)\)
Second derivative: \(u''(x) \approx \frac{u(x+h) - 2u(x) + u(x-h)}{h^2} + O(h^2)\)
2. Heat Equation: Explicit Method
The 1D heat equation \(u_t = \alpha u_{xx}\) with the FTCS (Forward Time, Central Space) scheme:
\(u_j^{n+1} = u_j^n + r(u_{j+1}^n - 2u_j^n + u_{j-1}^n)\)
where \(r = \alpha \Delta t / (\Delta x)^2\). Stable only if \(r \leq 1/2\) (von Neumann analysis).
1D Heat Equation: Explicit FTCS
PythonClick Run to execute the Python code
Code will be executed with Python 3 on the server
3. Crank-Nicolson: The Best of Both Worlds
Average the explicit and implicit schemes to get second-order accuracy in both space and time, while remaining unconditionally stable:
\(u_j^{n+1} - \frac{r}{2}(u_{j+1}^{n+1} - 2u_j^{n+1} + u_{j-1}^{n+1}) = u_j^n + \frac{r}{2}(u_{j+1}^n - 2u_j^n + u_{j-1}^n)\)
Implicit: requires solving a tridiagonal system at each time step. \(O(h^2 + (\Delta t)^2)\) accuracy.
Crank-Nicolson for Heat Equation
PythonClick Run to execute the Python code
Code will be executed with Python 3 on the server
4. The CFL Condition
The Courant-Friedrichs-Lewy condition is the fundamental stability criterion for explicit methods on hyperbolic (wave) equations:
\(\Delta t \leq C \frac{\Delta x}{|v_{\max}|}\)
The Courant number \(C = |v| \Delta t / \Delta x \leq 1\). Physical interpretation: the numerical domain of dependence must contain the physical domain of dependence.
Wave Equation: CFL Condition in Action
PythonClick Run to execute the Python code
Code will be executed with Python 3 on the server
5. Finite Element Method: Basics
Instead of approximating derivatives (finite differences), FEM approximates the solution itself as a sum of basis functions\(u(x) \approx \sum_j c_j \phi_j(x)\) and finds coefficients via the weak (variational) form.
Weak Form of Poisson's Equation
Strong form: \(-u''(x) = f(x)\) on \([0, 1]\), \(u(0) = u(1) = 0\)
Weak form: Find \(u \in H_0^1\) such that for all test functions \(v \in H_0^1\):
\(\int_0^1 u'(x) v'(x) \, dx = \int_0^1 f(x) v(x) \, dx\)
Integration by parts trades one derivative from \(u\) to \(v\), weakening the smoothness requirement. With piecewise-linear (hat function) basis, this yields a tridiagonal stiffness matrix.
1D Finite Element Method for Poisson Equation
PythonClick Run to execute the Python code
Code will be executed with Python 3 on the server
6. Spectral Methods
Use global basis functions (Fourier modes, Chebyshev polynomials) instead of local ones. For smooth solutions, spectral methods converge exponentially (faster than any polynomial rate).
Spectral Method: Solving Poisson with FFT
PythonClick Run to execute the Python code
Code will be executed with Python 3 on the server
7. Laplace Equation: 2D Steady State
2D Laplace Equation with Jacobi Iteration
PythonClick Run to execute the Python code
Code will be executed with Python 3 on the server