Wakefield under uncertainty¶
A uq_config in a wakefield run spreads the impedance. The figure of merit here is the
peak longitudinal impedance \(|Z_\parallel|\) in chosen frequency windows: a ZL
objective, ['min', 'ZL', [f0, f1, ...]], whose windows are the consecutive pairs of
frequencies in the list, in GHz. With a uq_config, each window’s peak comes back as a
mean and a standard deviation over the perturbed shapes.
Needs ABCI, downloaded from KEK (see the installation page), on Windows or with
wineelsewhere. See the wakefield guide and the wakefield tutorial.
import os
import tempfile
from cavsim2d import Study, EllipticalCavity
from cavsim2d.utils.style import apply_style
apply_style()
1. The cavity and the tolerances¶
A TESLA mid cell with beam pipes, in a study. Its equator half-axes A and B vary by
up to 0.05 mm either side of their nominal values, and the run asks for the peak ZL in
two windows: 0.2 to 2.0 GHz and 2.0 to 5.0 GHz.
cavs = Study(os.path.join(tempfile.mkdtemp(), 'wake_uq'))
midcell = [42, 42, 12, 19, 35, 57.7, 103.353]
cavs.add_cavity([EllipticalCavity(1, midcell, midcell, midcell, beampipe='both')], ['W'])
config = {
'MROT': 2, 'wakelength': 20, 'bunch_length': 25, 'processes': 1,
'uq_config': {
'variables': ['A', 'B'],
'objectives': [['min', 'ZL', [0.2, 2.0, 5.0]]],
'method': ['stroud3'], 'delta': [0.05, 0.05], 'processes': 1,
'cell_type': 'mid-cell', 'cell_complexity': 'simplecell',
},
}
2. Run it¶
Every quadrature node is a full ABCI wakefield solve, so this is the slowest of the UQ examples — a handful of perturbed geometries, each a complete time-domain run.
cavs.run_wakefield(config);
3. The impedance spread¶
cav.wakefield.uq_df is a table of the run’s statistics, one row per frequency window: the mean of the peak \(|Z_\parallel|\) over the perturbed geometries, and its standard deviation std, the spread the tolerance band induces on the HOM impedance. The values are in kΩ, the unit ABCI gives impedances in.
cavs['W'].wakefield.uq_df[['mean', 'std']].round(2)
| mean | std | |
|---|---|---|
| objective | ||
| ZL [max(0.2<f<2.0)] | 6.28 | 0.01 |
| ZL [max(2.0<f<5.0)] | 3.59 | 0.03 |
4. Plot the mean with its uncertainty band¶
plot_hom_scatter(uq=True) draws the UQ result directly: one panel per frequency window,
each cavity’s mean peak impedance as a point with its tolerance-induced ±1σ error bar,
and the mean and standard deviation written in the panel’s bottom-right corner. The
operating-point argument is omitted because these objectives are impedance windows rather
than per-operating-point quantities.
cavs.wakefield.plot_hom_scatter(uq=True);
See also: multicell wakefield under uncertainty, and the uncertainty quantification guide.