{'fraction_non_alphanumeric': 0.03047218505065953, 'fraction_numerical': 0.009634869049894858, 'mean_word_length': 4.511167298777918, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Periodic Poisson Solver for Particle Tracking

A method is described to solve the Poisson problem for a three dimensional source distribution that is periodic into one direction. Perpendicular to the direction of periodicity a free space (or open) boundary is realized. In beam physics, this approach allows to calculate the space charge field of a continualized charged particle distribution with periodic pattern. The method is based on a particle mesh approach with equidistant grid and fast convolution with a Green's function. The periodic approach uses only one period of the source distribution, but a periodic extension of the Green's function. The approach is numerically efficient and allows the investigation of periodic- and pseudo-periodic structures with period lengths that are small compared to the source dimensions, for instance of laser modulated beams or of the evolution of micro bunch structures. Applications for laser modulated beams are given.


I. INTRODUCTION
The fundamental problem of the analysis of beam dynamics is to solve the equation of motion for a multi particle system (N ∼ 10 3 · · · 10 9 ) in presence of external forces (caused by magnets, cavities etc.) and self forces. A particular difficulty is to determine the self-fields of the dynamic many-particle system. The coarsest approximation to solve this problem is the space charge or Poisson approach. It assumes that all particles are in uniform motion with identical velocity vector. Therefore the problem is equivalent to an electrostatic problem, and in principle one has to add for each observer particle the one over distance contribution from all other sources. This point-to-point interaction would allow the slightly better approach of individual uniform motion per particle, but its effort scales as N 2 . This is avoidable by a continualization so that the point particles are represented by a smooth density function.
Additionally the continualization solves a second problem that is usually not in the focus of interest: the near scattering of particles that approach much closer than the averaged particle distance. A proper tracking with near scattering needs not only the point-to-point interaction but also a very fine time step related to the minimal distance between particles.
Continuous density functions and fields are numerically represented either by superpositions of basis functions (finite element methods) or by mesh methods. In this report we use a three dimensional equidistant mesh for binning and compute the static potential by a fast convolution with a Green's function as described in [1,2]. This Green's function fulfills free space (or open) boundary conditions. Also the electric field is calculated on the mesh, by numeric differentiation. The field is interpolated to the particle positions and transformed into a collective force as it appears in the equation of motion. The numeric integration of the equation of motion is not described here.
The Poisson-particle-mesh approach is used widely and successfully in beam dynamics for instance in straight sections with constant energy, but also in particle sources or accelerating sections and even in sections with weak curvature. Sometimes the particle distribution has a fine sub-structure which has to be taken into account, for instance the particles perform plasma oscillations [3][4][5], a micro modulation builds up (micro-bunch-instability) or they interact in an undulator with a laser. Such high resolution computations need very fine meshes and high particle (or macro-particle) numbers so that they become numerically very expensive.
This numerical effort can be dramatically reduced when the approach assumes and utilizes periodicity: only the particles of one period have to be tracked and meshed. We describe such an approach where the periodicity of the source distribution is interchanged with the periodicity of the Green's function. Except for the calculation of the Green's function, the established method (Poisson-particle-mesh with equidistant mesh and fast convolution) can be used completely unchanged. We consider periodicity into one direction. The direction is arbitrary and needs not to coincide with a mesh axis. Perpendicular to this direction free space (or open) boundary conditions are realized.
The report is organized as follows. Section II is about general aspects of periodicity.
In section III we describe the approach, first the standard method (Poisson, particle-mesh, convolution with Green's function), then its modification with periodic Green's function.
In section IV we demonstrate the method with examples: the FLASH seeding section [6][7][8] with different particle densities and modulations, and parasitic heating after the LCLS laser heater [9,10]. For comparison of field calculation methods, we did tracking simulations with Astra [11] and the non-periodic and periodic implementation of the method described in this report, called QField.

II. PERIODICITY
Some aspects of spatial periodicity and pseudo-periodicity are illustrated in Fig. 1. The particles in panel (a) are randomly distributed while panel (b) shows a periodically repeated set S p of random particles. Distribution (a) is caused by applying a periodic transport map to random particles that are uniformly distributed into the direction of periodicity. Strictly periodic distributions as in (b) are used to approximate pseudo-periodic distributions as in (a).
For the strictly periodic approach we consider only a set S p of non-repeated particles.
As it can be seen in panels (b-e) there are many sets S p that describe the same periodic distribution. It is easy to manipulate such sets by shifting particles by a multiple of the repetition vector r p . The sets in (c) and (d) are chosen so that all particles are in a volume slice, where the front plane corresponds to the back plane shifted by r p . These slices might have any orientation (or shift), but there are orientations so that the volume of a box (or sphere) that includes all particles is minimal. The distribution in (b) are particles from one volume slice, that have been mapped by a periodic transport map. (Particles with nearly the same spatial coordinates, but with different momenta may be mapped to very different spatial coordinates.) For numerical reasons it might be advantageous to use sets without sudden change of density, as it can be seen in panel (e). This set has been composed similar as (c), but some particles close to the left boundary are shifted by r p (beyond the right boundary) and some particles close to the right boundary are shifted into the opposite direction. The probability of shifting depends on the distance to the boundary.
To keep periodicity, the set S p has to represent a distribution that is periodic in six dimensional phase space X = [x, y, z, p x , p y , p z ]. Periodically shifted particles are at X + nP , with P the vector of six dimensional periodicity. The required property for the transport . This is for instance fulfilled if only one spatial component of P is non-zero and T is a linear function of that component.
Real distributions are always pseudo-periodic since they are finite. Sometimes only a small part of a (long) bunch behaves periodically, as for instance in Figs. 6, 7. The phase space volume covered by the beam is usually small and the transport can be linearized, or at least locally (for one ore few periods) linearized. Therefore the Poisson approach can be used for distributions with finite extension in momenta space, although the uniform motion approach assumes identical momentum of all particles. In the same sense the periodical Poisson approach is applicable to distributions with non-zero momentum components of P , although this would mean particles with arbitrarily large momentum. An example is a bunch with energy chirp and micro modulation.
The Coulomb force drops with 1/r and the effect of a dipole perturbation drops with 1/r 2 . Therefore space charge effects are very localized and non-resonant. Pseudo-periodic behavior can be observed even for distributions with only few periods, as it can be seen in the first example of section IV.

A. Poisson Approach and Lorentz Force
The electro-magnetic field caused by a set S of discrete point particles with charge q i , position r i (t) and velocity v i (t) is estimated based on the assumption of collective uniform motion (of all particles) with the velocity v c . The particle positions are represented by orthonormal coordinates r i = x i e ⊥1 + y i e ⊥2 + z i e c , wherein the z-axis points in the direction of motion e c = v c / e c and the directions e ⊥1 and e ⊥2 are perpendicular. After Lorentz transformation to the rest frame, the coordinates are r i,c = x i e ⊥1 + y i e ⊥2 + z i γ c e c with γ c = 1/ 1 − β 2 c and β c = v c /c = v c /c. The electrostatic field may be computed from point-to-point interaction as with excluded self interaction. Therefore S i is the subset of all particles without particle i. The continualization replaces the particle distribution {q i , r i,c } by a continuous charge density function ρ c (r) and the electrostatic field is the negative gradient of the electrostatic potential Finally we transform back to the moving frame and calculate the Lorentz force The electrostatic potential caused by the charge density ρ = q c (0, 0, 0)/(h x h y h z ) in the cell which includes the origin, is with the Green's function This integral can be solved as [2]: with the anti-derivative and r = x 2 + y 2 + z 2 . The asymptotic behavior is obvious from Eq. (8).
To compute the potential at all mesh points φ m (j, k, l), caused by all mesh charges, one has to perform the summation with g(j, k, l) the Green's function at the mesh points r m (j, k, l). This can be done efficiently by a three-dimensional fast convolution. The components of the electric field are determined . These components, that are allocated on shifted meshes (as r m (j, k, l +1/2)), are interpolated to the Lorentz transformed particle positions r i,c to find the fields E i,c in the rest frame.
For an efficient computation of the Green's function on the mesh, one utilizes the asymptotic behavior for points far from the origin and calculates only near points by Eq. (9).
Therefore one calculates first the anti derivative H one octant (j, k, l ≥ 0) of the near-volume and then the Green's function itself. The field in other octants follows from mirror symmetry. Technically, the change to the asymptotic approximation is realized with a smooth switch function as "switched" Green's function The volume of pure asymptotic behaviour follows from the condition In Fig. 2 the Green's function is compared with the asymptotic approximation, and the ratios G a /G and G s /G are plotted for cubic mesh cells (h x = h y = h z ) and for mesh cells with large aspect ratio (h x = 10h y = 10h z ). The relative deviation of the asymptotic The switch function is calculated for the parameters C 2 = 2C 1 = 10. The relative deviation of the "switched" function is below 0.001 for the hole volume.

C. Periodic Source and Periodic Green's Function
Each particle of the set S p is infinitely repeated with the spatially periodic shift r p , see The particles in S p and the continuous function ρ c,p (r) generate the periodic behavior, but they are not restricted to a certain volume, as the volume of one period.
As for two dimensional charge distributions with infinite size into the third dimension, the potential of periodic distributions is usually not limited to a finite range. Therefore the this and to achieve convergence, by normalizing the potential to be zero at a certain point r 0 . The gradient ofφ c is identical to that of φ c . In the following we skip the tilde and write for the potential of the periodic distribution The summation term in the second integral can be interpreted as Green's function of a periodically repeated point charge. The Green's function of one mesh cell follows from the integration This can be expressed by the non-periodic Green's function as To compute the potential at mesh points φ m (j, k, l), caused by all mesh charges, one has to perform the summation with q c,p (j, k, l) the integrated charge of density ρ c,p in mesh cell (j, k, l) and g p (j, k, l) the periodic Green's function at the mesh points. Therefore the field calculation for periodic source distributions can be done by the same method as for a non-periodic source, only the Green's function and the source distribution have to be replaced by the periodic extension g p and the non-repeated representation q c,p .
For the numerical evaluation we set r 0 = 0 and split G p into the terms The finite sum is computed directly, using Eq. (14). The number M has to be chosen large enough, to fulfill the condition r ± Mr p > C 2 max{h x , h y , h z } for all points in the computation volume, compare Eq. 15. In order to calculate the infinite sums, we use the asymptotic Eq. (11) and the auxiliary function The auxiliary function f (p, q, 0) is periodic in p and can be written as fourier series For small values of q the auxiliary function is calculated with help of a Taylor expansion and the Taylor polynomial For practical simulations it is desirable to use a mesh that supports periodicity, and to shift the particles of the original set by a multiple of r p so that they fill a one-period-slice as in Fig. 1b and c. It stands to reason, to align the slice with respect to the mesh as in Fig. 1b. A small volume of filled mesh cells is preferable.
Meshes that do not support periodicity can be favorable to avoid extreme aspect ratios of mesh cells, as it would happen for supported periodicity if the ratio of non-zero components of r p is extreme. Such a mesh, as in Fig. 4d, gives reasonable results supposed the generating set S p is sufficiently smooth. (Sudden changes of density have to be resolved by the discretization.) The potential has to be computed in a volume that overlaps partially with the shifted volume. In overlapping regions the potential is not quite identical, due to non-periodic discretization errors. Therefore an appropriate interpolation between potentials in overlapping regions (while entering one region and leaving the other) helps to avoid discontinuous potentials and infinite fields.
The periodical Green's function has point symmetry to the origin G p (j, k, l) =

IV. APPLICATIONS
A. FLASH Seeding Section, with 800 nm Energy Modulation of a 1.5 kA Bunch In the seeding section of the FLASH free electron laser [6][7][8]  is short compared to bunch length, but long enough to permit pseudo periodic behavior.
As the optical beam in the undulator is much wider than the particle beam, the energy modulation amplitudeÊ (of 250 keV) is nearly transverse offset independent.
Effects in drift-quadrupole-lattices are the modification of particle energies, the modification of transverse optics and plasma oscillations. For the given parameters, the energy effect is strongest, transverse defocussing is weak and the length for a full plasma oscillation, in longitudinal phase space, is about L p = 120 m [5]. Therefore the longitudinal phase space distribution is nearly not altered on the short distance to the first chicane. The longitudinal dispersion of the first chicane R 56 = 220µm couples relative energy deviations δ E = (E − E 0 )/E 0 to longitudinal displacements δz = R 56 δ E , and creates density modulation due to the initial energy modulation. The effect of the second chicane is weak due to its small dispersion R 56 = 3µm. More important is the interchange between density and energy modulation, as it is typical for plasma oscillations, on the distance between chicane 1 and 3 of about L p /6. The bunch current with its modulation is shown in Fig 6a. Up to this position, the energy modulation has grown by more than a factor of ten to an amplitude of about 4 MeV. This amplification is beyond the linear regime and this will be exacerbated in the last chicane with R 56 = 170µm. This longitudinal dispersion is sufficient to shear particles, that were originally (during modulation) in one period, over several periods as it can be seen within the longitudinal phase space in Fig. 7a. At rollover "points" in longitudinal phase space, where the band with particles is folded back, current spikes appear as can be seen in Fig. 6b. These spikes cause strong space charge fields and lead to a complicated energy pattern after a further drift of about 15 m, see Figs. 7b. The results are in good agreement.
To verify the periodic approach, we did a high resolution full-bunch simulation with 20E6 macro particles with QField-none-periodic, and a periodic simulation with same macro

B. FLASH Seeding Section, with 266 nm Energy Modulation of a 45 A Bunch
This example compares the three-dimensional periodic model with a one-dimensional impedance model, for a periodic distribution that is modulated and compressed to achieve current spikes of maximal amplitude. Significant self effects happen on the drift-quadrupolelattice after the four magnet compressor chicane. The one-dimensional impedance model averages the longitudinal field of a round Gaussian beam versus the transverse offset, as derived in [12] , see also [5] . The setup is the same as before, but with different parameters and only one active chicane: beam energy E 0 = 700 MeV, bunch charge 0.3 nC, normalized emittance 1.5 µm, peak current 45 A, uncorrelated energy spread σ E = 3keV and Gaussian profiles. The particle beam is energy modulated by a laser of wavelength λ = 267 nm with the modulation amplitudê E = 0.2 MeV. The dispersion R 56 ≈ 145µm of the first chicane is adjusted for maximum bunching and maximum current spikes as it can be seen Fig. 11. The second and third chicane are switched off.
Directly before the first chicane, the phase space distribution is almost not changed by self effects, due to the small beam current, the high particle energy and the short travelled distance to this position. In contrast to the previous example, the particles are tracked through the magnetic fields of the chicane, but the effect of one-respectively three-dimensional self fields are so small, that Fig. 11 looks identical for both cases, and it is not to distinguish from the corresponding figure for a calculation without self-fields. The sharpness of the current spikes is not only determined by uncorrelated energy spread and longitudinal dispersion, but also by transverse emittance and second order coupling to the longitudinal direction. The current spikes are very short and the bunching factor b n = | exp(in2πz ν /λ)| /N is above ten percent even for spectral lines beyond the 30th harmonic. The required resolution of the longitudinal mesh has to be much better than than λ/30. It is set to 0.6 nm, which is 450 meshlines per period of the fundamental modulation and thus below the shortest possible rms length of R 56 σ E /E 0 that would appear if the particles are ideally (linear chirp, no non-linear effects) compressed to minimal length. There are about 220000 electrons per period which are directly simulated. A macro particle number equal (or higher) than the number of electrons can be easily handled with the periodical approach.
The particle distribution with sharp density spikes is tracked about 23 m through quadrupoles and drifts to the exit of the (inactive) third chicane. Figs. 12, 13 show the longitudinal phase space, the bunch current and the bunching for the one-and three-dimensional field model. The current spikes are diverged and the high harmonic content is significantly reduced, in good agreement of both models. It can be seen that the slope of the initial sawtooth-like modulation has been reduced, similar to the reduction of the energy modulation during a plasma oscillation, after a length that is short compared to the period length. In the one-dimensional model all particles in one slice feel the same longitudinal field. Therefore the only mechanism to increase the slice energy spread is individual longitudinal particle motion. The longitudinal field in the spikes is strongest and causes an energy modulation comparable to the initial laser modulation and a large energy spread. But the space charge distribution significantly violates the requirements for the one dimensional approach of a long bunch: γσ z ≫ σ ⊥ . The length of the current spike of few nano-meters times γ is not large compared to the typical transverse dimension of about 100 µm (= emittance ×β, see of flat bunches γσ z ≪ σ ⊥ the longitudinal field is proportional to the transverse density, as ∂E z /∂z ≈ divE = ρ/ε 0 .) This increases the slice energy spread as it can be seen in Fig. 13.

C. Parasitic Heating after LCLS Laser Heater
At LCLS a laser heater is used to increase the uncorrelated energy spread of the electron beam to counteract a microbunch instability [13] . Therefore the electron beam is energy modulated in an undulator that is in the middle of a short chicane, see Fig. 14. The periodic modulation directly after the undulator is (in principle) visible in longitudinal phase space.
This is different after the dogleg comprising of the last two chicane magnets: the angular divergence before the dogleg, due to emittance, causes spatial longitudinal divergence due to the dispersion parameter r 52 . This z-divergence is large compared to modulation wavelength so that the periodic behavior is obscured, see (∆E, z)-diagram in Fig. 17. Similarly, in spatial space appears no pattern of the harmonic excitation, see (x, z)-diagram in Fig. 17. Therefore it was unexpected to measure energy spectra with rms widths that are not proportional to amplitudes of the exciting laser field. The position of the spectrometer can be seen in Fig. 14. This effect is a clear indication for self effects and has been discussed, explained and estimated in [10] .
We give a simplified explanation for this effect. The transport equation from the exit of the laser heater undulator to an arbitrary position after the dogleg is with x 0 , x ′ 0 , z 0 , δ 0 =δ cos(kz 0 ) the phase space coordinates after the undulator and x, z the spatial coordinates (at the arbitrary position) after the dogleg and the relative modulation amplitudeδ. The energy spread before the undulator is neglected and for the beginning we neglect also the contribution of x 0 . Fig. 15 illustrates the transformation by Eq. 28: an equidistant orthogonal grid in the (x ′ 0 , z 0 )-plane is transformed to the (x, z) plane. The chosen numbers are typical for the given setup. It is obvious that the original area has been sheared and modulated and spatial density oscillations have been created. Also particles with the same initial coordinate z 0 but different slope x ′ 0 are distributed horizontally, they are still located on lines. To achieve a homogeneous spatial mixing, a horizontal spread of x 0 is necessary that is coupled by r 11 into the horizontal direction again. Supposed the fluctuation of r 11 x 0 is sufficiently large (compared to the horizontal distance between lines with ∆z 0 = λ), then the density is uniform, as for instance in Fig. 17. This is different in the vicinity of zero crossings of r 11 as in Fig. 16 with r 11 and optical functions β x , β y . At these positions appear spatial density fluctuations and space charge fields cause an additional energy modulation, which is correlated with the original modulation.  Fig. 17 refers to a position short after the laser heater chicane. The particles behave as expected by a theory neglecting self effects: the oscillating behavior is not visible, the particles are longitudinally smeared over a length larger than the period λ. The spectral density agrees with the predicted double bump structure [14]. Fig. 18 refers to the position 15.5 m, close to the zero crossing of r 11 . In the spatial diagram the periodic pattern appears as microbunching, although the relative longitudinal position of all the particles is not changed. The space charge fields due to the micro structure changes the particles energy and alters the energy distribution: the spectrum is different and its rms width is increased. At the position 17.5 m shown in Fig. 19, no microbunching is obvious but the energy distribution is significantly widened to σ E ≈ 12 keV. Fig. 20 shows the rms energy spread along the beamline for different heating strengths. The blue 2 keV curve is calculated without heating, the thick black line refers to a heating (from initially 2 keV) to 8 keV as in the previous figures. The parasitic heating effect can be clearly seen. The characteristic of this heating described in Fig. 21 showing the rms energy spread at the spectrometer entrance versus the initial energy spread. It is remarkable that parasitic heating changes not only the rms width but also the shape of the spectrum, see sub-panels with spectra in Figs

V. CONCLUSION
In this paper we developed a method to calculate the potential and electro-magnetic field of a periodic charge distribution that moves in free space with constant velocity. The charge distribution is three dimensional and periodic in one direction of space. The numerical technique is a modification of the well known particle-mesh-method with fast convolution of the discretized source with the Green's function of one cell. An efficient method has been described to compute the periodic Green's function so that only particles, representing one period, have to be considered for the convolution.
The method has been demonstrated with examples of pure spatial periodicity into the direction of motion. For example (A) a comparison with non-periodic simulations is shown.
Although the quasi-periodic part of the bunch is quite short, a good agreement is achieved. A non-periodic simulation for example (B) was beyond the available computational capacities. The periodic approach is numerically much more efficient than non-periodic simulations of bunches with quasi-periodicity, as the number of particles and the volume of the problem domain is reduced by orders of magnitude.