Asymmetric focusing study from twin input power couplers using realistic rf cavity field maps

Advanced simulation codes now exist that can self-consistently solve Maxwell’s equations for the combined system of an rf cavity and a beam bunch. While these simulations are important for a complete understanding of the beam dynamics in rf cavities, they require significant time and computing power. These techniques are therefore not readily included in real time simulations useful to the beam physicist during beam operations. Thus, there exists a need for a simplified algorithm which simulates realistic cavity fields significantly faster than self-consistent codes, while still incorporating enough of the necessary physics to ensure accurate beam dynamics computation. To this end, we establish a procedure for producing realistic field maps using lossless cavity eigenmode field solvers. This algorithm incorporates all relevant cavity design and operating parameters, including beam loading from a nonrelativistic beam. The algorithm is then used to investigate the asymmetric quadrupolelike focusing produced by the input couplers of the Cornell ERL injector cavity for a variety of beam and operating parameters.


I. INTRODUCTION
The effects on the beam dynamics due to the placement of both the input power couplers and higher order mode (HOM) couplers of superconducting radio-frequency cavities in linear accelerators have been studied extensively.The majority of this work focuses on the transverse momentum imparted to the beam due to a single input power coupler or a pair of upstream and downstream HOM couplers [1][2][3].Many mitigation techniques for eliminating this ''coupler kick'' have been proposed and studied for a variety of cavity geometries, including the TESLA-style ILC cavity, the CEBAF cavities [4], as well as the injector and main linac cavities for the proposed Cornell ERL [5][6][7][8].One of these techniques is to design the cavity with twin symmetric power couplers.This approach has been used in the design for the cavities in the current Cornell ERL injector prototype, a high-brightness photoelectron source.While this effectively eliminates the dipole coupler kick, it still produces off-axis quadrupolelike focusing near the couplers.Developing a way to correctly model this effect in heavily beam-loaded superconducting cavities like those found in high current electron accelerators-particularly high-brightness photoinjectors and rf guns (where the beam may not be considered ultrarelativistic)-is the goal of this investigation.
The layout of our work is as follows.First, drawing on previous studies [1][2][3][4][5][6][7][8], a detailed description of how to compute realistic field maps for rf cavities using lossless eigenmode solvers is given.This method incorporates all relevant cavity design and operating parameters.These include the cavity voltage, phase, detuning angle, input coupling, and beam loading.While the basis of this method has been previously developed, to our knowledge there is no single comprehensive account of this procedure in the literature.Additionally, for nonrelativistic beams, this treatment yields implicit expressions for the cavity fields.In order to extend the algorithm to account for low beam energies, approximations for computing the effective cavity voltage and R=Q of the cavity are given and tested.The use of these approximations results in explicit expressions for the cavity fields.Next, the definition of the coupler kick is also extended to the nonrelativistic regime by explicitly writing the effect in terms of the transfer matrix elements through the cavity field map.We provide one description of how to compute these matrices using orbit differentiation [9], and also give a simple method for expanding the cavity fields in the paraxial approximation assuming symmetry about the x-z and y-z planes (quadrupolelike symmetry).Having extended the algorithm for computing the cavity fields as well as the effect of the input couplers, we perform several checks on both and discuss the relevant numerical issues involved.Finally, we apply this methodology to the model of the Cornell ERL injector cavities and quantify the quadrupole focusing effect due to the use of twin symmetric input couplers.The effect is documented for scans of both the initial beam energy and the average beam current, and for both orientations of the cavity (the couplers at the cavity entrance vs exit).

II. FIELD GENERATION ALGORITHM
The computation of rf cavity fields can be greatly simplified by making one assumption: the effects of beam loading do not alter the form of the fields in the cavity.
Published by American Physical Society under the terms of the Creative Commons Attribution 3.0 License.Further distribution of this work must maintain attribution to the author(s) and the published article's title, journal citation, and DOI.
In this limit, the beam induces a voltage in the cavity in one of its fundamental modes.This assumption is valid if the amount of energy lost to each bunch, ÁU b , is very small compared to the energy stored in the cavity: In this limit, it is possible to create realistic fields from lossless eigenmode solvers.The procedure for synthesizing these field maps involves reconstructing the forward and reflected traveling waves in the input power coupler(s).
The proper normalization and phase of these waves are related to the cavity design and operating conditions.By correctly including the operating conditions, the combined traveling waves in the input coupler represent the forward power from the rf generator and the reflected power back out of the cavity.Proper construction of these waves ensures the correct form for the fields in the cavity.

