Introduction¶
cavsim2d is a Python toolkit for designing and analysing RF cavities: the resonators that accelerate particle beams. It is written for accelerator physicists and engineers, and for students learning cavity design.
It handles axisymmetric structures, those unchanged by a rotation about the beam axis, such as elliptical superconducting cavities, pillboxes, RF guns and beam-line parts such as bellows and tapers. An axisymmetric structure is fully described by its outline in a plane through the axis, so cavsim2d solves on that 2D cross-section rather than in 3D. That is why it runs on an ordinary computer: an eigenmode solve of a cell takes seconds.
What it does¶
Eigenmodes: the resonant frequencies and fields of a cavity, and the figures of merit computed from them, such as R/Q, the geometry factor G and the peak surface fields, for the accelerating modes and for the dipole and higher-order modes. The solver is built on the finite-element library NGSolve [Schoberl24].
Tuning: change a dimension until a mode sits at a target frequency, and tune the end cells of a multicell cavity for a flat field.
Wakefields: the wake a passing bunch leaves, its loss and kick factors, and the impedance spectrum, computed with the ABCI code [Chi24].
Frequency domain: the impedance, admittance and scattering matrices of a structure with ports, and the beam coupling impedance.
Multipacting: where electrons at the wall can multiply into an avalanche.
Optimisation: a search for the shapes with the best trade-offs between objectives, such as the peak surface field against R/Q.
Uncertainty quantification: how far the results spread under manufacturing tolerances, for any of the analyses above.
Every analysis works on every shape, including shapes you describe yourself, and cavities can be gathered into studies to compare designs.
What it does not do¶
cavsim2d models only axisymmetric structures. Couplers, ports in the side of a cavity and other parts that break the rotational symmetry need a 3D code. The fields are solved with perfectly conducting walls, and the wall losses are then computed from those fields, which is accurate for the good conductors cavities are made of.
How this documentation is organised¶
Getting started: Installation and the Quickstart.
Tutorials: twelve lessons that teach cavsim2d from the beginning, each building on the last.
User guide: a page for each analysis, describing it in full and ending with how-to guides for specific tasks.
Background and validation: why cavsim2d works the way it does, and how its results compare with exact answers and other codes.
Reference: every setting (Configuration reference), every class and method (API Reference), and the Glossary.