Optimising the end cells of a multicell cavity¶
In a multicell cavity the inner cells set the accelerating frequency and the field pattern, while the end cells, next to the beam pipes, are free to take another shape. This guide shapes the end cells of a 3-cell cavity for a high R/Q and a low peak electric field, with every candidate held at the accelerating frequency.
Three settings make that work:
'mid-cell'gives the dimensions of the inner cell, held fixed through the search.Bounds with the
_esuffix vary both end cells together:A_esets theAof the left and the right end cell to one value, so the cavity stays symmetric.The tune varies
L_e, the half-length of both end cells, to bring every candidate back to the frequency before it is scored.
To give a figure of merit an exact value instead, such as an R/Q of 330 Ohm, tune for
it with qoi_targets; see tuning to a figure of merit.
import os
import tempfile
from cavsim2d import Study, EllipticalCavity
F = 1300.0 # accelerating frequency [MHz]
NCELLS = 3 # one inner cell, two end cells
MID0 = [42, 42, 12, 19, 35, 57.7, 103.3] # A, B, a, b, Ri, L, Req [mm]
1. Tune the inner cell¶
Bring one inner cell to 1300 MHz by its equator radius Req. Its tuned dimensions are
the fixed core of the cavity, and the end cells start as copies of it.
mid_study = Study(os.path.join(tempfile.mkdtemp(), 'inner_cell'))
mid_study.add_cavity(EllipticalCavity(1, MID0, beampipe='none'), names='inner')
mid_study.run_tune({'freqs': F, 'cell_type': {'mid-cell': 'Req'}, 'tol': 3e-3});
p = mid_study['inner'].tuned.parameters
MID = [p[k] for k in ('A_m', 'B_m', 'a_m', 'b_m', 'Ri_m', 'L_m', 'Req_m')]
print(f'inner cell: Req {MID0[6]} -> {MID[6]:.3f} mm')
inner cell: Req 103.3 -> 103.367 mm
2. Search the end-cell shape¶
The bounds vary the ellipses of both end cells together. They keep every candidate a
valid cell: A_e + a_e stays below the half-length, and B_e + b_e below the room
between the iris and the equator. The two objectives pull against each other.
study = Study(os.path.join(tempfile.mkdtemp(), 'end_cells'))
study.add_cavity(EllipticalCavity(NCELLS, MID, MID, MID, beampipe='both'), names='cavity')
study.run_optimisation({
'mid-cell': MID, # the inner cell, held fixed
'bounds': {'A_e': [40, 44], 'B_e': [40, 46], 'a_e': [10, 13], 'b_e': [17, 21]},
'objectives': [['max', 'monopole:R/Q [Ohm]'], ['min', 'monopole:Epk/Eacc []']],
'tune_config': {'freqs': F, 'cell_type': {'end-cell': 'L_e'}},
'initial_points': 6, 'no_of_generation': 2, 'method': {'LHS': {'seed': 5}},
'mutation_factor': 3, 'crossover_factor': 3, 'elites_for_crossover': 2,
'chaos_factor': 2,
})
opt = study.optimisation
print(f'{len(opt.history)} candidates, {len(opt.pareto)} on the Pareto front')
0%| | 0/2 [00:00<?, ?it/s]
50%|█████ | 1/2 [01:11<01:11, 71.55s/it]
100%|██████████| 2/2 [02:12<00:00, 65.23s/it]
100%|██████████| 2/2 [02:12<00:00, 66.17s/it]
14 candidates, 8 on the Pareto front
3. The trade-off¶
Every candidate was tuned back to 1300 MHz by L_e before it was scored:
print('candidate frequencies [MHz]:', sorted(opt.history['freq [MHz]'].round(3).unique()))
opt.plot_pareto(normalise=False);
candidate frequencies [MHz]: [1300.0]
All 14 candidates are at 1300.0 MHz. Eight make up the front, and along it the two
objectives pull against each other: R/Q rises from 338.970 to 342.990 Ohm as the peak
electric field rises from 1.986 to 1.997 times the gradient. The range is narrow, 1.2 %
in R/Q and 0.6 % in the peak field, because only the end cells change. The table lists
the front by R/Q, with the end-cell half-length L_e each design needed to stay on
frequency.
cols = ['A_e', 'B_e', 'a_e', 'b_e', 'L_e'] + opt.objective_vars
opt.pareto[cols].sort_values('monopole:R/Q [Ohm]').round(3)
| A_e | B_e | a_e | b_e | L_e | monopole:R/Q [Ohm] | monopole:Epk/Eacc [] | |
|---|---|---|---|---|---|---|---|
| 0 | 42.333 | 43.500 | 10.750 | 19.333 | 59.723 | 338.970 | 1.986 |
| 2 | 41.000 | 41.500 | 12.250 | 20.000 | 59.693 | 339.534 | 1.989 |
| 6 | 41.205 | 44.682 | 13.000 | 18.572 | 58.975 | 340.947 | 1.990 |
| 3 | 41.000 | 44.500 | 12.750 | 18.667 | 58.537 | 341.197 | 1.991 |
| 4 | 40.951 | 44.510 | 12.693 | 18.708 | 58.402 | 341.283 | 1.991 |
| 5 | 40.720 | 44.634 | 12.670 | 18.739 | 57.944 | 341.647 | 1.992 |
| 1 | 40.333 | 45.500 | 11.250 | 20.667 | 55.495 | 342.978 | 1.993 |
| 7 | 40.255 | 45.209 | 11.096 | 21.000 | 55.364 | 342.990 | 1.997 |
See also¶
Why whole-cavity tuning needs field flatness: why tuning each end cell to the frequency also keeps the field flat.
The optimisation guide, and the optimisation tutorial.