A. The Cornell ERL injector cavity model
Before moving directly to the procedure for constructing realistic cavity fields, it is instructive to give a brief description of the Cornell ERL injector cavity as it is used as a working example in the following sections.The Cornell ERL photoinjector cryomodule houses five superconducting two-cell niobium rf cavities.The relevant design and nominal operating parameters for the injector cavities are listed in Table I.Each cavity is powered by two symmetric coaxial input couplers.The couplers are designed to deliver 50 kW of forward power when operating with 100 mA average current at a cavity voltage of 1 MV.The amount of coupling to the cavity can be adjusted depending on the desired operating conditions (low or high current running).This is accomplished by changing the insertion depth of the coupler antennas.To model the cavities we use the eigenmode field solver in CST MICROWAVE STUDIO (MWS) [10].Figure 1 shows the 3D injector cavity model used in MWS.The model assumes the cavity is made of perfectly conducting material surrounded by vacuum.The ends of the beam line are terminated by using an electric short (E k ¼ 0).The choice of boundary condition for the end of the coaxial power couplers is discussed later.The coordinate system in the model is defined so that the z axis in the model coincides with the beam axis (the positive direction is to the right in Fig. 1) and the y axis is parallel to the center axis of the twin symmetric input couplers.

Analytic expressions
To create the correct fields in the power coupler, it is necessary to derive analytic formulas for the fields in this region.Far from the end of the coupler and cavity, the fields take the form of two superimposed TEM traveling waves.We assume no other types of modes are excited in the coupler.In this region the fields are given by Here the ''þ'' and ''À'' subscripts label the forward and reflected waves in the top coupler (positive y axis).The tilde denotes that these quantities are phasors with an associated time dependence of e i!t .The location of the origin along the y axis, y 0 , is arbitrary.The forward and reflected power determine the amplitudes of each wave: The terms r o and r i are the outer and inner radius of the coaxial coupler.The reflection coefficient À is defined by the complex ratio of amplitudes of ẼÀ and Ẽþ : From this it follows that

Circuit model and relation to operating parameters
In addition to being related to the operating parameters, the forward and reflected power also satisfy the general formula for the conservation of energy in the cavity-beam system:  In this equation P c is the power lost in the cavity walls, and P b is the average power delivered to the beam.Satisfying the balance of powers in this equation provides one a useful check for the algorithm described below.From these quantities, the well-known quality factors for the cavity are defined [11,12]: The term P ext is the power emitted back out of the input couplers when the cavity is operated with both the beam and power generator turned off: P b ¼ P þ ¼ 0. In this limit, P ext ¼ P À .The quality factor associated with the power lost to the beam can be written as Q b ¼ 2ðÁU b =UÞ À1 .The criterium in (1) is equivalent to having a large value of Q b .Lastly, the measure of the coupling strength, denoted by , is defined as The above quantities can now be related to the operating conditions using transmission line theory and the equivalent circuit model for a beam-loaded cavity first given by Wilson [11].The notation used here more closely follows that of Wangler [13] in a similar treatment.Figure 2 shows the equivalent parallel circuit for the cavity and waveguide including beam loading.The waveguide is modeled as a matched external load coupled to the cavity circuit via a transformer.In the figure, the waveguide impedance Z WG has already been transformed into the cavity circuit.The effective voltage drop across the cavity is defined in terms of the energy gain of an electron traveling through the cavity on axis: The phase 0 is defined so that 0 ¼ 0 is the phase that maximizes the energy gain ÁWð 0 ¼ 0Þ ¼ maxðÁWÞ.In addition, the sign of 0 is chosen so that it also represents the difference in phase of the cavity voltage to the beam current.The cavity gap voltage is defined by taking the ultrarelativistic limit of the effective cavity voltage: The maximum effective voltage is used, along with the power lost in the cavity walls, P c , to define the effective shunt impedance: It is often useful to work with the ratio of the effective shunt impedance and the intrinsic quality factor: Finally, the loaded detuning parameter is defined as Here Á! is the difference between generator frequency and the resonant frequency of the cavity, and In terms of these definitions, the complex impedance of the cavity is given by [11] This impedance is in parallel to the beam impedance Z b ¼ ðV c =I b Þe i 0 .This amounts to having a total admittance of From the circuit, the waveguide impedance is given by Z WG ¼ R=.The general formula for the reflection coefficient can be written as Substituting in the total admittance and the waveguide impedance yields and the above expression for À, the forward and reflected powers can be solved for FIG. 2. Equivalent circuit model for a beam-loaded cavity as seen from the internal cavity circuit.The cavity is excited by the generator current i g and the beam current i b .
The formula for P þ is equivalent to the formula for the generator power P g in [11].With these expressions for the forward and reflected power, it is easy to directly verify the relationships in Eqs. ( 2) and (3), as well as the conservation of energy requirement in (4).
It should be noted that any parameters defined in terms of the energy gain of a single particle through the cavity, ÁW, are in fact functions of the fields we are trying to construct.This is due to the fact that the energy gain is not in general given simply by V 0 cos 0 in the nonrelativistic limit.This issue will be further addressed after the equations for the realistic field maps have been (implicitly) defined.

