A method for computing driving and detuning beam coupling impedances of an asymmetric cavity using eigenmode simulations

We propose a method for numerical calculation of driving and detuning transverse beam coupling impedances of an asymmetric cavity. The method relies on eigenmode simulations and can be viewed as an alternative to time domain wakefield simulations. A similar procedure is well-established for symmetric cavities, and this paper extends it to the case of an asymmetric cavity. The method is benchmarked with time-domain wakefield simulations and its practical implementation is discussed.


I. INTRODUCTION
In particle accelerators, the interaction of the particle beam with its surrounding is a source of coherent beam instabilities that may limit the performance of the machine. This interaction can be described by the wake function W (t) in the time domain, or, alternatively, by the impedance function Z(ω) in the frequency domain (t is the time and ω is the angular frequency). In this paper, we focus specifically on the transverse impedance Z ⊥ (ω) -a function that describes the transverse kick received by the trailing charge due to the fields excited by the driving charge. Let us call the transverse direction of interest x and the transverse impedance of interest Z x (ω).
The total transverse impedance Z x (ω) (measured in Ω) is a function of both the driving charge offset (x d , y d ) and the trailing charge offset (x t , y t ), with y being the second transverse coordinate. To the first order, the expansion of the total impedance around a point of interest (x 0 , y 0 ) can be written as with the coefficients of expansion c 1−5 first introduced in [1] and [2]. The coefficients describing the dependencies on the driving charge offset x d and the trailing charge offset x t are defined as the driving and the detuning impedances (measured in Ω/m), respectively: where we omit the irrelevant y-dependence. The driving and the detuning transverse impedances are also sometimes referred to as the dipolar and the quadrupolar (as in, for example, [3]). This is due to the similarity of their effect on the trailing charge to that of a dipole magnet and of a quadrupole magnet: a constant kick independent of x t , and a kick proportional to * sergey.arsenyev@cern.ch x t , respectively. This terminology, however, has nothing to do with the concept of dipolar and quadrupolar RF resonator modes, classified by the number of angular variations of the fields (see, for example, [4], p.41). To avoid this confusion, the "driving-detuning" terminology is used here instead.
We define the sum of Z driv (ω, x 0 ) and Z det (ω, x 0 ) as Z Σ (ω, x 0 ), also referred to as the "generalized term" in [5]. It describes the dependence of the total impedance on the transverse offset in the case when x d = x t . In certain cases, Z Σ (ω, x 0 ) is easier to measure (a single wire measurement is sufficient [6]) and easier to numerically calculate (see section III below). However, Z Σ (ω, x 0 ) by itself is not sufficient to study beam stability, as Z driv and Z det affect the beam in different ways, as was pointed out in [7] and discussed in ( [8] pp.44-47). For example, beam stability simulations with codes HEADTAIL [9] and Py-HEADTAIL [10] account for both Z driv and Z det , while the codes like DELPHI [11] and Nested Head-Tail [12] make use of only the driving impedance. In either case, Z driv and Z det have to be separated.
In the past, a procedure for separate measurements of Z driv and Z det with the wire techniques has been established [2,6]. In parallel, numerical tools have been developed with the possibility to separately compute the impedances. One of the most powerful numerical tools is the time-domain wakefield simulation (e.g. CST wakefield solver [13]). However, a time-domain calculation can be time-consuming and often there is a need for verification with an alternative numerical solver. If an impedance is of the resistive-wall type, calculations based on the field-matching technique (code IW2D [14]) or the transmission line technique (code TLWALL [5]) can serve as this alternative.
In this paper, we focus not on the impedance of the resistive-wall type, but on the impedance of the geometric type, and, in particular, impedance due to electromagnetic modes trapped in a resonant cavity. In this case, as well, an alternative to time-domain calculations exists. Namely, the impedance is found through the sum of the eigenmode solutions, each one characterized by its angular frequency ω res , shunt impedance R and quality factor Q. In this paper, we focus on this eigenmode approach and extend the range of applicability of the already existing method to the case of an asymmetric cavity. We define the cavity to be asymmetric if it does not possess the mirror symmetry in the direction of interest (defined here as x) around the beam trajectory. Note that a cavity symmetric around a point different from the beam trajectory will be considered asymmetric for our purpose.
In the symmetric case, Z driv and Z det are clearly separated, because each mode can have either driving or detuning non-zero impedance (a proof of this will be given in section III). The modes thus can be classified into "driving modes" and "detuning modes". In both cases, the impedance of a given mode can be found with the transverse resonator formula ( [3], p.72): where Z sym resonator if the mode is detuning, ω res is the angular resonance frequency, c is the speed of light, R x and R || are the transverse and the longitudinal shunt impedances defined here according to the "circuit definition" ( [4], p.47), both measured in Ω: Here Q is the quality factor of the resonant mode, V ||,x (x) is the complex longitudinal and transverse voltages in the cavity at the offset x, and U is the energy stored in the mode. An additional factor of (ω res /c) was inserted by the authors in Eq. (3) since the original formula in reference [3] assumes a different definition for the transverse shunt impedance (measured in Ω/m). The transition from R x to R || in Eq. (3) is made using the Panofsky-Wenzel theorem (see section II for details). The validity of the classification into driving modes and detuning modes disappears in the case of an asymmetric cavity, where each mode can possess both Z driv and Z det , with any ratio between the two. As will be shown below, Eq. (3) no longer gives Z driv or Z det , but instead gives Z Σ . To the best knowledge of the authors, no rigorously derived expressions for Z driv and Z det existed for asymmetric cavities. This paper aims to fill in this gap, thus enabling the use of the eigenmode method as an alternative to the time-domain method. Despite the time required for the postprocessing of the eigenmode data, the eigenmode method in many cases can be advantageous to the time-domain calculation. The problems of the time-domain method include resonant modes of very high Q-factors that take too long to decay, numerical noise due to the beam injection scheme and the field integration, and mesh constraints for most codes. Even in the cases when the time-domain method can be applied, the eigenmode method still serves as a valuable independent benchmarking tool.

