Accurate dynamics in an azimuthally-symmetric accelerating cavity

We consider beam dynamics in azimuthally-symmetric accelerating cavities, using the EMMA FFAG cavity as an example. By fitting a vector potential to the field map, we represent the linear and non-linear dynamics using truncated power series and mixed-variable generating functions. The analysis provides an accurate model for particle trajectories in the cavity, reveals potentially significant and measurable effects on the dynamics, and shows differences between cavity focusing models. The approach provides a unified treatment of transverse and longitudinal motion, and facilitates detailed map-based studies of motion in complex machines like FFAGs.


Introduction
Particle accelerators have become very complex, and the capability to compute accurate particle trajectories in these machines has become central to understanding their dynamics [1][2][3][4]. While there exist techniques for computing these dynamics in very general electromagnetic elements and complex fields -for example in fringe fields or extraction magnets -these computations can pose significant challenges. Radio-frequency (RF) cavities with time-dependent fields are an important example of time-dependent structures with complex fields that have significant effects on both the transverse and longitudinal motion in an accelerator. They can provide both acceleration and longitudinal confinement (bunching), and these devices are used in the majority of particle accelerators. As such, a detailed understanding of their dynamics is essential for the design and optimisation of modern particle accelerators. The equations of motion in these structures cannot be solved exactly, and the various approximations exhibit the usual trade-off between accuracy and speed. Hence the ability to construct accurate transfer maps with controlled approximations for such structures becomes of central importance.
To calculate the beam dynamics, we need to know the electromagnetic fields or, equivalently, the electromagnetic vector potentials. Once these are known in a given beam-line component, the equations of motion can be integrated numerically to compute an explicit particle trajectory for a given a set of initial conditions. For example, if the field is represented by a vector potential, one can apply numerical integration to Hamilton's equations to compute the motion. This is a wellestablished technique; but because it applies to the initial conditions of individual particles, it is a computationally intensive approach for long-term particle tracking in storage rings or other circular machines such as fixed-field alternating-gradient (FFAG) accelerators. As an alternative to direct integration, one may construct a transfer map for a given element. This is a single set of functions that describes the transformation of phase-space coordinates (position and momentum) from the -1 -to provide matrix-based RF models such as the Rozenzweig-Serafini model [17], the Chambers derivative model [17], and the Krafft model [18,19], which typically apply only to ultra-relativistic beams in periodic structures. There has also been some progress in using Hamiltonian methods for cavity modelling [15]. Of particular interest to models of transverse focusing are the beam-based measurements in, for example, [20,21], which provide an opportunity for studying potentially significant differences in the cavity focusing models.
The aim of this work is to build on that of [14] to calculate the beam dynamics of a real accelerating cavity and represent the transfer map both as a Taylor series and a mixed variable generating function derived directly from field data. The final output will place the RF cavity on an equal footing with other accelerator elements in modern tracking tools, which will be important for calculations of both transverse and longitudinal dynamics. As an illustration, the transverse dynamics in small rings may be perturbed by the focusing of the cavity, similar to the EMMA [9,22] closed-orbit variation with amplitude. In terms of longitudinal dynamics, the high-order effects of the cavity may be relevant when dealing with serpentine acceleration in FFAG machines. This includes variation in the time-of-flight with amplitude, and the need for complete FFAG simulations during acceleration, for which a detailed cavity model is mandatory. Further applications are the low-, medium-, and high-β cavities at facilities such as ESS, where the detailed beam dynamics in the cavities is important.
We shall perform a complete analytical fitting of the EMMA accelerating cavity [22,23] from a real electromagnetic azimuthally symmetric field map, giving a complete and analytic representation of the vector potential (and hence the field). The analytic field is ultimately computed from a single function, which is parameterised as a polynominal for use in other work. We shall then study the beam dynamics of the cavity using Hamiltonian and DA methods, including a consistent treatment of transverse and longitudinal effects, a treatment of the transverse focusing of a lowand high-β cavity, and computations of accurate transverse and longitudinal transfer maps as a function of phase. The calculated map of the cavity makes potentially measurable predictions and can be used in map-based simulations to give an accurate cavity model. The linear maps will be compared with the energy kick model and with commonly-used RF cavity focusing models, where we shall find potentially significant and measurable differences between the predictions. Finally, we shall also express the cavity dynamics using a 6D time-dependent generating function. This not only ensures a symplectic transformation, but also allows for symplectic interpolation between phases. The unified treatment of transverse and longitudinal dynamics presented is a step towards a consistent computational treatment of accelerating systems -e.g. serpentine acceleration in FFAG accelerators -and opens the possibility to a comparison of the model against measured focusing properties of real cavities.
The layout of this paper is as follows: section 2 describes the EMMA accelerating cavity used in this work, very briefly summarises the field fitting techniques, and performs the analysis to compute the analytic representation of the cavity vector potential. In section 3 we compute the Taylor series representation of the transfer maps using a DA code, study the resulting linear and non-linear maps, and compare to existing cavity models. We represent the transfer map as a 6D mixed-variable generating function in section 4, and in section 5 we draw our conclusions, where we demonstrate two representations of the accurate dynamics in an RF cavity based on real field data, providing a precise model of transverse and longitudinal dynamics.