Connection to eigenmode solutions
Having connected the analytic expressions for the fields in the coaxial coupler line to the cavity design and operating parameters, we now connect the analytic expressions to the solutions from the eigenmode solver.To recreate traveling waves in the coaxial coupler line of the forms given in (2), two sets of electric and magnetic fields are generated [1,3,[5][6][7][8].Each set is created by terminating the input coupler line in the computer model with either an electric or magnetic wall boundary condition.The field solutions in the coaxial line near the boundary will then be of the form electric wall

<
: where y BC is the position of the coupler boundary condition.It is now easy to identify these terms with the real and imaginary components of the fields given by the eigenmode solver: electric wall

<
: From here it is evident that adding AE=4 to the line length of the electric wall solutions transforms the fields into those produced using the magnetic wall condition (up to an overall sign).With these relations, the MWS field maps are added together in the following manner to yield the plane waves given in (2).First, the amplitudes are solved for in terms of the field maps: for some arbitrary radius a such that r i a r o .It turns out that the field generation algorithm is quite sensitive to the calculation of these amplitudes, as will be discussed later.The fields are normalized and combined to form traveling waves using A e e i AE ; Note the inclusion of the factor exp½AEikðy BC À y ref Þ.This is used to shift the origin of the traveling waves.The position y ref is the location of the reference plane, the point where the maximum in the amplitude of the electric fields occurs when the reflection coefficient À is positive and real.
The next section gives the procedure for how to compute the position of reference plane.It is easy to show using the analytic expressions for the field patterns in (15) that this combination of fields yields the correct set of traveling waves in the coaxial line.Plugging in the expressions for the forward and reflected waves, the total fields can be written as In these equations Áy ¼ y BC À y ref .These equations imply several important facts, all of which depend on the value of the reflection coefficient À.First, if the cavity is run under perfectly matched conditions, À ¼ 0, and the resulting fields are independent of the position of the reference plane.Physically this is due to the fact that when À vanishes, only an incoming traveling wave exists in the input coupler, for which there is no reference plane.The above equations also show that there are only two critical values of À for which the equations for the fields reduce to one of the two eigenmode solutions (either the electric or magnetic solutions).These occur when the reflection coefficient is given by À AE ¼ AE exp½ið2kÁyÞ.In general, these two critical values are complex and therefore not of interest when simulating cavities under normal operation (where reactive beam loading is compensated using cavity detuning and the reflection coefficient is real).Thus, in general, to correctly model the fields near the couplers, one must use both eigenmode solutions.

Finding the reference plane
The position of the reference plane is related to the phase of the reflection coefficient À.This is seen by computing the amplitude function of the total electric field in the coaxial line: The reference plane is defined as the position of the maximum of this function when the reflection coefficient À is real and positive.If À has some nonzero phase, then the position of the maximum in this function shifts by Áy ¼ ð À =4Þ.
It is possible to compute y ref using several solutions from lossless eigenmode solvers [12].When simulating the cavity fields using the eigenmode solver, there is no effect from a beam: I b ¼ 0. In this limit, the reflection coefficient for a real cavity becomes For strongly coupled cavities ( ) 1), this quantity is positive and close to unity when the cavity is run on resonance.If the cavity is tuned very far from resonance then c 0 !AE=2.In this limit À !À1, and À !AE.This implies that the amplitude maximum will shift by Áy ¼ AE=4.Thus, if one can simulate the lossless cavity model being detuned, then the position of the reference plane can be computed.This is accomplished by terminating the coupler with an electric (or magnetic) wall at several different positions.In general, MWS will produce two modes of interest with frequencies near the actual operating frequency ! of the real rf system.The coupler and the cavity regions in the model form a pair of coupled oscillators.Consequently, there will be two modes of oscillation: one with the fields in both regions oscillating in phase together, and another where the fields in the two regions oscillate out of phase.We call these modes the zero and modes of the cavity-coupler system.These labels do not correspond to the zero and resonant modes of the cavity itself, the latter of which is considered the normal mode of operation for the two cell cavities in the Cornell ERL injector.Figure 3 shows the results of varying the position of the electric wall condition and plotting the zero and modes of the global cavity-coupler system.In the region where the two mode frequencies nearly intersect, the ratio of the magnitudes of the fields in the coupler region to those in the cavity region is a maximum.In terms of a real cavity, this corresponds to tuning the cavity far from resonance.This means that the reference plane is then AE=4 from this position: Here y off BC is the position of the boundary condition when the cavity is simulated off resonance.Setting the boundary condition to this value makes it difficult to identify the cavity mode, which has a resonant frequency of 1300 MHz in the case of the Cornell injector cavity.This can be seen in Fig. 3.The two modes plotted here have frequencies which deviate from 1300 MHz when y ¼ y off BC .If the boundary position is moved by AE=4 then, according to (15), when one switches from the electric to magnetic wall, this will be equivalent to running the simulation with an electric wall at y off BC .One must then place the boundary in between y off BC and y off BC þ =4.As long as the boundary condition is not near these points and the coupler length is large enough to accommodate the TEM mode, the position of the boundary condition does not matter.Figure 4 shows this invariance of the radial electric fields in the coaxial input coupler at t ¼ 0. The fields shown are the combined forward and reflected traveling waves for the case where À ¼ 1.In this plot, the boundary condition has been varied from y off BC þ ð2=32Þ to y off BC þ ð6=32Þ.In the figure, the two fields with the shortest coupler length show the greatest difference from the rest of the fields created, as is expected.This does not invalidate the assumption that the position of the boundary condition is invariant within y off BC and y off BC þ =4, but provides the first indication that it may be necessary to add on length to the coupler in units of =2 to ensure the proper standing wave pattern is achieved near the boundary condition.This fact is addressed later on when we give a systematic check of the field generation algorithm.

