Spline cavities

A SplineCavity has a free-form wall: a Bézier curve through six control points, for shapes the elliptical cell cannot describe. This guide builds one and runs each analysis on it. The steps are the ones the tutorials teach for elliptical cells; only the geometry and the names of its dimensions change. Wakefield runs need ABCI (see Installation).

Build the cavity

The wall runs through control points p0 to p5, each a [z, r] pair in millimetres. Placing p1 and p4 at the beam-pipe radius, the same r as p0 and p5, makes the wall leave the pipe smoothly instead of at a sharp corner. The beam pipes go in the same dictionary as the geometry.

import numpy as np

from cavsim2d import SplineCavity, Study

geometry = {'p0': [0, 35], 'p1': [30, 35], 'p2': [42, 103],
            'p3': [78, 103], 'p4': [90, 35], 'p5': [120, 35]}
spline = SplineCavity({'geometry': geometry, 'beampipe': 'both', 'beampipe_length': 40},
                      name='spline')
spline.plot('geometry');
../../_images/37093b7c8a2a21a2c501f746219fd95a960623f5baaee0b604814bd8af5a10e4.png

The dashed polygon joins the control points. The curve starts at p0 and ends at p5, and the points between pull it towards themselves without lying on it. Each coordinate is a dimension of its own, named p<i>_z or p<i>_r, which you can tune, vary and optimise:

sorted(spline.tune_variables())
['p0_r',
 'p0_z',
 'p1_r',
 'p1_z',
 'p2_r',
 'p2_z',
 'p3_r',
 'p3_z',
 'p4_r',
 'p4_z',
 'p5_r',
 'p5_z']

Eigenmodes

spline.eigenmode.run({'mesh_config': {'h': 6, 'p': 3}})
q = spline.eigenmode.qois
for key in ['freq [MHz]', 'R/Q [Ohm]', 'G [Ohm]', 'Epk/Eacc []', 'Bpk/Eacc [mT/MV/m]']:
    print(f'{key:20s} {q[key]:8.3f}')
freq [MHz]           1823.009
R/Q [Ohm]              63.279
G [Ohm]               327.063
Epk/Eacc []             2.879
Bpk/Eacc [mT/MV/m]     12.522

The smooth cell resonates at 1823.009 MHz, with an R/Q of 63.279 Ohm and a geometry factor of 327.063 Ohm. Its peak surface fields are 2.879 times the accelerating gradient for the electric field, and 12.522 mT per MV/m for the magnetic field.

Wakefield

spline.wakefield.run({'MROT': 2, 'wakelength': 20, 'bunch_length': 25})
for key, value in spline.wakefield.qois.items():
    print(f'{key:20s} {value:.4g}')
spline.wakefield.plot_impedance('longitudinal');
|k_loss| [V/pC]      0.07621
k_FM [V/pC]          0.06782
k_loss_HOM [V/pC]    0.008385
|k_kick| [V/pC/m]    3.314
../../_images/b27be6f247d64b65e91997b345f1333e38868e6435363894453e88c9892642b1.png

A 25 mm bunch loses 0.07621 V/pC to the cavity: 0.06782 V/pC into the fundamental mode and 0.008385 V/pC into the higher-order modes. The kick factor, 3.314 V/pC/m, is the sideways kick per unit charge and per metre of offset. The impedance peaks at the fundamental mode, near 1823 MHz, and a smaller peak near 3000 MHz is the next monopole mode.

Multipacting

Launch the electrons from the equator region of the wall, between \(z\) = 40 and 80 mm (given in metres), with n_points adding launch sites between the mesh’s own wall points.

mp = spline.multipacting
mp.set_mesh_parameters(h=6, p=2, pec_maxh=1)
mp.set_emission_points([0.04, 0.08], n_points=40)
mp.show_emission_points();
../../_images/e25ebc3e5fc9dec6e5eb84fcee1da996867d9f7e00387d0eacb051b470fdafc5.png
mp.run({'epks': np.linspace(1e6, 50e6, 20), 'phis': np.linspace(0, 2 * np.pi, 36)})
mp.plot_counter();
mp.plot_enhanced_counter();
../../_images/d1122ba8c1e60dc63ee5e97527ce4e2d03937078e7f32ea9f6f7a3817f12140c.png ../../_images/fbc625dcccbd838d952df0967b215796a23dfb166941758e7c0a17df90c0bc42.png

No electron survives 20 impacts at peak fields up to 19 MV/m, or from 47 MV/m up. From 22 to 40 MV/m the counter function is about 0.2: a fifth of the launched electrons lock into a resonant path near the equator. The enhanced counter peaks at 0.0144, at 32 MV/m, far below 1, so those electrons do not multiply, and the cell does not multipact with this wall material.

Tune it

Tune by a control-point coordinate. Moving p2_r, the height of the first equator control point, changes the frequency strongly.

spline.tune.run({'freqs': 1800, 'cell_type': {'mid-cell': 'p2_r'},
                 'eigenmode_config': {'mesh_config': {'h': 6, 'p': 3}}});
result = spline.tune.qois['mid-cell']
print(f"p2_r: 103.000 -> {spline.tuned.get_tune_value('p2_r'):.3f} mm, "
      f"at {result['FREQ']:.3f} MHz")
p2_r: 103.000 -> 109.135 mm, at 1800.000 MHz

The tuner raised p2_r from 103 to 109.135 mm, which brings the cell to 1800.000 MHz: lifting the control point widens the cell near its equator, and a wider cell resonates lower.

Optimise its shape

An optimisation names its variables in the spline’s own terms. Here the equator control points move, p2_r keeps every candidate at 1800 MHz, and the search trades the peak electric field against R/Q.

study = Study('spline_optimisation')
study.add_cavity(SplineCavity({'geometry': geometry, 'beampipe': 'both',
                               'beampipe_length': 40}), names='spline')
study.run_optimisation({
    'bounds': {'p2_z': [36, 48], 'p3_z': [72, 84], 'p3_r': [95, 110]},
    'objectives': [['min', 'monopole:Epk/Eacc []'], ['max', 'monopole:R/Q [Ohm]']],
    'tune_config': {'freqs': 1800, 'cell_type': {'mid-cell': 'p2_r'}},
    'initial_points': 8, 'no_of_generation': 1,
    'mutation_factor': 3, 'crossover_factor': 3, 'chaos_factor': 2,
    'elites_for_crossover': 2, 'method': {'LHS': {'seed': 3}}, 'seed': 3,
})
opt = study.optimisation
opt.pareto[['p2_z', 'p3_z', 'p3_r'] + opt.objective_vars].round(3)
  0%|          | 0/1 [00:00<?, ?it/s]
100%|██████████| 1/1 [00:20<00:00, 20.95s/it]
100%|██████████| 1/1 [00:20<00:00, 20.95s/it]

p2_z p3_z p3_r monopole:Epk/Eacc [] monopole:R/Q [Ohm]
0 44.25 75.75 105.312 2.832 67.215
1 47.25 72.75 99.688 2.859 67.343

Two designs make up the front. The first has the lower peak field, 2.832 times the gradient, and the second the higher R/Q, 67.343 Ohm; neither is better in both, which is what keeps both on the front. Both are tuned to 1800 MHz. A real search would use more candidates and generations, as in the optimisation tutorial.

See also