JINST 10 P02005
2 The EMMA accelerating cavity The starting point for constructing the dynamics in the cavity is consideration of the electromagnetic fields contained in the cavity volume. These fields shall be used to fit an analytic vector potential, expressed as a power series in the transverse variables and suitable for calculating the beam motion in the cavity. Note that this form of the fields can also be used for analytic studies of the field behaviour in the cavity.

EMMA cavity overview, parameters and fields
The EMMA FFAG is a non-scaling FFAG accelerator located at Daresbury Laboratory. It has 42 cells: each consists of two offset quadrupoles that provide bending and focusing, and one RF accelerating cavity. The flat top of the electric field is 18 MV/m at the maximum designed field, the cavity frequency is 1.3 GHz and the total length of the cavity structure is 0.2 m. The design of the cavity is shown in figure 1. Shown in figure 2 are the electric field components E z (left) and E ρ (right) at a radius of 3.5 mm at phase π/4 for the TM 010 accelerating mode. The accelerating electric field, E z , falls to zero at each end of the cavity, and it is the longitudinal variation of that field which produces the radial electric field, E ρ . Note that the accelerating field is confined primarily to the region ± 0.05 m, which is relevant for the application of existing RF accelerating cavity focusing models later in this work. Figure 3 shows the longitudinal electric field E z as a function of azimuthal angle φ at z = 5 mm at varying values of the radius ρ in the cavity. As we shall show in section 2 there is considerable simplification to the vector potential analysis for the case of an azimuthally symmetric electric field and we shall demonstrate this symmetry for the EMMA cavity. We shall do this by consideration of the field profiles in figure 3, and validate this assumption mathematically later with explicit calculation of the functions we expect to be zero (e.g.f m , as defined later) for the azimuthally symmetric case. Figure 3 shows only a small variation as a function of φ as a residual 4-fold symmetry from the field solver.  Figure 3. The electric field E z as a function of φ at z = 5 mm at varying values of ρ. The field shows only a small variation as a function of φ as a residual 4-fold symmetry from the field solver.

Surface fitting methods to obtain the vector potential
Inside the RF accelerating cavity with no charges or currents, the vacuum form of Maxwell's equations apply and the time dependent electric field in the cavity obeys the wave equation where c denotes the speed of light in vacuum. The electric field can be decomposed into a series of standing wave modes, each with its own angular frequency ω l , where θ l is some arbitrary phase for the mode labelled by l. It immediately follows that each model obeys the vector Helmzholtz equation, with k l = ω l /c, -5 -These equations are obeyed by the electric fields in the cavity, and are the ones solved by the surface fitting method. Following the analysis in [14] we can express the solution to the electric field in the cavity, working in cylindrical polar coordinates, in a completely general form for a particular standing wave mode. For the derivation of these results, the reader is referred to [14]. The EMMA RF cavity has a strong azimuthal symmetry and this implies that we can make considerable simplification to the analysis of [14]. In this case the electric field in the cavity is written in terms of generalised gradients, where the generalised gradients for the azimuthally symmetric case, are obtained from the functioñ In this equation E zc0 is obtained from an azimuthal Fourier decomposition of the fields, Hence knowledge of this functionẽ 0 (k) for the electric field purely determines the electromagnetic field inside the cylinder. Given the harmonic dependence of the electric field, we can write for a given mode and as an explicit example we can write the cartesian vector potential assuming azimuthal symmetry as a power series in the transverse variables x and y, This form of the vector potential is suitable for the study of beam dynamics in the cavity, once the azimuthally symmetric generalised gradients (via. the functionẽ 0 (k)) are obtained.

