Computational Physics
Computational physics bridges theory and experiment — solving equations that cannot be solved analytically, simulating systems too complex for closed-form treatment, and testing theoretical predictions with numerical precision. It is now a third pillar of physics alongside theory and experiment.
- Implement and compare Euler, Verlet, and RK4 integrators and explain why symplectic methods conserve energy over long times.
- Derive the von Neumann stability condition for explicit finite-difference schemes and state when Crank-Nicolson is preferred.
- Apply the Metropolis algorithm to
- Describe molecular dynamics simulations: force evaluation, Nosé-Hoover thermostats, and the O(N log N) neighbor-list optimisation.
- Explain spectral (pseudospectral) methods and why they achieve exponential convergence for smooth periodic problems.
CP.1 Numerical Integration of ODEs
Most physics problems reduce to ODEs: ẋ = f(x, t). The simplest integrator:
Euler is first-order accurate (local error O(h²), global O(h)). For conservative systems it does not preserve energy. The Leapfrog/Störmer-Verlet method:
Verlet is second-order and symplectic — it preserves the Poincaré invariants (area in phase space) and exhibits bounded energy drift instead of accumulating error. Essential for long-time integrations (molecular dynamics, orbital mechanics).
The Runge-Kutta 4th order (RK4) method is the workhorse for non-conservative problems:
where k₁ = f(x_n, t_n), k₂ = f(x_n + hk₁/2, t_n + h/2), etc. Fourth-order accurate. Adaptive step-size control: use embedded methods (Runge-Kutta-Fehlberg RK45) that estimate local error and adjust h automatically.
CP.2 Finite Difference Methods for PDEs
Replace continuous derivatives with finite differences on a grid (spacing Δx, Δt):
1D Heat equation ∂u/∂t = D ∂²u/∂x²: Explicit FTCS: u_(i,n+1) = uᵢₙ + r(u_(i-1,n) − 2u_(i,n) + u_(i+1,n)) where r = DΔt/Δx². Stability requires r ≤ 1/2 (von Neumann analysis). Implicit Crank-Nicolson: r ≤ ∞ (unconditionally stable, second order in both t and x).
Wave equation ∂²u/∂t² = c² ∂²u/∂x²: FTCS explicit: u_(i,n+1) = 2u_(i,n) − u_(i,n-1) + s²(u_(i+1,n) − 2u_(i,n) + u_(i-1,n)) where s = cΔt/Δx (CFL number). Stability requires s ≤ 1 (Courant-Friedrichs-Lewy condition).
Simulate Earth's orbit around the Sun using Störmer-Verlet with adaptive timestep.
CP.3 Monte Carlo Methods
Monte Carlo integration: estimate ∫ f(x) dx by sampling random points. For d dimensions, the error scales as N^(−1/2) independent of d — far better than grid methods (which scale as N^(−2/d) in d dimensions, becoming useless for d ≫ 3).
Markov Chain Monte Carlo (MCMC)— Metropolis algorithm: Generate trial move x → x'. Accept if E(x') < E(x). If E(x') > E(x): accept with probability e^(−ΔE/(k_BT)). This samples the Boltzmann distribution P ∝ e^(−E/(k_BT)).
Applications: the Ising model (compute phase transition), protein conformation sampling, Bayesian posterior sampling, path integrals (lattice QCD computes hadron masses this way).
Quantum Monte Carlo (diffusion Monte Carlo, variational MC): computes exact ground state energies for quantum many-body systems. The Schrödinger equation in imaginary time τ = it: ∂ψ/∂τ = −Hψ → the long-time solution is the ground state (exponentially grows for ground state, decays for excited states). Treat this as a diffusion equation with source/sink from the potential.
CP.4 Molecular Dynamics
Molecular dynamics (MD): integrate Newton's equations for N interacting particles. Force: F_i = −∂U/∂r_i where U = Σ V(rᵢⱼ) (pair potential). Lennard-Jones potential: V(r) = 4ε[(σ/r)¹² − (σ/r)⁶] (repulsion + attraction).
Typical MD: N = 10⁴–10⁷ atoms, timestep h = 1 fs (10⁻¹⁵ s), total time 1 ns–1 μs. The key challenge: force calculation scales as O(N²) naively → reduced to O(N log N) with Verlet neighbor lists and particle-mesh Ewald for electrostatics.
Thermostats control temperature by coupling to a heat bath: Nosé-Hoover (NVT ensemble), Langevin dynamics (adds friction and random force).Barostats control pressure (NPT). Most biological simulations use NPT.
CP.5 Spectral Methods and FFT
For periodic boundary conditions or smooth solutions, expand in Fourier modes. Derivatives become multiplications: (d^n f/dx^n)_k = (ik)^n f_k. The FFT computes all N Fourier coefficients in O(N log N) time.
Pseudospectral method: advance in time in real space (simple); compute derivatives in k-space (accurate). For Navier-Stokes turbulence: dealiasing (2/3 rule removes aliasing error). Spectral accuracy: error ∝ e^(−cN) for smooth functions (exponential convergence vs. algebraic for finite differences).
DMRG (Density Matrix Renormalization Group): O(D³) algorithm to find ground states of 1D quantum systems with matrix product states (MPS). D is the bond dimension. For gapped systems: D grows slowly with system size (area law of entanglement). Extends to 2D (PEPS) and to finite T (MERA, MPO thermofield). State of the art for 1D quantum chemistry.
- Small timestep is not a proof of correctness: check convergence by reducing h and comparing invariants.
- Euler is rarely acceptable for long conservative dynamics: energy drift can dominate the physics.
- Stability and accuracy differ: a stable finite-difference scheme can still be too inaccurate.
- Random sampling needs equilibration: discard burn-in and account for autocorrelation.
- Spectral methods assume smoothness: discontinuities cause ringing and destroy exponential convergence.
- Verlet/leapfrog: symplectic integrator preserving phase space volume. Essential for Hamiltonian systems.
- RK4: fourth-order, general purpose. Adaptive step-size (RK45) controls global error automatically.
- onally stable.
- n distribution.
- FFT: O(N log N). Pseudospectral: exponential accuracy for smooth problems + 2/3 dealiasing rule.
- ns.