II. DERIVATION
In this section, we will derive an analogue of the transverse resonator formula (Eq. 3) that would work for the case of an asymmetric cavity. In fact, Eq. (3) will be replaced with two formulas (one for Z driv and one for Z det ), as in the asymmetric case a mode can possess both the driving and the detuning impedances. To do so, we will start (perhaps, counter-intuitively) with the longitudinal resonator formula that is valid regardless of the symmetry of the cavity. For our purpose, we will expand the longitudinal resonator formula to the case of unequal offsets of the driving and the trailing charges. Doing so will allow us to obtain the transverse driving and detuning impedances by applying the Panofsky-Wenzel theorem.
The longitudinal resonator formula that works for the case where we have separated the dependences on the offset and the frequency in the functions We now expand Eq. (5) to the more general case when the trailing charge does not necessarily follow the exact path of the driving charge. In using Eq. (5) we have made an assumption that the electromagnetic fields in the cavity are given by the single resonant mode. The time-behavior of the fields is dictated by the frequency and the Q-factor of the mode, and is, therefore, the same everywhere in the cavity. This means that the choice of the integration line x t does not affect the frequency response g(ω), but only changes the amplitude of the response. The amplitude depends now on both x d and x t through some function F : To find the function F , we examine the longitudinal voltage kick received by the trailing charge ∆V (t). This kick can be written as ∆V (t) = −qW || by the definition of the wake function, which for the resonator impedance is given by ( [3], p.72) whereω res = ω res 1 − 1 4Q 2 , α = ωres 2Q , and R Q || has been replaced with F (x d , x t ). For us, the only important part of this wake function is the coefficient ω res F (x d , x t ) in front of the time-structure. The time-structure is irrelevant for the purpose of this derivation and can be ignored by considering the voltage kick at a time much lower than the resonant period T = 2πω res This kick can also be written using the concept of the shunt impedance of the cavity. Immediately after the passage of the driving charge, the cavity voltage is in the decelerating phase (see [4], p.333), giving ∆V (t T ) = −|V || |. The cavity voltage is related to the energy stored in the mode U through the shunt impedance at the position of the trailing charge x t as In turn, U is determined by the energy initially deposited in the cavity by the driving charge U = kq 2 , where k = ω res f (x d )/2 is the loss factor ( [15], p.9) at the position of the driving charge x d . This gives By comparing Eq. (9) to Eq. (10), the unknown function We now apply Panofsky-Wenzel theorem (in the same way as in [15], p 23) to Eq. (11) to get the total transverse impedance Z We then find the driving and detuning impedances using their definitions (2) to get the final expressions

