Linaccalc: software for accelerating structure characteristics simulation based on equivalent circuit method

Nowadays design of accelerating structures is almost exclusively done using 2.5D and 3D codes based on finite elements method. Equivalent circuit method is frequently considered limited and inconvenient to use in real-life projects. However, low resource requirements make this method attractive for wide range sweep calculations.This paper describes LinacCalc application — a user friendly accelerating structure simulation software based on the equivalent circuit method. It allows calculating characteristics of the accelerating sections with large number of cells in short time on machines with moderate amount of computational power. Core application modules are validated by comparing calculation results with ones obtained by a conventional finite element method based programs.


Equivalent Circuit Method
Equivalent circuit method (ECM) is widely used in electrotechnics and radiotechnics for symplification of characteristics analysis of complicated schemes. The main idea behind ECM in accelerator technique is to represent a distributed field in an accelerating structure ( fig. 1) by a lumped element circuit.
Isolated cavity oscillations on a particular mode may by represented by a simple RLC circuit (serial or parallel). More complex structures are modeled by introduction of additional coupling elements. Adding coupling capacitors and inductors allows simulating structures with electric, magnetic or combined inter-cell coupling. Additional voltage sources and resistors help modeling generators and loads attached to the cell by waveguides. equivalent circuit for large phase velocity β accelerating sections. This circuit may be used to simulate an accelerating mode and a limited number of higher order modes in an accelerating section with arbitrary inter-cell connections. This paper describes LinacCalc -a web-based application for accelerating structure simulation using ECM. Program is split into functional modules; main application modules are described below. Base equations as well as comparison with finite element method (FEM) calculation results are presented.

Accelerating Field Distribution
Writing down the Kirchhoff's equations for each accelerating section cell and substituting lumped element parameters with electrodynamic ones yields the equation (1) [Kalyuzhny et al., 1994]. (1) A system of these equations is then transformed into the matrix form hold the properties of the cell itself. Elements off the diagonal represent a coupling between cells. In case of adjacent cell coupling the matrix is tridiagonal and may be solved analytically. However, a numerical solution of the system lifts many analytical solution limitations, allowing simulation of accelerating sections with arbitrary parameters and coupling.
Figures 3 and 4 show FEM and ECM simulation results for 4-cell standing wave (SW) and 6-cell traveling wave (TW) accelerating sections respectively. Normalized accelerating field difference for these methods has typical value of 2−4 %.

Section Reflection
Accelerating section reflection could by found from eq. (2) [Kaluzhny, 2011]. In case of a perfectly matched lossless section cell field ratioẊ n /Ẋ may be substituted with known cell phase advance exp (jθ). In practice section is never perfectly matched and in order to obtain cell field ratios full section simulation described in section 2 is required.
LinacCalc program calculates field distributions in frequency range by solving systems of equations shown in eq. (1) and then applies eq. (2) in order to obtain the section reflection. Figures 5 and 6 show FEM and ECM simulation results for 4-cell SW and 6-cell TW accelerating sections respectively. Normalized accelerating field difference for these methods has typical value of 0,1 MHz for resonance frequency and 2 % for reflection coefficient.

Waveguide Connection
In order to simulate accelerating section cascades one may use Thévenin-Helmholtz representation of the waveguide. In fig. 7 waveguide equivalent circuit is inserted into the end cells of two sections. Directed graph method allows calculating reflected waves required for the simulation. For the special case of passive section connection, which is usually the case in particle accelerators, equivalent circuit may be simplified. Accelerating section connection may be represented by a single resistor element with impedance obtained by eq. (2). LinacCalc implements this simplified section connection for most of the modules [Matsievskiy and Kaminskiy, 2017]. Figures 8  to 11 show FEM and ECM simulation results for two cascaded 3-cell TW accelerating sections connected by a waveguides of different lengths.
(3) Figures 12 and 13 show FEM and ECM simulation results for disk loaded waveguide (DLW) and disk loaded waveguide with magnetic coupling DLW-M based accelerating sections respectively.
For the small enough coupling between cells calculation result difference appear to be insignificant. However, with increasing coupling between cells (e.g. in deflector cells [Anisimov et al., 2010]) simulation error increases. This error may be observed in fig. 14 between "FEM" and "ECM uncorrected" curves. The reason for this accuracy deterioration is an increased non-adjacent cell coupling. Adding more coupling coefficients to the equivalent circuit allows increasing of calculation accuracy (curve marked "ECM corrected" in fig. 14).

Transitional Processes
LinacCalc allows calculation of the transitional processes in accelerating structures by a numerical solution of the time domain ordinary differential equation (ODE) system [Matsievskiy et al., 2018].
Each system equation has a form (6). After lowering ODE order and rearranging terms equation system transforms to eq. (7), which may be solved numerically. For the numerical solution LinacCalc utilizes fast and robust deSolve library [Soetaert et al., 2010].  LinacCalc is implemented in GNU R programming language using Shiny web application framework. Governing equations are specified in textual form close to mathematical notation later processed into GNU R code. This allows simpler equation specification and easier program debugging (user may dump governing matrix in both textual and numerical forms).
Another feature of the program is a metaprogramming simplification algorithm. Main idea behind it is a substitution of constant equation parameters with its values followed by evaluation of independent expressions. Because same parameters may be constant or variable in different calculations, e.g. parameter sweep over different parameter sets, this substitution is only possible in runtime.
Metaprogramming simplification is achieved by descending an equation abstract syntax tree (AST) followed by an ascending evaluation of independent expressions and their substitution by a calculation results. This feature is particular useful for reflection calculations in frequency range, significantly reducing number of costly floating point calculations.

Conclusion
Described in this paper ECM based program LinacCalc allows calculation of various accelerat-ing section characteristics. Calculation results for both SW and TW sections were compared to FEM solutions and match with tolerance close to the accelerating cell fabrication tolerance. User-friendly interface and ability to simulate accelerating sections with arbitrary parameters make it an attractive tool for accelerating structure design [Matsievskiy, 2021]. Calculation of the accelerating section variational characteristics, simulation of the transient processes and calculation of the long accelerating sections may be done using the presented program much faster then if using conventional FEM based programs. Further development plans include adding electron tracking module using Beamdulac-BL code [Kluchevskaia and Polozov, 2020].