Configuration reference¶
Every analysis is driven by one dictionary. This page lists all of them and all of their keys. See Concepts for the conventions they share:
Complete + saved. Missing keys fall back to the analysis’ defaults, and the merged dict (defaults + your overrides) is written to
config.jsonbeside the results, so a saved run records every setting it used.Keys double as kwargs.
cav.eigenmode.run(mesh_config={'h': 10})is the same as passing it in the dict; an explicit kwarg wins.Truthy, not present. Features switch on for a truthy value (an empty
uq_config={}does not trigger UQ).
Discovering the options¶
You do not have to memorise these — every default is available at runtime, from the object you are about to run:
cav.<solver>.config_samplereturns the complete default config of that solver, every key with its default, as a fresh copy to edit and pass straight back:cfg = cav.tune.config_sample, change what you need, thencav.tune.run(cfg).cfg_sample,sample_configandsample_cfgare the same thing, and calling it,cav.tune.config_sample(), works too. The study namespaces have it as well:study.eigenmode.config_sample,study.wakefield.config_sample,study.optimisation.config_sample.cav.config_sample(kind), orcav.cfg_sample(kind), prints the default for kind —'eigenmode','wakefield','tune','multipacting','fds','uq'or'optimisation'— and returns it.study.config_sample(kind)does the same and needs no cavity in the study.cav.<solver>.configis different: it is the saved config of a run that has already happened.
The samples are the solvers’ own defaults — the exact dicts run() merges over —
so they never drift from what a run uses. 'uq' and 'optimisation' have no
defaults to merge over; their samples are complete, valid templates whose
variables, bounds and objectives you replace with your own.
A sample displays with a note beside each key: what it does, its unit, and what
None stands for. The display is valid Python, so you can paste it into a script
and edit it there:
>>> cav.tune.config_sample
{
'freqs': None, # target [MHz]; None -> c/(4L) of the half cell, with a warning
'cell_type': None, # None -> {'mid-cell': 'Req'}, plus 'end-cell': 'L' for multicell
'tol': 0.0001, # stop once the frequency is this close to the target [MHz]
...
}
Units¶
Not every length is in the same unit. Geometry and mesh sizes are in millimetres, while lengths along the beam line that a solver adds (beam pipes, the wake, the PML) are in metres. The one geometry in metres is the RF gun’s (see RF gun (RFGun)):
Setting |
Unit |
Where |
|---|---|---|
Geometry parameters ( |
mm |
cavity definitions, optimisation, UQ |
RF-gun lengths and radii ( |
m |
RF gun |
RF-gun angles ( |
rad |
RF gun |
|
mm |
eigenmode, multipacting, frequency domain ( |
|
mm |
frequency domain |
|
mm |
wakefield |
|
m |
eigenmode, wakefield, frequency domain |
|
m |
wakefield |
|
m |
eigenmode |
|
m |
multipacting |
|
MHz |
tuning |
|
MHz |
frequency domain |
|
V/m |
multipacting |
|
s |
multipacting |
|
eV |
multipacting |
|
S/m |
eigenmode |
|
Ohm |
eigenmode |
Results carry their unit in the key name instead: 'freq [MHz]',
'R/Q [Ohm]', 'Epk/Eacc []'.
Accepted spellings¶
A few keys have a second spelling. A run renames it to the key in this reference before it merges the defaults in, so either works:
tune:
freqisfreqsandtoleranceistol; the legacyparameters+cell_typespair becomescell_typeeigenmode:
nmodesisn_modesoptimisation:
no_of_generationsisno_of_generationfrequency domain:
freqsisfrequenciesevery
run():overwriteisforce
Giving both spellings with different values raises an error. Any other key a run does not recognise gives a warning that suggests the closest valid key.
Cross-cutting keys¶
These appear in several configs:
processes(int, default 1) Worker processes for parallel evaluation (UQ nodes, optimisation candidates, multi-cavity studies).
rerun(bool, default True) Re-run even if cached results exist;
Falsereuses the results that match the cavity’s geometry and recomputes the rest.force(bool, default False) Answer yes to the question a run asks before it overwrites existing results or deletes results computed for a different geometry (see Keeping results consistent).
overwriteis the same key.uq_config(dict, default None) Nest this inside an eigenmode / wakefield / tune config to turn a single run into an uncertainty sweep — see Uncertainty quantification — nested uq_config.
Eigenmode — cav.eigenmode.run / study.run_eigenmode¶
polarisation(str | int | list, default
'monopole') The azimuthal order(s) to solve: a name ('monopole','dipole','quadrupole', …), the integerm, or a list. Everym >= 1is written toeigenmode/<pol name>/.mesh_config(dict, default
{'h': 20, 'p': 3, 'adaptive': None})hmaximum element size in mm;ppolynomial order (>= 2);adaptiveopt-in error-driven h-refinement. Passadaptive: Truefor the defaults, or a dict to tune it:{'tol': 1e-12, 'max_refinements': 8, 'max_ndof': 100000, 'theta': 0.25}— refine the elements whose recovery error exceedsthetaof each mode’s largest, until every requested mode’s error is belowtolor a DOF/refinement cap is hit.theta: 0refines every element: uniform, nested refinement. Adaptivity is a mode of the eigenmode solve, not a separate object: the refined mesh is the eigenmode result, socav.show_fields,cav.show_meshandcav.multipactingall use it directly, andcav.eigenmode.plot_convergence()plots the error/frequency-vs-DOF history the refinement records.n_modes/nmodes(int, default None) Number of eigenmodes to solve.
None→n_cells + 2.mode_of_interest(int | list | dict, default None) 1-based index of the mode(s) whose QOIs are reported.
None→ the accelerating pi-mode (monopole) / the lowest deflecting mode (m >= 1).boundary_conditions(str, default
'mm') One letter per beam-pipe end, left then right:'m'magnetic wall,'e'electric wall,'o'open (PML),'p'waveguide port ('pp'only, monopole only).'open'and'port'are aliases for'oo'and'pp'.n_port_modes(int, default 3) TM0n pipe modes kept per port with
boundary_conditions='port'.beampipe_length(float, default None) Length [m] of each beam pipe.
Noneuses the model’s own default: twice the mid-cell lengthL_mfor elliptical cavities.pml_length(float, default None) Length [m] of the absorbing layer that
'o'adds to a pipe end.None→ three pipe radii.pml_alpha(complex, default 1j) Complex stretch of that absorbing layer.
conductivity(float, default 5.96e7) Wall conductivity [S/m] for the loss-based Q / G.
surface_resistance(float, default None) Fixed surface resistance [Ohm] override (e.g. for SRF), used instead of
conductivity.beta(float, default 1) Particle velocity v/c. It sets the phase of the voltage integral, so it changes the accelerating voltage, R/Q, Eacc and the peak-field ratios (and the transverse kick for m ≥ 1), not the field or the frequency. Set it for a β < 1 structure, e.g.
0.6for a medium-β proton cavity.materials(dict, default None) Overrides the properties of dielectric regions declared with
cav.add_dielectric, e.g.{'quartz': {'eps_r': 3.8, 'tan_delta': 1e-4}}. Overrides merge, so{'quartz': {'tan_delta': 0.05}}sweeps the loss and leaveseps_ralone. Naming a region the cavity does not have raises.loss_model(str, default None) How a complex permittivity reaches Q:
'lossless'(real eigenproblem, dielectric loss added perturbatively),'lossy'(full complex eigenproblem), orNone/'auto'— inspect the loss tangents and switch to'lossy'abovetan_delta = 1e-2. Forcing'lossless'above that threshold is honoured, with a warning. Q is tagged'Q model'in the QOIs.arnoldi_vectors(int, default 6) Krylov vectors per shift in the lossy eigensolve.
f_shift(float, default 0) Spectral shift for the eigensolver.
pinvit_tol(float, default 1e-8) The eigensolver stops once the relative residual of every checked mode is below this. At 1e-8 frequencies are converged to about 1e-13 and the fields, and every figure of merit computed from them, to about 3e-7: below the discretisation error of any practical mesh. A looser value is faster; see Solver settings: time against accuracy for what each value buys. Round-off sets a floor under the residual, and on meshes with very small elements near the axis that floor can lie above 1e-8. The eigensolver then stops once the residual stops falling. It warns only if the floor is above 1e-5.
pinvit_converge_modes(int, default None) How many of the lowest modes must meet
pinvit_tol.Nonechecks alln_modes. Modes above the checked ones are still reported, but are not converged: check fewer modes only when you will not use the rest.pinvit_padding(int, default None) Extra vectors the eigensolver iterates on beyond
n_modes. They are never reported, but they make the highest requested modes converge in far fewer iterations.Noneuses twicen_modes, at least 2 and at most 30.pinvit_maxit(int, default 1000) Iteration cap. A solve that reaches it while the residual is still falling warns.
preconditioner(str, default
'direct') The eigensolver’s preconditioner:'direct', an exact factorisation, or'bddc', an approximate one that is cheaper per iteration but needs more iterations to reach the same tolerance.direct_solver(str, default
'sparsecholesky') The sparse direct solver used for every factorisation in the eigensolve. Any backend your NGSolve build provides:'sparsecholesky'is always available;'pardiso'and'umfpack'depend on how NGSolve was built.normalization_length(float, default None) Active length for the accelerating-voltage normalisation; elliptical cavities take it from
L_mautomatically.
Wakefield — cav.wakefield.run / study.run_wakefield¶
MROT(int, default 2)
0longitudinal,1transverse,2both.wakelength(float, default 50) Wake length [m].
bunch_length(float, default 25) RMS bunch length [mm].
beampipe_length(float, default None) Beam-pipe length [m];
None→ 3× the axial length.save_fields(bool | dict, default None)
True(or{'nshot': N}) saves electric field-line snapshots for the field animation.operating_points(dict, default None) Machine operating points (currents, bunch populations, bunch lengths) to fold into loss/kick-factor and HOM-power tables.
solver(str, default
'abci') The wakefield backend.MT(int, default 10) ABCI time steps per mesh cell. Values above 19, ABCI’s limit, are clamped to 19.
DDR_SIG,DDZ_SIG(float, default 0.1) Radial / axial mesh step as a fraction of the bunch length, capped at 1.25 mm, so a short bunch is always resolved. An explicit
mesh_config={'DDR': ..., 'DDZ': ...}(metres) overrides them.
Note
Adaptive refinement does not apply to wakefield. mesh_config['adaptive']
drives the NGSolve eigenmode backend (and, through it, multipacting, which reads
the eigenmode field). Wakefield uses the ABCI backend, which builds and meshes its
own deck from cav.profile() and is controlled by MT/DDR_SIG/
DDZ_SIG above — it has no NGSolve mesh to refine, so the eigenmode adaptive /
h / p keys are ignored there. This is a backend boundary, not a limitation of a
particular geometry.
Frequency domain — cav.fds.run¶
See Frequency-Domain Analysis for the stages (run, reduce, concatenate) and
their outputs.
frequencies(list, required)
[f_min, f_max, n]in MHz, or a list of frequencies [MHz].freqsis accepted too.polarisation(str | int | list, default
'monopole') The azimuthal order(s), as for the eigenmode solver. The monopole gives the longitudinal impedance, the dipole the transverse one.n_port_modes(int | dict, default 3) Pipe modes carried at each port, per family:
3carries three TM and three TE modes;{'TM': n, 'TE': n}sets them separately. Every mode that propagates below the highest frequency must be carried; the solver warns when one is not.beam(None | True | dict, default None) Adds the beam, for the generalised matrices and the beam coupling impedance:
True, or{'beta': 1, 'reference': 'auto', 'test_radius': None}withtest_radiusin mm.mesh_config(dict, default
{'h': 20, 'p': 3}) Largest element sizeh[mm] and polynomial orderp, as for the eigenmode solver.beampipe_length(float, default None) Pipe length [m] at each open end.
Noneuses the model’s own default.materials(dict, default None) Overrides the properties of regions declared with
cav.add_dielectric(), as for the eigenmode solver. A loss tangent makes the matrices complex.strategy(str, default
'glued') For anAssembly:'glued'meshes the whole line as one model;'coupled'solves each element on its own, to be reduced and joined through its port modes.store_snapshots(bool, default False) Keeps every solution of the sweep, so that
reduce()uses them instead of solving at its own frequencies.reduce(dict, default None)
{'tol': 1e-8, 'n_snapshots': 12}reduces (and, forstrategy='coupled', joins) right after the sweep.direct_solver(str, default
'sparsecholesky') The sparse direct solver used at every frequency, as for the eigenmode solver.progress(bool, default True) Progress bar over the frequencies.
Tuning — cav.tune.run / study.run_tune¶
freqs(float | list, default None) Target frequency [MHz] (a list gives a per-cavity target).
Nonetunes an elliptical cavity to the pi-mode estimate \(c/4L\) of its half-cell length, with a warning; other models need it.cell_type(dict, default None)
{cell block: handle}, e.g.{'mid-cell': 'Req'}. Schedule several blocks ({'mid-cell': 'Req', 'end-cell': 'L'}) to tune them in turn — see Tuning.Nonetunes the mid-cellReq, plus the end-cellLon a multi-cell elliptical cavity.eigenmode_config(dict) The eigenmode settings used for the solve at each tuning step.
solve_tuned(bool, default False) After tuning, also run the eigenmode analysis on the tuned cavity (
cav.tuned) witheigenmode_config.tol(float, default 1e-4) Frequency tolerance [MHz]: the secant stops once the frequency is this close to the target.
maxiter(int, default 10) Maximum secant iterations.
Multipacting — cav.multipacting¶
Emission sites are set with cav.multipacting.set_emission_points(xrange, ...)
(or xrange / n_points in the config); the rest are run() keys:
mode(int, default 0) Which computed mode to track (0 = the first).
polarisation/n_modes(default None) Solve multipacting’s own field for this polarisation / this many modes (
None→ reuse the monopole eigenmode field).epks(array, default None) Peak-field levels [V/m] to sweep (
None→ 0–80 MV/m, 192 steps).phis(array, default None) RF launch phases (
None→ 72 phases over[0, 2*pi]).v_init(float, default 2) Secondary-emission energy [eV].
t_max(float, default 1e-7) Tracking duration [s].
loss_model(str, default
'field') How escaped particles are handled.pec_maxh(float, default None) If set [mm], multipacting builds its own finer field on a mesh this size (with
mesh_config) instead of reusing the eigenmode one.n_points(int, default None) Extra emission sites interpolated along the wall in-band.
proc_count(int, default None) Worker count (
None→ auto).progress(bool, default True) Live progress bar over the field-level sweep.
Uncertainty quantification — nested uq_config¶
Nest inside an eigenmode / wakefield / tune config to sweep the uncertain geometry.
variables(list of str) Geometry variables to perturb, in that model’s own names (
['Req', 'Ri']for elliptical,['p2_r']for spline, …).delta(list of float) The spread of each variable, added to it in the variable’s own unit (mm; m for an RF gun), not a fraction:
delta=0.3is a spread of 0.3 mm. With a quadrature rule or['lhs', N]it is the half-width of a uniform spread,x - deltatox + delta(standard deviationdelta / sqrt(3)); with['normal', N]it is the standard deviation. A spread far below the solver’s numerical resolution leaves the result unchanged.perturbation_mode(str, default
'add')'add'→x + d(in the variable’s unit);'mul'→x * (1 + d)(da fraction).['add', d]or['mul', d]gives the spread here instead of indelta.method(list) How the perturbed shapes are chosen:
['Quadrature', 'Stroud3'](default) or'Stroud5', Monte Carlo with a normal spread['normal', N], or Latin hypercube['lhs', N]. The method sets the distribution; there is no separatedistributionkey (a config that sets one is told it is not read).cell_complexity(str, default
'simplecell')'simplecell'perturbs the mid/end-cell groups;'multicell'makes every half-cell an independent random variable (honouring continuity). Available for eigenmode and wakefield.independent_half_cells(bool, default False) Multicell only: perturb every half-cell independently then weld (average) the shared seams — the WEPB015 before/after-continuity workflow.
cell(default
'all') Simplecell eigenmode and wakefield UQ:'all'varies each variable in every cell type separately ('A'->A_m,A_el,A_er); any other value takes the variables exactly as named (['A_m']).cell_type(str, default
'mid-cell') Robust tuning: the cell type whose variables vary.objectives(list) The QOIs to gather:
'pol:qoi'for eigenmode ('monopole:R/Q [Ohm]'), or['min', 'ZL', [lo, hi]]/['min', 'ZT', ...]for wakefield impedance (the interval is a flat[lo, hi, …]GHz list defining consecutive windows).tune_config(dict, default None) Re-tune each perturbed variant to a target frequency before measuring, so only the shape varies at fixed frequency (the paper workflow).
Optimisation — study.run_optimisation¶
bounds(dict)
{variable: [lo, hi]}in that model’s own variable names (mm). A fixed variable takes equal bounds.objectives(list of lists)
[direction, metric, ...]— direction'min'/'max'/'equal'; metric a polarisation-qualified QOI ('monopole:Epk/Eacc []') or a wakefield'ZL'/'ZT'with a frequency-interval third element.tune_config(dict) Applied to every candidate so each is on-frequency before its objectives are read.
initial_points(int) Initial candidates before the GA evolves.
no_of_generation(int, default 100) Number of GA generations (
no_of_generationsalso works).method(dict, default LHS) Initial-point sampler, e.g.
{'LHS': {'seed': 5}}.crossover_factor/mutation_factor/chaos_factor(int) How many offspring come from crossover, mutation and random injection each generation.
elites_for_crossover(int) Top candidates retained in the parent pool.
weights(list) Per-objective weights.
seed(int) Makes the run reproducible.