## 2 Code Description
### Space Charge Solvers  
Due to several reasons, the space charge forces during DYNAMION beam dynamics simulations are usually taken into account by calculation of the particle-particle interaction. With this, the most details of the non-uniform particle distribution are accounted for, despite high CPU time. However, with the ever-increasing capacities of modern computers and the development of parallel computing, this problem becomes less and less important. Moreover, as numerous comparisons of calculations with experimental data have shown, it is quite sufficient to use an ensemble of \(10^{3}\)-\(10^{4}\) particles to solve a wide range of typical problems for linacs [14; 17; 28; 29; 30]. In this case, the main and necessary condition for obtaining a reliable result is an adequate solving of the continuous equation of particle motion by discrete numerical methods, i.e., a sufficiently small timestep of integration, as well as the calculation of the Coulomb interaction between particles at each step. The internal electrical and magnetic self fields are calculated as:  
\[ \begin{array}{l}\stackrel{{\rightarrow}}{{E}}_{j}=\sum\limits_{ i=1}^{N}\frac{q_{i}}{\left(\stackrel{{\rightarrow}}{{r}}_{0}^{2}-R^{2} \right)^{\frac{3}{2}}}\cdot\stackrel{{\rightarrow}}{{r}}_{ij}\\ \stackrel{{\rightarrow}}{{H}}_{j}=\sum\limits_{i=1}^{N}\frac{q_{i}} {\left(\stackrel{{\rightarrow}}{{r}}_{0}^{2}-R^{2}\right)^{\frac{3} {2}}}\cdot\stackrel{{\rightarrow}}{{R}}\\ \stackrel{{\rightarrow}}{{r}}_{ij}=\left(x_{j}-x_{i},y_{j}-y_{i},z_{ j}-z_{i}\right)\\ \stackrel{{\rightarrow}}{{v}}_{j}=\left(y_{x},v_{y},v_{z}\right)\\ \stackrel{{\rightarrow}}{{R}}=\left[\stackrel{{ \rightarrow}}{{r}}_{ij}\times\frac{\stackrel{{\rightarrow}}{{v}}_{ j}}{c}\right]\end{array}  \tag{4}\]  
where \(q_{i}\)--charge of the particle, \(v_{j}\)--velocity and \(r_{ij}\)--distance between two particles. Up to medium beam energies (relative velocity \(\beta\) < 0.5), the time of calculation can be remarkably decreased, neglecting the magnetic component. In order to prevent artificial collisions of particles after discrete steps of integration, a special routine is introduced [14]. Nevertheless, due to the relatively small size of the integration steps, the probability of such collisions is significantly low. Usually, more than 200 steps per characteristic length, corresponding to the phase length of \(360^{\circ}\), are performed. Mostly the simulations are carried out with one bunch, whose phase length (referred to the operating frequency) does not exceed \(\pm 180^{\circ}\). To prevent an artificial longitudinal widening of continuous beam or relatively long bunch under space charge influence, two additional virtual neighboring bunches are created. The distance from their centers to the reference particle is \(\pm 360^{\circ}\) correspondingly. These virtual bunches are always identical to the original bunch; virtual bunches only serve to calculate space charge effects adequately. Initially and all the time, the development of the DYNAMION software was exclusively targeted to the most detailed and reliable modeling of the dynamics of the ensemble (even at the expense of CPU time) but not for fast approximate calculations. Obviously, the calculation of the space charge effects takes up most of the entire process. Therefore, as a part of further code optimization, a fast solver of the Poisson equation is recently under development, as well as the adjustment of the code for parallel computing. Additionally, a fast and precise Semi-Analytical space charge Solver (SAS) [31] was created for the DYNAMION software package. A continuous space charge density function, required for the semi-analytical solution, is reconstructed from the discrete particle coordinates by a polynomial interpolation using Chebyshev nodes for higher accuracy. Starting from a particle number above \(5\times 10^{3}\), SAS calculates space charge effects faster than the particle-particle method. In particular, SAS is about 24 times faster for \(10^{4}\) particles.