Computing R=Q, V c , and Q ext
Having now defined all of the relevant cavity design and operation parameters, and given the procedure for constructing the cavity fields assuming all of these parameters are known, it is now time to address the problem discussed in previous sections that many of the operating conditions depend on the computed energy gain through the fields.This means that the fields have actually been implicitly defined in terms of themselves.In this section we resolve this issue.In addition we also briefly describe a convenient method for computing the external quality factor [7].
Because the injector cavities are designed to have large Q ext values, the fields in the cavity cells are standing waves.This fact can be used to compute approximate values for the cavity voltage V c and R=Q.The quantities are defined as The total energy stored in the fields can be approximated by noting assuming the cavity is not run far off resonance.This approximation is valid because the majority of the energy stored in the fields is found in the cavity cells.This means that this quantity can be approximated by since the standing wave field pattern in the cavity cells should be roughly the same as the standing wave from the MWS eigenmode solver.Here m is a scaling factor used to normalize the fields to the correct voltage.This can be easily computed by tracking particles through the on-axis field E m z ðr ¼ 0Þ.The above equation makes use of the fact that MWS normalizes the energy in its solutions to 1 J.The solution E e could also be used.Similarly, with the initial phase offset i 2 ½0; 2. We define off so that ÁWð off Þ ¼ max½ÁWð i Þ.The effective cavity voltage and R=Q are then explicitly given by Figure 5 shows the results of computing the on-axis energy gain as a function of initial phase of the cavity through both the realistic fields, computed with the algorithm described above (light blue line), and the fields generated by MICROWAVE STUDIO using a magnetic wall boundary condition (dark blue line).For this scan, the initial kinetic energy of the beam KE i ¼ 1 MeV, the speed-of-light cavity voltage V 0 ¼ 1 MV, the average beam current I b ¼ 100 mA, the phase offset of the cavity 0 ¼ 30 deg (red FIG. 4. Radial electric field generated by combining the forward and reflected waves for À ¼ 1 and t ¼ 0 sec .The fields are evaluated so that the radial field in the coupler is given by E z (V=m) in that region.line), Q 0 ¼ 10 10 , Q ext ¼ 4 Â 10 4 , and the reactive beam loading is compensated.The green line shows the computed value of ÁW ¼ eV c cos 0 , which intersects the graph at the correct point.It is apparent that the energy gain of both sets of fields is the same, verifying the assumptions made for the computation of ÁW and R=Q.
The last quantity to compute before constructing the realistic cavity fields is Q ext .Several methods for computing Q ext from two eigenmode solutions have been previously proposed [12,14].We use a method prescribed by Buckley and Hoffstaetter [7].This method generally assumes one input coupler, but is easily modified for the case of several identical input couplers.Assume the cavity has been excited by a generator to some voltage and the generator then switched off.After some time, only waves traveling out of the cavity will be present, and the fields E À and B À can be used to compute Q ext .First, the stored energy in the cavity is computed: where ¼ A e =A m .The integrals over the electric fields are known.MICROWAVE STUDIO normalizes the integrals over each set of fields to 1 J.Thus, the total energy stored in the cavity is The power flowing out of the coupler(s) is given by

