Eigenmode Analysis

Maxwell Eigenvalue Problem — Unified Formulation (\(m \ge 0\))

Governing Equations

We start from the time-harmonic Maxwell’s equations in a source-free, lossless vacuum domain \(\Omega\) with a perfectly conducting boundary (PEC) \(\partial\Omega_{\text{PEC}}\):

\[\nabla \times \mathbf{E} = -i\omega\mu_0 \mathbf{H}\]
\[\nabla \times \mathbf{H} = i\omega\varepsilon_0 \mathbf{E}\]

where \(\omega\) is the angular frequency, \(\mu_0\) is the vacuum permeability, and \(\varepsilon_0\) is the vacuum permittivity. Taking the curl of the first equation and substituting the second yields the vector wave equation for the electric field \(\mathbf{E}\):

\[\nabla \times \left( \nabla \times \mathbf{E} \right) = k^2 \mathbf{E}, \quad k^2 = \frac{\omega^2}{c_0^2}\]

where \(c_0 = 1/\sqrt{\mu_0\varepsilon_0}\) is the speed of light. The boundary condition on PEC walls is:

\[\mathbf{n} \times \mathbf{E} = \mathbf{0} \quad \text{on } \partial\Omega_{\text{PEC}}\]
\[\mathbf{n} \times (\nabla \times \mathbf{E}) = \mathbf{0} \quad \text{on } \partial\Omega_{\text{PMC}}\]

Fourier Azimuthal Ansatz and Scaling

For 2D axisymmetric geometries, we adopt cylindrical coordinates \((z, r, \phi)\). We expand the 3D electric field in a Fourier series in azimuth \(\phi\):

\[\mathbf{E}(z, r, \phi) = \mathbf{E}_{rz}(z, r) \cos(m\phi) + E_\phi(z, r) \sin(m\phi) \mathbf{e}_\phi\]

where \(m \ge 0\) is the azimuthal mode number (angular harmonic).

Weak Formulation

The fields are discretized on the product space \(H(\text{curl}, \Omega_{2D}) \times H^1(\Omega_{2D})\). The trial functions are \((\mathbf{u}, u_\phi)\) and the test functions are \((\mathbf{v}, v_\phi)\). The scalar \(H^1\) space is constructed with an order \(p+1\) and is zero on the axis \(r=0\) and PEC walls (dirichlet="PEC|AXI"). The elevated polynomial order \(p+1\) for the nodal space \(H^1_{p+1}\) is not an independent choice but a consequence of the exact sequence property underlying the Nédélec/hierarchical construction of \(H(\mathrm{curl})_p\): the space is built such that

\[\nabla H^1_{p+1}(\Omega_{2D}) \subset H(\mathrm{curl})_p(\Omega_{2D})\]

holds exactly at the discrete level.

Substituting the scaled ansatz into the wave equation, integrating against the cylindrical volume measure \(\mathrm{d}V = 2\pi r \mathrm{d}r \mathrm{d}z\), and integrating over \(\phi\) yields the bilinear forms for all \(m \ge 0\) [CASW05]:

\[a((\mathbf{u}, u_\phi), (\mathbf{v}, v_\phi)) = \int_{\Omega_{2D}} \left[ r (\nabla \times \mathbf{u}) \cdot (\nabla \times \mathbf{v}) + \frac{1}{r} \left( m^2 \mathbf{u}\cdot\mathbf{v} + m\mathbf{u}\cdot\nabla v_\phi + m\nabla u_\phi \cdot \mathbf{v} + \nabla u_\phi \cdot \nabla v_\phi \right) \right] \mathrm{d}A\]
\[b((\mathbf{u}, u_\phi), (\mathbf{v}, v_\phi)) = \int_{\Omega_{2D}} \left[ r \mathbf{u}\cdot\mathbf{v} + \frac{1}{r} u_\phi v_\phi \right] \mathrm{d}A\]

where \(\mathrm{d}A = \mathrm{d}z \mathrm{d}r\).

Gradient Kernel Projection