III. DISCUSSION
First, it is interesting to notice that that the sum of the two equations (13) gives which matches the symmetric cavity expression Eq. (3). This means that Eq. (3) when applied to the case of an asymmetric cavity, gives neither Z driv nor Z det , but their sum. As was stated in the introduction, finding Z Σ x is easier as it only requires the first polynomial coefficient of the parabolic fit, and is not sensitive to the errors in f and f (see below). Second, the general Eq. (13) can be applied to a completely symmetric cavity as a particular case. One can infer from Eq. (13) that the modes in a symmetric cavity are either purely detuning or purely driving. This distinction comes naturally as the two following cases: non-zero longitudinal impedance f (x 0 ) = 0, and zero longitudinal impedance f (x 0 ) = 0. To show this, we first note that f (x 0 ) = 0 due to the symmetry. It means that in the case f (x 0 ) = 0 the driving impedance is equal to zero, and the detuning impedance becomes In the other case f (x 0 ) = 0 we have a 0/0-type fraction, hence the limit has to be taken when approaching the point of symmetry x 0 . The 0/0-type fraction is resolved by Taylor-expanding the function f around The two terms in the second equation of (13) cancel out, giving zero detuning impedance. The driving impedance becomes Z driv 2ω f (x 0 ), again confirming Eq. (3). To sum up, in a symmetric cavity, a mode with non-zero longitudinal impedance has no driving contribution, while a mode with zero longitudinal impedance has no detuning contribution.
Third, a practical implementation of Eq. (13) deserves a separate discussion. If f and f are calculated by numerical differentiation, even a small numerical error in f will result in significant uncertainties. A more practical solution is to do a parabolic fit to the data in some window w around the point of interest x 0 (see Fig. 1), and determine f and f from the corresponding coefficients. In section IV, the two ways will be compared by applying them to a simple cavity with and without artificially added computational noise. Special attention should be taken when the method is applied to a symmetric or to a slightly asymmetric cavity (e.g. the only source of asymmetry is an HOM coupler). In that case, driving modes have vanishingly low f (x 0 ) and f (x 0 ), and blindly applying Eq. (13) will result in diverging results for both Z driv x and Z det x due to the term f 2 /f . The problem only applies to driving modes, as for detuning modes the term in question simply goes to zero since f (x 0 ) = 0 and f (x 0 ) = 0.
One way to avoid this problem is to constrain the fitting parabola to go through zero (the "tangent constraint"), thus resolving the f 2 /f ratio. This constraint can be triggered when the value of f falls below the error bar of the eigenmode simulation within the fitting window, as shown in Fig. 1. The constraint is implemented by looking for the fit not in the general form f = ax 2 + bx + c, but in the form f = a(x − x * ) 2 with x * somewhere in the window (x 0 − w/2) ≤ x * ≤ (x 0 + w/2). This solution allows to correctly determine Z driv x , however at the expense of losing the small non-zero value of Z det x (plugging f = a(x − x * ) 2 in Eq. (13) yields exactly zero detuning impedance). If in fact there is a need to determine the low level of Z det x , the fitting window w should be adjusted not to cover the tangent point x * , with the step between the sampling points scaled down accordingly.
Offset x

IV. CHECK FOR A SIMPLE CAVITY
As an example, we consider a T M 210 mode at the frequency of 2.5 GHz excited in a rectangular resonator shown in Fig. 2 (top). If the beamline is put in the center x 0 = 0, it corresponds to the case of a symmetric cavity, while a shifted beamline with x 0 = 0 corresponds to the asymmetric case.
Let us first examine the validity of Eq. (13) with no regard of numerical errors in the calculation of the shunt impedance. For that, the simplicity of the considered geometry allows for an analytical derivation of (R/Q) || . The electric field in the selected mode is given by where A is a constant, a and b are the dimensions of the cavity as shown in Fig. 2, and ω res is the angular resonant frequency of the mode. The voltage and the stored energy in the mode are computed as