Combining these expressions gives
In this equation k ¼ !=c.The factor of 1=2 in brackets is included for the case of the twin symmetric couplers used in the Cornell injector cavity model.If the normalization of the fields is different (or not known), the factor 2 þ 1 becomes 2 U m þ U e , which can still be computed directly from the eigenmode fields.The realistic fields can now be computed: first V c , R=Q, and Q ext are computed using the above expressions.With these quantities and the rest of the operating conditions, the forward and reflected power P AE , and the reflection coefficient À are computed.Then, using ( 16) and ( 17), the cavity fields are constructed.The new fields can be used to recompute V c and the process iterated until the field profiles converge to a unique result.In the cases studied in this work, at most two iterations were needed.

A. Generalizing the definition of the coupler kick
To quantify the effect of the input power couplers on the linear beam dynamics of the cavity model, we generalize the formulas for the normalized momentum change in cavity.This is done by first examining the coupler kick, as defined in the literature, and its connection to the momentum change in the cavity.This leads to a natural generalization of the momentum change in terms of the transfer matrix elements through the cavity.
The normalized coupler kick, as defined by Dohlus [2], is to linear order kðx; yÞ ¼ Vðx; yÞ e z Á Vð0; 0Þ ¼ where the complex voltage gain Vðx; yÞ is defined as Note that this definition assumes an ultrarelativistic and therefore rigid beam.The coefficients v x;0 and v y;0 quantify any voltage change (normalized to the on-axis voltage gain) due to dipolelike fields.In general, any structure that breaks the cylindrical symmetry of the cavity may contribute to these terms.The remaining coefficients quantify both the focusing due to the cavity and the focusing due to the input and HOM couplers.The normalized voltage change can be directly used to compute the momentum kick imparted to a particle traversing the cavity: Re½kðx; yÞe ið!s=cÞ V acc : Here s denotes the position of a particle with respect to the center of the beam.The formula for the momentum change can now be generalized by allowing the transverse and longitudinal offset of particles moving through the cavity to vary.In this case, the momentum change can still be related to the initial particle offset from the reference particle, using the transfer matrix elements: Dividing by the change of the reference energy defines the normalized momentum change through the cavity:

Transfer matrix computation
For nonrelativistic beam energies the transfer matrix elements cannot be computed using analytic or semianalytic methods like those of Rosenzweig and Serafini [15].A simple method, used by TEAPOT [9], to compute the transfer matrix is to numerically differentiate particle trajectories.We use an eighth-order implicit symplectic integrator [16] Each of the four particle trajectories is offset slightly in one of the four phase space variables.Labeling the jth particle trajectory as u ðjÞ and its initial offset in the jth phase space variable as Áu ðjÞ , the transverse transfer matrix elements can then be computed using The initial offsets Áu ðjÞ must be made small enough so as to avoid nonlinear effects, as well as to ensure the symplecticity of the resulting transfer matrix.Using the symplectic integrator with initial particle position and momentum offsets of 10 À15 meters, and 10 À15 ½ respectively, yields transfer matrices which preserve the symplecticity of the system to near machine accuracy: detðMÞ À 1 $ 10 À15 .Scanning the initial offsets between 10 À4 and 10 À14 shows little variation in the matrix elements themselves.