Analytic representation of the vector potential in the cavity
The azimuthal symmetry of the cavity fields mean we need, in oirder to analytically represent the vector potential in the cavity, to compute the function e 0 (k) as given by equation (2.6). To compute this function we need the longitudinal electric field on the surface of some cylinder inscribed inside the cavity volume. This cylinder should be inside the material of the cavity, but large enough to enclose the required working volume for the computation of the cavity maps. The fields within this cylinder are then completely described. For the purposes of this work we take a cylinder inscribed inside the cavity of radius √ 12.5 mm 2 + 12.5 mm 2 = 17.7 mm. We have performed the relevant Fourier integrals over the longitudinal field, equation (2.6) using Filon integration to obtain the real functionẽ 0 (k), valid at 17.7 mm, and smaller, radii. It is plotted in figure 4, where the function itself is shown on the left plot and the logarithm of the function is shown on the right plot to show the decay to zero at large Fourier variable k.  As a complete check of the analysis, we have computed the functionsẽ m (k) andf m (k) for m > 0, as defined in [14], with azimuthal decomposition of the fields to find these functions are very small compared toẽ 0 (k) and make no significant contribution to the fitted fields. We find the reconstructed fields at smaller radii are identical to those obtained with the functionẽ 0 (k). Now that the functionẽ 0 (k) is known from the analysis on the surface of the cylinder, the electric and magnetic fields may be reconstructed at any location inside this cylinder. The result of the calculation of the field at a a radius of 3.5 mm using equation (2.4a) is shown in figures 5 and 6 for the longitudinal field and radial field respectively as a function of the longitudinal distance z inside the cavity. In both of these figures the left plot shows the physical field, with the line showing the field reconstructed from the surface fitting and the points showing the field from the field map at this radius. The right plot in both figures shows the difference between the two, expressed as a fractional difference in figure 5 and a unnormalised difference 1 in figure 6. The figures show the longitudinal and radial field is completely reconstructed using the functionẽ 0 (k), with a small residual. We have checked the field reconstruction at other radii and found similar results, that the field is completely reconstructed using the functionẽ 0 (k) with only a small residual.
The fitted fields can be reconstructed using this method along any axis in the cavity. As an example figure 7 shows the reconstructed E z field on-axis (ρ = 0). Now that the fields are described by analytic functions, field studies may be made or, as is done in the rest of this work, beam     To allow the fields in the cavity to be reconstructed analytically, knowledge of the function e 0 (k) is sufficient. We have fitted Chebyshev polynomials of the 2nd kind to e 0 (k), requiring terms up to tenth order for an accurate fit, giving

EMMA cavity transfer maps
Now that we have obtained an analytic form of the vector potential in the EMMA RF cavity, we can use Hamiltonian and DA methods to calculate the transfer map of the cavity in Taylor series form. We shall compare this transfer map to direct integration through the cavity and to existing kick and focusing models of the cavity.

