Discipline Elective I – Computational Physics
(M.Sc. Physics – First Elective)
1. Simple Explanation
Computational physics uses numerical algorithms and computer simulations to solve physical problems that are difficult or impossible to tackle analytically.
- Why it matters – Modern research relies on large‑scale simulations (e.g., climate models, lattice QCD).
- What you’ll learn – Discretisation of differential equations, root‑finding, Monte‑Carlo techniques, parallelisation, and error analysis.
- Goal – Be able to design, implement, and validate a computational model for a physics problem.
2. Key Points
| # | Concept | Why It’s Important | Typical Tools / Libraries |
|---|---|---|---|
| 1 | Discretisation | Convert continuous equations (ODE/PDE) into algebraic systems. | Finite Difference, Finite Element, Spectral Methods |
| 2 | Stability & Convergence | Numerical solutions must approach the true solution as step‑size → 0. | CFL condition, truncation error analysis |
| 3 | Root‑Finding & Optimization | Many problems reduce to solving (f(x)=0) or minimizing a cost function. | Newton‑Raphson, Bisection, Gradient Descent |
| 4 | Monte‑Carlo (MC) | Stochastic sampling for integrals, statistical mechanics, random walks. | Importance sampling, Metropolis–Hastings |
| 5 | Eigenvalue Problems | Needed for quantum mechanics, vibrational analysis, stability. | Power Method, QR algorithm, Jacobi diagonalisation |
| 6 | Parallelisation & Performance | Large problems require multi‑core or GPU acceleration. | OpenMP, MPI, CUDA, Numba |
| 7 | Error Estimation & Validation | Quantify confidence in results. | Richardson extrapolation, comparison with analytic limits |
| 8 | Software & Workflow | Reproducibility and maintainability. | Python + NumPy/SciPy, Fortran/C++ for performance, Git, Jupyter |
3. Worked Example
Problem: Solve the time‑independent Schrödinger equation for a particle in a one‑dimensional infinite square well of width (L) using the finite‑difference method.
3.1. Theoretical Background
The Schrödinger equation (atomic units, (\hbar=1, m=1)):
[ -\frac{1}{2}\frac{d^{2}\psi(x)}{dx^{2}} = E,\psi(x), \qquad 0 < x < L ] with boundary conditions (\psi(0)=\psi(L)=0).
Analytic solutions: (E_n = \frac{n^2\pi^2}{2L^2}).
3.2. Discretisation
- Divide the domain into (N) intervals: (x_i = i,\Delta x), (i=0,\dots,N).
- (\Delta x = L/N).
- Approximate second derivative by central difference:
[ \frac{d^{2}\psi}{dx^{2}}\Big|{x_i}\approx \frac{\psi{i+1} - 2\psi_i + \psi_{i-1}}{(\Delta x)^2} ]
Insert into Schrödinger equation:
[ -\frac{1}{2}\frac{\psi_{i+1} - 2\psi_i + \psi_{i-1}}{(\Delta x)^2} = E,\psi_i ]
Rearrange to eigenvalue form:
[
- \frac{1}{2(\Delta x)^2}\psi_{i-1} + \frac{1}{(\Delta x)^2}\psi_i - \frac{1}{2(\Delta x)^2}\psi_{i+1} = E,\psi_i ]
This is a tridiagonal matrix equation (H\mathbf{\psi} = E\mathbf{\psi}) with
[ H_{ii} = \frac{1}{(\Delta x)^2}, \quad H_{i,i-1} = H_{i,i+1} = -\frac{1}{2(\Delta x)^2} ]
3.3. Implementation (Python)
import numpy as np
from scipy.linalg import eigh_tridiagonal
# Parameters
L = 1.0 # width of the well
N = 100 # number of intervals
dx = L / N
# Tridiagonal matrix elements
diag = np.full(N-1, 1.0 / dx**2) # main diagonal
off = np.full(N-2, -0.5 / dx**2) # sub/super diagonal
# Compute lowest 3 eigenvalues/vectors
e_vals, e_vecs = eigh_tridiagonal(diag, off, select='i', select_range=(0,2))
print("Computed energies:")
for i, E in enumerate(e_vals):
print(f" n={i+1} : E = {E:.6f}")
# Analytical energies
n = np.arange(1,4)
E_analytical = (n**2 * np.pi**2) / (2 * L**2)
print("\nAnalytical energies:")
for i, E in enumerate(E_analytical):
print(f"