Off-axis expansion of the fields
Because we are only concerned with linear dynamics, we can use an off-axis expansion of the fields (as opposed to a full 3D interpolation) to speed up the particle tracking.In general, the fields can be expanded around the beam axis in the form fðx; y; zÞ ¼ X 1 n;m¼0 f ðn;mÞ ðzÞx n y m ; f ðn;mÞ ðzÞ ¼ 1 m! Á n! @ nþm f @x n @y m r¼0 : The use of twin couplers in the cavity model imposes mirror symmetry in the x-z and y-z planes.These symmetries imply The expression for the magnetic fields follows directly from the form of the electric field and Maxwell's equations.For tracking we keep only the terms in the field expansions to first order (the terms in brackets above with n ¼ m ¼ 0): The first order transverse expansion coefficients in these expressions can be expanded around the axisymmetric first order coefficients.For axisymmetric fields the first order coefficients have the form where the radial and azimuthal components are given by [17] The superscripts in this equation denote the number of derivatives taken with respect to the radial coordinate r.
For fields displaying the quadrupole symmetry described in (21), one can define . To the appropriate order, Maxwell's equations then impose Figure 6 shows the first order expansion coefficients for the electric field in the coupler region computed from the general 3D field maps.It is clear from the figure that the field expansion coefficients are of the form given in (25).Similar agreement was found for the magnetic field coefficients.The form of the fields in (23) shows directly that the use of symmetric power couplers decouples the x and y phase space variables and eliminates the dipole kick.
It is also apparent that the longitudinal momentum gain is independent of the initial particle transverse offset to first order.The equation for the coupler kick in (19) reduces to We find it useful to look at the gradient of this quantity with respect to the initial transverse offset: Plugging the linearized fields into the Lorentz force law gives with F ð1Þ r ¼ eðE ð1Þ r À cB ð1Þ Þ, the axisymmetric radial focusing force gradient, and The transverse gradients of these two forces satisfy From this it is tempting to write the transfer matrix elements in a similar form; however, in general.Only in the ultrarelativistic limit does this relationship hold.In this limit the focusing matrix elements reduce to integrals over the transverse gradients of the force components.The relative difference between x and y can be quantified using The last term reduces to ð x À y Þ= r as v !c, giving a measure of the effect of the quadrupole focusing relative to the ''overall'' focusing strength.

IV. CHECKING THE ALGORITHM A. Computation of the transfer matrix
As the coupler kick is quantified in terms of the transfer matrix elements, it is important to check both the accuracy of the method to compute each element as well as the symplecticity of the total transfer matrix.To check the symplecticity of the transfer matrices, we compute the determinant of the matrices as a function of z through the cavity.Using the phase space variables in (20), the determinant should be unity.We also compare the transfer matrix elements to those computed using a simple ''driftkick-drift'' method which is inherently symplectic.The results of these comparisons are shown in Fig. 7.The initial offset of the phase space variables used in position and normalized momentum is 10 À15 m and 10 À15 ½, respectively.With these offsets, the determinant of the transfer matrix is equal to unity to machine accuracy, as seen in Fig. 7(a).The comparison of the transfer matrix elements with the drift-kick-drift method, Fig. 7(b), shows good agreement, indicating that either method could be used.
)/2 FIG. 6.The expansion coefficients of E x and E y in the coupler region at t ¼ 0. Shown here are E ð1Þ r (dark blue), E ð1;0Þ x (green), E ð0;1Þ y (red), and the average the two (light blue).
Having two methods of computing the transfer matrix elements is convenient for cross-checking and debugging.