From the vector potential to the transfer map
To compute the transfer map we shall start from the classical relativistic Hamiltonian, where p denotes the canonical momenta for a particle of charge q and mass m, and the particle is moving in a scaler potential φ and vector potential A. We note that it is assumed that the vector and scalar potentials generally depend on the spatial position coordinates. Following the standard procedure of writing this Hamiltonian in a form where the potential depends on the longitudinal distance through the accelerator s it becomes where β 0 and γ 0 are the reference velocity and relativistic γ function corresponding to the reference momentum p 0 . In this Hamiltonian we have used the canonical variable pairs on the extended phase space and defined the longitudinal momentum variable as The longitudinal coordinate conjugate to the longitudinal momentum is given by We have also set the scalar potential to zero and normalised the components of the vector potential to the reference momentum, with Bρ denoting the beam rigidity. The independent variable is given by σ and, given, they are simply related by For the case where the canonical variables and potentials are small, the Hamiltonian, equation (3.2), can be expanded using the paraxial approximation using the Hamiltonian, generating terms of the form (p x − a x ) 2 . A significant advancement in the treatment of split Hamiltonians of this form was made by Wu et al. [24], which allows conversion of Lie transformation -10 -terms involving (p x − a x ) 2 into p 2 x terms and the construction of an explicit symplectic integrator. This is achieved by defining a function I x of the vector potential, and using the Lie algebraic identity e : f : e :g: e :− f : = exp : e : f : g : (3.11) to rewrite terms in the Hamiltonian involving (p x − a x ) 2 as exp −∆σ : Here we define the Lie operator : f : by the rule that it acts on any other function by taking a Poisson bracket, where q denotes the coordinates and p denotes the momenta. This splitting method, using integrals and derivatives of the vector potential, allows the Hamiltonian defined in equation (3.2) to be written as a sum of solvable pieces and an explicit symplectic integrator to be constructed for a vector potential with s dependence. At this stage we can use a differential algebra (DA) code to write explicit transformations of the canonical variables, if the potential is expressed as a power series in the variables (x, y, z) with s dependent coefficients. The result is a representation of the transfer map as a Taylor series in the initial canonical variables. This method requires truncation of the Taylor series for any realistic case, violating symplecticity and requires storage of a large number of power series coefficients.

