Eigenmode analysis¶
The eigenmode solver finds the resonant modes of a cavity: their frequencies, their fields, and the figures of merit computed from those fields, such as R/Q, the geometry factor G and the peak surface fields. One solver covers every azimuthal order: the monopole modes (\(m=0\)), which accelerate, the dipole modes (\(m=1\)), which deflect, and higher orders. It is built on NGSolve; Theory and Numerical Formulation derives the formulation.
Your first cavity: a pillbox and An elliptical cavity and its figures of merit teach the basics, and Is the mesh fine enough? shows how to check that a result has converged. This page is the full reference.
Running it¶
Solve one cavity:
cav.eigenmode.run()
or every cavity in a study at once:
study.run_eigenmode()
Without settings, the solver finds the monopole modes on a mesh of 20 mm elements of
order 3, and solves n_cells + 2 modes, enough for the accelerating mode of a
multicell cavity. Settings go in a dictionary, or as keywords; see Settings below.
Reading the results¶
cav.eigenmode.qois holds the figures of merit of the mode of interest: by default
the accelerating mode, which for a multicell cavity is the \(\pi\)-mode.
q = cav.eigenmode.qois
print(q['freq [MHz]'], q['R/Q [Ohm]'])
Key |
Unit |
Description |
|---|---|---|
|
MHz |
Frequency of the mode. |
|
J |
Stored energy. |
|
MV |
Accelerating voltage along the axis. |
|
MV/m |
Accelerating gradient: the voltage over the active length. |
|
\(\Omega\) |
Shunt impedance over quality factor: how strongly the mode couples to the beam (longitudinal for the monopole, transverse for higher orders). |
|
W |
Power lost in the walls. |
|
— |
Quality factor. |
|
\(\Omega\) |
Geometry factor, \(G = Q R_s\), independent of the wall material. |
|
— |
Peak electric field on the wall over the accelerating gradient. |
|
mT/(MV/m) |
Peak magnetic field on the wall over the accelerating gradient. |
A multicell cavity also reports kcc [%], the coupling between cells, and
ff [%], the field flatness: the lowest peak of the on-axis field in any cell over
the highest. The Glossary defines every term.
Each key carries its unit, but you do not have to type it. The name without its unit
is enough, in any letter case, so q['R/Q'], q['freq'] and q['ff'] read the
same values as q['R/Q [Ohm]'], q['freq [MHz]'] and q['ff [%]']. A few short
forms work too:
'f'or'frequency'for the frequency;'epk'and'bpk'for the peak fields over the gradient,Epk/EaccandBpk/Eacc('Epk'on its own is the peak field itself,Epk [MV/m]).
If you do give a unit, it must be the stored one: q['freq [GHz]'] raises an error
rather than returning the frequency in MHz. A name that matches nothing raises a
KeyError that lists the closest names.
cav.eigenmode.qois_df holds every solved mode of every polarisation, one row per
mode, as a pandas.DataFrame. Beside the figures of merit it has these columns:
Column |
Meaning |
|---|---|
|
Azimuthal order (0 monopole, 1 dipole, 2 quadrupole, …) |
|
Its name |
|
The mode’s place within its polarisation, counting from 0 in order of frequency |
|
|
df = cav.eigenmode.qois_df
# the dipole modes that couple most strongly to the beam
df[df.polarisation == 'dipole'].nlargest(5, 'R/Q [Ohm]')
# the monopole modes that accelerate; the others (TE modes) have R/Q = 0
mono = df[df.m == 0]
mono[mono['R/Q [Ohm]'] > 1e-6]
cav.eigenmode.qoi() reads one value from any solved polarisation and mode. Name
the polarisation, and the mode if you want one other than the mode of interest,
counting from 1, the same way an objective names them (see Objective names):
cav.eigenmode.qoi('R/Q') # the monopole mode of interest
cav.eigenmode.qoi('dipole:R/Q_t') # the dipole mode of interest
cav.eigenmode.qoi('dipole:2:freq') # the second dipole mode
For a study, study.summary() returns one row per cavity with every number of its
mode of interest, the figures of merit first: frequency, R/Q, field flatness, G,
G R/Q, the peak fields over the gradient, the cell coupling, Q and the shunt
impedance. Pass the columns you want, by full or short name:
study.summary(['freq', 'R/Q', 'ff', 'Epk/Eacc', 'Bpk/Eacc'])
Looking at the modes¶
cav.show_mesh() # the mesh, in an interactive view
cav.show_fields() # the electric field of the mode of interest
cav.show_fields(mode=0, which='H') # the magnetic field of the lowest mode
cav.plot_axis_field() # the accelerating field along the axis
cav.plot_dispersion() # a multicell cavity's passbands
show_fields shows the mode of interest unless you give mode, which counts from
0 in order of frequency, unlike mode_of_interest; see Mode numbering. The
show_* methods open an interactive view in a notebook; the plot_* methods draw
a matplotlib figure.
Settings¶
Pass the settings as a dictionary, or as keywords, which take precedence:
cav.eigenmode.run(mesh_config={'h': 10}). Settings you leave out keep their
defaults, and the run saves the complete set it used in eigenmode/config.json.
eigenmode_config = {
'polarisation': 'monopole',
'n_modes': 10,
'mesh_config': {'h': 15, 'p': 3},
'conductivity': 5.96e7,
'mode_of_interest': 9,
}
cav.eigenmode.run(eigenmode_config)
The main settings follow; Eigenmode — cav.eigenmode.run / study.run_eigenmode lists them all.
polarisation(int, str or list, default
'monopole') The azimuthal order(s) to solve:0or'monopole',1or'dipole',2or'quadrupole', and so on. A list solves several in one run.mesh_config(dict) The mesh.
h(float, default 20): the largest element size, in mm.p(int, default 3): the polynomial order of the elements. Raisingpusually improves a result faster than shrinkingh.adaptive(bool or dict, default None): refine the mesh where the error is largest, repeatedly.Trueuses the default settings; a dictionary setstol(the target error),max_refinementsandmax_ndof(the largest number of unknowns).
n_modes(int, default
n_cells + 2) How many modes to solve, per polarisation.mode_of_interest(int, list or dict) The mode(s) whose figures of merit
qoisreports, counting from 1. For the monopole it defaults to the accelerating mode, moden_cells. See Mode numbering.conductivity(float, default
5.96e7S/m) The conductivity of the walls, which setsPlossandQ.surface_resistance(float, default None, in Ohm) A surface resistance to use instead of the one the conductivity gives, for example the BCS resistance of a superconducting wall.
beta(float, default 1) The particle’s speed over the speed of light, used in the accelerating voltage \(V = \left|\int E_z\, e^{i\omega z/(\beta c)}\, dz\right|\). It changes the voltage, R/Q,
Eaccand the peak-field ratios, not the field or the frequency. Set it for a cavity built for slower particles, for example0.6for a medium-β proton cavity.boundary_conditions(str, default
'mm') What closes each beam-pipe end; see Open ends and external Q.materials,loss_model,arnoldi_vectorsSettings for cavities with dielectric regions; see Dielectric regions.
Open ends and external Q¶
boundary_conditions is a two-letter code, one letter for each beam-pipe end, left
then right:
Code |
End |
Meaning |
|---|---|---|
|
magnetic wall |
Closed. The default, and the right model for a mode trapped in the cavity. |
|
electric wall |
Closed, with the opposite symmetry. |
|
open |
The pipe ends in an absorbing layer (a perfectly matched layer, PML), so a wave travelling out along the pipe leaves and does not return. |
|
waveguide port |
The pipe ends in a port that carries its own waveguide modes away
( |
'mm' closes both ends and 'oo' opens both. 'open' is short for 'oo',
and 'port' for 'pp'.
Why open ends¶
A closed end reflects. For a mode below the beam pipe’s cutoff frequency that costs nothing: its field has died away before it reaches the end. A mode above the cutoff travels out along the pipe in a real cavity, but a closed end reflects it back, so the solver reports the high \(Q\) of the walls alone, which can be ten orders of magnitude too large.
With open ends, the solver reports how fast each mode loses energy, as a \(Q\):
Q_eig []: from how fast the mode decays, the most direct measure, and the one to trust;Q_rad []: from the power flowing out through the pipe ends;Q_diel []: from the power lost in dielectric regions, if there are any;Q balance []: \((1/Q_\mathrm{diel} + 1/Q_\mathrm{rad})\,Q_\mathrm{eig}\), which is 1 when the measured losses account for the decay. A value far from 1 for a radiating mode means the absorbing layer is too short or too coarse.
The total Q [] combines the decay with the wall loss,
\(1/Q = 1/Q_\mathrm{wall} + 1/Q_\mathrm{eig}\). A port run reports the loss through
the ports as Q_ext [] instead.
cav = EllipticalCavity(1, [42, 42, 12, 19, 35, 57.7, 103.353], beampipe='both')
cav.eigenmode.run({'boundary_conditions': 'oo', 'n_modes': 10})
cav.eigenmode.qois_df[['freq [MHz]', 'Q []', 'Q_wall []', 'Q_eig []']]
An open end needs a beam pipe to absorb into (beampipe='both', or the matching
one-sided setting), and cannot yet be combined with dielectric regions. The absorbing
layer is three pipe radii long by default; pml_length (metres) and pml_alpha
change it. An open solve also finds modes of the absorbing layer itself;
cav.eigenmode.stable_modes(other) keeps only the modes that stay put when the pipe
or the layer is lengthened in a second solve.
The impedance needs an open end¶
cav.eigenmode.impedance() builds the beam’s impedance spectrum from the modes, and
refuses to do so from a fully closed solve: above the cutoff, a closed solve’s Q values
are wrong by orders of magnitude. Solve with at least one open end or with ports, use
Wakefield analysis for the broadband answer, or pass Q= to give the loaded
\(Q\) yourself.
Dielectric regions¶
A cavity is vacuum inside unless you fill part of it with a dielectric, such as a
ceramic window, a beam-pipe liner or an absorber ring, with
add_dielectric():
cav = Pillbox(1, [20, 37.5, 2.5, 0, 5], beampipe='both')
# a 0.5 mm-thick quartz tube lining the 5 mm opening, along the whole cavity
cav.add_dielectric('quartz', 3.8, z=(-1e4, 1e4), r=(2.0, 2.5), maxh=0.15)
cav.eigenmode.run(mesh_config={'h': 3, 'p': 3})
The region is a ring: a rectangle in (z, r), in millimetres, cut to the cavity,
so a generous span such as z=(-1e4, 1e4) means “the full length”. maxh sets
the element size inside the region. A thin layer needs it: a 0.5 mm tube in a cavity
meshed at the default h = 20 would otherwise be crossed by a single element.
Each region adds one figure of merit, Epk_<material> [MV/m], the peak field
inside the dielectric, which matters for breakdown. The field jumps at the surface of
a dielectric, so the peak inside is not the peak on the metal wall.
The materials setting overrides a region’s properties for one run:
{'quartz': {'eps_r': 3.8, 'tan_delta': 1e-4}}, or {'quartz': 3.8} for the
permittivity alone. Overrides add to what the region declared, so
{'quartz': {'tan_delta': 0.05}} changes only the loss. Naming a region the cavity
does not have raises an error.
Dielectric loss¶
A region can be lossy. Give its loss tangent, \(\tan\delta\):
cav.add_dielectric('alumina', 9.8, tan_delta=1e-4,
z=(-1e4, 1e4), r=(2.0, 2.5), maxh=0.15)
There are two ways to compute the \(Q\) that results. loss_model chooses, and
by default the solver picks by the loss tangent.
Perturbation, the default up to \(\tan\delta = 10^{-2}\) ('lossless'). The
cavity is solved as if it were lossless, and the loss is integrated over the
resulting field:
This costs nothing beyond the lossless solve and is accurate for low-loss materials such as sapphire, alumina and quartz. The frequency and the field it reports are the lossless ones.
The full lossy solve, the default above \(\tan\delta = 10^{-2}\) ('lossy').
The frequency is solved for as a complex number, \(\omega = \omega_r + i\alpha\),
and \(Q_\text{diel} = \omega_r / 2\alpha\), so the \(Q\), the frequency and
the field all include the loss. A lossy ferrite or an absorber with
\(\tan\delta\) of 0.1 to 1 needs it, and it costs about twice a lossless solve.
If a lossy run warns that a mode did not converge, raise arnoldi_vectors
(default 6).
A run with a lossy material reports:
Key |
Description |
|---|---|
|
|
|
the total \(Q\), from the wall, dielectric and radiation losses together |
|
the wall loss alone |
|
the dielectric loss alone |
|
the power lost in the dielectric |
|
the largest loss tangent in the run |
G [Ohm] stays the wall’s, \(Q_\text{wall} R_s\), so it does not depend on the
filling. The loss tangent can be varied in uncertainty quantification like any
dimension, as 'alumina:tan_delta'.
Limits¶
Magnetic materials (\(\mu_r \neq 1\)) are not supported, and raise an error.
A conductive loss is not modelled, because it depends on the frequency being solved for; give the loss tangent at the frequency of interest instead.
Only the eigenmode solver takes dielectrics into account. The wakefield and multipacting analyses raise an error on a cavity with dielectric regions, rather than treat it as vacuum.
Dielectric regions need a built-in shape, or one of your own written as in Writing a new cavity model; a cavity loaded from a
.geofile cannot carry them.
How-to guides¶
How the solver’s results compare with exact answers and with other codes is in Validation.