Phys2274 Computational Physics


E.S. Swanson
217 Allen Hall

class meets Tuesday and Thursday, 2:30-3:45, 105 Allen Hall.

Office Hours: Tuesday and Thursday, 3:45 - 5:00.

this site in Belorussian

Course Description:

Modern computational methods have opened up a new realm in physics, allowing the study of complex nonlinear phenomena for the first time. We will explore a number of classic examples in this course, including the logistic map, nonlinear oscillators, chaotic planetary motion, molecular dynamics, and the Ising model. Additional topics are coding basics, integration, partial differential equations, quantum scattering and bound states, quantum magnetism, and the Monte Carlo method as applied to classical and quantum systems.

The primary focus of the course will be on physics, thus you will be expected to learn a computer language (if you do not know one already). No prior computer expertise is required, but the learning curve will be steep! The goal is to turn you into a computer-literate graduate student, with sufficient background to know what can be done with computers and where to go for resources. An important aspect of this will be the ability to produce and present professional quality research material.

Course Objectives:

By the end of PY2274 the student will be able to:


I will also be referring to the following Supplementary Texts:

These books are kinda expensive. Since the course will be largely self-contained, I recommend that you buy Numerical Recipes, which is the standard reference book and will likely be all you ever need. Sethna is a terrific introductory book, with many numerical examples. Giordano is a standard undergraduate level text. Gibbs is graduate level, but very brief.

Marking Scheme:

0.7 assignments + 0.3 final project


  1. coding basics:: Arrays, matrices, loops, IO, graphing, programming style, programming tips, testing your code, understanding your problem, debugging your code.
  2. numbers:: binary representation of numbers, floating point precision, largest and smallest numbers, errors and stability.
  3. integration, differentiation, extrapolation:: discretization schemes, evaluating polynomials, continued fractions, Borel summation, Pade approximants, extrapolation methods, interpolation methods, integration, singular integrands, adaptive quadrature, simple Monte Carlo, Fourier transforms and FFT.
  4. odes:: differencing, Euler, Euler-Cromer, Runge-Kutta, the damped, driven oscillator, chaos, the logistic map, make your own plants!
  5. pdes:: relaxation methods, multigrid methods, error analysis and stability, forward/backward differencing, implicit/explicit algorithms, the advection-diffusion problem.
  6. molecular dynamics:: gases, the equipartition theorem, melting, the Fermi-Pasta-Ulam problem.
  7. linear algebra::
    1. matrix inversion, solving integral equations
    2. diagonalization, tridiagonal systems, tridiagonalising, the Lanczos algorithm, stability and round-off
    3. quantum mechanics, 1d Schroedinger equation, basis functions, nonorthogonal bases, quantum bound states, scattering (momentum space, T-matrix), functional scattering method.
    4. more integral equations
    5. minimisation, integral equation (iii), fitting functions and data, minuit.
  8. Monte Carlo method:: theory, random numbers, Markov chains, ergodicity, Metropolis, heat bath, annealing, applications to percolation, the Ising model, Z(2) lattice gauge theory.
  9. survey of contemporary computational physics:: (we emphasize algorithms and computational issues) lattice gauge theory, climate modelling, numerical general relativity, supernovas, protein folding, quantum spin systems, nuclear physics.


Images from the Course

Affine Map
Logistic Map Bifurcation Plot
Damped, Driven Oscillator Phase Map
Exponential Function with the
Quotient-Difference Algorithm and
Pade Approximants
Argon gas Molecular Dynamics, low temp
Argon gas Molecular Dynamics, high temp
Magnus Force and Golf Balls
1+1 D Advection-Diffusion
Argon Molecular Dynamics
pair correlation function.
Argon Molecular Dynamics,
Emergent Disorder
Logistic Map Invariant Density (mu=3.8)
1-d anisotropic Heisenberg Antiferromagnet
spin chain, L=24, g=-1
Accuracy in S-wave SHO eigenvalues
Magnetisation in the Ising Model
Spin-Spin Correlation Function
in the Ising Model
Ising Spins at kT = 2.5
Z2 Gauged Spin Model
average plaquette
1d aHAF extrapolation

percolation demo

Computer Stuff:

This a a course in computational physics, so you will be doing a lot of coding. You will also be doing analytical work to back up your coding! I will spend almost no time teaching programming -- you are expected to pick this up yourself (if you have not already). Ideally, you will have ready access to a computer with a decent operating system and support software. I recommend the following: All algorithms will be taught in pseudo-code. I will support fortran coding (in other words if you have a bug or a question, I will help you). Other acceptable languages are C, C++, and python.

Installation help:

All of the recommended software is free and runs on any windows, mac, or linux system. You can find everything on the web with a judicious google search; I have collected much of the information here [if you find mistakes or additional information, please let me know!]
If you have a windows laptop, I suggest you make it dual boot. Alternatively, you can install cygwin on your machine. Its not perfect, but its free and works.
most linux systems have built-in fortran support. This is often as f2c -- a fortran to C converter program, f77 -- a wrapper program that generates executables using f2c, gfortran an implementation of the fortran90 convention, gfort -- .... You can obtain many of these from fink (for the mac).
gfortran for the mac
Python is already installed on macs, but is not quite what we want, as apple has walled it off for their own use. I recommend installing the Enthought distribution, that includes all the modules you will likely need.
Enthought Python Distribution
[Earn 10 points by telling me how to install python on the iPhone!]
If you have an older version of gnuplot, you should update. The new versions have fitting functionality and allow rotating 3d graphs; useful and very slick!
gnuplot linux binary (?) [html]
There are many all-in-one tex packages out there.
teTex is a nice package


programming style guide





code libraries

parallel programming

Statement: If you have a disability for which you are or may be requesting an accommodation, you are encouraged to contact both your instructor and Disability Resources and Services, 216 William Pitt Union, (412) 648-7890/(412) 383-7355 (TTY), as early as possible in the term. DRS will verify your disability and determine reasonable accommodations for this course. A comprehensive description of the services of that office can be obtained at