The transfer maps of the cavity
The transfer maps are computed in Taylor series form using the fitted vector potential combined with the split Hamiltonian given by the paraxial form of equation (3.2). The DA code allows each of the transfer maps for the canonical variables to be written as multi-variable power series in all the canonical variables [25]. This form of the map is useful for particle tracking but in general must be truncated at some order to keep a reasonable number of terms. The integrator is formulated by the sequential evaluation of the Lie operations defined by the split Hamiltonian in section 3.1, with appropriate integrals and differentials of the vector potential. The result is the transfer map for the EMMA cavity in terms of Taylor series of the canonical variables for the map of one complete transformation through the EMMA cavity. In this work we will study the behaviour of the cavity transfer maps as a function of arrival phase with respect to the maximally accelerating phase. These transfer maps are, by virtue of the approach, valid for both non-relativistic and relativistic regimes. Hence we will compute the maps for two representative cases to illustrate the differences between the two. The first is a ultra-relativistic regime with the particle velocity close to the speed of light, and the second is a sub-relativistic regime. Table 1 shows the beam particle parameters used for these two cases and all the beam dynamics in this work are computed for these two test particles, -11 - one with velocity close to c and with a lower velocity. These cases are denoted β = 1 (although the velocity is not exactly c) and β < 1.
We have implemented the Wu-Forest-Robin (WFR) integrator in [24] in the DA code described in [25], using the Hamiltonian given above and implementing the paraxial approximation. The vector potential at a given step through the cavity is expressed using the field fitting described in the previous section. The result is the transfer map for any particle moving through the cavity, with one truncated power series representation for a given cavity RF phase. Whilst the integrator is formally symplectic, and symplectic to machine precision when implemented numerically, the DA power series representation is not symplectic due to truncation of the series. The symplectic error is the order of the truncated series and may be reduced by adding additional terms to the power series representation.
The linear maps are obtained from the linear terms in the Taylor series representation of the map from the entrance to the exit of the cavity. In general this map is written as with a Taylor series representation where X i = (x, p x , y, p y , z, δ ) denotes one of the canonical variables . The constant term corresponds to an acceleration of the appropriate variable, the elements R i j represent the linear part of the map and the T i jk represent the first non-linear terms in the map. The maps are written as a function of phase, arising from the e i(ωt+φ 0 ) oscillation of the vector potential. Before we study the complete linear maps, we can compare the transfer maps across the cavity with the kick model described in the introduction to this paper. This model, commonly used to particle tracking codes, models the action of the cavity as a kick to the momentum coordinate sandwiched between two half-cavity drifts. The resulting model gives a kick to both the momentum variable and the conjugate position variable, as well as a non-zero R 56 . In the language of this work this is equivalent to the transformations 17) and the linear matrix element where L is the length of the cavity and V is the voltage.
-12 - To compare to the complete cavity model in this work we normalise the energy gain in the cavity (i.e. the additive term to δ ) to account for the transit time factor, and a single normalisation factor fixed at φ 0 = 0 is sufficient for identical predictions of this term between the two models. Retaining this factor, figure 9 shows the prediction of the z kick and the R 56 matrix element between the two models. The level of agreement between these terms in the kick model and the FFCM is good in terms of numerical size of the matrix elements and the variation of z 0 with phase. This gives a useful cross-check of the FFCM but also indicates the dominant linear dynamics in the cavity arise from the kick action of the integrated accelerating fields combined with a drift through the body of the cavity. We can also conclude that particle tracking codes can therefore accurately approximate linear longitudinal motion in a cavity using an energy kick combined with a drift model to generate the R 56 transfer matrix element. This generates the linear momentum compaction behaviour but ignores the longitudinal focusing term R 65 and non-linear corrections to both transverse and longitudinal terms. The fitted fields RF cavity model (FFCM) makes it possible to calculate the linear transfer map for the cavity, including the terms predicted by the kick model but also the complete set of linear transfer terms as a function of phase. This includes the transverse focusing terms not present in kick models and which can be compared to cavity focusing matrix models. The linear transfer maps as a function of phase are shown in figure 10 for the case of β = 1. These terms shown in this figure correspond to transverse focusing (R 21 ), the determinant of the linear transfer map, longitudinal dynamics (R 56 and R 65 ), the momentum gain of the particle (δ 0 ) and the longitudinal constant term (z 0 ) (needed to maintain symplecticity). From this figure the longitudinal focusing is maximised (R 65 ) when the energy gain is minimised and the transverse focusing is always negative for all values of the phase. This is the expected behaviour for a relativistic particle in the cavity and has been observed in previous studies and measurements [20]. The longitudinal R 56 shows the sinusoidal behaviour already compared to the kick model, and we also calculate R 65 , which is not present in the kick model. These transfer maps give access to an accurate time of flight through the cavity as a function of phase and longitudinal momentum deviation, allowing a complete inclusion of the cavity in longitudinal motion simulations and also allow accurate transverse focusing effects to be included. For example, detailed simulation of longitudinal motion have been performed in the EMMA FFAG to study serpentine acceleration using a single kick model of a cavity. The accurate transfer maps presented here would increase the accuracy of such simulations and include transfer map terms omitted from simpler models.  Figure 10. Linear transfer maps for the field fitted cavity using the β = 1 parameters as a function of cavity phase.
The corresponding linear transfer map plots for the β < 1 case are shown in figure 11, again as a function of phase. Of particular interesting are the transverse focusing term, showing the potentially strong transverse focusing of a low velocity beam in an RF cavity. It is interesting the note the different behaviour of the transverse focusing term at low β , which can be both positive and negative. The longitudinal focusing term is generally of the opposite sign to the transverse focusing term. All the focusing terms are of larger magnitude for lower velocity particles than for the relativistic particles considered in figure 10, with potentially large consequences for transverse and longitudinal dynamics simulations involving low-beta accelerating structures such as ESS [27] or HEI-ISOLDE [28].
We note the possibility of comparison to measurement of cavity transfer maps, as performed in [20,21], to experimentally validate the transverse and longitudinal focusing term predictions.   Figure 11. Linear transfer maps for the field fitted cavity using the β < 1 parameters as a function of cavity phase. plots shows the fractional difference between the two calculations. In both particle velocity regimes we consider the agreement is good, with a small residual attributable to the impact of the paraxial approximation. We have explicitly checked the other linear terms in the FFCM, such as δ 0 , z 0 , R 56 and R 65 and found similar levels of agreement and low residuals between the DA analysis and the direct integration through the fields. the linear map. The transverse focusing naturally emerges from the FFCM developed in this work and hence gives a more accurate description of cavity focusing. There are several commonly used models of transverse focusing in RF cavities, and we can compare the fitted field model to the Chambers and to the Krafft models, which are transverse focusing models for RF cavities valid for β = 1. The Chambers model ( [29], see equation (13) of [17]) follows directly from the Rosenzweig and Serafini model [17] for the case of a pure π-mode cavity 2 For the case of a particle accelerated from γ i to γ f the transverse focusing transfer matrix takes the form where γ is the cavity energy gradient in units of mc 2 , γ i, f are the initial and final Lorentz factors, In these equations φ 0 represents the phase of the particle with respect to the on-crest phase and the matrix acts on the space (x, x ). The Krafft model [18,19] is derived assuming β = 1, and gives the transverse transfer matrix of an RF cavity to be In these equations m i j represent the transfer matrix elements and E(z) represents the electric field in the cavity as a function of longitudinal position through the cavity, taken to be 18 MV/m in the central region. To compute maps for the EMMA cavity appropriate for a comparison with the transfer maps for the cavity presented in this work, the middle 0.1 m region of the cavity is assumed to be the accelerating region, and this map for either the Chambers or Krafft model is inserted between two 0.05 m drift regions to form the 0.2 m cavity structure. The resulting linear maps for R 21 obtained for the Chambers and Krafft model can be seen in figure 14 as the dashed and dotted lines, showing a reasonable agreement in the prediction of the two models of the term R 21 using EMMA parameters. The level of agreement between the two models is consistent with [19,20]. The comparison of these models with the FFCM calculation of R 21 can also be seen in figure 14 for the EMMA cavity parameters and the β = 1 particle parameters. The correspondence in behaviour as a function of phase is consistent, with qualitatively similar features of negative R 21 for all phases (as observed in [19,20]) and a consistent variation with φ 0 . However the models give different predictions for R 21 . This uncertainty in R 21 is compatible with the analysis in [19,20] and demonstrate the level of uncertainty inherent in some transverse focusing models. The levels of consistency and inconsistency between the three models is potential significant and could be tested experimentally and also used an a measure of uncertainty in beam dynamics simulations. As previously noted the transverse focusing of the cavity is a measurable quantity, as done in [20], and would be an interesting validation of the accurate model presented in this work.
The FFCM gives access to the non-linear transfer matrix elements as a function of phase in a natural way from the DA approach, extending previous approaches. The dominance of nonlinear terms in the map is cavity phase dependent, and a complete analysis of the dominant terms should take place with a complete map-based study of an accelerator ring. However the non-linear behaviour of the cavity can be illustarted by two examples. The first is an analysis of the dominant non-linear terms for the momentum deviation δ map at the maximally accelerating phase. These coefficients are shown in the left plot of figure 15 at the maximally accelerating phase, using the notation abcde f for the transfer matrix term δ a z b p c y y d p e x x f , and indicate the variation of the energy gain in the phase space of the accelerated particle.
The non-linear behaviour of the cavity at this phase is rich, and several terms have potentially large impact on the beam. These include the geometic term z 3 and the chromatic term δ (x, y) 2 .
-17 -These terms, and other large non-linear transfer map terms, have the potential to perturb the longitudinal and transverse motion. As a second illustation of the non-linear behaviour we can compute the non-linear momentum compaction factors T 566 and T 5666 as a function of cavity phase. These are shown in the middle and right plots of figure 15, and these non-linear terms will contribute to the path length through the cavity for off-momemtum particles. They are potentially important for longitudinal dynamical simulations, for example serpentine acceleration in FFAGs and in any machine dependent on time of flight control like an energy recovery linac. In principle they could be measured by suitably sensitive beam-based experiments. A complete non-linear analysis requires a machine context but as a first look, the leading non-linear contribution to the momentum compaction is an order of magnitude lower than the linear contribution for a momentum deviation δ = 5 × 10 −3 . Finally we note the possibility of additional higher order terms from relaxing the paraxial approximation of the Hamiltonian, potentially extending the analysis presented here.  Figure 15. The non-linear coefficients of the transfer map for δ (left), using the notation δ a z b p c y y d p e x x f and the non-linear momentum compaction factors T 566 (middle) and T 5666 (right) as a function of cavity phase.