A major challenge in Maxwell eigenvalue computations is the presence of an infinite-dimensional kernel of electrostatic gradient fields that correspond to spurious modes with eigenvalue \(k^2 = 0\). To see how this kernel relates to the product-space formulation, we present the step-by-step derivation of the gradient operator and its real-valued transformation.

Derivation of the 3D Gradient

Let \(\Psi(r, z, \phi)\) be a 3D scalar potential. For a given azimuthal mode number \(m\), we decompose it into a 2D meridian potential \(\psi(r, z)\) multiplied by the angular phase:

\[\Psi(r, z, \phi) = \psi(r, z) e^{\mathrm{i}m\phi}\]

The 3D gradient operator \(\nabla\) in cylindrical coordinates \((r, z, \phi)\) is defined as:

\[\nabla \Psi = \frac{\partial \Psi}{\partial r}\hat{\mathbf{r}} + \frac{\partial \Psi}{\partial z}\hat{\mathbf{z}} + \frac{1}{r}\frac{\partial \Psi}{\partial \phi}\hat{\boldsymbol{\phi}}\]

Substituting our ansatz \(\Psi = \psi e^{\mathrm{i}m\phi}\) into the definition:

\[\nabla(\psi e^{\mathrm{i}m\phi}) = \frac{\partial(\psi e^{\mathrm{i}m\phi})}{\partial r}\hat{\mathbf{r}} + \frac{\partial(\psi e^{\mathrm{i}m\phi})}{\partial z}\hat{\mathbf{z}} + \frac{1}{r}\frac{\partial(\psi e^{\mathrm{i}m\phi})}{\partial \phi}\hat{\boldsymbol{\phi}}\]

Applying the partial derivatives:

  • For the radial component: \(\frac{\partial(\psi e^{\mathrm{i}m\phi})}{\partial r} = \frac{\partial \psi}{\partial r}e^{\mathrm{i}m\phi}\)

  • For the axial component: \(\frac{\partial(\psi e^{\mathrm{i}m\phi})}{\partial z} = \frac{\partial \psi}{\partial z}e^{\mathrm{i}m\phi}\)

  • For the azimuthal component: \(\frac{1}{r}\frac{\partial(\psi e^{\mathrm{i}m\phi})}{\partial \phi} = \frac{1}{r}\left(\mathrm{i}m \psi e^{\mathrm{i}m\phi}\right)\)

Gathering the components yields:

\[\nabla(\psi e^{\mathrm{i}m\phi}) = \left( \frac{\partial \psi}{\partial r}\hat{\mathbf{r}} + \frac{\partial \psi}{\partial z}\hat{\mathbf{z}} + \frac{\mathrm{i}m}{r}\psi\hat{\boldsymbol{\phi}} \right) e^{\mathrm{i}m\phi}\]

Let the 2D meridian gradient be denoted by \(\nabla_{rz} \psi = \frac{\partial \psi}{\partial r}\hat{\mathbf{r}} + \frac{\partial \psi}{\partial z}\hat{\mathbf{z}}\). The 3D gradient vector mapped to the product space components \(\begin{pmatrix} \mathbf{u} \\ u_\phi \end{pmatrix}\) can be written by factoring out \(e^{\mathrm{i}m\phi}\):

\[\begin{split}\nabla_{3\mathrm{D}} \psi = \begin{pmatrix} \nabla_{rz} \psi \\ \frac{\mathrm{i}m}{r}\psi \end{pmatrix}\end{split}\]

Transformation to a Real-Valued Formulation

To avoid dealing with the coordinate singularity \(\frac{1}{r}\) and the imaginary unit \(\mathrm{i}\) directly inside the finite element spaces, a substitution is made for the azimuthal field component. By setting the azimuthal vector component variable to \(u_\phi = \mathrm{i}r E_\phi\), the operator naturally simplifies.

When mapping a scalar field \(\psi\) to this modified product space, the substitution scales the azimuthal slot by \(\mathrm{i}r\). Multiplying the analytical component \(\frac{\mathrm{i}m}{r}\psi\) by \(\mathrm{i}r\):

