Here are some of the codes I've written. They're mainly focussed on tokamak research, but some are more generally useful. All released under an open-source license: BSD, MIT, GPL, or LGPL, depending on my mood at the time. See the individual codes for details.


A free boundary Grad-Shafranov solver, written in Python. Calculates tokamak equilibria given a set of coils and plasma profiles.


Provides a Python interface to D.G.Muir's IDAM library, used to access data from the Mega-Amp Spherical Tokamak (MAST).


A tokamak flux grid generator, written in IDL. Intended to be an easy to use and reliable grid generator, but still at quite an early stage of development. If anyone makes improvements to the code, please submit a patch to help improve it. Main features are:

  • Can handle an arbitrary number of x-points
  • Fills in default settings if not supplied
  • Detects when invalid settings are used, corrects them and tries again


A collection of routines for analysing tokamak equilibria. Currently includes reading DSKGATO and ELITE inputs, and some neoclassical theory calculations of trapped particle fractions, viscosities, and bootstrap current


This is a fast image enhancement program, written in C. It takes a series of images, or an IPX video from the MAST photron camera; processes the frames as specified by a scripting language; and writes the processed frames either as a set of numbered images (in PNG or BMP format) or as an IPX video. Using a Makefile-like scripting language, the layout of the output frames and the processing steps can be customised. In addition to many standard image processing functions:

  • Amplification
  • Contrast maximisation
  • Gamma correction
  • Gaussian blurring/smoothing
  • Median noise removal
  • Sharpening using the Unsharp-Mask algorithm
the code maintains a window of frames of variable width. A pixel-wise average or minimum of these frames can be treated as a slowly-varying "background" which can be subtracted from the central frame, leaving only transient features like filaments. Some care must be taken when using these methods since they can result in artifacts but generally they work very well.


Most of my research time is spent working on this. It's a finite difference simulation code, written in C++ and parallelised using MPI and OpenMP.


This is a graphical interface in Python for reading, analysing, and plotting data from the MAST experiment and other sources. It uses the PyIDAM interface to read the data, PySide to create the interface, and matplotlib to draw the plots. It's intended to eventually replace the XPAD code currently used for this purpose, but is not yet ready for use really.

HPC for D

A collection of interfaces to libraries for High Performance Computing in the D programming language. Currently only a basic interface to MPI is working