EMMA cavity time dependent generating functions
So far in this work we have computed the dynamics through the EMMA cavity using a truncated power series derived from an explicit symplectic integrator. This means the transformation is inherently non-symplectic and provides a non-compact representation of the map. An alternative approach is to describe the dynamics using mixed-variable generating functions. These provide a compact and symplectic representation of the motion [11]. For example, one of the transformation from the WFR integrator can be written as the generating function, where the entrance and exit variables are related by In [11] a technique was proposed to directly construct the overall generation function describing the transformation through a machine element by concatenating the generating functions describing -18 -the steps in the WFR explicitly symplectic integrator [24]. This procedure was performed using an iterative method to concatenate two generating functions of the second kind, F A and F B , into the generating function representing the overall transformation F C . We have extended the method in [11] to the case of time dependent generating functions operating on 6-dimensional phase space. This adds considerable algebraic complexity to the method but the underlying philosophy remains the same. A further difference to [11] is the expression of the transformation of the extended phase space variables (s, p s ) using explicit transformations, with the dynamics of the remaining six phase space variables expressed using the generating functions. This approach permits expression of the 6D motion as a generating function while retaining the evolution of s through explicit equations. The appropriate generating functions of the second kind for the WFR integrator are We have omitted the obvious expressions for F y , F I y and F I −1 y and h denotes the step size. The extension of the method in [11] to the six dimensional time dependent case proceeds as follows. Let F A (x 1 , p x2 , y 1 , p y2 , z 1 , δ 2 ) be the generating function for the transformation from (x 1 , p x1 , y 1 , p y1 , z 1 , δ 1 ) to (x 2 , p x2 , y 2 , p y2 , z 2 , δ 2 ) and F B (x 2 , p x3 , y 2 , p y3 , z 2 , δ 3 ) be the generating function for the transformation from (x 2 , p x2 , y 2 , p y2 , z 2 , δ 2 ) to (x 3 , p x3 , y 3 , p y3 , z 3 , δ 3 ). We form the six dimensional generating function F C (x 1 , x 2 , x 3 ), where x i denotes the phase space variables of step i then, following [11], F C provides a generating function of the second kind which represents the transformation from x 1 to x 3 provided the intermediate variables x 2 = (x 2 , p x2 , y 2 , p y2 , z 2 , δ 2 ) are eliminated from F C . This is done with the equations which we write as a set of six polynomials These polynomials are written to order N in the intermediate variables, with coefficients which depend on x 1 and x 3 . To solve for the intermediate variables (e.g. x 2 ) we construct the 6D Jacobian matrix The solution for the intermediate variables (x 2 , p x2 , y 2 , p y2 , z 2 , δ 2 ) T is then found by assuming the initial solutions X (0) = (0, 0, 0, 0, 0, 0) T and constructing improved solutions iteratively using Newton's method, beginning at n = 1.
We have computed the overall generating function for the EMMA accelerating cavity using the techniques described in this section and the generalised gradients of the EMMA cavity. The generating function of the second kind is is computed for the transformation through the cavity, from s = −0.1 m to s = +0.1 m using the paraxial Hamiltonian and the WFR integrator. The generating functions for the steps of the integrator are given by equation (4.4). We retain terms up to fifth order in the generating function and performed the computations in Mathematica [26]. The result is a fifth order mixed variable generating function describing the transformation of the canonical variables through the cavity. The appropriate derivative are then computed and a set of implicit equations solved to calculate the transfer map through the cavity. Note the entire dynamics in the cavity are compactly represented by the mixed variable generating function for a particular phase.
The transfer functions, the transformation of coordinates and momenta as functions of the initial coordinates x and p x , are shown in figures 16 and 17 for the canonical pairs (y, p y ) and (z, δ ) respectively. We show the pair (y, p y ) as this is not dominated by the drift map (which is why we do not show (x, p x )). The calculation is done for a RF phase of φ = 0 and L denotes the length of the cavity.
To understand the accuracy of the generating function description of the map, we have also calculated the the transfer functions by direct numerical integration of Hamilton's equations, as was done in the analysis in section 3. The resulting residuals for the transfer maps are shown in figures 18 and 19 for the canonical pairs (y, p y ) and (z, δ ) respectively.
The residuals are small, showing the generating function of the overall cavity gives a good description of the dynamics. We can explore the dynamics further by comparing the linear transfer maps of the cavity as a function of phase using the generation function method with the linear transfer map obtained from the DA analysis of the cavity dynamics described in section 3. We shall focus on the term R 21 , giving the linear transverse focusing for compactness.  Figure 18. The fractional residuals of the 6D generating function and a direct integration throught the cavity for y(L) and p y (L) transfer maps as a function of (x(0), p x (0)).  Figure 19. The fractional residuals of the 6D generating function and a direct integration throught the cavity for z(L) and δ (L) transfer maps as a function of (x(0), p x (0)). The left plot of figure 20 shows the R 21 element of the linear transfer map computed with both the DA analysis of section 3 (line) and the generating function analysis of this section (spots). The resulting residual between the two methods is shown in the right plot of figure 20. The residual is very small and verifies the accurate description of the dynamics of the EMMA cavity with a 6-dimensional generating function.
Hence we can represent the motion through cavity in a alternative way to the previous section by using a 6D mixed variable generating function. This provides a compact, efficient and symplectic representation of the map, at the cost of a numerical and iterative procedure to obtain the generating function. An advantage of this representation would be the abilty to interpolate between phases of the cavity the coefficients of the generating function, which would give a symplectic map for the interpolated phase. This would not be the case for interpolating between coefficients of a Taylor seris represention of the map. However the associated numerical cost solving the implicit equations of the generating function representation is potential high, estimated around a factor of five for a single element based on the required number of evaluations and iterations. This topic requires further study in a realistic case to fully understand these implications.