\[u_\phi = (\mathrm{i}r) \cdot \left(\frac{\mathrm{i}m}{r}\psi\right) = (\mathrm{i} \cdot \mathrm{i}) \cdot m \cdot \psi = - m \psi\]

Therefore, in this transformed product space coordinate system, the exact continuous gradient operator acts as:

\[\begin{split}G_{\text{continuous}}\psi = \begin{pmatrix} \nabla_{rz} \psi \\ -m\psi \end{pmatrix}\end{split}\]

Discrete Projector Construction

For any \(m \ge 0\), the gradient kernel \(\mathcal{K}_m\) in the product space takes the form:

\[\mathcal{K}_m = \{ (\nabla \psi, -m \psi) : \psi \in H^1(\Omega_{2D}), \psi = 0 \text{ on } \partial\Omega_{\text{PEC}} \}\]

To project out this gradient kernel during the iterative PINVIT solver steps, we construct the discrete block gradient matrix \(G_m\):

\[\begin{split}G_m = \begin{bmatrix} G_{\text{rz}} \\ -m I \end{bmatrix}\end{split}\]

where \(G_{\text{rz}}\) is the discrete gradient operator mapping from the scalar potential space to the edge \(H(\text{curl})\) space. We define a \(b\)-orthogonal projector \(P_m\) that filters out this kernel:

\[P_m = I - G_m (G_m^T B G_m)^{-1} G_m^T B\]

where \(B\) is the mass matrix corresponding to the bilinear form \(b\). The projector \(P_m\) is applied to wrap the preconditioned inverse system inside the PINVIT eigensolver to ensure rapid convergence without spurious mode pollution.

Quantities of Interest (QOIs)

Longitudinal QOIs

Once the fields are computed, the following figures of merit are evaluated:

  1. Stored Energy \(U\):

    \[U = \frac{1}{2} \varepsilon_0 \int_{\Omega} |\mathbf{E}|^2 \mathrm{d}V = \pi \varepsilon_0 \int_{\Omega_{2D}} \left( r |\mathbf{E}_{rz}|^2 + \frac{1}{r} |u_\phi|^2 \right) \mathrm{d}z \mathrm{d}r\]
  2. Accelerating Voltage \(V_{\text{acc}}\) and Gradient \(E_{\text{acc}}\):

    Integrated along the \(z\)-axis (\(r=0\)) for a particle traveling at speed \(\beta c_0\) [Wan08]:

    \[V_{\text{acc}} = \left| \int_{z_{\text{min}}}^{z_{\text{max}}} E_z(z, 0) e^{i \frac{\omega z}{\beta c_0}} \mathrm{d}z \right|, \quad E_{\text{acc}} = \frac{V_{\text{acc}}}{L_{\text{active}}}\]

    where \(L_{\text{active}} = 2 L_{\text{cell}} N_{\text{cells}}\) is the active cavity length.

  3. Shunt Impedance over Q \((R/Q)\):

    \[\frac{R}{Q} = \frac{V_{\text{acc}}^2}{\omega U}\]
  4. Surface Power Dissipation \(P_{\text{loss}}\):

    \[P_{\text{loss}} = \frac{1}{2} R_s \int_{\partial\Omega_{\text{PEC}}} |\mathbf{H}|^2 \mathrm{d}S = \pi R_s \int_{\Gamma_{\text{PEC}}} r \left( |H_{rz}|^2 + |H_\phi|^2 \right) \mathrm{d}s\]

    where \(R_s = \sqrt{\frac{\omega\mu_0}{2\sigma}}\) is the surface resistance of the cavity wall with conductivity \(\sigma\) [PKH08].

  5. Quality Factor \(Q\) and Geometry Factor \(G\):

    \[Q = \frac{\omega U}{P_{\text{loss}}}, \quad G = Q R_s = \frac{\omega \mu_0 \int_{\Omega} |\mathbf{E}|^2 \mathrm{d}V}{\int_{\partial\Omega} |\mathbf{H}|^2 \mathrm{d}S}\]
  6. Peak Fields \(E_{\text{pk}}\) and \(B_{\text{pk}}\):

    Pointwise maxima along the PEC boundary:

    \[E_{\text{pk}} = \max_{\Gamma_{\text{PEC}}} |\mathbf{E}|, \quad B_{\text{pk}} = \mu_0 \max_{\Gamma_{\text{PEC}}} |\mathbf{H}|\]

