Implementation of the Integrated Green’s Function Method for 3D Poisson’s Equation in a Large Aspect Ratio Computational Domain ()
1. Introduction
The solution of the three-dimensional (3D) Poisson equation plays an important role in many fields. In particle accelerator research, the nonlinear space-charge effects due to Coulomb interactions among charged particles play an important role in high-intensity and high-brightness beam physics since such effects can cause beam quality degradation, halo formation, and even particle losses. In order to study the space-charge effects in the charged particle beam self-consistently, one needs to solve the 3D Poisson equation at each time step with the evolving particle density distribution. When the beam (e.g. electron beam) energy increases, in the beam frame computational domain, the longitudinal to transverse aspect ratio becomes larger and larger due to the relativistic effect. In such a case, an integrated Green’s function method was developed and showed to be more effective than the standard Green’s function method to solve the 3D Poisson equation subject to open boundary conditions since it does not require resolving the variation of the Green’s function through the computational domain [1]. In recent years, this method has been adopted in a number of particle accelerator beam dynamics codes for the self-consistent simulation of the space-charge effects [2]-[11]. However, there is no publication on how this method is implemented. Direct implementation of the mathematical expression of the integrated Green’s function method can result in substantially more computational cost. In this paper, we report on an efficient implementation method that reduces the computational cost by more than a factor 50 and alternative expressions that avoid cancellation errors under certain extreme conditions.
2. Integrated Green’s Function Solution to 3D Poisson’s Equation
The electric potential
of the space-charge fields satisfies the following Poisson’s Equation:
(1)
where
is the charge density distribution function, and
is the permittivity in vacuum. The solution of the above Poisson’s Equation subject to the 3D free space open boundary condition can be written as:
(2)
where the Green’s function G is given by:
(3)
To compute the above integral numerically, we define a computational domain containing the beam with a range of
,
and
, and discretize each dimension using
,
and
grid points. Then, we decompose this integral in the entire computational domain as a summation of
small cell integrals with each grid point located at the center of the cell.
(4)
where
,
, and
. If we assume that the charge density is constant within each cell centered at the grid point
, i.e.
, from the above equation, the electric potential on this grid point can be approximated as:
(5)
where
,
, and
, and the effective Green function
is given as:
(6)
where
,
, and
are cell size in each dimension, respectively. The above integral can be calculated analytically in a closed form for the Green’s function given in Equation (3) as [12]:
(7)
where
(8)
where
. With the effective Green’s function
, the summation of Equation (5) can be computed effectively using the FFT method [1] [13].
3. Efficient Implementation
The effective Green’s function in the above equation involves eight f-function evaluations. The range of the variables in the function f covers the range from
to
,
to
, and
to
, which suggests two times grid points are needed in each dimension for this function. However, a careful check of Equation (6) suggests that the effective Green’s function should have the same symmetry property as the original Green’s function, i.e., changing the sign of an individual variable in Equation (7) will not affect the value of the function. This can be seen from Equation (6),
or by using Equation (7) and
results in
for x (same applies to y and z). Hence, only the first quadrant of the effective Green’s function is needed. This saves the computational cost by about a factor of eight. Furthermore, by computing the f function on one corner of the integrated cell for an extended grid (i.e.,
instead of N)
for
,
, and
, the f function values at the other seven corners of the cell in the Equation (7) can be obtained from the shift of this function on the grid. For example, the f function value at the upper right corner of the cell will be
for
,
, and
. Only one f function evaluation is needed instead of eight function evaluations in Equation (7). This saves the computational cost by another factor of eight. In total, the efficient implementation can save the computing time of the effective Green’s function by more than a factor of 60 compared with the direct brute force implementation. An illustration of this implementation in Fortran90 is given in Figure 1.
![]()
Figure 1. The Fortran90 implementation of the effective Green’s function calculation.
As a test of the practical performance of the above implementation, we measured the computing time of the above implementation and the computing time of the brute force implementation with a variety of problem sizes
. Figure 2 shows the speedup of the above implementation as a function of one-dimensional grid points in the real application. More than 50 speedup is achieved for problem sizes greater than 64 × 64 × 64.
From the above implementation, it is seen that the variable x, y, z in Equation (8) will be less than zero only when
, or
, or
. The negative value of the variable could cause cancellation error in the evaluation of
, or
, or
. In some extreme applications, e.g., with very high electron beam energy, the longitudinal bunch length in the beam frame can be much larger than the transverse beam size. This results in the
and a large cancellation error in
and even overflow of
for
.
The aforementioned cancellation error is due to the subtraction of two close real numbers on finite precision digital computers. This numerical cancellation error can be mitigated by either increasing the precision of each number on a computer or by using the following alternative expressions to replace the original summation in the Equation (8) or the Equation (8) itself.
Figure 2. The speedup of the efficient implementation as a function of one-dimensional grid points.
Firstly, we can declare the variables x, y, z, and r in the above implementation as quadruple precision. This substantially increases the accuracy of each variable on a digital computer and reduces the cancellation error due to the double-precision representation of a variable.
Secondly, by making use of the function relationship
, neglecting the terms that do not contribute to the field calculation (i.e.
), the Equation (8) can be rewritten as:
(9)
This equation avoids the sum of two close but opposite sign variables in the original equation and the resultant cancellation error.
Thirdly, one can define a small tolerance number
(e.g. 10−10) and use the Taylor expansion to obtain the following approximation:
(10)
The above approximation is used in the natural logarithm function to mitigate the cancellation error.
Fourthly, one can rewrite the expression in the natural logarithm function of Equation (8) as:
(11)
The above expression turns the original summation of two opposite sign variables into an expression that includes subtraction of these variables and avoids the cancellation error.
4. A Benchmark Example
As a test, we used a 100 pC electron beam with a 3D Gaussian density distribution and computed the electric fields in the beam frame from all of the above schemes and from a semi-analytical solution. The semi-analytical electric potential in the rest beam frame for a Gaussian density distribution is given by [14]:
(12)
where Q is the total charge of the beam, and
,
,
are the RMS sizes of the beam in each dimension. In this test, we assumed that
mm and
mm. We varied electron beam kinetic energy so that the electron beam longitudinal bunch length
in the beam frame increased with the increase of beam energy. This increases the longitudinal-to-transverse aspect ratio with the increase of beam energy in the beam frame. We used 129 × 129 × 257 grid points to solve the Poisson equation using the above integrated Green’s function method in the rest beam frame. Electric fields are numerically computed from
in this frame using a second-order finite difference approximation.
Figure 3 shows horizontal and longitudinal electric fields as a function of longitudinal coordinate z in the beam frame from the semi-analytical solution and from the original integrated Green’s function method at 100 GeV electron beam energy. It is seen that the electric fields from the numerical integrated Green’s function solution agree with those from the semi-analytical solution very well.
In order to check the valid regime of the integrated Green’s function method, we varied the electron beam kinetic energy from 100 GeV to 100 TeV. This results in about 2 × 105 to 2 × 108 longitudinal-to-transverse aspect ratio for the computational cells in the rest beam frame. Figure 4 shows the maximum horizontal relative electric field error and the maximum longitudinal relative electric field error as a function of the electron beam kinetic energy using the original double
Figure 3. Horizontal electric field Ex (top) and longitudinal electric field Ez (bottom) as a function of longitudinal coordinate z in the beam from the semi-analytical solution (magenta) and from the integrated Green’s function method (green) at 100 GeV electron beam energy. There are two lines in each plot sitting on top of each other.
precision logarithm integrated Green’s function (IGF), the quadruple precision logarithm IGF, the arcsinh IGF, the approximated logarithm IGF, and the rewritten logarithm IGF. Here, the differences between the numerical solutions from the integrated Green’s function method and the semi-analytical solutions were calculated on the three-dimensional 33 × 33 × 65 grid points for both the horizontal electric field and the longitudinal electric field. These differences are normalized by the maximum values of the horizontal electric field and the longitudinal field from the semi-analytical model, respectively, to attain the 3D relative errors. The maximum relative errors are attained from the relative errors on the 3D grid. It is seen that all five integrated Green’s function implementations yield nearly the same less than 0.1% relative errors up to 50 TeV beam energy. This is probably due to the fact that the cancellation error occurs only
and
![]()
Figure 4. The maximum horizontal relative electric field error (top) and the maximum longitudinal relative electric field error (bottom) as a function of the electron beam kinetic energy using the original double precision logarithm IGF (plus), the quadruple precision logarithm IGF (cross), the arcsinh IGF (star), the approximated logarithm IGF (empty square), and the rewritten logarithm IGF (solid square).
has a small contribution to the total 3D summation. At the 100 TeV electron beam energy, the original logarithm integrated Green’s function fails due to the cancellation error in the evaluation of
and the resultant overflow of the logarithm function. The other four mitigation schemes all work well and yield less than 0.1% relative errors. The computational cost of the quadruple precision implementation of the IGF is the highest (more than 10 times the original IGF) due to the lack of direct hardware support for such operations. The computational cost of the arcsinh implementation of the IGF is about a factor of two of that of the original IGF. The computational costs of the approximated IGF and the rewritten IGF implementations are close to that of the original IGF, while the rewritten IGF implementation does not need to specify any tolerance number.
5. Conclusion
In this paper, we present an efficient implementation of the integrated Green’s function method to solve the 3D Poisson’s Equation in a large aspect ratio computational domain subject to the open boundary conditions. Our implementation suggests more than a factor of 50 reduction of computational cost compared with the direct brute force implementation. Furthermore, several alternative expressions are proposed to avoid cancellation errors and work well under extreme conditions. This implementation can have applications in many fields, such as high-brightness beam physics in particle accelerators, plasma physics, and micromagnetics, where the solution of 3D Poisson equation in the large aspect ratio computational domain is needed.
Acknowledgements
This work was supported by the U.S. Department of Energy under Contract No. DE-AC02-05CH11231 and used computer resources at the National Energy Research Scientific Computing Center.