Conclusion
In this work we have computed the transfer map of a real accelerating cavity, using field fitting, differential algebra and generating function techniques. The representations of the map give an insight into the dynamics in the cavity, provide accurate maps with potentially measureable effects and, using 6D generating functions, provide a symplectic representation of the dynamics.
The calculation has two steps. The first is to use a real electromagnetic azimuthally symmetric field map of the EMMA FFAG accelerating cavity and perform a fitting to obtain an analytic representation of the vector potential. The function e 0 (k) is sufficient to specify the fields and can be parameterised as a polynominal for use in other work. The second step is to calculate the beam dynamics in the cavity using Hamiltonian and DA techniques, to represent the transfer map as a function of phase as either a truncated Taylor map or as a mixed variable generating function. The two stages are not coupled, so the analytic vector potential, as written in equation (2.10), can be used in other beam dynamics simulations, and the DA and 6D generating function analysis performed for the cavity can be done for an arbitrary time dependent structure.
The result, as presented in this work, gives a cavity mode which includes a complete and consistent treatment of transverse and longitudinal effects such as focusing and non-linear time of flight and the ability to compute accurate transverse and longitudinal transfer maps as a function of phase. The calculation makes predictions of transfer map parameters which are potentially measureable and which may be important for detailed machine simulations. In this work the linear maps were compared to the energy kick model and commonly used RF cavity focusing models, with notable differences. The cavity dynamics can also be represented as a 6D time dependent generating function to ensure a symplectic transformation and allow symplectic interpolation between phases, for example to model systems with variable arrival phase. We hope the unified treatment of transverse and longitudinal dynamics presented is a step towards consistent computational treatment of accelerating systems, for example serpentine acceleration in FFAG accelerators, and opens the possibility to a comparison of the model to measured focusing properties of the cavity and potential application to proton driver machines such as ESS. Our hope is to place accelerating cavities on the same mathematical footing as other machine elements in tracking and beam dynamics simulations.
There are some issues that remain to be investigated. The linear cavity models studied show the same qualitative behaviour for quantities such as R 21 but different normalisations. This interesting obversation, possibly related to the differing assumptions in the models, could be disentangled through an experimental campaign. A further extension would be the use of an exact Hamiltonian in a form amenable to the WFR integrator, for example the exact Hamiltonian in [24]. Such an approach would be complementry to the one presented here and would be an interesting study of the higher order behaviour of the cavity. Beyond this, the next step for the EMMA FFAG would be the construction of a map-based simulation, with both accurate transfer maps for the offset quadrupoles and the RF cavities in the ring to study aspects such as the serpentine acceleration process. These studies would be important to understand dynamics in these machine, understand beam-based measurements made on EMMA and would be a step forward in the modelling of small rings. The calculations presented here can also be readily extended to the non-azimuthally symmetric case to quantify the impact of couplers and tuners on the transfer map, and to apply these techniques to elements like deflecting cavities. Detailed transfer maps for these common accelerator structures without this symmetry can then be achieved.
The fitted vector potential is available through equation (2.10) for use in other work. The transfer maps and the generating functions are available from the authors as a function of phase to be used as accelerating cavity models in tracking codes.