Chris Rogers, ISIS, Rutherford Appleton Laboratory, United Kingdom.
Andreas Adelmann, PSI, Villigen, Switzerland.
OPAL (Object Oriented Parallel Accelerator Library)  is a parallel open source tool for charged-particle optics in linear accelerators and rings, including 3D space charge. Using the MAD language with extensions, OPAL can run on a laptop as well as on the largest high performance computing systems. OPAL is built from the ground up as a parallel application exemplifying the fact that high performance computing is the third leg of science, complementing theory and experiment. The OPAL framework makes it easy to add new features in the form of new C++ classes. OPAL comes in two flavours:
• OPAL-cycl: tracks particles with 3D space charge including neighbouring turns in cyclotrons and FFAs with time as the independent variable.
• OPAL-t: models beam lines, linacs, rf-photo injectors and complete XFELs excluding the undulator.
The code is managed through the git distributed version control system. A suite of unit tests have been developed for various parts of OPAL, validating each part of the code independently. Unit tests use the google testing framework. System tests validate the overall integration of different elements. Documentation is written in asciidoc. Tools are available to readily convert asciidoc into formats such as pdf and html for display.
The OPAL code supports simulation of FFAs using analytical scaling field maps, 3D sector field maps and variable frequency RF cavities characteristic of many FFA designs. The FFA routines complement the existing cyclotron models and full three-dimensional space charge solvers including boundary conditions.
User configurable modules provide different tracking routines and field map routines. Fields are placed in a three-dimensional world and macro-particles are tracked through the field maps.
Several field map routines are provided that support implementation of scaling and non-scaling FFAs, both in the design and operation phase of the accelerator.
For a perfectly scaling sector field, fields off the midplane are calculated to arbitrary order using a recursive power series. Considering a coordinate system , the field can be written as
with representing the azimuthal angle in spiral coordinates
and the field dependence on radius
The fringe field on the midplane is modelled using
so that represents the length of the flat-top and represents the length of the field fall-off. Away from the midplane, the coefficients are calculated by requiring that Maxwell’s equations are observed, yielding a recursion relation in terms of the derivatives of
with even and odd terms related by
is implemented using C++ inheritance making alternate fringe field models, for example Enge function, simple to implement so long as the function and its derivatives are continuous. The coefficients of are calculated during the lattice construction to minimise overhead during stepping.
Multipole models are provided to enable modelling of non-scaling FFAs. Because OPAL enables arbitrary placement of potentially overlapping fields, such multipoles can be used to represent field errors in FFA main magnets.
Rectangular and sector multipoles are enabled with soft edged fringe fields. Sector multipoles can be configured with fixed radius of curvature or in the case of dipoles and combined function magnets, a radius of curvature programmed to follow a reference trajectory.
Rectangular pillbox-style RF cavities can be tracked with hard- or soft-edged fields. In the hard-edged model, time variation of the field is given by
where , and are parameters of the RF cycle whose time dependence can be programmed by the user according to a polynomial. All other components of the field are zero.
Soft-edged cavities are described in Cartesian coordinates by a series expansion off the midplane,
It is assumed that variations in , and occur on a timescale much longer than the RF frequency so that they do not contribute significantly to the magnetic field. Recursion relations can be derived assuming Maxwell’s laws,
Odd terms of and even terms of and are 0.
OPAL can read in a 3D magnetic field map placed on a regular grid in cylindrical polar coordinates. The field at an arbitrary point is inferred by tri-linear interpolation.
Output of the field map is an essential part of the validation of a given lattice. OPAL provides methods to write out the electromagnetic field map as a four-dimensional grid in Cartesian or cylindrical polar coordinates and time. Field maps can be written over an arbitrary region in space-time.
To demonstrate the simulation in OPAL, a radial sector magnet with DF geometry is considered. In this lattice, protons are simulated between 3 and 30 MeV. The lattice has 8 cells and a 3 m inner diameter with a field index 3. The doublet structure in each cell can be seen by examination of the field maps. The orbit excursion is approximately 1 m. The similarity of the orbits and the radial dependence on energy can be observed in fig. 1. The orbits at different azimuthal angles are identical bar an increase in radius and a concomitant increase in beam energy, as expected from the scaling condition.
In a scaling FFA both the closed orbit and the linear order transverse optics must scale with momentum. The constancy of tune with energy is shown in fig. 2. At each energy a particle has been tracked on the closed orbit and another particle has been tracked with the same energy but initially deviating from the closed orbit by 2 mm and 1 mm in horizontal and vertical space respectively. The phase advance of each particle is calculated on a cell-by-cell basis and this is converted to the fractional part of the cell tune. The tune is seen to be constant as expected.
More complicated arrangements can also be simulated to support injection, extraction and acceleration studies. Consider the lattice shown in fig. 3. In this example, spiral FFA magnets have been modelled with a field index of 7.1, and a spiral angle of 41. Injection dipoles have been added in order to simulate a closed orbit bump onto a foil that might be used for injection. The dipole fields were chosen to return the circulating proton beam to the closed orbit following the beam bump. Several different injection dipole fields were simulated, and all of the closed orbits have been superimposed onto the same figure to demonstrate simulation of painting at injection. Very wide dipoles have been simulated in order to support optimisation of the lattice; where the bump dipoles overlap the FFA main magnets OPAL superposes the two fields. Following optimisation, the radial extent of the dipoles can be curtailed as desired by the user.
An example of an acceleration cycle for the spiral FFA lattice described above is shown in fig. 4. Here a few particles have been simulated accelerating over a 0.5 ms acceleration cycle from 3 MeV to 30 MeV. Particle were simulated initially at the reference phase, but with kinetic energy deviations of up 0.5 MeV from the reference particle. The frequency was varied during the acceleration cycle to keep the synchronous phase constant despite the change in time-of-flight around the ring with energy. In this example the RF voltage was held constant during the acceleration cycle. The simulated particles were successfully accelerated except for the particle with initially 2.5 MeV energy, which was lost from the RF system.
OPAL can be used to simulate FFAs in a number of different circumstances. A number of field models are available in OPAL to support both analytical and numerical calculation of FFAs, together with injection, acceleration and extraction systems. The extensions to OPAL for FFA simulation complement the existing cyclotron models and full three-dimensional space charge solvers.