Open boundaries (PML) and the radiated impedance¶
A cavity eigenmode solve normally puts a closed wall across each beam-pipe end
(boundary_conditions='mm', a magnetic wall). That is the right model for a trapped
mode, whose field has already decayed to nothing by the time it reaches the pipe. It is
the wrong model for a mode above the beam-pipe cutoff: such a mode physically
propagates out of the pipe and never comes back, but a closed end reflects it. The solver
then reports it as a sharp resonance with the high ohmic \(Q_0\) of the wall material,
instead of the low radiation-limited \(Q\) it really has.
Because the reconstructed impedance scales with \(Q\),
that error goes straight into \(|Z|\).
Setting boundary_conditions='oo' replaces both end walls with a perfectly matched
layer (PML): an absorbing extension of the beam pipe that lets the wave leave. The
eigenvalues then come out complex, \(\omega = \omega_0 + i\,\omega_i\), and the imaginary
part is the radiation loss:
This example solves the same TESLA cavity both ways and checks the result against a time-domain wakefield run, which has an open pipe by construction.
It also shows the part that is easy to get wrong. An open solve returns two kinds of eigenpair above the cutoff — genuine resonance poles of the open cavity, and modes of the finite PML block — and nothing in the results table separates them. Section 5 is about telling them apart, because the artifacts turn out to carry the largest \(R/Q\) in the whole set.
See the eigenmode guide and the wakefield guide.
import os
import tempfile
import matplotlib.pyplot as plt
import numpy as np
from cavsim2d import EllipticalCavity
from cavsim2d.utils.style import apply_style
apply_style()
workspace = tempfile.mkdtemp()
1. The cavity¶
A 3-cell TESLA cavity — two end cells around a mid cell — with beam pipes at both ends
(beampipe='both'). The pipes matter here: they are what the radiating modes escape
through, and their radius sets the cutoff frequency that divides trapped modes from
propagating ones. Note that it is the end cell’s aperture that the pipe inherits, not
the mid cell’s.
For the lowest monopole (TM\(_{01}\)) pipe mode that cutoff is
with \(R_i\) the pipe radius. Everything below \(f_c\) is trapped; everything above it radiates.
# A B a b Ri L Req [mm]
midcell = [ 42.00, 42.00, 12.0, 19.0, 35.0, 57.6520, 103.3536]
endcell_l = [ 40.34, 40.34, 10.0, 13.5, 39.0, 55.7251, 103.3536]
endcell_r = [ 42.00, 42.00, 9.0, 12.8, 39.0, 56.8407, 103.3536]
def tesla(name):
cav = EllipticalCavity(3, midcell, endcell_l, endcell_r,
beampipe='both', name=name)
cav.set_workspace(os.path.join(workspace, name))
return cav
cav_closed = tesla('tesla_closed')
cav_open = tesla('tesla_open')
c0 = 299792458.0
Ri = endcell_l[4] * 1e-3 # pipe radius = end-cell aperture [m]
f_cutoff = 2.405 * c0 / (2 * np.pi * Ri) / 1e6
print(f'beam-pipe radius {Ri * 1e3:.1f} mm')
print(f'TM01 pipe cutoff {f_cutoff:.1f} MHz')
cav_closed.plot('geometry');
beam-pipe radius 39.0 mm
TM01 pipe cutoff 2942.3 MHz
2. The usual solve: closed ends¶
This is the default. Fifty monopole modes, which covers the first passbands and reaches
well past the cutoff. The wall is copper — the solver’s default conductivity — so the
ohmic \(Q_0\) lands near \(3\times10^{4}\). With niobium it would be orders of magnitude
larger, and everything below about \(Q_0\) being far too high above cutoff only gets
stronger.
eigen_config = {
'polarisation': 'monopole',
'n_modes': 50, # enough to reach past the pipe cutoff
'mesh_config': {'h': 10, 'p': 3},
'force': True, # skip the overwrite prompt (this notebook is run headless)
}
cav_closed.eigenmode.run(dict(eigen_config, boundary_conditions='mm'))
closed = cav_closed.eigenmode.qois_df
closed[['freq [MHz]', 'Q []', 'R/Q [Ohm]', 'ff [%]']]
| freq [MHz] | Q [] | R/Q [Ohm] | ff [%] | |
|---|---|---|---|---|
| 0 | 1281.681695 | 29259.855751 | 2.740981e-02 | 50.736100 |
| 1 | 1293.828853 | 29361.598398 | 4.466749e-03 | 99.744705 |
| 2 | 1300.008497 | 29307.536427 | 3.323323e+02 | 98.642866 |
| 3 | 2391.165470 | 31738.384203 | 1.213864e+00 | 29.534609 |
| 4 | 2420.570382 | 31678.231675 | 1.541160e+01 | 19.822320 |
| 5 | 2450.896087 | 31128.031873 | 8.334806e+01 | 12.867093 |
| 6 | 2488.067601 | 54356.346310 | 1.415542e-10 | 0.000000 |
| 7 | 2500.606956 | 53653.119970 | 1.771916e-11 | 0.000000 |
| 8 | 2506.659281 | 53904.788923 | 1.431859e-10 | 0.000000 |
| 9 | 2680.499811 | 44503.121053 | 5.910324e-02 | 82.373009 |
| 10 | 2712.352299 | 44821.699820 | 2.077561e+00 | 95.274572 |
| 11 | 2754.653151 | 46292.057367 | 1.037956e-01 | 55.583611 |
| 12 | 3134.655284 | 34627.083287 | 1.213569e+00 | 3.744947 |
| 13 | 3135.716260 | 34580.234932 | 3.216804e+00 | 1.832900 |
| 14 | 3411.651719 | 38899.135750 | 2.938189e+00 | 52.753129 |
| 15 | 3457.310694 | 39448.715992 | 4.668869e-01 | 18.696058 |
| 16 | 3534.271197 | 42033.951689 | 3.575426e+00 | 37.056840 |
| 17 | 3679.212404 | 49598.007340 | 5.401360e+00 | 38.005885 |
| 18 | 3702.011219 | 62894.383987 | 1.818043e-09 | 0.000000 |
| 19 | 3726.681676 | 72197.209298 | 3.518128e-10 | 0.000000 |
| 20 | 3728.723052 | 71434.408506 | 2.004984e-09 | 0.000000 |
| 21 | 3738.365912 | 61806.632535 | 7.579225e-10 | 0.000000 |
| 22 | 3762.785867 | 64654.288242 | 2.840331e-09 | 0.000000 |
| 23 | 3762.818412 | 42400.735210 | 4.602171e+00 | 42.797830 |
| 24 | 3784.795641 | 62082.918609 | 6.594884e-10 | 0.000000 |
| 25 | 3848.232273 | 40340.587073 | 2.636283e+00 | 13.014899 |
| 26 | 3855.797284 | 38088.461919 | 1.441329e+01 | 1.932878 |
| 27 | 3888.918220 | 38507.651199 | 1.005276e+01 | 1.786831 |
| 28 | 3981.763363 | 44701.125357 | 1.567840e+00 | 55.682656 |
| 29 | 4087.941066 | 50815.472410 | 4.411024e+00 | 13.676029 |
| 30 | 4183.114227 | 58775.390530 | 2.741313e-01 | 66.124729 |
| 31 | 4488.223168 | 44268.936053 | 1.872184e+01 | 68.771401 |
| 32 | 4518.565984 | 48357.092284 | 2.066167e+00 | 35.502955 |
| 33 | 4630.320011 | 54620.084572 | 5.634612e+00 | 35.540208 |
| 34 | 4638.048415 | 55762.946373 | 1.348000e-07 | 0.000000 |
| 35 | 4658.597254 | 52325.508766 | 9.621152e-07 | 0.000000 |
| 36 | 4700.702218 | 64035.997918 | 5.365117e+00 | 14.455187 |
| 37 | 4701.867300 | 60245.686107 | 3.758421e-06 | 100.000000 |
| 38 | 4735.500370 | 50027.643314 | 7.384399e-07 | 82.214936 |
| 39 | 4750.283598 | 48663.115947 | 1.305416e-05 | 88.050811 |
| 40 | 4775.063777 | 54319.338151 | 1.510585e-06 | 19.144443 |
| 41 | 4867.155781 | 43783.700788 | 4.447475e-01 | 4.787049 |
| 42 | 4875.960310 | 74207.874788 | 2.524291e-04 | 6.545309 |
| 43 | 4882.777273 | 44587.746060 | 3.936037e-01 | 12.796281 |
| 44 | 4902.090652 | 44874.499311 | 3.994305e+00 | 3.710627 |
| 45 | 4925.084424 | 44779.831051 | 3.759479e+00 | 1.901832 |
| 46 | 4975.994204 | 73417.316112 | 4.974674e-04 | 14.641994 |
| 47 | 5047.850528 | 57620.144210 | 5.092212e-03 | 2.204736 |
| 48 | 5062.593837 | 65429.052986 | 4.934103e-03 | 13.941968 |
| 49 | 5128.782906 | 78570.538991 | 7.723051e-03 | 19.771570 |
Every mode carries the same \(Q\) of order \(3\times10^{4}\) — the copper wall loss alone. Nothing in this table knows that the modes above the cutoff are not confined.
3. The same solve with open ends¶
The only change is boundary_conditions='oo'. The solver attaches a PML block to each
pipe mouth, meshes it as part of the same domain, and solves the resulting complex
eigenproblem.
cav_open.eigenmode.run(dict(eigen_config, boundary_conditions='oo'))
opened = cav_open.eigenmode.qois_df
opened[['freq [MHz]', 'Q []', 'Q_wall []', 'Q_rad []', 'Prad [W]', 'R/Q [Ohm]', 'ff [%]']]
| freq [MHz] | Q [] | Q_wall [] | Q_rad [] | Prad [W] | R/Q [Ohm] | ff [%] | |
|---|---|---|---|---|---|---|---|
| 0 | 1281.681798 | 29260.315860 | 29260.315870 | 1.073540e+14 | 2.086605e-15 | 2.787675e-02 | 50.732275 |
| 1 | 1293.829352 | 29362.851069 | 29362.851099 | 3.623937e+13 | 6.239859e-15 | 4.543089e-03 | 99.734303 |
| 2 | 1300.008778 | 29308.386204 | 29308.386224 | 5.481283e+13 | 4.145171e-15 | 3.322731e+02 | 98.629225 |
| 3 | 2391.161958 | 31740.048897 | 31740.634764 | 1.719348e+09 | 2.430647e-10 | 1.261099e+00 | 29.543213 |
| 4 | 2420.562171 | 31679.864318 | 31681.634990 | 5.668023e+08 | 7.463780e-10 | 1.557170e+01 | 19.826512 |
| 5 | 2450.887206 | 31125.860518 | 31128.195502 | 4.149504e+08 | 1.032288e-09 | 8.412557e+01 | 12.861193 |
| 6 | 2488.065946 | 54319.158299 | 54319.158299 | 1.530736e+15 | 2.840796e-16 | 1.094127e-25 | 13.824346 |
| 7 | 2500.607112 | 53638.559294 | 53638.559294 | 4.027884e+16 | 1.085043e-17 | 5.195332e-25 | 17.562646 |
| 8 | 2506.659279 | 53895.702050 | 53895.702050 | 1.811962e+15 | 2.417824e-16 | 4.569619e-24 | 40.096651 |
| 9 | 2680.440575 | 44419.338351 | 44493.433166 | 2.667804e+07 | 1.755838e-08 | 1.028658e-01 | 82.469878 |
| 10 | 2712.232366 | 44380.828439 | 44794.346690 | 4.808031e+06 | 9.856792e-08 | 1.792942e+00 | 95.265018 |
| 11 | 2754.581912 | 45634.066311 | 46269.363351 | 3.323807e+06 | 1.448197e-07 | 3.217207e-02 | 55.443306 |
| 12 | 2950.214180 | 151.396836 | 33981.240174 | 1.520676e+02 | 5.270092e-04 | 3.694164e+01 | 1.593377 |
| 13 | 2950.223599 | 150.919190 | 34005.254706 | 1.515823e+02 | 5.270682e-04 | 5.927121e+01 | 0.875394 |
| 14 | 3016.583234 | 18.212891 | 33493.303759 | 1.822121e+01 | 1.449994e-02 | 2.701476e+01 | 1.735937 |
| 15 | 3016.650833 | 18.169833 | 33500.824665 | 1.817804e+01 | 1.451690e-02 | 4.297555e+01 | 0.865663 |
| 16 | 3154.107441 | 7.478490 | 35760.332456 | 7.477929e+00 | 3.502639e-02 | 7.835297e+01 | 0.472502 |
| 17 | 3154.569648 | 7.493899 | 35765.419878 | 7.492369e+00 | 3.506059e-02 | 2.945991e+01 | 0.730882 |
| 18 | 3372.659884 | 4.429038 | 36921.063754 | 4.426955e+00 | 6.671701e-02 | 1.278091e+02 | 0.116068 |
| 19 | 3375.632520 | 4.417115 | 36936.552605 | 4.413422e+00 | 6.709205e-02 | 1.836300e+01 | 2.641547 |
| 20 | 3431.878739 | 57.116313 | 39360.268804 | 5.717676e+01 | 1.000803e-02 | 2.828475e+00 | 60.103761 |
| 21 | 3506.207735 | 16.930222 | 38782.368166 | 1.692748e+01 | 3.132914e-02 | 1.889192e+01 | 10.099211 |
| 22 | 3595.369618 | 15.380984 | 39416.939603 | 1.537655e+01 | 3.543791e-02 | 3.250723e+01 | 26.379489 |
| 23 | 3655.885216 | 3.047149 | 38225.182318 | 3.043848e+00 | 1.044375e-01 | 1.488037e+02 | 1.029855 |
| 24 | 3657.359710 | 3.022662 | 38241.216460 | 3.017034e+00 | 1.049099e-01 | 1.147976e+01 | 0.984144 |
| 25 | 3702.001991 | 62724.148256 | 62724.148300 | 5.655862e+11 | 1.143974e-12 | 6.965034e-25 | 37.060142 |
| 26 | 3726.681840 | 72190.756325 | 72190.756329 | 1.160608e+13 | 5.611970e-14 | 9.454953e-27 | 16.335486 |
| 27 | 3728.723125 | 71429.613943 | 71429.613996 | 8.128093e+11 | 8.017702e-13 | 1.025314e-25 | 10.478969 |
| 28 | 3738.366055 | 61764.750916 | 61764.750925 | 3.992300e+12 | 1.636580e-13 | 6.702333e-26 | 20.236595 |
| 29 | 3762.786004 | 64645.110130 | 64645.110141 | 5.232537e+12 | 1.256828e-13 | 3.059321e-28 | 41.567610 |
| 30 | 3784.795975 | 62043.049027 | 62043.049038 | 3.871381e+12 | 1.708658e-13 | 1.006456e-22 | 12.526744 |
| 31 | 3801.194925 | 24.153707 | 44672.943588 | 2.414472e+01 | 2.555246e-02 | 1.212190e+01 | 40.279250 |
| 32 | 3851.530329 | 221.748793 | 40900.751373 | 2.228144e+02 | 2.998170e-03 | 5.181005e+00 | 8.166328 |
| 33 | 3859.373138 | 89.861606 | 41854.773625 | 8.999508e+01 | 7.355359e-03 | 5.483850e-01 | 12.583539 |
| 34 | 3979.586978 | 2.347666 | 39306.084667 | 2.340058e+00 | 1.447754e-01 | 8.306390e+00 | 0.005107 |
| 35 | 3979.697569 | 2.362341 | 39290.339134 | 2.357815e+00 | 1.443724e-01 | 1.395220e+02 | 0.224605 |
| 36 | 3936.745042 | 49.792002 | 40601.395727 | 4.980293e+01 | 1.337571e-02 | 1.616448e+01 | 69.078348 |
| 37 | 4039.544987 | 15.658776 | 43638.585796 | 1.564298e+01 | 4.092250e-02 | 2.896902e+01 | 10.762963 |
| 38 | 4173.749074 | 28.356058 | 50579.413278 | 2.832852e+01 | 2.449360e-02 | 2.440490e+00 | 69.257241 |
| 39 | 4336.664637 | 1.991927 | 40162.726323 | 1.981966e+00 | 1.852465e-01 | 5.645385e+00 | 0.000686 |
| 40 | 4335.547782 | 2.000001 | 40142.028404 | 1.994018e+00 | 1.846080e-01 | 1.145472e+02 | 0.000742 |
| 41 | 4727.290132 | 1.669878 | 40881.129024 | 1.657834e+00 | 2.288774e-01 | 4.229138e+00 | 0.000000 |
| 42 | 4734.848825 | 1.671748 | 40863.883319 | 1.664319e+00 | 2.289250e-01 | 8.368305e+01 | 0.000000 |
| 43 | 4605.113754 | 109.663928 | 49599.740474 | 1.096474e+02 | 7.260869e-03 | 4.019093e+00 | 25.738943 |
| 44 | 4640.039009 | 44836.460853 | 57011.059986 | 4.305122e+06 | 1.852665e-07 | 1.038848e-27 | 23.347615 |
| 45 | 4661.612539 | 9116.678809 | 54058.759811 | 2.484559e+06 | 3.137526e-07 | 1.482699e-26 | 21.060776 |
| 46 | 4695.663407 | 216.272017 | 60794.827054 | 2.165119e+02 | 3.770176e-03 | 5.389879e+00 | 16.167441 |
| 47 | 4702.759921 | 2514.635317 | 60810.673058 | 1.625866e+07 | 4.908458e-08 | 2.236110e-24 | 16.434549 |
| 48 | 4714.206773 | 73.087420 | 46178.600323 | 8.890433e+05 | 3.300876e-07 | 2.365423e-25 | 76.953164 |
| 49 | 4716.590389 | 67.238149 | 47342.822559 | 9.718967e+05 | 3.001439e-07 | 1.466999e-25 | 100.000000 |
The open run splits the total \(Q\) into its two channels,
and reports each separately. Q_wall [] is the same ohmic number the closed run gave;
Q_rad [] is new, and it is what the closed run could not see.
Two independent measurements of the same loss¶
Q_rad [] is obtained by integrating the power actually flowing out of the pipe mouths,
Q_eig [] comes from somewhere else entirely — the imaginary part of the eigenvalue, i.e.
how fast the mode decays. Neither is derived from the other, so comparing them is a real
check. Q balance [] is that comparison, and equals 1 when they agree:
opened[['freq [MHz]', 'R/Q [Ohm]', 'Q_rad []', 'Q_eig []', 'Q balance []']]
| freq [MHz] | R/Q [Ohm] | Q_rad [] | Q_eig [] | Q balance [] | |
|---|---|---|---|---|---|
| 0 | 1281.681798 | 2.787675e-02 | 1.073540e+14 | 8.634463e+13 | 0.804298 |
| 1 | 1293.829352 | 4.543089e-03 | 3.623937e+13 | 2.890062e+13 | 0.797492 |
| 2 | 1300.008778 | 3.322731e+02 | 5.481283e+13 | 4.353572e+13 | 0.794261 |
| 3 | 2391.161958 | 1.261099e+00 | 1.719348e+09 | 1.719585e+09 | 1.000138 |
| 4 | 2420.562171 | 1.557170e+01 | 5.668023e+08 | 5.668300e+08 | 1.000049 |
| 5 | 2450.887206 | 8.412557e+01 | 4.149504e+08 | 4.149457e+08 | 0.999989 |
| 6 | 2488.065946 | 1.094127e-25 | 1.530736e+15 | 5.549712e+17 | 362.551794 |
| 7 | 2500.607112 | 5.195332e-25 | 4.027884e+16 | 8.277158e+18 | 205.496415 |
| 8 | 2506.659279 | 4.569619e-24 | 1.811962e+15 | 5.922941e+17 | 326.879963 |
| 9 | 2680.440575 | 1.028658e-01 | 2.667804e+07 | 2.667351e+07 | 0.999830 |
| 10 | 2712.232366 | 1.792942e+00 | 4.808031e+06 | 4.807551e+06 | 0.999900 |
| 11 | 2754.581912 | 3.217207e-02 | 3.323807e+06 | 3.323578e+06 | 0.999931 |
| 12 | 2950.214180 | 3.694164e+01 | 1.520676e+02 | 1.520744e+02 | 1.000044 |
| 13 | 2950.223599 | 5.927121e+01 | 1.515823e+02 | 1.515920e+02 | 1.000064 |
| 14 | 3016.583234 | 2.701476e+01 | 1.822121e+01 | 1.822280e+01 | 1.000088 |
| 15 | 3016.650833 | 4.297555e+01 | 1.817804e+01 | 1.817969e+01 | 1.000091 |
| 16 | 3154.107441 | 7.835297e+01 | 7.477929e+00 | 7.480055e+00 | 1.000284 |
| 17 | 3154.569648 | 2.945991e+01 | 7.492369e+00 | 7.495470e+00 | 1.000414 |
| 18 | 3372.659884 | 1.278091e+02 | 4.426955e+00 | 4.429569e+00 | 1.000591 |
| 19 | 3375.632520 | 1.836300e+01 | 4.413422e+00 | 4.417643e+00 | 1.000956 |
| 20 | 3431.878739 | 2.828475e+00 | 5.717676e+01 | 5.719932e+01 | 1.000395 |
| 21 | 3506.207735 | 1.889192e+01 | 1.692748e+01 | 1.693762e+01 | 1.000599 |
| 22 | 3595.369618 | 3.250723e+01 | 1.537655e+01 | 1.538699e+01 | 1.000679 |
| 23 | 3655.885216 | 1.488037e+02 | 3.043848e+00 | 3.047392e+00 | 1.001164 |
| 24 | 3657.359710 | 1.147976e+01 | 3.017034e+00 | 3.022901e+00 | 1.001945 |
| 25 | 3702.001991 | 6.965034e-25 | 5.655862e+11 | 9.008595e+13 | 159.278913 |
| 26 | 3726.681840 | 9.454953e-27 | 1.160608e+13 | 1.294451e+15 | 111.532197 |
| 27 | 3728.723125 | 1.025314e-25 | 8.128093e+11 | 9.631771e+13 | 118.499757 |
| 28 | 3738.366055 | 6.702333e-26 | 3.992300e+12 | 4.368769e+14 | 109.429869 |
| 29 | 3762.786004 | 3.059321e-28 | 5.232537e+12 | 4.119628e+14 | 78.730993 |
| 30 | 3784.795975 | 1.006456e-22 | 3.871381e+12 | 3.418674e+14 | 88.306315 |
| 31 | 3801.194925 | 1.212190e+01 | 2.414472e+01 | 2.416677e+01 | 1.000913 |
| 32 | 3851.530329 | 5.181005e+00 | 2.228144e+02 | 2.229576e+02 | 1.000643 |
| 33 | 3859.373138 | 5.483850e-01 | 8.999508e+01 | 9.005495e+01 | 1.000665 |
| 34 | 3979.586978 | 8.306390e+00 | 2.340058e+00 | 2.347806e+00 | 1.003311 |
| 35 | 3979.697569 | 1.395220e+02 | 2.357815e+00 | 2.362483e+00 | 1.001980 |
| 36 | 3936.745042 | 1.616448e+01 | 4.980293e+01 | 4.985314e+01 | 1.001008 |
| 37 | 4039.544987 | 2.896902e+01 | 1.564298e+01 | 1.566440e+01 | 1.001369 |
| 38 | 4173.749074 | 2.440490e+00 | 2.832852e+01 | 2.837196e+01 | 1.001534 |
| 39 | 4336.664637 | 5.645385e+00 | 1.981966e+00 | 1.992026e+00 | 1.005076 |
| 40 | 4335.547782 | 1.145472e+02 | 1.994018e+00 | 2.000101e+00 | 1.003051 |
| 41 | 4727.290132 | 4.229138e+00 | 1.657834e+00 | 1.669946e+00 | 1.007306 |
| 42 | 4734.848825 | 8.368305e+01 | 1.664319e+00 | 1.671816e+00 | 1.004505 |
| 43 | 4605.113754 | 4.019093e+00 | 1.096474e+02 | 1.099069e+02 | 1.002367 |
| 44 | 4640.039009 | 1.038848e-27 | 4.305122e+06 | 2.099596e+05 | 0.048770 |
| 45 | 4661.612539 | 1.482699e-26 | 2.484559e+06 | 1.096603e+04 | 0.004414 |
| 46 | 4695.663407 | 5.389879e+00 | 2.165119e+02 | 2.170441e+02 | 1.002458 |
| 47 | 4702.759921 | 2.236110e-24 | 1.625866e+07 | 2.623106e+03 | 0.000161 |
| 48 | 4714.206773 | 2.365423e-25 | 8.890433e+05 | 7.320328e+01 | 0.000082 |
| 49 | 4716.590389 | 1.466999e-25 | 9.718967e+05 | 6.733378e+01 | 0.000069 |
Read that table with its R/Q [Ohm] column beside it, because the balance splits the modes
in a way that is easy to misread.
Every mode that couples to the beam at all sits within about a percent of 1: a surface integral of \(\mathbf{E}\times\mathbf{H}^{*}\) and the decay rate of a complex eigenvalue, computed without reference to each other, land on the same \(Q\). That is the check passing, and it is the evidence that the layer is genuinely absorbing rather than merely lengthening the pipe.
Where it fails, it fails on modes with \(R/Q \sim 10^{-25}\,\Omega\) — TE modes and other eigenpairs with no field on the axis — plus the fundamental trio near 1300 MHz. In both cases the comparison is between two numbers that are essentially zero (radiated fluxes of order \(10^{-13}\) W, or two \(Q\) values of order \(10^{13}\)), so the ratio is roundoff.
Q balance [] is therefore a check on the absorbing layer, and a good one. What it is
not is a filter for the impedance: every mode it rejects here contributes \(10^{-25}\) kΩ,
and dropping all of them changes \(|Z|\) by nothing at all. The modes that really do need
filtering are in section 5 — and every one of them passes this check.
4. Which modes actually radiate¶
Plotting \(Q_{\text{rad}}\) against frequency separates the two populations. Below cutoff the layer receives an evanescent tail and almost no power, so \(Q_{\text{rad}}\) runs away to enormous values — the mode is trapped, exactly as the closed solve assumed. Above cutoff \(Q_{\text{rad}}\) collapses by many orders of magnitude, and that is the number that sets the impedance.
fig, ax = plt.subplots(figsize=(8, 4))
ax.semilogy(closed['freq [MHz]'], closed['Q []'], 's--', label=r'$Q_0$ closed ends')
ax.semilogy(opened['freq [MHz]'], opened['Q_rad []'], 'o-',
label=r'$Q_\mathrm{rad}$ open ends (PML)')
ax.axvline(f_cutoff, ls=':', color='k',
label=f'TM$_{{01}}$ pipe cutoff {f_cutoff:.0f} MHz')
ax.set_xlabel('f [MHz]')
ax.set_ylabel('Q []')
ax.legend()
plt.show()
5. Not every eigenvalue above the cutoff is a mode¶
Here is the part that costs people a factor of five.
A PML is an approximation to an open pipe. The physical resonance poles of the open
cavity are fixed by its geometry, so they do not care how long the absorbing block is. The
finite block, however, is itself a resonator, and it contributes eigenpairs of its own.
Those PML-block modes are damped — the layer absorbs them — so they arrive with a
perfectly plausible low \(Q\), a Q balance [] of 1.00, and no other tell.
The one thing that distinguishes them is that they are properties of the layer, not of
the cavity. So change the layer. pml_length sets the block length in metres (the
default is 3× the pipe radius) and pml_alpha its complex stretch.
cav_long = tesla('tesla_long_pml')
cav_long.eigenmode.run(dict(eigen_config, boundary_conditions='oo',
pml_length=0.234)) # default here is 0.117 m
longer = cav_long.eigenmode.qois_df
print(f'default PML : {len(opened):2d} modes')
print(f'2x PML : {len(longer):2d} modes')
default PML : 50 modes
2x PML : 50 modes
cav.eigenmode.stable_modes() keeps the modes the second solve also found at the same
frequency: each must be the other’s nearest match, within a tolerance scaled to its
linewidth. \(Q\) is only a tie-breaker, because the \(Q\) of a genuine mode near the cutoff
can drift with the layer while its frequency stays put. classify_modes() returns the
same verdict with the evidence behind it.
trusted = cav_open.eigenmode.stable_modes(cav_long.eigenmode)
# Judge only where BOTH runs have modes. Each run returns its lowest n_modes, so the
# two need not reach the same ceiling, and a mode above the other run's highest has no
# partner to be matched against -- it would look 'unstable' for that reason alone.
f_top = min(opened['freq [MHz]'].max(), longer['freq [MHz]'].max())
print(f"default PML reaches {opened['freq [MHz]'].max():.0f} MHz, "
f"2x PML reaches {longer['freq [MHz]'].max():.0f} MHz")
print(f'comparing below {f_top:.0f} MHz, where both runs have modes')
judged = ((opened['freq [MHz]'] > f_cutoff) & (opened['R/Q [Ohm]'] > 1e-3)
& (opened['freq [MHz]'] <= f_top))
kept = judged & opened.index.isin(trusted.index)
print()
print(f'beam-coupled modes above cutoff : {judged.sum()}')
print(f' ... that survive a longer PML: {kept.sum()}')
dropped = opened[judged & ~opened.index.isin(trusted.index)]
dropped[['freq [MHz]', 'Q []', 'R/Q [Ohm]', 'Q balance []']]
default PML reaches 4735 MHz, 2x PML reaches 4246 MHz
comparing below 4246 MHz, where both runs have modes
beam-coupled modes above cutoff : 21
... that survive a longer PML: 8
| freq [MHz] | Q [] | R/Q [Ohm] | Q balance [] | |
|---|---|---|---|---|
| 12 | 2950.214180 | 151.396836 | 36.941644 | 1.000044 |
| 13 | 2950.223599 | 150.919190 | 59.271214 | 1.000064 |
| 14 | 3016.583234 | 18.212891 | 27.014756 | 1.000088 |
| 15 | 3016.650833 | 18.169833 | 42.975550 | 1.000091 |
| 16 | 3154.107441 | 7.478490 | 78.352968 | 1.000284 |
| 17 | 3154.569648 | 7.493899 | 29.459910 | 1.000414 |
| 18 | 3372.659884 | 4.429038 | 127.809096 | 1.000591 |
| 19 | 3375.632520 | 4.417115 | 18.362997 | 1.000956 |
| 23 | 3655.885216 | 3.047149 | 148.803719 | 1.001164 |
| 24 | 3657.359710 | 3.022662 | 11.479758 | 1.001945 |
| 34 | 3979.586978 | 2.347666 | 8.306390 | 1.003311 |
| 35 | 3979.697569 | 2.362341 | 139.522032 | 1.001980 |
| 38 | 4173.749074 | 28.356058 | 2.440490 | 1.001534 |
That is the whole problem in one table. The discarded modes
come in near-degenerate pairs, a few parts per million to a tenth of a percent apart: one per pipe. An axisymmetric cavity has no such degeneracy at a fixed azimuthal order, so a pair like that is the two pipes, not one resonance of the cavity;
are mostly broad, with \(Q\) between 2 and 20, so each spans hundreds of MHz and contributes across the whole above-cutoff range, and several carry an \(R/Q\) above \(100\,\Omega\);
and have
Q balance []of 1.00, so the layer check waves every one of them through.
They dominate the reconstructed impedance, and they are artifacts of the truncation.
Note also what does not work as a test: refining the mesh. The mesh does not change the
PML block’s dimensions, so a block mode survives an h refinement happily. It is
pml_length, pml_alpha or the pipe length that has to move. And no test is perfect:
a genuine mode can be dropped and an artefact kept, which is why the impedance below
keeps the unfiltered curve on the plot.
6. What that does to the impedance¶
cav.eigenmode.impedance() sums the modes as parallel RLC resonators, using each mode’s
own Q [].
Asking the closed solve for an impedance is refused outright — its above-cutoff \(Q\) values are not physical, so there is no useful spectrum to build from them:
cav_closed.eigenmode.impedance('longitudinal')
ERROR:: refusing to reconstruct impedance from a CLOSED-boundary eigenmode solve. The pipe ends reflect, so every mode above the beam-pipe cutoff keeps its ohmic Q0 instead of its radiation Q and |Z| comes out ~100-1000x too high. Re-run with boundary_conditions='oo' (an open/PML end -- see the open_boundary_impedance example), use cav.wakefield for the broadband answer, or pass an explicit Q= if you know the loaded Q and want the reconstruction anyway.
To see how far off a closed-boundary reconstruction is, force the issue: Q= states the
quality factors explicitly, which bypasses the check. Handing it the closed solve’s own
Q [] gives the spectrum the closed model would imply.
Q_closed = closed.sort_values('freq [MHz]')['Q []'].to_numpy()
ax = cav_open.eigenmode.plot_impedance('longitudinal', show=False,
label='open ends (PML)')
cav_closed.eigenmode.plot_impedance('longitudinal', ax=ax, show=False, Q=Q_closed,
ls='--', label='closed ends (forced with $Q_0$)')
ax.axvline(f_cutoff, ls=':', color='k',
label=f'TM$_{{01}}$ pipe cutoff {f_cutoff:.0f} MHz')
ax.legend()
plt.show()
ipykernel_32900\2586252951.py:3: UserWarning: This impedance sums all 50 computed modes, with no beam-pipe/PML mode filter. Above the beam-pipe cutoff it includes modes of the pipe and the absorbing layer, which are artefacts of the truncated domain and can dominate |Z|. Filter the set with cav.eigenmode.stable_modes(<a second solve with a different beampipe_length or pml_length>) and pass modes=. The filtering is not perfect: genuine cavity modes may have been discarded (a Q that has not converged with pipe length, or a mode the second solve missed) and some beam-pipe or PML modes may still be included. Treat |Z| above the beam-pipe cutoff as indicative and check it against a wakefield solve.
ax = cav_open.eigenmode.plot_impedance('longitudinal', show=False,
ipykernel_32900\2586252951.py:5: UserWarning: This impedance sums all 50 computed modes, with no beam-pipe/PML mode filter. Above the beam-pipe cutoff it includes modes of the pipe and the absorbing layer, which are artefacts of the truncated domain and can dominate |Z|. Filter the set with cav.eigenmode.stable_modes(<a second solve with a different beampipe_length or pml_length>) and pass modes=. The filtering is not perfect: genuine cavity modes may have been discarded (a Q that has not converged with pipe length, or a mode the second solve missed) and some beam-pipe or PML modes may still be included. Treat |Z| above the beam-pipe cutoff as indicative and check it against a wakefield solve.
cav_closed.eigenmode.plot_impedance('longitudinal', ax=ax, show=False, Q=Q_closed,
Below the cutoff line the two curves lie on top of each other: the PML does not disturb a trapped mode. Above it they separate by orders of magnitude, and the open-boundary curve replaces the spurious needles with the broad humps a propagating mode really produces.
7. Checking against the wakefield¶
A time-domain wakefield run drives the cavity with a bunch through an open pipe, so it includes radiation without being asked to. It is the independent check on everything above — with two caveats that decide what the comparison can actually show.
The bunch sets how far up the comparison means anything. The impedance is the wake spectrum deconvolved by the bunch spectrum, and a Gaussian bunch of length \(\sigma_z\) has little left to deconvolve above roughly \(c/(2\pi\sigma_z)\) — 2.7 GHz at the 25 mm used here. Above that the wakefield curve is increasingly noise-dominated, so read the shapes rather than the values. A shorter bunch moves that limit up (5 mm reaches past 13 GHz) at the cost of a much longer run.
Narrow resonances will not match, and should not. A 50 m wake is a 167 ns window, so the narrowest resonance it can resolve has \(Q \approx f T \sim 10^{2}\)–\(10^{3}\). The fundamental’s real \(Q\) is \(2.9\times10^{4}\), so the wakefield peak at 1300 MHz is truncation-limited and lands orders of magnitude below the eigenmode value. That is a property of the reference, not an error in the modes. Below cutoff, compare \(f\) and \(R/Q\); above it, compare \(|Z|\).
cav_open.wakefield.run({'MROT': 0, 'wakelength': 50, 'bunch_length': 25,
'force': True})
cav_open.wakefield.qois
{'|k_loss| [V/pC]': 0.51,
'k_FM [V/pC]': 0.44402,
'k_loss_HOM [V/pC]': 0.06597999999999998}
f_max = opened['freq [MHz]'].max()
# The PML-stable modes. plot_impedance also draws the reconstruction from every
# mode, dashed, so the effect of the filter stays visible.
ax = cav_open.eigenmode.plot_impedance('longitudinal', show=False, modes=trusted)
cav_open.wakefield.plot_impedance('longitudinal', ax=ax, show=False)
ax.axvline(f_cutoff, ls=':', color='k',
label=f'TM$_{{01}}$ pipe cutoff {f_cutoff:.0f} MHz')
ax.set_xlim(0, f_max) # the eigenmode sum stops at the highest computed mode
ax.set_ylim(1e-3, 1e5)
ax.legend()
plt.show()
ipykernel_32900\2970115695.py:5: UserWarning: This impedance sums 26 of 50 computed modes, after beam-pipe/PML mode filtering. The filtering is not perfect: genuine cavity modes may have been discarded (a Q that has not converged with pipe length, or a mode the second solve missed) and some beam-pipe or PML modes may still be included. Treat |Z| above the beam-pipe cutoff as indicative and check it against a wakefield solve. The reconstruction from every mode is drawn on the same axes (dashed) to show how much the filter changes.
ax = cav_open.eigenmode.plot_impedance('longitudinal', show=False, modes=trusted)
Above the cutoff the filtered curve drops towards the wakefield while the unfiltered one (dashed) stays well above it — the collective contribution of those few broad artifacts. Section 8 puts a number on that excess, on a quantity that can actually carry one. Below the cutoff the filter removes no modes, and the eigenmode peaks tower over the wakefield exactly as the truncation argument predicts. The two curves still part there: the broad artefacts above the cutoff have linewidths of hundreds of MHz, and their tails reach well below their own frequency.
What remains above the cutoff is a limit of the model itself. The impedance is a sum of resonators, each with a positive shunt impedance, so modes whose linewidths overlap add up; that is exact for an isolated resonance and less so as modes broaden. Filtering the mode set, above, is what works today, and it is not perfect either: it can drop a genuine mode whose \(Q\) has not converged, or keep a pipe mode whose frequency happens to repeat. That is why the reconstruction warns, and why the unfiltered curve stays on the plot.
8. The comparison that actually settles it: the loss factor¶
Peak \(|Z|\) is a bad thing to compare. A 50 m wake is a 167 ns window, so the narrowest line the wakefield can resolve has \(Q \sim 10^2\)–\(10^3\) against the fundamental’s \(2.9\times10^4\): its peak is truncation-limited and lands orders of magnitude low. That says nothing about whether the modes are right.
The loss factor does not have that problem. \(k\) is an integral of \(\mathrm{Re}\,Z\) over the bunch spectrum, and truncating a wake broadens a resonance while preserving its area. So \(k\) compares cleanly even when \(|Z|\) cannot.
Each mode contributes a point-charge loss factor
and a bunch of rms length \(\sigma_z\) weights it by the form factor \(\exp[-(\omega_n\sigma_z/c)^2]\). That weighting is the whole difference between a point charge and a real bunch — it is not a limitation of the eigenmode method, and once it is applied the two calculations are directly comparable.
ABCI exports its own cumulative \(k(<f)\), so the two can simply be overlaid.
C0 = 299792458.0
sigma_z = 25e-3 # the bunch the wakefield ran with [m]
m = opened.sort_values('freq [MHz]')
fe = m['freq [MHz]'].to_numpy()
k_point = 2 * np.pi * fe * 1e6 * m['R/Q [Ohm]'].to_numpy() / 4 * 1e-12 # V/pC
k_bunch = k_point * np.exp(-(2 * np.pi * fe * 1e6 * sigma_z / C0) ** 2)
wk = cav_open.wakefield.wake_z[['fk [MHz]', 'k_loss(f) [V/pC]']].dropna()
fw = wk['fk [MHz]'].to_numpy()
kw = wk['k_loss(f) [V/pC]'].to_numpy()
def staircase(f, k, f_end):
"""A mode sum is a step function: flat between modes, jumping at each one."""
xs, ys, run = [0.0], [0.0], 0.0
for fi, ki in zip(f, k):
run += ki
xs += [fi, fi]
ys += [ys[-1], run]
return np.array(xs + [f_end]), np.array(ys + [ys[-1]])
f_end = fe.max()
fig, ax = plt.subplots(figsize=(9, 5))
ax.plot(*staircase(fe, k_point, f_end), lw=1.1, ls=':',
label=r'eigenmode sum, point charge ($\sigma_z \to 0$)')
ax.plot(*staircase(fe, k_bunch, f_end), lw=2.0,
label=r'eigenmode sum, $\sigma_z = 25$ mm')
ax.plot(fw, kw, lw=2.0, label=r'wakefield (ABCI), $\sigma_z = 25$ mm')
ax.axvline(f_cutoff, ls=':', color='k',
label=f'TM$_{{01}}$ pipe cutoff {f_cutoff:.0f} MHz')
ax.set_xlabel('f [MHz]')
ax.set_ylabel(r'cumulative $k(<f)$ [V/pC]')
ax.set_xlim(0, f_end)
ax.legend(fontsize=8, loc='upper left')
plt.show()
below = fe <= f_cutoff
print(f'{'':32}{'eigenmode':>12}{'ABCI':>12}')
print(f'{'k, modes below cutoff':32}{k_bunch[below].sum():12.4f}'
f'{np.interp(f_cutoff, fw, kw):12.4f}')
print(f'{'k, all computed modes':32}{k_bunch.sum():12.4f}{kw[-1]:12.4f}')
print(f'{' (above-cutoff modes add)':32}{k_bunch[~below].sum():12.4f}'
f'{kw[-1] - np.interp(f_cutoff, fw, kw):12.4f}')
print()
print('ABCI time-domain loss factors:', cav_open.wakefield.qois)
eigenmode ABCI
k, modes below cutoff 0.5029 0.5170
k, all computed modes 0.6966 0.5197
(above-cutoff modes add) 0.1937 0.0027
ABCI time-domain loss factors: {'|k_loss| [V/pC]': 0.51, 'k_FM [V/pC]': 0.44402, 'k_loss_HOM [V/pC]': 0.06597999999999998}
Below the cutoff the two curves lie on top of each other — the same steps at the same frequencies, agreeing to about 3% all the way up. That is the eigenmode reconstruction working exactly as advertised, and it is a far stronger statement than the \(|Z|\) overlay could make.
At the cutoff they part company. The wakefield goes essentially flat; the mode sum keeps climbing, and the modes it climbs on are the broad, low-\(Q\), large-\(R/Q\) ones from section 5 — the PML-block artifacts.
The dotted curve is there to head off a natural misreading: the point-charge sum is about fourteen times the 25 mm one. If the eigenmode side really were “stuck at zero bunch length” it would sit far above the wakefield everywhere, not agree with it to 3%. It does not, because the form factor has been applied.
Why \(R/Q\) stops being a property of the geometry¶
\(R/Q = V^2/(\omega U)\) is purely geometric — no material, no wall loss — for a confined mode. Every trapped mode in this run reports the identical \(U\), because the eigenvector is normalised and the whole field is inside the cavity.
A radiating mode is not confined, and \(U\) is only the energy inside the computational domain. Above the cutoff the modes here keep between 16% and 99% of their normalised energy inside the physical region, the rest having leaked into the absorbing layer. So \(U\) — and with it \(R/Q\) and \(k_n = V^2/4U\) — measures where you chose to truncate, not the cavity. The modes with the most energy outside come back with the most inflated \(R/Q\), and those are precisely the ones inflating the loss factor above the cutoff.
That is the concrete form of the general statement: above the pipe cutoff there is no discrete mode to attach a geometric \(R/Q\) to.
What to take away¶
Reconstructing an impedance from a closed-boundary solve is refused: above the beam-pipe cutoff the reflection at the end wall replaces a radiation \(Q\) with the ohmic \(Q\) of the wall. Pass
Q=only if you know the loaded \(Q\) yourself.boundary_conditions='oo'fixes that at the source, at the cost of one extra PML block per pipe end in the mesh.Above the cutoff, solve twice. A single open solve mixes real resonance poles with modes of the finite absorbing block, and the artifacts are the broad, high-\(R/Q\) ones that dominate a reconstructed impedance. Vary
pml_length(orpml_alpha— not the mesh) and keep what does not move, withcav.eigenmode.stable_modes().Q balance []validates the absorbing layer. It does not identify these artifacts, which pass it at 1.00.Below the cutoff the wakefield is the one that cannot resolve a narrow line; compare \(f\) and \(R/Q\) there, not peak \(|Z|\). And keep the bunch short enough that the wake spectrum still carries information at the frequencies being compared.
Compare loss factors, not peak \(|Z|\). \(k\) is an integral over the bunch spectrum and survives the wake truncation that makes a high-\(Q\) peak incomparable. Weighted by the same bunch, the mode sum reproduces the wakefield to ~3% below the cutoff.
\(R/Q\) is geometry-only for a confined mode. Above the cutoff part of the field lives outside the computational domain, so \(U\) — and therefore \(R/Q\) — depends on where the domain ends.
The wakefield solver remains the reference for broadband impedance: an eigenmode reconstruction contains exactly the modes that were solved and nothing else — no broadband or resistive-wall contribution, and nothing above the highest computed mode.
Where to go next¶
An elliptical cavity and its figures of merit — fundamental mode figures of merit and passbands.
Wakefields and impedance — wake potential details and bunch length parameters.