Computational Physics with Python

Simulate the modern physics frontier from scratch: quantum mechanics and computing, statistical physics and Monte Carlo, chaos, and complex systems.

10 projects, 250 hands-on levels, run in your browser.

Syllabus

  • Quantum States & Measurement: Quantum mechanics, built from scratch in numpy. A qubit is just a vector of complex amplitudes. Represent quantum states, put them in superposition, and extract physical predictions with the Born rule, the probabilistic measurement that lies at the heart of quantum theory. This is the foundation of quantum computing.
  • Quantum Gates & Circuits: Quantum gates are unitary matrices that transform qubit states. Build the Pauli gates and the Hadamard, compose them into circuits (matrix products), extend to multi-qubit systems with the tensor product, and apply the two-qubit CNOT gate, the operations from which every quantum algorithm is built.
  • Entanglement & Quantum Algorithms: Entanglement is quantum computing's defining resource: correlations between qubits with no classical explanation. Detect entanglement, see the measurement correlations that puzzled Einstein, implement quantum teleportation, and build Grover's search algorithm, your first quantum algorithm with a real speedup.
  • Wavefunctions & the Schrodinger Equation: Continuous quantum mechanics: the wavefunction describes a particle's state in space. Discretize space, build the Hamiltonian as a matrix, and solve the Schrodinger equation as an eigenvalue problem to find quantized energy levels, the physics of atoms. Then watch a particle tunnel through a barrier it classically cannot cross.
  • Randomness & Monte Carlo: Randomness is a computational tool. Simulate random walks (the physics of diffusion), estimate pi by throwing random darts, integrate functions by random sampling, and see how the law of large numbers makes these estimates converge. Monte Carlo methods turn hard problems into easy averages, the physics of the very many.
  • Statistical Mechanics: The Ising Model: The Ising model is statistical physics' most famous simulation: a lattice of spins that, with the Metropolis Monte Carlo algorithm, spontaneously orders into a magnet below a critical temperature. Build the spins and energy, implement Metropolis sampling, and watch a phase transition emerge, order from disorder.
  • Nonlinear Dynamics & Chaos: Simple deterministic rules can produce unpredictable behavior, chaos. Iterate the logistic map and watch it go from a steady state through period-doubling to chaos. See the butterfly effect (tiny differences exploding), measure it with the Lyapunov exponent, and explore the Lorenz attractor, the system that launched chaos theory.
  • Cellular Automata & Emergence: Complex behavior from simple local rules. A cellular automaton updates each cell from its neighbors, yet produces chaos, fractals, and life-like patterns. Build elementary 1D automata (Rule 30's chaos, Rule 90's fractal), then Conway's Game of Life and its gliders, the deepest demonstration that simple rules generate emergent complexity.
  • Complex Networks: Networks are everywhere: social ties, the web, neurons, power grids, disease spread. Represent a network as a matrix, measure its degree, clustering, and path lengths, discover the small-world effect (six degrees of separation), and simulate epidemics and percolation. Emergence on a different stage: how the structure of connections shapes collective behavior.
  • Capstone: Critical Phenomena: The grand finale: the universal physics of phase transitions and criticality, the thread running through this whole track. Build percolation (a geometric phase transition with a sharp critical threshold), the self-organizing sandpile, and power-law analysis. Discover universality, why magnets, percolation, epidemics, and chaos share the same critical mathematics, and characterize a critical transition from scratch.

Key concepts

  • Cellular automaton: A grid of cells updated by a local rule each step; simple rules produce complex emergent patterns.
  • Chaos: Deterministic dynamics with extreme sensitivity to initial conditions, so long-term prediction fails despite fixed rules.
  • Critical phenomena: The universal behavior near a phase transition, where quantities follow power laws independent of microscopic detail.
  • Entanglement: A correlation between quantum systems so strong that measuring one instantly determines the other, with no classical analog.
  • Ising model: A lattice of spins (+/-1) with neighbor interactions; a canonical model of phase transitions, simulated with Monte Carlo.
  • Monte Carlo method: Estimating quantities by random sampling, used for integration and for simulating statistical-physics systems.
  • Observable: A measurable quantity (energy, position), represented by an operator whose expectation value is the average measurement.
  • Phase transition: A qualitative change of a system's state (e.g., ordered to disordered) at a critical parameter, marked by diverging fluctuations.
  • Quantum state: A vector (amplitudes) describing a quantum system; measurement yields an outcome with probability equal to the squared amplitude.
  • Schrödinger equation: The fundamental equation governing how a quantum state evolves in time; solved numerically by discretizing space and time.
  • Superposition: A quantum system can be in a combination of basis states at once; measurement collapses it to one with the corresponding probability.