Horizontal coordinate x [mm]
-50 0 50 where L is the length of the cavity and 0 is the vacuum permittivity. Fixing the vertical coordinate y to zero leads to the following expression for f ( which is shown in Fig. 2 (bottom) as the solid black line. Given Eq. (13), the driving and the detuning impedances for some offset x 0 become These quantities can be checked against time-domain wakefield simulations, for which the CST wakefield solver [13] was used. For this, the cavity was enclosed in the walls of lossy metal (conductivity σ = 10 5 S/m) giving the considered mode the quality factor Q = 146. For each of the few selected offsets x 0 , a small opening was made in the walls around x 0 to allow for the passage of the beam. The real part of the transverse impedance was observed for both the beam line and the integration line at x 0 , and for small displacements of either line. The variation of the height of the resonance impedance peak with the displacement of the beamline gave Z driv x , and the variation with the displacement of the integration line gave Z det x . These quantities are plotted in Fig. 3 together with the analytical result (Eq. (18)). A generally good agreement is achieved for all offsets x 0 including the case of a completely symmetric cavity (x 0 = 0), which confirms the validity of the derived theory. Note specifically that the point x 0 = 0 corresponds to the case f (x 0 ) = 0, f (x 0 ) = 0, and the point x 0 = 37.5 mm corresponds to the case f (x 0 ) = 0, f (x 0 ) = 0 (Fig. 2,  bottom). The absence of the detuning impedance or the driving impedance at these points confirms the statement made in section III.  So far we only showed that the derived theory gives correct results when we take the analytical expression for f (x) as an input. Another interesting question is how accurate would the results be if instead we took actual eigenmode simulations as an input. To check this, we used an eigenmode solver (Ansys HFSS [16] or CST Microwave Studio [17]) to find the values of f at a series of offsets spaced by 3 mm (crosses in Fig. 2, bottom). As expected for such a simple cavity, the data is in a very good agreement with the analytical result. We then apply the two methods discussed in section III to find f and f from the data.
The first method is to numerically differentiate f (x) after spline-interpolating the data points to define the function everywhere between the points. Since the eigenmode data for such a simple cavity is very precise, the resulting Z driv and Z det match nicely with the analytical result (crosses in Fig. 4, top). As was mentioned in section III, for a completely symmetric cavity the numerical differentiation gives a diverging result, hence the missing crosses at x 0 = 0. The second method is the parabolic fit. For this, a window of w = 12 mm was used when fitting the points, meaning that the fits are based on the values of f at the point of interest, plus two additional points on each side. The obtained Z driv and Z det are shown in Fig. 4 (top) as circles. The tangent constraint was enforced for the parabolic fits that contain the central point (x = 0) in the fitting window. This allowed for a correct estimation of Z driv even for the completely symmetric case (red circle at x 0 = 0), but at the expense of giving Z det = 0 for the 5 central points, as was discussed in section III. The agreement of Z driv and Z det with the analytical result is not as good for the parabolic fit as it was for the numerical differentiation (circles vs crosses in Fig. 4, top). However, since the shape of the fitting function is constrained to be a parabola, this method is more robust when applied to eigenmode data with larger error bars. To illustrate this, we artificially added random errors of relatively small amplitude (0.025 Ω) to the data points in Fig. 2 (bottom). We then applied both methods to the new "noisy" data, and obtained the impedances shown in Fig. 4 (bottom). The results of the parabolic fit are less distorted by the added noise, and this method is therefore preferred for complex geometries.

V. CHECK FOR A REALISTIC CAVITY
As an example of an asymmetric cavity with complex geometry, we chose the roman pot structure shown in Fig. 5 (top). The roman pot is an experimental technique for the detection of forward protons from elastic or diffractive scattering. Detectors are placed inside a secondary vacuum vessel, called pot, and moved into the primary vacuum of the machine through vacuum bellows [18]. For this example, we set the pot to be 20 mm away from the beam, resulting in a strongly asymmetric geometry in the vertical direction y. The following analysis was therefore done for the vertical impedance Z y .
First, a traditional time-domain calculation was done using the CST wakefield solver in the same way as in section IV, with the resulting driving and detuning impedances plotted in Fig. 6 (top). For comparison with an eigenmode analysis we chose the mode at the frequency of 360 MHz, corresponding to the most prominent peak in the impedance spectrum. The impedances at this resonant frequency are listed in Table I. The chosen mode is primarily excited in the bellows region (see Fig. 5 the narrow gap between the pot and the outer walls. The narrow gap requires sophisticated meshing and makes the mode a good candidate to test the eigenmode method. Then, we performed the eigenmode analysis for the integration line offsets ranging from −5 to 5 mm with a step of 1 mm. The longitudinal shunt impedance and the parabolic fit are shown in Fig. 5 (bottom). The resulting driving and detuning impedances are listed in Table I together with the resonant frequency and the Q-factor estimated with the eigenmode solver. The corresponding resonant peak is also plotted against the wakefield data in Fig. 6 (bottom). Since the resonant frequencies obtained by the two methods are 10 MHz off (an error due to the complex geometry and the different mesh types), the eigenmode peak appears shifted but otherwise resembles the wakefield one for both Z driv y and Z det y . In the absolute values, the two methods agree within  15%. Most of this difference can be explained by the different Q-factors in the eigenmode and the wakefield solvers. Indeed, in the wakefield solver, the Q-factor deduced from the width of the resonance peak is lower than the eigenmode value (Table I). This source of error can be canceled out if we use the Q-factor from the wakefield solver in the eigenmode formula. Then, the difference between the two methods decreases to only 4%. As a conclusion, in this case of a realistic structure, the developed method provides the correct decomposition of detuning and driving impedances of the main resonant  mode.

VI. CONCLUSIONS
We developed a method to separately compute the driving (dipolar) and the detuning (quadrupolar) geometrical transverse impedances of an asymmetric cavity. As an input, the method takes eigenmode data for a chosen cavity mode: the longitudinal shunt impedance (R/Q) || for several transverse offsets, and the mode's frequency and Q-factor. The method was benchmarked for the case of a simple cavity (displaced rectangular resonator) and a realistic cavity (roman pot), showing a good agreement with time-domain calculations in both cases. For practical implementation of the method, we also investigated how numerical noise in the input eigenmode data affects the end results. It was concluded that a parabolic fit of the data is preferred when the method is applied to realistic cavities.

VII. ACKNOWLEDGEMENTS
This work was supported by the European Union's Horizon 2020 research and innovation programme under grant No 654305. We also thank Carlo Zannini, Agnieszka Chmielinska, and Elias Métral for the useful discussions and Nicola Minafra for the choice of the benchmarking geometry.