Multicell wakefield under uncertainty¶
Wakefield under uncertainty varies a cavity’s dimensions
cell type by cell type: every inner cell takes the same draw. A real multicell cavity is
welded from parts formed one by one, so each cell differs. With
uq_config['cell_complexity'] = 'multicell', every half-cell varies on its own, while
the halves that meet at an equator or an iris keep one shared dimension, as in the
eigenmode multicell example.
import os
import tempfile
from cavsim2d import Study, EllipticalCavity
from cavsim2d.utils.style import apply_style
apply_style()
1. A two-cell cavity and its uncertainty¶
A two-cell TESLA-like cavity. We put a manufacturing tolerance on the equator radius
Req. delta is an additive perturbation in millimetres (not a fraction), so
delta=[0.3] is a realistic ±0.3 mm equator tolerance — a perturbation much smaller
than this leaves the impedance unchanged to the solver’s numerical resolution.
Under cell_complexity='multicell' the shared entries collapse to one random variable
each — Req is shared by a cell’s two halves, so a two-cell cavity has two
independent Req random variables (one per cell). UQ runs through Study, not a bare
Cavity.
cavs = Study(os.path.join(tempfile.mkdtemp(), 'mc_wake_uq'))
mid = [42, 42, 12, 19, 35, 57.7, 103.353]
cavs.add_cavity([EllipticalCavity(2, mid, mid, mid, beampipe='both')], ['W'])
config = {
'MROT': 2, 'wakelength': 5, 'bunch_length': 25, 'processes': 1,
'uq_config': {
'variables': ['Req'],
'delta': [0.3], # +/- 0.3 mm equator tolerance (additive, mm)
'objectives': [['min', 'ZL', [0.2, 2.0, 5.0]],
['min', 'ZT', [0.2, 2.0, 5.0]]],
'method': ['Quadrature', 'Stroud3'],
'cell_complexity': 'multicell',
'processes': 1,
},
}
2. Run it¶
Every quadrature node is a full ABCI wakefield solve on a perturbed multicell geometry,
so this is the slowest of the UQ examples. MROT=2 asks for both the longitudinal
(ZL) and transverse (ZT) impedance; the objectives read the peak |Z| in each
frequency window (in GHz — a flat [lo, mid, hi] list defines the windows
lo<f<mid and mid<f<hi).
cavs.run_wakefield(config);
3. The impedance spread¶
cav.wakefield.uq_df is a table of the run’s statistics, one row per window: the mean of the peak impedance across the perturbed multicell geometries, and its standard deviation std, the spread the per-cell equator tolerance induces. The values are in kΩ for ZL and kΩ/m for ZT, the units ABCI gives impedances in.
cavs['W'].wakefield.uq_df[['mean', 'std']].round(3)
| mean | std | |
|---|---|---|
| objective | ||
| ZL [max(0.2<f<2.0)] | 3.082 | 0.004 |
| ZL [max(2.0<f<5.0)] | 1.769 | 0.006 |
| ZT [max(0.2<f<2.0)] | 23.140 | 0.172 |
| ZT [max(2.0<f<5.0)] | 18.239 | 0.155 |
4. Mean with its uncertainty band¶
plot_hom_scatter(uq=True) draws all four windows — longitudinal and transverse — each
mean as a point with its tolerance-induced ±1σ error bar, and the mean and standard
deviation in the panel’s bottom-right corner.
cavs.wakefield.plot_hom_scatter(uq=True);
The std column is the headline: a per-cell equator-radius tolerance of a few tenths
of a millimetre already moves the higher-order-mode impedance by a measurable amount.
See also: the simplecell wakefield UQ (mid/end-cell groups) and the eigenmode multicell UQ/SA (the same independent-half-cell parameterisation, with a Sobol sensitivity analysis).