4. Tune a cell to a target frequency¶
A cell’s dimensions set its frequency. In a design you fix most of them for other reasons, such as the peak fields or the iris size, and adjust one until the cell resonates where you need it. The tuner does that adjustment for you.
In this tutorial you will:
Build a cell that resonates at the wrong frequency.
Tune its equator radius until it resonates at 1300 MHz.
Read the tuned dimensions and follow the tuner’s steps.
Solve the tuned cell and compare it with the original.
Before you start: work through An elliptical cavity. Running the whole notebook takes about a minute.
1. A cell at the wrong frequency¶
Take the TESLA cell from Tutorial 2, but with an equator radius of 108 mm instead of 103.35 mm.
import pandas as pd
from cavsim2d import EllipticalCavity, WARM
cell = EllipticalCavity(1, [42, 42, 12, 19, 35, 57.7, 108.0], beampipe='none',
name='detuned_cell')
cell.eigenmode.run()
print(f"{cell.eigenmode.qois['freq [MHz]']:.3f} MHz")
1236.928 MHz
It resonates at 1236.9 MHz, 63 MHz below the target: a larger cell resonates lower.
2. Tune it¶
cell.tune.run() takes the target frequency, freqs in MHz, and cell_type, which
says which dimension the tuner may change in which cells. A single cell is a
'mid-cell', and the equator radius Req is the natural dimension to tune: it
moves the frequency strongly and leaves the iris, which sets the peak fields,
alone.
cell.tune.run({'freqs': 1300, 'cell_type': {'mid-cell': 'Req'}});
3. The result¶
cell.tune.qois holds what the tuner found, for each cell type it tuned. Tuned
dimensions carry the suffix of their cell type: Req_m is the equator radius of
the mid cells.
result = cell.tune.qois['mid-cell']
print(f"Req = {result['parameters']['Req_m']:.3f} mm, "
f"frequency = {result['FREQ']:.3f} MHz")
Req = 103.367 mm, frequency = 1300.000 MHz
The tuner settled on Req = 103.367 mm, which brings the cell to 1300.000 MHz,
within 0.02 mm of the TESLA cell’s 103.353 mm.
At each step the tuner changes Req, solves the cell again, and uses the change in
frequency to choose the next value. plot_convergence() shows those steps.
cell.tune.plot_convergence();
The first trial, 113.4 mm, goes the wrong way and drops the frequency to about
1170 MHz; that is how the tuner learns how the frequency responds to Req. Over the
next steps it closes in, and it ends on the dashed target line at step 5.
4. The tuned cell¶
The tuner never changes your cavity. It creates a new one, cell.tuned, with its
own results folder, ./detuned_cell/tuned/. Solve it like any other cavity, and
compare the figures of merit before and after.
tuned = cell.tuned
tuned.eigenmode.run()
foms = ['freq [MHz]', 'R/Q [Ohm]', 'G [Ohm]', 'Epk/Eacc []', 'Bpk/Eacc [mT/MV/m]']
pd.DataFrame({'original': {k: cell.eigenmode.qois[k] for k in foms},
'tuned': {k: tuned.eigenmode.qois[k] for k in foms}}).round(3)
| original | tuned | |
|---|---|---|
| freq [MHz] | 1236.928 | 1300.000 |
| R/Q [Ohm] | 113.001 | 113.469 |
| G [Ohm] | 260.973 | 271.034 |
| Epk/Eacc [] | 1.987 | 1.992 |
| Bpk/Eacc [mT/MV/m] | 4.091 | 4.171 |
Tuning moved the frequency by 63 MHz. R/Q and the two peak-field ratios changed by
less than 2 %, and G by about 4 %. The equator radius sets the frequency without
disturbing the rest of the design much, which is why it is the usual dimension to
tune.
Draw both outlines on one set of axes. show=False holds each plot back so the
next can draw on the same axes; the figure appears when the cell finishes.
tuned=True draws the tuned cavity, and WARM is cavsim2d’s colour palette.
ax = cell.plot('geometry', show=False, label='original', color=WARM[0])
cell.plot('geometry', ax=ax, tuned=True, show=False, label='tuned', color=WARM[1])
ax.legend();
What you learned¶
cav.tune.run()adjusts one dimension until the cavity resonates atfreqs;cell_typesays which dimension, in which cells.cav.tune.qoisholds the tuned dimensions, andcav.tune.plot_convergence()the tuner’s steps.The tuned design is a new cavity,
cav.tuned, with its own folder; the original is never changed.
Next¶
Tune a multicell cavity: tune the inner cells and the end cells of a 9-cell cavity, and flatten its field.