Category Archives: Accelerator Physics

Running MAD8 on OSX 10.8 to 10.11

(* Update: checked to work on 10.11 El Capitan as well *)

If you’ve worked in accelerator physics in any significant way, then you will have heard of MAD (‘Methodical Accelerator Design’) written at CERN many, many years ago, but still widely used for optics design, matching, and various tracking and nonlinear work. Quite a few working accelerators have been designed using various versions of it, including the SRS, DIAMOND, ALICE, and some parts of CLIC; I know these examples because I used MAD for them!

MAD8, the older-style code written in Fortran, has given way to MADX (it’s not considered polite to ask what happened to MAD9, but its legacy lives on in several other codes), and support for MAD8 has effectively stopped, with a few legacy versions floating around. SLAC implemented linac-style acceleration into their version 8.23acc, and a long time ago I did an optimised (and slightly debugged) version of MAD8 for Windows called 8.23dl. (By the way, you can tell which version you’re using from the code version at the top of any plot, so I know who you are if you’re using my version!). There are slight differences, but more or less you can trust what comes out of them.

MADX has taken over, but there are still reasons to use MAD8 from time to time. Most people who have used MAD8 have a love/hate relationship with it: they’ve had to get used to the code and its idiosyncrasies, but the combination of the simple XSIF file format and the relatively nice command structure means you can ‘get stuff done’. This is particularly true if you have some old input files that you don’t want to bother to convert to MADX format (yes, I hate converting files).

Whilst there are installers for MAD8 on Windows (my old friend James Jones has a really nice integrated package), and Linux is basically no problem, us poor old Mac users tend to be the poor cousins, especially with new OSes like 10.8. But fear not, here is a recipe for getting MAD8 up and running on OSX 10.8 Mountain Lion.

The procedure is as follows:

  • Grab a copy of all the files from:
  • The mad8 binary is hard-wired to look for library files in one location, so you will need to create the following directory path (using sudo probably):/sw2/lib/gcc4.4/lib/
    Put the libgcc_s.1.dylib and libgfortran.3.dylib files into this directory
  • Put the other files in a directory of your choice. I chose ~/dev/mad8/
  • chmod u+x * in this directory
  • If you don’t already have a file called dict, then do cp mad8.dict dict.

That’s it! You should now be able to run MAD8. I’ve included an input file for the old Daresbury SRS called srs.mff, which you can get here: srs.mff.

You can now run MAD8 using e.g.:
./mad8s < srs.mff > echo.txt

This should create a file that you can load, and a print file that you can see your output in. Plenty of tools are available to work these files.

You may find on first running mad8s that you get a prompt to install X windows. Go ahead and do that, or get it direct from

Hope that helps!

RCUK Careers in Research Case Studies

A little while ago I took part in the RCUK Case Study of research careers in the UK. It’s interesting to read the stories of different people – I seem to be one of the older people who answered the survey questions! Anyway, you can look at the case studies, and even read mine if you want! I’ve copied it below.

Producing beams of high-energy radiation is increasingly important both for research and industry. Particle accelerators use electromagnetic fields to propel charged particles, such as protons or electrons at very high speeds to form these beams, which have a wide range of uses. This includes understanding the laws of physics and treating cancer. Hywel Owen describes how his career path owed a lot to chance.

“Research helps to ennoble man and to create the conditions in which one day there will be no hunger and where all our material needs will be met. If we reduce want, we lessen the chances of war.”

My work focuses on design, simulation and experimentation involving particle accelerators. I’m a Lecturer in the Accelerator Group at the University of Manchester’s School of Physics and Astronomy, and a member of the Cockcroft Institute for Accelerator Science. I teach Undergraduates and postgraduates, manage research grants and staff, and oversee safety. I have been closely involved in most of the particle accelerators constructed in the UK over the past 20 years and am an adviser for a range of programmes.

My parents are both teachers with strong beliefs in the benefit of education. I rebelled against them by going into physics instead of music, which they both taught. I still love music though. As a child, I had good scientific toys: luminous stars on the ceiling, a microscope, a chemistry set, a ZX81 computer and lots of books. I also had a passion for museums, and frequently visited the Science and Natural History Museums. In particular I liked the Foucault pendulum and computer exhibitions, which I still remember today. As a teenager, I had good social guidance from my local sports club and was mentored by a genetics lecturer who remains a friend. I was also very fortunate to go to a good school where it was assumed you would be academic. The teaching was superb, but the careers advice was less good – I would have benefited from more structured guidance both from school and my parents.

Personally, I don’t believe in the standard idea of a ‘career’ as a progression from one point to the next. But I do think it is a good idea to try out a number of things early on, build your experience and find out what path is best for you.

My path went from a first degree in Physics to a PhD in Physics, both in Manchester. When that finished, there were few industry jobs in my specialist area – liquid crystals – and limited postdoctoral positions in the UK, so I looked at other physics topics. By chance, I found a great post working for the Daresbury Laboratory on the design of the DIAMOND synchrotron, which was a hugely enjoyable project for seven years. After DIAMOND, there was a succession of projects which did not get off the ground, and I decided to look for an academic post, ending up in Manchester where I had first started my research career.

I love designing things that make the world a better place, and this forms the basis of my motivation in life. I probably differ from most academics, in that I don’t have a particular passion to ‘find out the truth’. I am quite happy not knowing it. But I do care if there is ‘a point’ to my work.

Installing Elegant on OSX 10.8 Mountain Lion

This is a short guide to installing the accelerator code Elegant on OSX 10.8 Mountain Lion, hopefully giving an error-free, step-by-step guide with a bit more information than is available from the Elegant website and forums.

OS Version: OSX 10.8 Mountain Lion
Elegant Version: 25.1.0 (Nov 7, 2012)

Installation Steps:

  1. Install XCode and Java if you don’t already have them installed (see for details); use the App Store to install XCode. You will probably want to disable Java in your browser after installation.
  2. Install Command Line Tools at XCode>Preferences>Downloads>Components
  3. Install fink binaries using
  4. Carry out the following commands:
    fink selfupdate-rsync
    fink index -f
    fink update-all
  5. Install gfortran using this installer:
  6. Install elegant (darwin-x86 32/64 bit Nov 8 2012) and SDDS binaries (darwin-x86 Nov 7 2012) from the APS software website. Put everything into a folder in your home directory, i.e. in ~/bin/
  7. Download the defns.rpn file and put it in ~/bin/ as well.
  8. You will probably want the SDDS.m file as well if you’re going to be using Mathematica.
  9. Add this line to your .bash_profile:
    export RPN_DEFNS=”~bin/defns.rpn”
    (hint: cp .bash_profile vis.bash_profile to make it visible for editing, then copy back)
  10. Following the instructions on this site,,
    execute the following commands:
    fink install libpng3 <- see update below, this doesn’t seem to be needed now.
    fink install openmotif3
    fink install readline5
    fink install gd2      (…this one takes ages)
    fink install libtiff

That should be it! Quit and restart your, and you should be able to run elegant from the command line.

Update July 25th 2013: I recently re-installed everything, and noticed that fink-0.34.5 doesn’t seem to be able to find libpng3 when you run fink install libpng3. I tested running without this library, and elegant seems to be happily making png files without this library.