Computational Physics in Python

The following handouts were developed for my section of the course Physics 281, Computational Physics which uses Mark Newman’s excellent introduction Computational Physics as the course text.  These handouts are intended to supplement Newman’s book with some additional topics:

  • Using Spyder and Anaconda Distribution
  • More advanced plotting and graphics with Matplotlib including 3D plotting, animations, and introductory image analysis
  • Least-squares fitting of models to data (linear and nonlinear)
  • Using scipy and numpy for special functions, linear algebra, numerical integration, integrating ODEs, Fourier analysis, random number distributions.
  • Quick intro to Jupyter Notebook
  • Introductory object-oriented Python
  • Additional programming features including: Controlling output format, writing data files, using modules, optional and keyword function arguments, list comprehensions, tuples, and exception handling.

Here are the handouts:

Miscellaneous useful files:

  •   (module for easy least-squares fitting, see Fitting models to data handout)
  •  (needed at present make Mayavi work on Windows, see Getting started with Anaconda Distribution handout)

Note: The .py files in this list have been renamed as .txt files to enable download (many systems will not allow download of .py files because they are executable).