Transverse QOIs and Panofsky–Wenzel Relation

For deflecting higher-order modes (\(m \ge 1\)), the accelerating force is transverse. Since the longitudinal field \(E_z\) vanishes on the axis for \(m \ge 1\), the longitudinal voltage is integrated along an off-axis line at radius \(r_0\) (typically half the beam aperture radius):

\[V_z(r_0) = \left| \int_{z_{\text{min}}}^{z_{\text{max}}} E_z(z, r_0) e^{i \frac{\omega z}{\beta c_0}} \mathrm{d}z \right|\]

By the Panofsky–Wenzel theorem, the transverse kick voltage \(V_t\) is related to the gradient of the longitudinal voltage:

\[V_t = \frac{m V_z(r_0)}{k r_0}\]

The transverse shunt impedance over Q is normalized by the off-axis factor to remain independent of the choice of \(r_0\):

\[\left( \frac{R}{Q} \right)_t = \frac{V_t^2}{\omega U r_0^{2(m-1)}}\]

Lossy Dielectrics

A dielectric sub-domain enters the eigenproblem through the mass form alone: the weak form above is assembled with \(\varepsilon_r\) inside the \(b(\cdot,\cdot)\) integral, so the eigenvalue is still \(\lambda = k_0^2 = (\omega/c_0)^2\) and no interface condition has to be imposed by hand — \(H(\text{curl})\) enforces tangential-\(\mathbf{E}\) continuity and \(u_\phi = r E_\phi\) is tangential to any \(r\)-\(z\) interface, while normal \(\mathbf{D}\) continuity is natural.

With the \(e^{+\mathrm{i}\omega t}\) convention a lossy medium has

\[\varepsilon_r = \varepsilon_r' - \mathrm{i}\varepsilon_r'', \qquad \tan\delta = \frac{\varepsilon_r''}{\varepsilon_r'}\]

and cavsim2d offers two treatments of the imaginary part.

Perturbative Treatment