B. Numerical issues
As mentioned before, it is important to accurately compute the amplitudes of the sinusoidal fields in the coupler region.The computation of these amplitudes depends mainly on two things: the mesh size used to compute the fields in MICROWAVE STUDIO, and the length of the coupler section of the cavity model.For meshing the cavity we use MICROWAVE STUDIO's automatic meshing algorithm.The parameters used by MICROWAVE STUDIO to define the mesh are the lines per wavelength, lower mesh limit, and mesh line ratio.For these simulations, we set all of these to the same value.To test that we have found the correct mesh size, the transfer matrix elements were computed for meshes of 20, 30, and 40 lines=wavelength.In addition to this, we added =2 and to the length of the coupler section.The starting coupler length is y BC þ =8.From Eq. ( 18) it is clear that this should not have any effect on the fields in the cavities or the position of the reference plane.As we are interested in computing the transfer matrix elements from the fields, we use the focusing element to quantify the dependence on the mesh size and coupler length.Figure 8 shows the focusing element in the ðy; p y Þ phase space.The transfer matrix elements were computed for a 100 mA beam, on-crest beam with initial energy of 350 kV, and a 1 MV cavity voltage.It is clear that adding at least =2 is required to the reduce the dependence of the focusing element on the mesh size.Consequently, the MWS solutions for the original coupler length (labeled þ0 in the figure) are not used for any of the studies in this work.For the þ=2 and þ cases, the change with mesh size is roughly 2% when going from 20 to 40 lines=wavelength.The difference between the elements computed for those two cases at each mesh size is roughly 2% to 3%.This difference is likely being limited by other factors: the residual tolerance of the MWS field solutions, how accurately the cavity fields are phased and normalized, and the resulting numerical integration and differentiation of the particle trajectories through the fields.

C. Semianalytic check
One check of the algorithm to compute the coupler kick is to take the ultrarelativistic limit of the transfer matrix through the cavity.In this limit V c ! V 0 and R=Q !220 .This allows the computation of À without any numerical integration.The fields can then be constructed and compared to the general algorithm given above.Figure 9 shows the ðx; p x Þ transfer matrix elements computed with the general algorithm for constructing the fields (blue) and the semianalytic algorithm in the ¼ 1 limit (green).The agreement in the matrix elements as well as the fields is very good.

V. RESULTS
Having developed and tested a method for producing realistic cavity fields and computing the coupler kick for nonrelativistic beams, we turn to investigating the effect for the Cornell ERL injector cavity model.As we will  show, the results of these simulations demonstrate the need to be able to model the coupler effects for a variety of input conditions.The full set of input parameters required to generate the fields in the Cornell cavity model is given in Table II.In addition to the parameters listed in the table, we also vary the orientation of the cavity (couplers at the entrance or exit of the cavity as seen from the incoming beam).In the Cornell injector the cavities are arranged so that the first cavity is oriented with the coupler at the exit of the cavity.The orientation of the subsequent cavities alternates.We limit the number of parameters varied in our simulations to a subset most often used in normal operation.The amount of coupling to the cavity is set for high current running, as this should increase the effect of the quadrupole focusing due to the couplers.To simulate this geometry, the coupler antennas are inserted into the cavity so that they are nearly flush with the beam pipe, setting Q ext to 4:6 Â 10 4 .By making the antennas fully flush in the cavity model, the Q ext calculated from the fields is 4:02 Â 10 4 .This corresponds to roughly 1 mm difference in the insertion depth of the coupler and is therefore considered acceptable for simulating the high current setup of the injector cavities.In general, the cavities may be run slightly off-crest in order to minimize growth of the projected emittance through the cryomodule.We simplify this by simulating the cavity fields on-crest, as the offsets in the injector phases are usually less than 5 deg.Also, during normal operation, any reactive beam loading is compensated by detuning the cavity.These two restrictions imply sin 0 ¼ tanc 0 ¼ 0. The remaining parameters left to vary then include the initial kinetic energy of the beam, the average current, and the cavity voltage.

A. Kinetic energy scans
It is instructive to scan the initial kinetic energy of the beam first.The current voltage of the ERL DC gun used in beam operations is 350 keV.For proposed high current runs (100 mA average current), the beam is accelerated from the gun voltage to roughly 5 MeV in the cryomodule.It is also instructive to look at the quadrupole focusing in the ultrarelativistic limit.We perform two scans of the initial kinetic energies: one from the gun voltage to 5 MeV (the injector parameters), and the second from 5 MeV to 1 GeV (ultrarelativistic limit), for both cavity orientations.Figure 10 shows the results of both scans for a 1 MV cavity gap voltage.
For the low energy scan, the first thing to note is that the mean focusing effect is approximately the same for both cavity orientations in both energy scans.This implies the majority of the focusing occurs in the cavity cells.In general, the quadrupole strength has different behavior for both orientations, as shown in Fig. 11.For the case where the coupler is at the entrance to the cavity " Á starts at À161% and sharply increases to around À11% as the initial energy increases.When the coupler is at the exit, " Á decreases from À1 to À36% in an essentially linear fashion.In both cases the overall focusing and the quadrupole effect should become asymptotic as the particles become ultrarelativistic.Figures 10(c) and 10(d) show that the these asymptotic values are quite different from the values at 5 MeV.The asymptotic values are À1138 and 2168% for the coupler at the entrance/exit, respectively.The difference in sign is due to the fact that the mean of x and y is near zero and has a different sign for each cavity orientation.Table III gives the values of the quadrupole strength relative to the mean focusing for initial kinetic energies near those at the entrance to each of the five cavities in the injector, as well as the asymptotic values.The most significant result here is that the quadrupole effect becomes very pronounced at low initial energy if the input couplers are located at the cavity entrance.The opposite is true when the couplers are at the cavity exit, here the quadrupole effect is larger at higher energy (5 MeV in the injector).Also, in the ultrarelativistic limit, the quadrupole effect becomes increasingly more important as the mean focusing vanishes.

B. Current scans
The dependence of the linear focusing as a function of beam current is also of interest, as the current will have to  be ramped up to 100 mA in proposed experiments in the injector.Figure 12 shows the results of scanning the current from 0 to 100 mA for a 350 keV initial beam energy, and a 1 MV cavity voltage.Figure 12(a) shows the current scan when the couplers are located at the entrance of the cavity.In this case, the quadrupole strength is strong; however, the dependence on the current is small.When the couplers are at the exit of the cavity [Fig.12(b)], the dependence on current is more pronounced, with the quadrupole effect decreasing roughly linearly to near zero at 100 mA.Initially, both of these plots contained a noticeable amount of noise.This noise is caused by ''jitter'' in the on-crest phase offset, off , used to phase the cavity properly.To eliminate this noise, we fit a polynomial to the plot of off as a function of the beam current and used the polynomial to evaluate off ðI b Þ in a second current scan.The dependence of the quadrupolelike focusing on the beam current demonstrates an important point for beam operations, as having current dependent focusing in the linear optics will effect the centroid motion.Thus, in addition to the effects of space charge, the dependence of the coupler focusing on current will have to be properly accounted for.

VI. CONCLUSION
We have developed and tested an algorithm for producing realistic field maps for superconducting rf cavities from eigenmode solver solutions.The algorithm incorporates the effects of beam loading and detuning, and is generalized to include the acceleration of nonrelativistic beams.In addition we have generalized the definition of the coupler kick to correctly describe the linear optics for low energy beams.Fields for the rf cavities in the Cornell ERL injector have been created for various initial beam energies and average currents.The rf quadrupole focusing produced by the input couplers has been computed for these fields and shown to be significant for certain beam parameters and cavity orientations.The algorithm given in this work assumes that the single bunch beam loading is small enough that the condition ÁU b =U ( 1 holds.While the fields generated in this work generally satisfied this requirement with the single bunch loading on the order of 10 À5 to 10 À4 , further study may be warranted to place a stricter bound on ÁU b =U.In addition, since only the linear beam dynamics have been computed here, the effects of space charge and wakefields must be included for a full model of the cavity-beam dynamics at high current.In closing, we note that, once one finds the reference plane and correct length of the coupler(s) for a given cavity model, the field generation algorithm described in this work can be included in any tracking code that can handle complex electromagnetic field maps and can compute the on-axis energy gain of particles through each cavity.This allows for its possible inclusion in both offline and online simulation codes.

FIG. 1 .
FIG. 1. MICROWAVE STUDIO model of ERL injector cavity showing the cavity exterior (left), and the cavity cross section and the inner conductors of the coaxial power couplers (right).

FIG. 3 .
FIG.3.Frequency of 0 and modes in coupler region vs coupler length.

FIG. 7 .
FIG. 7. (a) Comparison of the transfer matrix determinant to unity.(b) Comparison of the symplectic ray differentiation algorithm (blue) to the drift-kick-drift algorithm (green).

FIG. 11
FIG.10.Scans of the initial beam kinetic energy for both orientations of the cavity model.

FIG. 12 .
FIG.12.Current scan from 0 to 100 mA for an initial beam energy of 350 keV and the couplers located at the entrance (a), and the couplers located at the exit (b).

TABLE II .
List of simulation input parameters.

TABLE III .
Relative quadrupole strength vs initial beam energy.