The lossless problem is solved with \(\varepsilon_r'\) and the loss is evaluated afterwards on the resulting field, exactly as the wall loss is:

\[P_{\text{diel}} = \frac{1}{2}\,\omega\,\varepsilon_0 \int \varepsilon_r''\,|\mathbf{E}|^2\,\mathrm{d}V, \qquad U = \frac{1}{2}\,\varepsilon_0 \int \varepsilon_r'\,|\mathbf{E}|^2\,\mathrm{d}V\]

so that

\[Q_{\text{diel}} = \frac{\omega U}{P_{\text{diel}}} = \frac{\int \varepsilon_r'\,|\mathbf{E}|^2\, r\,\mathrm{d}A} {\int \varepsilon_r''\,|\mathbf{E}|^2\, r\,\mathrm{d}A}, \qquad \frac{1}{Q} = \frac{1}{Q_{\text{wall}}} + \frac{1}{Q_{\text{diel}}}\]

The matrices, the eigensolver and the gradient-kernel projector are untouched. The error is \(O(\tan^2\delta)\) in the eigenvalue, and because the integration is performed over the lossless mode the treatment cannot represent the field redistribution the loss causes — nor any frequency shift, since the real eigenproblem never saw \(\varepsilon_r''\).

Full Complex Eigenproblem

Weighting the mass form by the complex \(\varepsilon_r\) gives

\[A\mathbf{x} = \lambda B\mathbf{x}, \qquad B = B' - \mathrm{i}B'', \qquad \lambda \in \mathbb{C}\]

with \(A\) real symmetric positive semi-definite and \(B\) complex symmetric — not Hermitian. Three consequences follow:

  • \(\lambda\) is complex, so \(\omega = c_0\sqrt{\lambda}\) has \(\mathbf{E} \propto e^{-\alpha t}\) with \(\alpha = \operatorname{Im}\omega\); the stored energy decays as \(e^{-2\alpha t} = e^{-\omega_r t/Q}\), giving

    \[Q_{\text{diel}} = \frac{\operatorname{Re}\omega}{2\operatorname{Im}\omega}\]
  • eigenvectors are no longer \(B\)-orthogonal in the Hermitian sense: they satisfy \(\mathbf{x}_i^T B \mathbf{x}_j = 0\) (transpose, no conjugate);

  • the preconditioned inverse iteration (PINVIT) used for the real problem assumes a Hermitian pencil and does not apply.

The spectrum is therefore reached with shift-and-invert Arnoldi on \((A - \sigma B)^{-1} B\). On a 2D meridian mesh the shifted matrix is small enough to factorise with a sparse direct solver, so no preconditioner is needed.

The choice of shifts is what makes this tractable. The gradient kernel \(\mathcal{K}_m\) is still present at \(\lambda \approx 0\) and is high-dimensional; under the shift-invert map every kernel vector lands at magnitude \(|1/\sigma|\), so a shift far from the band lets the kernel crowd the Krylov space. cavsim2d first solves the lossless problem and centres one Arnoldi run on each lossless eigenvalue: the physical mode then maps to \(\sim 1/(\sigma \tan\delta)\), orders of magnitude above the kernel cluster. Each run’s best eigenpair is accepted only if its relative residual

\[\frac{\|A\mathbf{x} - \lambda B\mathbf{x}\|}{|\lambda|\,\|B\mathbf{x}\|}\]

is small; otherwise the shift is re-centred on the eigenvalue just found and the run repeated, which is what large \(\tan\delta\) requires, since the mode has then moved far from its lossless position. Accepted modes are deduplicated and sorted by \(\operatorname{Re}\lambda\).

Wall loss remains perturbative on both paths. Folding it into the eigenproblem through a Leontovich impedance boundary condition would introduce \(Z_s = (1+\mathrm{i})\sqrt{\omega\mu/2\sigma} \propto \sqrt{\omega}\) and make the problem nonlinear in \(\omega\). A conductive dielectric loss, \(\varepsilon_r'' = \sigma/(\omega\varepsilon_0)\), is nonlinear in \(\omega\) for the same reason and is likewise not modelled.

Selection

The perturbative treatment is used up to \(\tan\delta = 10^{-2}\) and the complex eigenproblem above it. The threshold follows from the \(O(\tan^2\delta)\) error: at \(\tan\delta = 10^{-2}\) the two agree to a few parts in \(10^{5}\), and by \(\tan\delta \sim 1\) they differ by tens of percent in both \(Q\) and frequency. eigenmode_config['loss_model'] overrides the choice.

Impedance Spectrum from Eigenfrequencies and Quality Factors

The impedance spectrum the beam sees can be reconstructed from the eigenmode results alone: each resonant mode behaves as a parallel \(RLC\) resonator, completely characterised by its resonant frequency \(f_i\), its \((R/Q)_i\) and its quality factor \(Q_i\) — exactly the quantities the eigenmode solver reports. The longitudinal beam-coupling impedance is the sum of Breit–Wigner resonator terms

\[Z_\parallel(f) = \sum_i \frac{R_i}{1 + \mathrm{i}\, Q_i \left( \dfrac{f}{f_i} - \dfrac{f_i}{f} \right)}, \qquad R_i = \frac{1}{2}\, Q_i \left( \frac{R}{Q} \right)_i\]

where \(R_i\) is the shunt impedance of mode \(i\) (the factor \(1/2\) reflects the accelerator convention \(R/Q = V^2/(\omega U)\) used above). On resonance, \(Z_\parallel(f_i) = R_i\) is real; the \(3\,\text{dB}\) full width of each peak is \(f_i / Q_i\). As \(f \to 0\) every longitudinal term vanishes.

For the transverse (deflecting, \(m \ge 1\)) impedance, the transverse \((R/Q)_t\) from the Panofsky–Wenzel relation above (in \(\Omega\)) is converted to a transverse shunt impedance in \(\Omega/\mathrm{m}\) by the factor \(\omega_i / c_0\), and each resonator term carries an additional \(f_i / f\) :

\[Z_\perp(f) = \sum_i \frac{f_i}{f} \cdot \frac{R_{t,i}}{1 + \mathrm{i}\, Q_i \left( \dfrac{f}{f_i} - \dfrac{f_i}{f} \right)}, \qquad R_{t,i} = \frac{1}{2}\, Q_i \left( \frac{R}{Q} \right)_{t,i} \frac{\omega_i}{c_0}\]

whose DC limit is finite and purely inductive, \(Z_\perp(0) = \mathrm{i} \sum_i R_{t,i} / Q_i\). The cavity is axisymmetric, so the two transverse planes are degenerate and a single transverse \(R/Q\) describes both.

Two caveats. First, the eigenmode solver reports the unloaded \(Q_0\) (wall losses only); if the mode is damped by couplers or absorbers, the beam sees the loaded \(Q_L\), which should be substituted for \(Q_i\) — lowering \(Q\) broadens the resonance and reduces its peak while leaving \(R/Q\) (a pure geometry quantity) unchanged. Second, the reconstruction contains exactly the modes that were solved and nothing else: no broadband/resistive-wall contribution and nothing above the highest computed mode. Within that range, however, it is essentially exact — it has no wake-length truncation, so it complements a wakefield solve, whose spectral resolution \(\Delta f \sim c_0 / (2 L_{\text{wake}})\) limits how well narrow (high-\(Q\)) resonances are resolved. cavsim2d exposes both through the same frame layout (cav.eigenmode.impedance() vs cav.wakefield.impedance()) so the reconstructed and the simulated spectra can be overlaid directly.

Zienkiewicz–Zhu (ZZ) Error Estimator

A Posteriori Error Estimation

To achieve high precision with minimum degrees of freedom, cavsim2d implements an adaptive mesh refinement (AMR) loop driven by a recovery-based a posteriori error estimator.

The standard finite-element approximation yields a discontinuous magnetic field \(\mathbf{H} \propto \nabla \times \mathbf{E}\) across element boundaries. The Zienkiewicz–Zhu (ZZ) technique reconstructs a continuous recovered field \(\mathbf{H}^*\) in the \(H^1\) space via patch recovery [ZZ87, ZZ92]:

\[\mathbf{H}^* = \sum_{j} H^*_j \phi_j\]

where \(\phi_j\) are the continuous nodal basis functions. The recovered nodal values \(H^*_j\) are computed by a least-squares projection of the discontinuous FE field \(\mathbf{H}\) over a patch of elements surrounding node \(j\).

Element-wise Error Indicator

The error in element \(K\) is estimated as the difference between the recovered field and the raw FE field:

\[\eta_K^2 = \int_K r \left| \mathbf{H} - \mathbf{H}^* \right|^2 \mathrm{d}A\]

Doerfler Marking and Refinement

In each refinement step, we compute the indicators \(\eta_K\) for all elements. Let \(\eta_{\text{max}} = \max_K \eta_K\). We mark elements for refinement using the Doerfler marking strategy with threshold parameter \(\theta \in (0, 1]\) [Dorfler96]:

\[\text{Mark } K \quad \text{if } \eta_K > \theta \eta_{\text{max}}\]

Marked elements are subdivided using Netgen’s 2D local refinement algorithms, and the polynomial order \(p\) is re-applied to curve the newly created elements along the boundary. The refinement terminates when the maximum error across all solved physical modes falls below a tolerance:

\[\max_{\text{modes}} \left( \max_K \eta_K \right) < \text{tol}\]