원시데이터 수집 시스템
선정목록으로

A method to compute periodic sums

관련 수소연료전지 · (6) PEM(고분자전해질막)

기본 정보

저자
  1. Gumerov, Nail A.
  2. Duraiswami, Ramani
DOI
10.48550/arxiv.1310.4374
저널
arXiv (Cornell University)
발행년도
2022
발행기관
Cornell University
피인용수
0
라이선스
0
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.48550/arxiv.1310.4374
토픽
Composite Material Mechanics
OpenAlex ID
W6910654706

평가 내용

관련도
관련
사업분야
수소연료전지 · (6) PEM(고분자전해질막)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '수소연료전지 > PEM(고분자전해질막)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

In a number of problems in computational physics, a finite sum of kernel functions centered at $N$ particle locations located in a box in three dimensions must be extended by imposing periodic boundary conditions on box boundaries. Even though the finite sum can be efficiently computed via fast summation algorithms, such as the fast multipole method (FMM), the periodized extension is usually treated via a different algorithm, Ewald summation, accelerated via the fast Fourier transform (FFT). A different approach to compute this periodized sum just using a blackbox finite fast summation algorithm is presented in this paper. The method splits the periodized sum in to two parts. The first, comprising the contribution of all points outside a large sphere enclosing the box, and some of its neighbors, is approximated inside the box by a collection of kernel functions ("sources") placed on the surface of the sphere or using an expansion in terms of spectrally convergent local basis functions. The second part, comprising the part inside the sphere, and including the box and its immediate neighborhood, is treated via available summation algorithms. The coefficients of the sources are determined by least squares collocation of the periodicity condition of the total potential, imposed on a circumspherical surface for the box. While the method is presented in general, details are worked out for the case of evaluating electrostatic potentials and forces. Results show that when used with the FMM, the periodized sum can be computed to any specified accuracy, at an additional cost of the order of the free-space FMM. Several technical details and efficient algorithms for auxiliary computations are provided, as are numerical comparisons.

본문 113,055자

본문 펼치기
## A method to compute periodic sums Nail A. Gumerov <sup>_∗_</sup> and Ramani Duraiswami <sup>_†_</sup> Institute for Advanced Computer Studies University of Maryland, College Park October 15, 2013 revised March 30, 2014 Abstract In a number of problems in computational physics, a finite sum of kernel functions centered at _N_ particle locations located in a box in three dimensions must be extended by imposing periodic boundary conditions on box boundaries. Even though the finite sum can be efficiently computed via fast summation algorithms, such as the fast multipole method (FMM), the periodized extension is usually treated via a different algorithm, Ewald summation, accelerated via the fast Fourier transform (FFT). A different approach to compute this periodized sum just using a blackbox finite fast summation algorithm is presented in this paper. The method splits the periodized sum in to two parts. The first, comprising the contribution of all points outside a large sphere enclosing the box, and some of its neighbors, is approximated inside the box by a collection of kernel functions (“sources”) placed on the surface of the sphere or using an expansion in terms of spectrally convergent local basis functions. The second part, comprising the part inside the sphere, and including the box and its immediate neighborhood, is treated via available summation algorithms. The coefficients of the sources are determined by least squares collocation of the periodicity condition of the total potential, imposed on a circumspherical surface for the box. While the method is presented in general, details are worked out for the case of evaluating electrostatic potentials and forces. Results show that when used with the FMM, the periodized sum can be computed to any specified accuracy, at an additional cost of the order of the free-space FMM. Several technical details and efficient algorithms for auxiliary computations are provided, as are numerical comparisons. Keywords periodic sums; fast multipole method; Ewald summation; GPU computing; kernel independent methods; molecular dynamics; long-range interactions Acknowledgments Work partially supported by the following sources: AFOSR under MURI Grant W911NF0410176 (PI Prof. J. G. Leishman, monitor Dr. D. Smith); by NSF award 1250187 (PI: Prof. B. Balachandran); by Grant G34.31.0040 (PI: Prof. I. Akhatov) of the Russian Ministry of Education & Science.; and by Fantalgo, LLC. _∗_ Corresponding Author. Also at Center for Micro and Nanoscale Dynamics of Dispersed Systems, Bashkir State University, Ufa, Russia; and at Fantalgo, LLC., Elkridge, MD 21075; E-mail: gumerov@umiacs.umd.edu; Phone: +1-301-405-8210; Fax: +1-301-314-9658; web: [http://www.umiacs.umd.edu/users/gumerov](http://www.umiacs.umd.edu/users/gumerov) _†_ Also Department of Computer Science, and at Fantalgo, LLC. E-mail:ramani@umiacs.umd.edu, web: http://www.umiacs.umd.edu/users/ramani 1 ### 1 Introduction Many problems in physics, chemistry and materials science lead to a free-space finite “particle” sum of _N_ functions, _K_, centered at locations x _i_ _∈_ Ω0 _⊂_ R <sup>3</sup>, where Ω0 is a rectangular box _d_ 1 _× d_ 2 _× d_ 3 centered at the origin of the reference frame _φ_ ˜ ( y ) = _N_ _i_ =1 _qiK_ ( y _−_ x _i_ ) _._ (1) For evaluation at _N_ locations y, this sum has a quadratic cost. There are efficient and arbitrarily accurate approximation algorithms for this summation (e.g., the fast multipole method, FMM [6]). Often, an extension to this sum for _φ_ <sup>˜</sup> must be computed in which periodic boundary conditions are enforced on box boundaries, resulting in the potential _φ_ . This can be evaluated by replacing the sum (1) with the infinite sum _N_ _i_ =1 �( _i_ 1 _d_ 1 _, i_ 2 _d_ 2 _, i_ 3 _d_ 3) : ( _i_ 1 _, i_ 2 _, i_ 3) _∈_ Z <sup>3�</sup> _φ_ ( y ) = p _qiK_ ( y _−_ x _i_ + p ) _,_ p _∈_ P = _._ (2) For some functions _K_, such as those representing the field of an electrostatic charge, this infinite sum may be divergent or conditionally convergent. In this case certain side conditions may be needed to compute a physically relevant sum. Usually such infinite sums are performed using Fourier-transform based Ewald summation [1], which is accelerated via the FFT. This method is described briefly in Appendix D. Accounting for all pairwise interactions the method can achieve _O_ ( _N_ log _N_ ) complexity, for _N_ particles in the box Ω0 which is periodically replicated over the full space [2, 3]. Because of the technique used for grid-toparticle interpolation these methods are usually low-order. A high-order accurate Gaussian interpolation based Ewald summation algorithm was recently presented in [4, 5]. Another scalable algorithm, which can be employed for computation of periodic sums (2) is the FMM. A criticism of FMM algorithms has been that they are relatively harder to implement, combining the need for efficient data structures, careful analysis and computation of special functions, and mixed memory access patterns. Nevertheless, several open-source and commercial packages implementing the FMM for standard kernels in free space have become available. The FMM is used less often in practice to compute periodic sums, even though several methods to handle periodic boundary conditions using extensions to the basic FMM have been proposed, starting from the first publication of the algorithm [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]. Some authors (e.g. [12]) claim that the overhead in the FMM for computation of periodic sums can be negligibly small. This is true under a few conditions, but not in others. This is discussed in detail in a section entitled Discussion. Analysis of the FMM and its plane-wave variant, which is better-suited tor large _N_ and parallel architectures than the smooth particle mesh Ewald algorithm, is presented in [17]. However, all these methods require constructing a new and different algorithm - a periodic variant, for which optimized implementations are not in general available. Furthermore, some of these algorithms may not extend easily to non-cubic domains. It can be mentioned in this context that any FMM has a so-called break-even point, _Nb_, such that at _N_ _<_ _Nb_ brute force summation (1) is faster than the FMM computation. The value of _Nb_ depends on the method used, implementation, required accuracy (the FMM is an approximate algorithm), and hardware. It may vary in a range _Nb_ _∼_ 10 <sup>2</sup> _−_ 10 <sup>4</sup>, which is of the order of _N_ for some practical problems (e.g. for some molecular dynamics simulations). In such cases, the use of periodic FMM just for the purpose of computing of infinite sums (2) even if the overhead for periodization will be zero is questionable if some other periodization method, which can use finite brute force summation algorithms is available. Special purpose hardware such as graphics processors or heterogeneous CPU/GPU architectures also allow the fast computation of finite sums, either via brute force summation [18], or via the mapping of the 2 FMM onto these architectures [19, 20, 21, 22]. Yokota et al. [22] favorably compare a large scale FMMbased vortex element computations with a direct numerical simulation via periodic pseudospectral methods. Their simulations could have been faster and more accurate - the FMM was executed on a finite system composed of 3 <sup>3</sup> images, which while not being truly periodic also makes using the FMM significantly more expensive. The problem this paper seeks to address is: _Given_ _a_ _black-box_ _fast_ _summation_ _algorithm_ _(FSA)_ _for_ _computing finite sums with a given kernel K_ ( y _−_ x _i_ ) that is available to the user, _is it possible to compute_ _the same sum with periodic boundary conditions without any modification of the FSA?_ We provide a positive answer to this question. Our algorithm has the same cost as the FSA, and can be computed to any user specified accuracy _ϵ_, and does not use the FFT. The basic idea of the method is to divide the sum (2) in to two parts. One part computes a finite sum of particles that lie within a sphere centered at the box. This is computed using the available FSA. The other part, is an approximation of the field within the box due to all particles outside the sphere. The field due to these sources can be represented within the box in terms of local expansions. Such local expansions have also been proposed in other attempts to extend the FMM to periodic systems, but are there derived by explicit translation of multipole expansions from outside the box of interest into it. In our method, we propose to determine the coefficients directly from the periodicity conditions on the potential, which results in solution of a relatively small overdetermined function-fitting problem, easily solved via standard algorithms - e.g., rank-revealing _QR_ decomposition. This step is in the spirit of the “kernel-independent” FMM methods [26, 27]. In this context we should mention Ref. [15]. Even though it is dedicated to the Helmholtz equation in two dimensions, a method for “periodization” of free-space solutions similar in spirit to that presented here was proposed and tested. Moreover, the cited paper contains an additional “periodization” method based on boundary integrals, which can be tried for different kernels and space dimensionality (also see [28], where periodization along one dimension is performed). We present this “periodization” approach in a general setting, but focus computational examples on the evaluation of the electrostatic potential _φ_ and its gradient _∇φ_ at _M_ evaluation points y _j_ _∈_ Ω0 _⊂_ R <sup>3</sup> due to _N_ charged particles of charge _qi_ placed in Ω0, and subject to periodic boundary conditions on _∂_ Ω0. This reduces to computing the infinite, conditionally convergent, sum (1), with kernel function _K_ : <u>1</u> _K_ ( y _−_ x ) = _|_ y _−_ x _|_ <sup>_,_</sup> y _̸_ = x ; _K_ ( y _−_ x ) = 0 _,_ y = x _,_ _N_ _i_ =1 _qi_ = 0 _._ (3) and the net charge in each box being zero. Of course, in practical applications, such as in molecular dynamics, there will be other computations beyond the sum necessary to stabilize the overall computations. This paper does not consider these, focusing on the electrostatic sum at a single time step. The periodization method could be easily applied to other kernels for which a “fast summation algorithm” (FSA) is available. As long as the periodic sum makes sense, and the kernel _K_ can be expanded over some local basis, the proposed method should work. Conditions similar to the charge neutrality in (3) may be necessary. The proposed method can also be applied for 2D problems, though we present it in 3D. Also, the periodic extension of the computational domain (box) may be performed only along one or two coordinates, for which Ewald summation may have problems. ### 2 Proposed method 2.1 Periodization The box on which the periodic sum is to be computed is denoted Ω0. Let _S_ 0 be a ball of radius _R_ 0 centered at the center of the box Ω0 and containing it. Let _Sb_ be another ball with the same center and radius _Rb_ _> R_ 0 3 (see Fig. 1). We denote as Ω _b_ a finite region which includes the ball _Sb_ (the minimal Ω _b_ is the ball _Sb_ ). We decompose the infinite sum as x _j /∈_ Ω _b_ _qjK_ ( y _−_ x _j_ ) _,_ (4) _φ_ ( y ) = _φnear_ ( y )+ _φfar_ ( y ) _,_ _φnear_ ( y ) = x _j_ _∈_ Ω _b_ _qjK_ ( y _−_ x _j_ ) _,_ _φfar_ ( y ) = where _φnear_ ( y ) is to be computed using the FSA (assumed to be the FMM in the sequel) to the specified accuracy _ϵ_ while _φfar_ ( y ) is computed by some other method at least to the same accuracy. The sources in the infinite domain are indexed as x _j_ = x _i −_ p, _qj_ = _qi_ for appropriate vectors p _∈_ P (see Eq. (2)). W _b_ _Sb_ ( _c_ ) y _l_ W 0 _S_ 0 _R_ 0 _O_ x _i_ ~ y _l_ ( _c_ ) _Rb_ Figure 1: The particle sum (2) in the box Ω0, subject to periodic boundary conditions on the box boundary, is to be computed to a specified accuracy _ϵ_ . The boundary condition can be enforced by the image method, which results in an infinite set of copies of the box Ω0. The proposed method divides the sum into a near-field component in Ω _b_ and a far-field sum. To apply the FMM to the kernel function _K_ ( y ) it should be possible to approximate it via a convergent series over a set of local basis functions _{Rt_ ( y ) _}_ . This means that for any source point x _j_ _∈/_ Ω _b_ we have the factorization _K_ ( y _−_ x _j_ ) = _P_ _t_ =1 _Bt_ ( x _j_ ) _Rt_ ( y ) + _ϵ_ <sup>(</sup> _j_ <sup>_P_</sup> <sup>)</sup> _,_ _|_ x _j| > Rb,_ _|_ y _| < R_ 0 _,_ (5) where _P_ is the number of terms retained in the infinite series, _Bt_ ( x _j_ ) are the expansion coefficients, and _ϵ_ <sup>(</sup> _j_ <sup>_P_</sup> <sup>)</sup> is the truncation error depending on _|_ x _j|_ and _R_ 0. The basis functions can be some standard choices, or, 4 as in the kernel independent FMM [27], can be taken to be a collection of kernel functions, centered outside the region of approximation ��� x _t_ ( _s_ )��� _> Rb,_ (6) _Rt_ ( y ) = _K_ - y _−_ x <sup>(</sup> _t_ <sup>_s_</sup> <sup>)</sup> - y _−_ x <sup>(</sup> _t_ <sup>_s_</sup> <sup>)</sup> <sup>)</sup> - _,_ where x <sup>(</sup> _t_ <sup>_s_</sup> <sup>)</sup> are a collection of sources located outside ball _Sb_ . This method has the flavor of “equivalent source” methods. Since the function _K_ depends only on the distance between its argument, it is a “radial basis function”, or RBF [24]. While any approximation scheme may be used, the use of kernel _K_ as RBF is dictated by the fact that this kernel satisfies the underlying equation (e.g. the Laplace equation), so the approximation to the field via the sum of such RBFs also satisfies the equation (if it is linear and space invariant). Substituting Eq. (5) into the expression for _φfar_ ( y ) from Eq. (4), we obtain _φfar_ ( y ) = _Ct_ = _P_ _t_ =1 x _j /∈_ Ω _b_ _CtRt_ ( y ) + _ϵ_ <sup>(</sup> <sup>_P_</sup> <sup>)</sup> _,_ (7) x _j /∈_ Ω _b_ _qjBt_ ( x _j_ ) _,_ _ϵ_ <sup>(</sup> <sup>_P_</sup> <sup>)</sup> = _qjϵ_ <sup>(</sup> _j_ <sup>_P_</sup> <sup>)</sup> _._ A necessary condition for our method is convergence of both infinite sums _Ct_ and _ϵ_ <sup>(</sup> <sup>_P_</sup> <sup>)</sup> . The problem of computation of _φfar_ ( y ) has been reduced to that of determination of _P_ fitting coefficients _Ct_ . These can be determined via least-squares collocation as follows. Consider a set of _L_ _>_ _P_ check points, Y <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _⊂_ _S_ 0 _\_ Ω0. A point y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _∈_ Y <sup>(</sup> <sup>_c_</sup> <sup>)</sup> has two properties:first,��� y _l_ ( _c_ )��� _< R_ 0, and, second, that there exists p _∈_ P such that point ��� _< R_ 0, and, second, that there exists p _∈_ P such that point _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _∈_ Y <sup>(</sup> <sup>_c_</sup> <sup>)</sup> has two properties:first, ��� y _l_ ( _c_ ) y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> = y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> + p _∈_ _S_ 0 (see Fig. 1). This means that - y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _,_ _l_ = 1 _, ..., L._ (8) _φ_ - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> = _φ_ In terms of decomposition (4) and representation of the far field (7) this system can be rewritten as _P_ _t_ =1 _AltCt_ = _fl_ + _ϵ_ <sup>(</sup> _l_ <sup>_P_</sup> <sup>)</sup> _,_ _l_ = 1 _, ..., L,_ (9) y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _,_ _fl_ = _φnear_ y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _−_ _φnear_ - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _Alt_ = _Rt_ - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _−_ _Rt_ where ��� _ϵl_ ( _P_ )��� = ��� _ϵ_ ( _P_ ) � y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - _−_ _ϵ_ <sup>(</sup> <sup>_P_</sup> <sup>) �</sup> y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> ���� ⩽ 2 max y _∈S_ 0 �� _ϵ_ ( _P_ ) ( y )�� _._ We have _L_ linear equations in _P_ unknowns _C_ 1 _, ..., CP_ . As we are not constrained with the size of the set of the set points, _L_ _>_ _P_ can be selected to provide a substantial oversampling, so minimization of functional ��� = ��� _ϵ_ ( _P_ ) � y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _l_ where ��� _ϵl_ ( _P_ ) - _−_ _ϵ_ <sup>(</sup> <sup>_P_</sup> <sup>) �</sup> y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - _P_ _t_ =1 �2 _AltCt −_ _fl_ _F_ ( _C_ 1 _, ..., CP_ ) = _L_ _l_ =1 _,_ (10) should take care about the “noise” introduced into the approximation due to _ϵ_ <sup>(</sup> _l_ <sup>_P_</sup> <sup>)</sup> . The least square mini mization procedure is well known and formally it results in solution C = A <sup>_†_</sup> f _,_ A <sup>_†_</sup> = - A <sup>_T_</sup> A - _−_ 1 A _T,_ (11) where C = _{Ct}_ and f = _{fl}_ are organized as column vectors of size _P_ and _L_, respectively and A <sup>_†_</sup> is the _P_ _× L_ matrix, which is the pseudoinverse of A, and superscript _T_ denotes transposition. Note that this notation is formal, and is not the way the least-squares problem is solved in practice. Rather a stable 5 algorithm such as the rank-revealing QR decomposition [32] is used, while it is strongly recommended to precompute and store matrix decompositions in the “set” part of the algorithm to reduce the cost of the “get” part. The known coefficients C allow computation of _φfar_ ( y ) and can be added to the _φnear_ obtained via the FSA. However, some technical details need to be specified. In the next section we provide analysis and details for the important case of the Coulombic kernel (2). A similar collocation of kernel based RBF expansions at a relatively small amount of the check points is also used in the “kernel independent” FMM [26] with basis functions (6). There, the collocation is at the level of the boxes in the FMM octree data structure, and fitting takes the place of expansions and translations. Here, we collocate the differences of the overall solution at a set of check points y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> and at their periodic images � y _l_ <sup>(</sup> <sup>_c_</sup> <sup>), at the level of the overall domain to determine the expansion coefficients for</sup> <sup>_φfar_</sup> <sup>.</sup> 2.2 Check point set Figure 2: The check point distributions over the surface of a unit sphere for _p_ = 16: random distribution ( _L_ = 3 _p_ <sup>2</sup> points), the Gauss spherical grid ( _L_ = 2 _p_ <sup>2</sup> _−_ _p_ ), and the Thomson points ( _L_ = _p_ <sup>2</sup> ). Selection of an optimal set of check points Y <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _⊂_ _S_ 0 _\_ Ω0 is not trivial. A good check point set should yield a well conditioned solution, and sample the solution well spatially. A simple way which does not yield such a well conditioned set is to select the points y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _∈_ Y <sup>(</sup> <sup>_c_</sup> <sup>)</sup> on the boundary of box Ω0. This is because such a well conditioned set is to select the points y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _∈_ Y <sup>(</sup> <sup>_c_</sup> <sup>)</sup> on the boundary of box Ω0. This is because the corresponding periodic point � y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> will then also be located on the box boundary on the face opposite to the corresponding periodic point � y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> will then also be located on the box boundary on the face opposite to y _l_ <sup>(</sup> <sup>_c_</sup> <sup>).</sup> <sup>In this case the distances from the box center to</sup> <sup>y</sup> _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> and to y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> will be the same, so both points will be located on a sphere of radius _r_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _l_ <sup>.</sup> <sup>If the basis is based on spherical functions, then several of these will</sup> take the same value for symmetrical points on the sphere, and the fitting equations may be rank deficient. To avoid this degeneracy, the set Y <sup>(</sup> <sup>_c_</sup> <sup>)</sup> was chosen from points on the surface of ball _S_ 0. Three distributions were tried (see Fig. (2): i) random uniformly distributed points, ii) Gaussian nodes (zeros of the Legendre polynomial along _θ_, _Pp_ (cos _θ_ ), see [33]) and equispaced with respect to _ϕ_ ), and, iii) the almost uniform distribution of points over the sphere obtained by solving the so-called Thomson problem of the equilibrium position of mutually repelling electrons constrained to be on the surface of the sphere [34], see [35]. Methods ii) and iii) show better results than the random distribution, as shown in Section 3. Further, we fond that using the Thomson points for the interpolation in Eq. 6 provides good accuracy. _l_ <sup>(</sup> <sup>_c_</sup> <sup>).</sup> <sup>In this case the distances from the box center to</sup> <sup>y</sup> _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> and to y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> 6 2.3 Periodization algorithm The algorithm has two parts. In a first preliminary set-up step, denoted “set”, the check points are determined, and the matrix decompositions necessary to compute the least squares fit with the matrix A in Eq. (11) are precomputed. In simulations where the domain Ω0 is fixed and the particles move, as in molecular dynamics, this matrix does not change, and the cost of the “set” step is amortized over the entire simulation. The second part of the algorithm, denoted “get,” computes the right hand side and solution of the fitting equations via an inexpensive step such as backsubstitution. The accuracy depends on the choice of basis functions, and the parameters _P_, _L_, and _Rb_ . In the next section we provide both a theoretical and an empirical study for the case of the Coulombic kernel (Green’s function of Laplace’s equation). 2.3.1 Algorithm “set” 1. Set the circumsphere radius _R_ 0 = <sup><u>1</u></sup> 2 ~~�~~ _d_ <sup><u>2</u></sup> 1 <sup>+</sup> <sup>_d_</sup> <sup><u>2</u></sup> 2 <sup>+</sup> <sup>_d_</sup> 3 <sup><u>2.</u></sup> <sup>Based on the required accuracy determine</sup> <sup>_Rb_</sup> <sup>,</sup> _P_, and _L_ ⩾ _P_ . 2. Generate _L_ check points distributed over the surface of the ball _S_ 0, y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _∈_ _∂S_ 0, _l_ = 1 _, ..., L._ Denote this point set as _Yc_ 1. _l_ <sup>(</sup> 2 <sup>_c_</sup> <sup>)</sup> <sup>_, y_</sup> _l_ <sup>(</sup> 3 <sup>_c_</sup> <sup>)</sup> _l_ 3 3. For each point y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> = - _yl_ <sup>(</sup> 1 <sup>_c_</sup> <sup>)</sup> _l_ <sup>(</sup> 1 <sup>_c_</sup> <sup>)</sup> <sup>_, y_</sup> _l_ <sup>(</sup> 2 <sup>_c_</sup> <sup>)</sup> _,_ _l_ = 1 _, ..., L,_ find a point y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _∈_ _S_ 0, such that two Carte sian coordinates of y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> are the same as those of the respective coordinates of y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _._ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _l_ <sup>,</sup> <sup>while</sup> <sup>the</sup> <sup>other</sup> coordinate, � _ylk_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _lk_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> <sup>is shifted by</sup> <sup>_dk_</sup> <sup>with respect to</sup> <sup>_y_</sup> _lk_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _lk_ <sup>(</sup> <sup>_c_</sup> <sup>).</sup> <sup>Denote</sup> <sup>_Yc_</sup> <sup>2 =</sup> y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> 4. Form the _L × P_ fitting matrix A = _{Alt}_, _Alt_ = _Rt_ - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> Form the _L × P_ fitting matrix A = _{Alt}_, _Alt_ = _Rt_ - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - _−_ _Rt_ - y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> �, _l_ = 1 _, ..., L, t_ = 1 _, ..., P,_ where _Rt_ ( y ) are the basis functions at the checkpoints. _l_ _−_ _Rt_ 5. Compute matrix decomposition of A necessary to solve the least squares problem. 6. (optional) Precompute other parameters which do not depend on the source distribution. If the summation needs certain auxiliary computations to ensure convergence, do those steps. For the Coulomb kernels this may involve computation of the integrals of the basis functions over the box Ω0. 2.3.2 Algorithm “get” 1. Periodically extend the source box Ω0 to cover the ball _Sb_ of radius _Rb_ . The newly generated sources and charges will have coordinates _X_ p = _{_ x _i_ + p _}_ for the values of the periodization vector p 1 _, ...,_ p _b_ from set P (see Eq. (2)) and charges _Q_ p = _{qi} ._ Denote the set of all sources as _Xb_ = _X_ 0 _∪_ _X_ p 1 _∪_ _... ∪_ _X_ p _b_ . These constitute Ω _b_ . 2. Find the set of _Nb_ sources _Xnear_ by removing sources from the set _Xb_ that are outside the sphere _Sb_, and satisfy _|_ x _j| > Rb_ ( _Xnear_ = _{_ x _∈Xb_ : _|_ x _|_ ⩽ _Rb}_ ) _._ 3. Using the FSA compute _φnear_ for a given set of evaluation points _Y_ 0 = _{_ y _j}, j_ = 1 _, ..., M_ residing in Ω0 and belonging to sets _Yc_ 1 and _Yc_ 2, i.e. for points from the set _Y_ = _{_ y _∈Y_ 0 _∪_ _Yc_ 1 _∪_ _Yc_ 2 _} ._ If gradient computations are needed, compute _∇φnear_ at y _j_ _∈_ _Y_ 0 _._ 4. Form the right hand side of the periodization equation f = _{fl}, fl_ = _φnear_ y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> Form the right hand side of the periodization equation f = _{fl}, fl_ = _φnear_ - y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - _−_ _φnear_ - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> �, _l_ = 1 _, ..., L,_ organized in a column vector. _−_ _φnear_ - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> _l_ 7 5. Using the matrix decompositions in the “set” step solve the fitting equations for the _P_ expansion coefficients C = ( _C_ 1 _, ..., CP_ ) <sup>_T_</sup> _._ This step can formally be written as C = A <sup>_†_</sup> f _._ 6. (optional) Compute the constant shift or other modification of the far field potential, if needed. 7. Evaluate _φfar_ ( y _j_ ), and if gradient computation is needed, _∇φfar_ ( y _j_ ), at y _j_ _∈_ _Y_ 0. 8. Get the periodized solution of the problem, _φ_ ( y _j_ ) = _φnear_ ( y _j_ )+ _φfar_ ( y _j_ ) _,_ y _j_ _∈_ _Y_ 0 _,_ and if gradient computation is needed, _∇φ_ ( y _j_ ) = _∇φnear_ ( y _j_ ) + _∇φfar_ ( y _j_ ) _,_ y _j_ _∈_ _Y_ 0. Remark 1 _In molecular dynamics and other N-body simulations the source and evaluation points are the_ _same, so Y_ 0 = _X_ 0 _._ Remark 2 _In Step 5 for the Laplacian kernel and spherical basis functions_ C = ( _C_ 2 _, ..., CP_ ) <sup>_T_</sup> _._ _In this case_ _optional Step 6 provides C_ 1 _(see Eqs (36)-(39))._ _Otherwise set C_ 1 = 0 _._ Remark 3 _Step 2 reduces_ Ω _b to the ball Sb, which is not necessary, but is efficient._ 2.3.3 Complexity Evaluation of the kernel at a single point requires _O_ (1) operations. So, _O_ ( _P_ ) operations are needed to evaluate all basis functions. The complexity, _O_ ( _P_ ), is also achieved when basis functions at a point can be computed recursively (as for the spherical basis functions). With _L_ = _O_ ( _P_ ) we can estimate the complexity of the “set” part of the algorithm as - _P_ <sup>3�</sup> _C_ <sup>(</sup> <sup>_set_</sup> <sup>)</sup> = _O_ (1) + _O_ ( _P_ ) + _O_ ( _P_ ) + _O_ ( _P_ ) + _O_ - _P_ <sup>3�</sup> + _,_ (12) - _O_ ( _P_ <sup>5</sup> <sup>_/_</sup> <sup>2</sup> )� = _O_ where we assumed that computation of the matrix decomposition (e.g., via QR) _O_ - _P_ <sup>3�</sup> where we assumed that computation of the matrix decomposition (e.g., via QR) _O_ - _P_ <sup>3�</sup> operations, as _P_ _∼_ _L_ . The term in the square brackets is the cost of the optional step for the Laplace kernel and spherical basis functions, using the method presented in Appendix B. For the “get” part of the algorithm, assuming that _Nb_ = _O_ ( _N_ ) and _P_ _≪_ _N_ we have _C_ <sup>(</sup> <sup>_get_</sup> <sup>)</sup> = _O_ ( _N_ )+ _O_ ( _N_ )+ _C_ <sup>(</sup> <sup>_FSA_</sup> <sup>)</sup> + _O_ ( _P_ )+ _O_ ( _P_ <sup>2</sup> )+[ _O_ ( _N_ )]+ _O_ ( _PN_ )+ _O_ ( _N_ ) = _O_ ( _PN_ )+ _C_ <sup>(</sup> <sup>_FSA_</sup> <sup>)</sup> _,_ (13) where _C_ <sup>(</sup> <sup>_FSA_</sup> <sup>)</sup> is the cost of the finite summation algorithm and the cost of the optional step of the algorithm is put in the square brackets (see Appendix C for this step for the Laplacian kernel). This cost for the brute force summation is _O_ ( _N_ <sup>2</sup> ), while if the FMM is used as the FSA it can be estimated as follows. In the FMM, generation of the data structure for _M_ _∼_ _N_ points is _O_ ( _Nl_ max) which for deep trees, _l_ max = _O_ (log _N_ ), results in formal _O_ ( _N_ log _N_ ) complexity. However, in practice the depth of the trees in three dimensions is relatively small (e.g. _l_ max _<_ 10) for sizes _N_ _<_ 10 <sup>7</sup> and even at larger _l_ max this cost is much smaller than the cost of the run part of the FMM. Moreover, the translation time in the FMM usually dominates over the time of generation and evaluation of expansions of complexity _O_ ( _PFMM_ _N_ ), where _PFMM_ is the size of the expansions in the FMM. For optimal _l_ max the FMM using _O_ - _PFMM_ <sup>2</sup> <sup>_α_</sup> - methods - _P_ <sup>2</sup> <sup>_α_</sup> _PFMM_ is the size of the expansions in the FMM. For optimal _l_ max the FMM using _O_ - _PFMM_ <sup>2</sup> <sup>_α_</sup> - methods for translations in three dimensions scale as _O_ ( _PFMM_ <sup>_α_</sup> <sup>_N_</sup> <sup>)</sup> <sup>or</sup> <sup>_O_</sup> <sup>(</sup> <sup>_P_</sup> _FMM_ <sup>_α_</sup> <sup>_N_</sup> <sup>),</sup> <sup>where</sup> 2 <sup><u>1</u></sup> <sup>⩽</sup> <sup>_α_</sup> <sup>⩽</sup> <sup><u>3</u></sup> 4 <sup>for</sup> <sup>well</sup> for translations in three dimensions scale as _O_ ( _PFMM_ <sup>_α_</sup> <sup>_N_</sup> <sup>)</sup> <sup>or</sup> <sup>_O_</sup> <sup>(</sup> <sup>_P_</sup> _FMM_ <sup>_α_</sup> <sup>_N_</sup> <sup>),</sup> <sup>where</sup> 2 <sup><u>1</u></sup> <sup>⩽</sup> <sup>_α_</sup> <sup>⩽</sup> <sup><u>3</u></sup> 4 <sup>for</sup> <sup>well</sup> studied kernels such as those for the Laplace and Helmholtz equations (in the latter case additional log <sup>_β_</sup> _N_, _β_ _>_ 0 factors appear in the algorithm complexity, which we drop in the present estimate). Optimized kernel independent FMM has complexity _O_ ( _PFMM_ _N_ ). This can be summarized as _FMM_ <sup>_α_</sup> <sup>_N_</sup> <sup>),</sup> <sup>where</sup> 2 <sup><u>1</u></sup> _FMM_ _FMM_ <sup>_α_</sup> <sup>_N_</sup> <sup>)</sup> <sup>or</sup> <sup>_O_</sup> <sup>(</sup> <sup>_P α_</sup> _C_ <sup>(</sup> <sup>_get_</sup> <sup>)</sup> = _O_ ( _PFMM_ <sup>_α_</sup> <sup>_N_</sup> <sup>) +</sup> <sup>_O_</sup> <sup>(</sup> <sup>_PN_</sup> <sup>)</sup> <sup>_,_</sup> <u>12</u> <sup>⩽</sup> <sup>_α_</sup> <sup>⩽</sup> <sup>1</sup> <sup>_._</sup> (14) Note that for the Laplacian kernel in three dimensions truncation numbers _p_ = _P_ <sup>1</sup> <sup>_/_</sup> <sup>2</sup> and _pFMM_ = _P_ <sup>1</sup> <sup>_/_</sup> <sup>2</sup> _FMM_ <sup>should</sup> <sup>increase</sup> <sup>as</sup> <sup>_O_</sup> <sup>(log</sup> <sup>_N_</sup> <sup>)</sup> <sup>for</sup> <sup>a</sup> <sup>fixed</sup> <sup>absolute</sup> <sup>_L∞_</sup> <sup>-norm</sup> <sup>error</sup> <sup>(see</sup> <sup>error</sup> <sup>bounds</sup> <sup>below),</sup> <sup>while</sup> they are constant for the relative _L_ 2-norm errors. 8 ### 3 Laplacian kernel A fundamental feature of the Laplace equation that any constant is a solution. Thus, one of the basis functions is a constant (say, _R_ 1 ( y ) _≡_ 1). Moreover, any constant satisfies periodic boundary conditions, and so this part of the solution cannot be determined, as _R_ 1 ( y ) belongs to the null-space of the Laplacian operator. System (9) also shows that _Al_ 1 = _R_ 1 - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - _−_ _R_ 1 - y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - = 0 for any _l_, so for any _L_ ⩾ _P_ the - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> operator. System (9) also shows that _Al_ 1 = _R_ 1 - y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - _−_ _R_ 1 - y - _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> - = 0 for any _l_, so for any _L_ ⩾ _P_ the rank of matrix A cannot exceed _L −_ 1, in which case the coefficient _C_ 1 can be arbitrary. To remove this rank deficiency of A we can simply remove the constant basis function from consideration, formulate the problem as the problem of determination of coefficients _Ct_ for _t_ = 2 _, ..., L_ and then add an arbitrary constant _C_ 1 to the solution. Indeed, in many cases the value of the potential is not important, as only differences and gradients determine physical quantities such as the electric field, velocities, forces, etc. For comparison with the FFT-based Poisson equation solutions however, it is desirable to obtain _C_ 1, in which case an additional condition, zero period average, needs to be imposed. These will be discussed in a separate subsection. Here we just mention that many other equations have the same problem (e.g. the biharmonic equation) and the null-space of some equations, such as the Helmholtz equation, may have larger dimension, and an analysis similar to the one for the Laplace equation presented here would be needed. _l_ _−_ _R_ 1 3.1 Spherical basis functions While the basis functions can be simply selected according to Eq. (6), we instead consider the closely related polynomial basis, in which case we can establish error bounds. In spherical coordinates ( _r, θ, ϕ_ ) related to the Cartesian coordinates via _x_ = _r_ sin _θ_ cos _ϕ,_ _x_ = _r_ sin _θ_ sin _ϕ,_ _z_ = _r_ cos _θ,_ (15) the local and multipole solutions of the Laplace equation in 3D can be represented as _Rn_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>r</sup> <sup>) =</sup> <sup>_αm_</sup> _n_ <sup>_m_</sup> _n_ <sup>_rnY_</sup> _n_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>_θ, ϕ_</sup> <sup>)</sup> <sup>_,_</sup> _Sn_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>r</sup> <sup>) =</sup> <sup>_βm_</sup> _n_ <sup>_m_</sup> _n_ <sup>_r−n−_</sup> <sup>1</sup> <sup>_Y_</sup> _n_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>_θ, ϕ_</sup> <sup>)</sup> <sup>_,_</sup> _n_ = 0 _,_ 1 _, . . .,_ _m_ = _−n, ..., n._ (16) Here _Rn_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>r</sup> <sup>) are the regular (local) spherical basis functions and</sup> <sup>_S_</sup> _n_ <sup>_m_</sup> Here _Rn_ <sup>_m_</sup> <sup>(</sup> <sup>r</sup> <sup>) are the regular (local) spherical basis functions and</sup> <sup>_S_</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>r</sup> <sup>) the singular (or multipole) spher-</sup> ical basis functions; _α_ <sup>_m_</sup> _n_ <sup>and</sup> <sup>_βm_</sup> _n_ <sup>are</sup> <sup>normalization</sup> <sup>constants</sup> <sup>which</sup> <sup>can</sup> <sup>be</sup> <sup>selected</sup> <sup>by</sup> <sup>convenience,</sup> <sup>and</sup> _Yn_ <sup>_m_</sup> <sup>(</sup> <sup>_θ, ϕ_</sup> <sup>) are the orthonormal spherical harmonics:</sup> <sup>_m_</sup> _n_ <sup>and</sup> <sup>_βm_</sup> _n_ _n_ <sup>_m_</sup> <sup>(</sup> <sup>_θ, ϕ_</sup> <sup>) are the orthonormal spherical harmonics:</sup> _Yn_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>_θ, ϕ_</sup> <sup>) =</sup> <sup>_N_</sup> _n_ <sup>_m_</sup> _n_ <sup>_mP_</sup> _n_ <sup>_|m|_</sup> _n_ <sup>_|m|_</sup> ( _µ_ ) _e_ <sup>_imϕ_</sup> _,_ _µ_ = cos _θ,_ (17) _Nn_ <sup>_m_</sup> <sup>= (</sup> <sup>_−_</sup> <sup>1)</sup> <sup>_m_</sup> <u>2</u> _<u>n</u>_ <u>+ 1</u> <u>(</u> _<u>n −|m|</u>_ <u>)!</u> _n_ = 0 _,_ 1 _,_ 2 _, ...,_ _m_ = _−n, ..., n,_ 4 _π_ ( _n_ + _|m|_ )! <sup>_,_</sup> where _Pn_ <sup>_|m|_</sup> where _Pn_ <sup>_|m|_</sup> ( _µ_ ) are the associated Legendre functions [33]. We will use the definition of the associated Legendre function _Pn_ <sup>_m_</sup> <sup>(</sup> <sup>_µ_</sup> <sup>) that is consistent with the value on the cut (</sup> <sup>_−_</sup> <sup>1</sup> <sup>_,_</sup> <sup>1) of the hypergeometric function</sup> Legendre function _Pn_ <sup>_m_</sup> <sup>(</sup> <sup>_µ_</sup> <sup>) that is consistent with the value on the cut (</sup> <sup>_−_</sup> <sup>1</sup> <sup>_,_</sup> <sup>1) of the hypergeometric function</sup> _Pn_ <sup>_m_</sup> <sup>(</sup> <sup>_z_</sup> <sup>) (see Abramowitz & Stegun, [33]).</sup> <sup>These functions can be obtained from the Legendre polynomials</sup> _Pn_ ( _µ_ ) via the Rodrigues’ formula 1 _−_ _µ_ <sup>2�</sup> <sup>_m/_</sup> <sup>2</sup> <sup>_<u>dm</u>_</sup> _dµ_ _dµ_ <sup>_n_</sup> - _n ._ (18) _Pn_ <sup>_m_</sup> <sup>(</sup> <sup>_µ_</sup> <sup>) = (</sup> <sup>_−_</sup> <sup>1)</sup> <sup>_m_</sup> <sup>�</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>_µ_</sup> <sup>) = (</sup> <sup>_−_</sup> <sup>1)</sup> <sup>_m_</sup> <sup>�</sup> _dµ_ <sup>_<u>dmm</u>_</sup> <sup>_Pn_</sup> <sup>(</sup> <sup>_µ_</sup> <sup>)</sup> <sup>_,_</sup> _Pn_ ( _µ_ ) = 2 <sup>_n_</sup> <u>1</u> _n_ ! _dµd_ <sup>_n_</sup> _µ_ <sup>2</sup> _−_ 1 Straightforward computation of these basis functions involves several relatively costly operations with special functions and use of spherical coordinates. Further, as defined above, these functions are complex, which is an unnecessary expense for real valued computations. In [19] real basis functions were defined as - Re _{Snm_ <sup>_},_</sup> _m_ ⩾ 0 (19) Im _{Sn_ <sup>_m},_</sup> _m <_ 0 <sup>_,_</sup> 9 _R_ - _n_ <sup>_m_</sup> <sup>=</sup> - Re _{Rnm_ <sup>_},_</sup> _m_ ⩾ 0 _S_ - _n_ <sup>_m_</sup> <sup>=</sup> Im _{Rn_ <sup>_m},_</sup> _m <_ 0 <sup>_,_</sup> with _Rn_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>and</sup> <sup>_S_</sup> _n_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>defined via Eq.</sup> <sup>(16) are</sup> - <u>4</u> _<u>π</u>_ <u>(</u> _<u>n −</u>_ _<u>m</u>_ <u>)!(</u> _<u>n</u>_ <u>+</u> _<u>m</u>_ <u>)!</u> _,_ (20) 2 _n_ + 1 _α_ <sup>_m_</sup> _n_ <sup>= (</sup> <sup>_−_</sup> <sup>1)</sup> <sup>_n_</sup> ~~�~~ <u>4</u> _<u>π</u>_ (2 _n_ + 1) ( _n −_ _m_ )!( _n_ + _m_ )! <sup>_,_</sup> _β_ <sup>_m_</sup> _n_ <sup>=</sup> _n_ = 0 _,_ 1 _, ....,_ _m_ = _−n, ..., n._ Only local basis functions are needed here, and can be computed via an efficient recursive process, without spherical coordinates, _R_ �0 <sup>0</sup> <sup>= 1</sup> <sup>_,_</sup> _R_ �1 <sup>1</sup> <sup>=</sup> <sup>_−_</sup> <sup><u>1</u></sup> _R_ �1 <sup>_−_</sup> <sup>1</sup> = <sup><u>1</u></sup> (21) 2 <sup>_x,_</sup> 2 <sup>_y,_</sup> - _yR_ <sup><u>�</u></sup> _|_ <sup>_|_</sup> _m_ <sup>_m_</sup> _|−_ <sup>_|−_</sup> 1 <sup>1</sup> _|_ <sup>_|_</sup> _m_ <sup>_m_</sup> _|−_ <sup>_|−_</sup> 1 <sup>1</sup> <sup>_−_</sup> <sup>_xR_</sup> <sup><u>�</u></sup> _|_ <sup>_−|_</sup> _m_ <sup>_m_</sup> _|−_ <sup>_|_</sup> 1 <sup>+1</sup> _,_ _|m|_ = 2 _,_ 3 _, ...._ 2 _|m|_ _|m|−_ 1 _R_ - _|_ <sup>_|_</sup> _m_ <sup>_m_</sup> _|_ <sup>_|_</sup> <sup>=</sup> <sup>_−_</sup> - _xR_ <sup><u>�</u></sup> _|_ <sup>_|_</sup> _m_ <sup>_m_</sup> _|−_ <sup>_|−_</sup> 1 <sup>1</sup> _|_ <sup>_|_</sup> _m_ <sup>_m_</sup> _|−_ <sup>_|−_</sup> 1 <sup>1</sup> <sup>+</sup> <sup>_y_</sup> <sup><u>�</u></sup> <sup>_R_</sup> _|_ <sup>_−|_</sup> _m_ <sup>_m_</sup> _|−_ <sup>_|_</sup> 1 <sup>+1</sup> _|m|−_ 1 2 _|m|_ _,_ _R_ - _|_ <sup>_−|_</sup> _m_ <sup>_m_</sup> _|_ <sup>_|_</sup> = _|m|−_ 1 _R_ - _|_ <sup>_m_</sup> _m|_ +1 <sup>=</sup> <sup>_−z_</sup> <sup>�</sup> <sup>_R_</sup> _|_ <sup>_m_</sup> _m|_ <sup>_,_</sup> _m_ = 0 _, ±_ 1 _, ....,_ _<u>n</u>_ <sup>_m_</sup> _<u>−</u>_ <u>1</u> <sup>+</sup> <sup>_r_</sup> <sup>2 �</sup> <sup>_R_</sup> _<u>n</u>_ <sup>_m_</sup> _<u>n</u>_ _R_ - _n_ <sup>_m_</sup> <sup>=</sup> <sup>_−_</sup> <sup>(2</sup> <sup>_n −_</sup> <sup>1)</sup> <sup>_z_</sup> <sup><u>�</u></sup> <sup>_Rm_</sup> ( _n −|m|_ _<u>n−</u>_ <u>1</u> <sup>+</sup> <sup>_r_</sup> <sup>2 �</sup> <sup>_R_</sup> _<u>n</u>_ <sup>_m_</sup> _<u>−</u>_ <u>2</u> <sup>_−_</sup> <sup>1)</sup> <sup>_z_</sup> <sup><u>�</u></sup> <sup>_Rm_</sup> _,_ _n_ = _|m|_ + 2 _, ....,_ _m_ = _−n, ..., n._ ( _n −|m|_ ) ( _n_ + _|m|_ ) While this basis is good for the FMM, the matrix A for fitting _φfar_ was found to be poorly conditioned, because the functions decay strongly. We fix this problem using the following renormalized basis _R_ - _n_ <sup>_m_</sup> <sup>=</sup> ~~�~~ ( _n −_ _m_ )!( _n_ + _m_ )! _R_ <sup>�</sup> _n_ <sup>_m,_</sup> _n_ = 0 _,_ 1 _, ....,_ _m_ = _−n, ..., n._ (22) was from the complex basis _Rn_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>,</sup> <sup>where</sup> <sup>_α_</sup> _n_ <sup>_m_</sup> _n_ <sup>_m_</sup> <sup>=</sup> This basis can be obtained in the same manner as _R_ - _n_ <sup>_m_</sup> ( _−_ 1) <sup>_n_</sup> <sup>~~�~~</sup> 4 _π/_ (2 _n_ + 1). Complex basis functions _Rn_ <sup>_m_</sup> <sup>with</sup> <sup>a</sup> <sup>similar</sup> <sup>normalization</sup> <sup>_αm_</sup> _n_ ( _−_ 1) <sup>_n_</sup> <sup>~~�~~</sup> 4 _π/_ (2 _n_ + 1). Complex basis functions _Rn_ <sup>_m_</sup> <sup>with</sup> <sup>a</sup> <sup>similar</sup> <sup>normalization</sup> <sup>_αm_</sup> _n_ <sup>(without</sup> <sup>the</sup> <sup>factor</sup> ( _−_ 1) <sup>_n_</sup> ) were used in [37]. Note further that the _p_ -truncated expansion of a harmonic function _φfar_ over the basis (22) can be written as _P_ _t_ =1 _n_ <sup>_m_</sup> <sup>(</sup> <sup>y</sup> <sup>)</sup> <sup>_,_</sup> <sup>_P_</sup> <sup>=</sup> <sup>_p_</sup> <sup>2</sup> <sup>_,_</sup> _φfar_ ( y ) = _p−_ 1 _n_ - _n_ =0 _m_ = _−n_ _C_ - _n_ <sup>_mR_</sup> <sup>�</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>y</sup> <sup>) =</sup> _CtRt_ ( y ) _,_ _Ct_ = _C_ <sup>�</sup> _n_ <sup>_m_</sup> _n_ <sup>_m,_</sup> <sup>_Rt_</sup> <sup>(</sup> <sup>y</sup> <sup>) =</sup> <sup>_R_</sup> <sup>�</sup> _n_ <sup>_m_</sup> _t_ = ( _n_ + 1) <sup>2</sup> _−_ ( _n −_ _m_ ) _,_ _n_ = 0 _,_ 1 _, ...., p −_ 1 _,_ _m_ = _−n, ..., n._ (23) The latter form of the sum, where stacking of coefficients is used, is consistent with (7). The gradient of the potential is needed to compute the force. This can be computed as _P_ _t_ =2 _∇φfar_ ( y ) = _p−_ 1 _n_ =1 _n_ _m_ = _−n_ E - <sup>_m_</sup> _n_ <sup>_R_</sup> <sup>�</sup> _n_ <sup>_m_</sup> <sup>(</sup> <sup>y</sup> <sup>) =</sup> E _tRt_ ( y ) _,_ (24) where E <sup>�</sup> _n_ <sup>_m_</sup> <sup>are vectors in R3.</sup> <sup>In [39] one can find relations between the coefficients of the potential and the</sup> gradient. 3.2 Error bounds For the Laplacian kernel _K_, Eq. (2), _p_ -truncated expansions (5) over the basis _{Rn_ <sup>_m}_</sup> <sup>,</sup> <sup>Eq.</sup> <sup>(16),</sup> <sup>have</sup> <sup>a</sup> well-known error bound - _p_ _,_ _p_ = _P_ <sup>1</sup> <sup>_/_</sup> <sup>2</sup> _._ (25) 10 - _<u>R</u>_ <u>0</u> _|_ x _j|_ ��� _ϵj_ ( _P_ ) ��� _<_ <u>1</u> _|_ x _j| −_ _R_ 0 The expansion error (7) due to all sources located in R <sup>3</sup> _\_ Ω _b_ then can be bounded as x _j_ _∈_ R <sup>3</sup> _/_ Ω _b_ - _p_ (26) <u>max</u> _<u>|qi|</u>_ _<_ ��� _ϵ_ ( _P_ )��� _Rb −_ _R_ 0 <u>max</u> _<u>|qi|</u>_ ⩽ _Rb −_ _R_ 0 R <sup>3</sup> _/_ Ω _b_ x _j /∈_ Ω _b_ - _<u>R</u>_ <u>0</u> - _p_ ⩽ <sup><u>max</u></sup> <sup>_<u>|qi|</u>_</sup> _|_ x _j|_ _Rb −_ _R_ 0 - _<u>R</u>_ <u>0</u> _|_ x _j|_ - _p_ _dV,_ _n_ ( x ) - _<u>R</u>_ <u>0</u> _r_ _n_ ( x ) = x _j_ _∈_ R <sup>3</sup> _/_ Ω _b_ _δ_ ( x _−_ x _j_ ) _,_ _r_ = _|_ x _| ._ Here we introduced the the number density _n_ ( x ), which for integral estimates can be replaced with a constant density _n_ 0 = _N/V_ 0, where _V_ 0 is the volume of box Ω0, _V_ 0 = _d_ 1 _d_ 2 _d_ 3. In this case the integral can be evaluated as - _∞_ _Rb_ - _<u>R</u>_ <u>0</u> _r_ _R_ 0 - _p_ _<u>b</u>_ _r_ <sup>2</sup> _dr_ = <sup>4</sup> <sup>_πn_</sup> <sup><u>0</u></sup> <sup>_R_</sup> <sup>3</sup> _p −_ 3 _<u>b</u>_ <sup>_πn_</sup> <sup><u>0</u></sup> <sup>_R_</sup> <sup>3</sup> _λ_ = <sup>_<u>Rb</u>_</sup> _p −_ 3 <sup>_λ−p,_</sup> _R_ 0 - _p_ _dV_ _∼_ 4 _πn_ 0 R <sup>3</sup> _/_ Ω _b_ - _<u>R</u>_ <u>0</u> _n_ ( x ) _r_ _._ (27) Hence, we have an approximate error bound _<u>b</u>_ ��� _ϵ_ ( _P_ )��� ≲ 4 _πn_ <u>0</u> _R_ 3 _Rb −_ _R_ 0 <u>max</u> _<u>|qi|</u>_ (28) _p −_ 3 <sup>_λ−p._</sup> _√_ <sup><u>1</u></sup> 2 <sup>_d_</sup> For a cubic domain we have _d_ 1 = _d_ 2 = _d_ 3 = _d, R_ 0 = <sup><u>1</u></sup> 2 For a cubic domain we have _d_ 1 = _d_ 2 = _d_ 3 = _d, R_ 0 = <sup><u>1</u></sup> 2 <sup>_d_</sup> 3 _, Rb_ = _λR_ 0, and we get ��� _ϵ_ ( _P_ )��� ≲ <u>3</u> _<u>πN</u>_ <u>max</u> _d_ _<u>|qi|</u>_ ( _λ −_ 1) ( _p_ <u>1</u> _−_ 3) _λ_ <sup>_p−_</sup> <sup>3</sup> <sup>_._</sup> <u>1</u> ( _λ −_ 1) ( _p −_ 3) _λ_ <sup>_p−_</sup> <sup>3</sup> <sup>_._</sup> (29) The actual error achieved in practice is expected to be much smaller than this estimate since it neglects cancellation effects due to the total charge neutrality. Also in the above equation one can set _d_ = 1 to obtain a non-dimensional measure of the absolute error (since the Laplace equation is scale-independent). 3.3 Optimization when using the FMM There are three free parameters, _p_, _pFMM_, and _λ_, which can be selected to optimize algorithm performance. Assuming that the number of charges, their intensities and distribution as well as the domain Ω0 are fixed, and computations performed with some prescribed tolerance, _ϵ_, the optimization problem can be formulated as _ϵP_ ( _p, λ_ ) = _ϵ,_ _ϵFMM_ ( _pFMM_ _, λ_ ) = _ϵ,_ _C_ <sup>(</sup> <sup>_get_</sup> <sup>)</sup> ( _p, pFMM_ _, λ_ ) _→_ min _,_ (30) where _ϵP_ and _ϵFMM_ are the error bounds for the periodization and the FMM respectively, while _C_ <sup>(</sup> <sup>_get_</sup> <sup>)</sup> is the cost of the “get” step. In practice, these performance dependences should be determined experimentally, using the qualitative theoretical estimates provided below for guidance. Our tests show that the cost of the FMM is the major contributor to the overall cost of the algorithm. We set the parameter _pFMM_ by the prescribed accuracy _ϵ_, and approximate _ϵP_ ( _p, λ_ ) as _ϵP_ ( _p, λ_ ) = _BP λ_ <sup>_−p_</sup> _,_ _p_ ( _λ_ ) = <sup><u>ln (</u></sup> <sup>_<u>BP /ϵ</u>_</sup> <sup><u>)</u></sup> _,_ (31) ln _λ_ where _BP_ is some constant. The number of evaluation points is _Mb_ = _N_ +2 _L_, while the number of sources to be summed is _Nb_ = _Agf_ _λ_ <sup>3</sup> _N_, where _Agf_ is a geometric factor, _._ (32) 11 _Agf_ = <sup>_<u>π</u>_</sup> 6 - _d_ <sup>2</sup> <u>1</u> <sup>+</sup> <sup>_d_</sup> <sup>2</sup> <u>2</u> <sup>+</sup> <sup>_d_</sup> <u>3</u> <sup>2</sup> �3 _/_ 2 _d_ 1 _d_ 2 _d_ 3 For a perfectly optimized FMM the complexity estimate is provided in Appendix A, Eq. (46), where the ratio of the domains occupied by the sources and evaluation points is _Vs/Vr_ = _Bgf_ _λ_ <sup>3</sup>, where 1 ⩽ _Bgf_ ⩽ _Agf_ and _Bgf_ tends to 1 and _Agf_ at relatively low and high levels of subdivision, _l_ max, respectively. This is due to the fact that the check point set is distributed over the surface of a sphere, and they should provide a negligible contribution to the overall complexity at large _l_ max. Assuming _L ∼_ 2 _p_ <sup>2</sup> the cost can be estimated as ~~�~~ _Agf_ _C_ <sup>(</sup> <sup>_FMM_</sup> <sup>)</sup> = _Ctd_ _Bgf_ _MN_ + _CgenAgf_ _Nλ_ <sup>3</sup> + _CevM,_ (33) _M_ = _N_ 1 + <sup><u>4</u></sup> <sup>_<u>p</u>_</sup> <sup>2 (</sup> <sup>_<u>λ</u>_</sup> <sup><u>)</u></sup> _N_ _._ It is seen that the complexity is a sum of the decreasing and increasing functions, a minimum at some _λ_ = _λopt_ is expected. It is not difficult to find it for the case when _λ_ is close to 1 and 4 _p_ <sup>2</sup> _≪_ _N._ Indeed, introducing _ξ_ = _λ −_ 1 _≪_ 1 we have from Eq. (31) _p_ _∼_ _ξ_ <sup>_−_</sup> <sup>1</sup> ln ( _BP /ϵ_ ) and expanding Eq. (33) at small _ξ_ and _p_ <sup>2</sup> _/N_ we obtain - _Agf_ _Bgf_ + 3 _CgenAgf_ _ξ_ (34) �1 _/_ 2 + 2 _Cev_ �1 _/_ 2 + _CgenAgf_ + _Cev_ + <sup><u>2 ln2 (</u></sup> <sup>_<u>BP /ϵ</u>_</sup> <sup><u>)</u></sup> _Nξ_ <sup>2</sup> _Ctd_ _C_ <sup>(</sup> <sup>_FMM_</sup> <sup>)</sup> = _N_ _Ctd_ _._ - _Agf_ _Bgf_ This function has a minimum at - _Agf_ _Bgf_ ��1 _/_ 3 �1 _/_ 2 + 2 _Cev_ _._ (35) _ξopt_ = - <u>4 ln</u> <sup>2</sup> <u>(</u> _<u>BP /ϵ</u>_ <u>)</u> 3 _CgenAgf_ _N_ _Ctd_ which shows that at large _N_ optimal _λ_ should be shifted towards the limit _λ_ = 1 _._ Also this shows that at large _N_ we have _p_ <sup>2</sup> _/N_ _∼_ _N_ <sup>_−_</sup> <sup>1</sup> <sup>_/_</sup> <sup>3</sup> _→_ 0, which justifies the above asymptotic solution, and shows that the part of the overall cost depending on _λ_ in Eq. (34) tends to zero. 3.4 Constant shift in potential Several methods can be proposed to determine coefficient _C_ 1 if it is needed. In particular because we choose to compare our results with the Ewald summation method, we need it. Of course, the simplest case is that when the potential value, _φ_ 0, is prescribed or known at some point y 0, in which case _C_ 1 = _φ_ 0 _−_ _φnear_ ( y 0) _−_ _P_ _t_ =2 _CtRt_ ( y 0) _._ (36) Note then that the Fourier based methods for periodization of Green’s function produce solution with some mean of the potential _φmean_ (since the zero mode of the Fourier transform is zeroed). This particular solution corresponds to _⟨φ⟩_ Ω0 = <sup><u>1</u></sup> _V_ 0 Ω0 _φ_ ( y ) _dV_ ( y ) = _φmean._ (37) In this case for consistency we should set _C_ 1 = _φmean −_ <sup><u>1</u></sup> _V_ 0 Ω0 _t_ <sup>(0)</sup> = <sup><u>1</u></sup> _V_ 0 _φnear_ ( y ) _dV_ ( y ) _−_ _P_ _t_ =2 _CtRt_ <sup>(0)</sup> _t_ <sup>(0)</sup> <sup>_,_</sup> _Rt_ <sup>(0)</sup> Ω0 _Rt_ ( y ) _dV_ ( y ) _._ (38) 12 As shown in Appendix D, the Ewald summation produces _φmean_ = 0, and we do the same for our method. Integrals _Rt_ <sup>(0)</sup> can be computed relatively easy, since _Rt_ ( y ) are polynomials in the Cartesian coordinates of y of degree which does not exceed _p −_ 1, for which case exact quadratures exist. In fact, for a given box size ratio (e.g. for cube) these can be precomputed, scaled and used independently of particular source distribution (see Appendix B). The first integral can be represented as a sum <u>1</u> _V_ 0 Ω0 Ω0 _qj_ Φ0 ( x _j_ ) _,_ Φ0 ( x ) = <sup><u>1</u></sup> _V_ 0 _φnear_ ( y ) _dV_ ( y ) = x _j_ _∈_ Ω _b_ _K_ ( y _−_ x ) _dV_ ( y ) _._ (39) In Appendix C we provide analytical expressions for functions Φ0 ( x ). Despite their unwieldiness, their computation for a given x is _O_ (1). Overall it is a _O_ ( _N_ ) procedure to compute the sum and constant _C_ 1, which is consistent with the overall complexity of the method. There also exist symmetries for periodic location of sources, which can be used to accelerate these computations, if this becomes an issue. Note also that results of Appendix C can be applied for computation of integrals representing the far field (38) in the case when the RBF, Eq. (6), is used. ### 4 Numerical tests To check the accuracy and performance of the method we conducted several numerical tests. There are very few known analytical solutions, so for comparison we also implemented and tested a simple version of the Ewald summation method as an alternative method (see Appendix D). 4.1 Small size tests As validation, we performed tests with different number of sources in the box. First, we conducted a small size test, with a cubic domain Ω0 and eight sources of charges _qi_ = _±_ 1 located at the vertices, so that neighboring sources have opposite charges and the infinite domain forms a regular equispaced grid. Physically this corresponds to crystal structures, such as formed by molecules NaCl _._ As the reference for accuracy tests we computed the Madelung constant for this crystal [38], _N_ _i_ =1 _Ma_ Na = _−Ma_ Cl = _φ_ ( y Na) = _R_ NaCl p _qiK_ ( y Na _−_ x _i_ + p ) (40) = _∞_ _j,k,l_ = _−∞,_ _j_ <sup>2</sup> + _k_ <sup>2</sup> + _l_ <sup>2</sup> <sup>_̸_</sup> =0 <u>(</u> _<u>−</u>_ <u>1)</u> <sup>_j_</sup> <sup>+</sup> <sup>_k_</sup> <sup>+</sup> <sup>_l_</sup> ( _j_ <sup>2</sup> + _k_ <sup>2</sup> + _l_ <sup>2</sup> ) <sup>2</sup> <sup>=</sup> <sup>_−_</sup> <sup>1</sup> <sup>_._</sup> <sup>74756459463318219</sup> <sup>_...,_</sup> where y _Na_ is the location of Na atom and _R_ NaCl is the distance between the closest neighbor atoms (in the tests we used _d_ 1 = _d_ 2 = _d_ 3 = 1, in which case _R_ NaCl = 0 _._ 5). We also computed this constant using the Ewald summation and compared spatial distributions of the potential. As the measures of the relative errors we used _M_ _i_ =1 _ϵ_ 2 = ����� _,_ ��� _φ_ ( _Present_ ) _−_ _φ_ ( _Ewald_ )���2 <u>���</u> _φ_ ( _Ewald_ )���2 _,_ _∥φ∥_ 2 = ~~�~~ <u>�</u> - <sup><u>1</u></sup> _M_ _φ_ <sup>2</sup> ( y _i_ ) _,_ (41) _ϵM_ = _<u>Ma</u>_ <sup>(</sup> <sup>_comp_</sup> <sup>)</sup> _Ma_ <sup>(</sup> <sup>_true_</sup> <sup>)</sup> ����� _Ma_ <sup>(</sup> <sup>_true_</sup> <sup>)</sup> <sup>_−_</sup> <sup>1</sup> where y _i_ _∈_ Ω0 are the receivers located on the grid used for the Ewald summation. For the high accuracy test, we selected a 44 _×_ 44 _×_ 44 grid, _ξ_ = 12, and the sampling neighborhood for each source _Nr_ = 20 for the Ewald method (see Appendix D). This setting provides _ϵM_ _≈_ 10 <sup>_−_</sup> <sup>14</sup> (i.e. 14 13 digits of the Madelung constant). High accuracy test for the present method was performed with _p_ = 35 _,_ _√_ _Rb_ = 1 _._ 5 - _λ_ = _Rb/R_ 0 = 3�, which resullts in errors _ϵM_ _≈_ 6 _·_ 10 <sup>_−_</sup> <sup>14</sup> and _ϵ_ 2 _≈_ 9 _·_ 10 <sup>_−_</sup> <sup>13</sup> . For the middle _Rb_ = 1 _._ 5 - _λ_ = _Rb/R_ 0 = 3�, which resullts in errors _ϵM_ _≈_ 6 _·_ 10 <sup>_−_</sup> <sup>14</sup> and _ϵ_ 2 _≈_ 9 _·_ 10 <sup>_−_</sup> <sup>13</sup> . For the middle accuracy test we used 24 _×_ 24 _×_ 24 grid, _ξ_ = 10, and the sampling neighborhood for each source _Nr_ = 10, in which case the Ewald method results in _ϵMa_ _≈_ 6 _·_ 10 <sup>_−_</sup> <sup>9</sup> . In our method we used _p_ = 16 _,_ _Rb_ = 1 _._ 5, which produced errors _ϵM_ _≈_ 7 _·_ 10 <sup>_−_</sup> <sup>8</sup> and _ϵ_ 2 _≈_ 10 <sup>_−_</sup> <sup>6</sup> . These tests show that errors _ϵM_ and _ϵ_ 2 are related and the former one approximately one order of magnitude smaller than the latter. So in the following accuracy tests we measured only _ϵM_ for our method, which is independent of the Ewald summation routine. These computations were performed for the check points y _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> distributed on the Gauss spherical grid. - _λ_ = _Rb/R_ 0 = _√_ _l_ <sup>(</sup> <sup>_c_</sup> <sup>)</sup> distributed on the Gauss spherical grid. 10−20 10−16 10−12 10−8 10−4 Theoretical error 3 2.5 2 1.5 1 5 10 15 20 25 30 p log10(εΜ) −2 −4 −6 −8 −10 −12 −14 −16 100 10−4 10−8 10−12 10−16 Madelung Constant for NaCl Figure 3: The relative error, _ϵM_, in computations of the Madelung constant for NaCl crystal using the present method (colors). The chart on the graph compares the theoretical computational error, _ϵth_ = _Cϵ_ ( _R_ 0 _/Rb_ ) <sup>_p_</sup> with the actual error for all data points used to plot the chart on the left. Ideally, the graph on the right should be a straight line (shown). Constant _Cϵ_ was set as _ϵM_ _/ϵth_ for _p_ = 10 and _λ_ = _Rb/R_ 0 = 1 _._ 5. Figure 3 shows the dependence of _ϵM_ computed for 651 values of parameters _λ_ = _Rb/R_ 0 and _p_ controlling the accuracy. The chart on the right shows that the computational errors are consistent with theoretical error bound _ϵth_ = _Cϵ_ ( _R_ 0 _/Rb_ ) <sup>_p_</sup> . For very small values of _ϵth_ the computational errors are affected by the double precision roundoff errors. This shows that the parameters can be set to achieve the required accuracy. 3 _._ Table 1: Error _ϵM_ for different check point distributions at _λ_ = _Rb/R_ 0 = _√_ _<u>p</u>_ <u>Gauss sph.</u> <u>grid</u> <u>T(256)</u> <u>T(400)</u> <u>Rand.</u> _<u>L</u>_ <u>= 2</u> _<u>p</u>_ <sup><u>2</u></sup> <u>Rand.</u> _<u>L</u>_ <u>= 3</u> _<u>p</u>_ <sup><u>2</u></sup> <u>Rand.</u> _<u>L</u>_ <u>= 5</u> _<u>p</u>_ <sup><u>2</u></sup> <u>8</u> <u>4.85(-6)</u> <u>3.87(-6)</u> <u>3.90(-6)</u> <u>3.39(-5)</u> <u>2.21(-5)</u> <u>1.92-(5)</u> <u>12</u> <u>1.17(-7)</u> <u>4.60(-8)</u> <u>6.28(-8)</u> <u>1.53(-6)</u> <u>1.04(-6)</u> <u>5.10(-7)</u> <u>16</u> <u>7.16(-8)</u> <u>3.43(-7)</u> <u>2.74(-8)</u> <u>6.26(-7)</u> <u>3.50(-7)</u> <u>1.85(-7)</u> Table 1 shows some results of the tests with different distributions of the check points. Here for the case of random distributions for any set size we performed 100 runs and the maximum error is reported. It is seen that the lowest errors were achieved using the Thomson point distributions. The number of such points should be not less than _p_ <sup>2</sup> _−_ 1, which is necessary (but not sufficient) condition for the use of the present method. When the number of check points approaches _p_ <sup>2</sup> _−_ 1 the accuracy of the method deteriorates. Con 14 clusion here is that if a database of the Thomson points or some analogous method of deterministic uniform distribution of the check points exsist, then that method is recommended. In fact, the Gauss spherical grid also provides good results (the order of the error is the same). This grid is easy to generate for any _p_, and that is why this was used in the tests. The error for random distributions is about one order of magnitude larger than that for the Gauss spherical grid or for the Thomson points. It slowly decays with the growing oversampling. Perhaps, there is no reason to use random sets, which anyway show strong dependence of the error on _p_ and also can be used if needed. We also performed the accuracy test for different basis functions (RBF, Eq. (6)), where 256 Thomson sampling sources x <sup>(</sup> _t_ <sup>_s_</sup> <sup>)</sup> were located on ball _Sb_, while the check points were the same as for the last line of Table 1 ( _p_ = 16). In this case we obtained _ϵM_ _≈_ 1 _._ 32 _·_ 10 <sup>_−_</sup> <sup>7</sup>, which is approximately two times larger than the error when using the spherical basis functions. 4.2 Large scale tests The large scale tests were conducted for systems with _N_ up to 2 <sup>23</sup> _∼_ 10 <sup>7</sup>, for which _O_ ( _N_ log _N_ ) summation algorithms are needed. The main purpose of these tests was to check the performance and scaling of the present algorithm. The reported wall clock times were measured on an Intel QX6780 (2.8 GHz) 4 core PC with 8 GB RAM and averaged over ten runs of the same case. We used a well-tested standard version of the FMM for the Laplacian kernel in three dimensions, where all translations are performed with _O_ - _p_ <sup>3</sup> _FMM_ - complexity using the rotation-coaxial translation-back ro - _p_ <sup>3</sup> all translations are performed with _O_ - _p_ <sup>3</sup> _FMM_ - complexity using the rotation-coaxial translation-back ro tation (RCR) algorithm. The code implements a standard multipole-to-local translation stencil with the maximum 189 neighborhood (see details in [40]). The code was parallelized for 4 core CPU machine using OpenMP with parallelization efficiency close to 100%. While faster versions of the FMM were available to the researchers (say utilizing graphics processors, [19]), the version used for the tests was selected to provide consistent scaling of different algorithm parts, as the periodization algorithm was implemented on multicore CPUs. For the tests we treated the FMM as a black box FSA and used it “as is” without any modifications. First we ran accuracy tests, when the charges have random intensity, _±_ 1, and zero total sum and are located inside a unit cube at regularly spaced grid points (subgrids of 60 _×_ 60 _×_ 60 grid). The potential at charge locations (reference solution) was computed with high accuracy using the Ewald method (grid 60 _×_ 60 _×_ 60, _ξ_ = 15 _, Nr_ = 24). The present method with _p_ = 40 and _pFMM_ = 30 for this case showed error _ϵ_ 2 _≈_ 1 _._ 2 _·_ 10 <sup>_−_</sup> <sup>10</sup> . Further performance tests were conducted with lower tolerance to ensure that the error of the reference solution does not affect error and optimization studies. In all cases the Gauss spherical grid ( _L_ = 2 _p_ <sup>2</sup> _−_ _p_ ) was used for the check points. Figure 4 illustrates distribution of potentials generated by 27,000 charges in a box computed by two different methods sampled on 60 _×_ 60 _×_ 60 grid. It is seen that periodic solutions obtained using the Ewald method and present method are almost the same ( _ϵ_ 2 _<_ 5 _·_ 10 <sup>_−_</sup> <sup>7</sup> ), while substantially different from the non-periodic solution (the free field generated by the same sources). This also shows that accounting for the near field (sources in Ω _b_ ) substantially improves the non-periodic solution, but the far field component is still of magnitude comparable with the near field. This far field is smooth and its addition to the near field results in an accurate periodic solution. As the theory predicts existence of an optimal value of parameter _λ_ for a given tolerance we conducted tests to determine this value experimentally. Tables 2 and 3 display the results of these tests. Here we computed potential alone (no gradient computations). The difference between the cases shown in the tables is in the number of charges (27,000 and 216,000, respectively). In these tests _pFMM_ = 16, which provided the relative _L_ 2-norm error of the FMM itself smaller than tolerance _ϵtol,_ 2. Since the truncation number _p_ changes discretely, there is the minimal integer _p_ = _p_ min at which _ϵ_ 2 _<_ _ϵ_ 2 _,tol_, where _ϵ_ 2 is defined by Eq. (41). This _p_ is slightly depends on _N_ and is shown in the tables. The periodization algorithm was executed with this _p._ The tables also show the number of sources, _Nb_, and the total number of evaluation points, 15 _FMM_ Ewald summation 0.5 0 −0.5 −0.5 0 0.5 Present method 0.5 0 −0.5 −0.5 0 0.5 −0.5 −0.5 0 0.5 periodic − nonperiodic 0.5 400 200 400 200 400 200 nonperiodic sum 0.5 0 φ 0 0 φ 0 0 φ 0 0 0 0 −200 −400 400 200 −0.5 −0.5 0 0.5 Near field, λ = 1.3 0.5 −200 −400 200 −200 160 140 120 100 −0.5 −0.5 0 0.5 Far field, λ = 1.3 0.5 0 −0.5 −0.5 0 0.5 0 0 0 φ φ 0 −200 −400 −600 φ −200 −400 Figure 4: Comparison of periodic solutions at the median plane _z_ = 0, obtained by different methods for 30 _×_ 30 _×_ 30 sources of random intensity _qi_ = _±_ 1 in a unit box. The top row shows respectively the periodic solution obtain by the Ewald method, the non-periodic solution, and the difference between the former and latter potentials. The bottom row shows the periodic solution obtained by the method proposed in this paper, and its near and far field components for _λ_ = 1 _._ 1. Computations performed with _p_ = 80 _, pFMM_ = 16. _N_ +2 _L_ . These numbers provide data of the size of the problem solved by the FMM. It is seen that the FMM execution time is a non-monotonic function of _λ_, as at the increasing _λ_ we have increasing _Nb_ = _O_ - _Nλ_ <sup>3�</sup> and decreasing _L ∼_ 2 _p_ <sup>2</sup> min <sup>.</sup> <sup>It is noticeable that despite of substantial change of</sup> <sup>_Nb_</sup> <sup>the FMM time does not</sup> change significantly. The time of the “set” part of the algorithm increases dramatically at large _p_ (as _p_ <sup>6</sup> ). However, for a given _p_ and computational domain the pseudoniverse matrix can be precomputed and stored independently on the number of charges and their distribution. So this should not be considered as a limiting factor. These tests bring us to conclusion that practical optimal _λ_ are in the range _∼_ 1 _._ 2 _−_ 1 _._ 5. Smaller or larger _λ_ can be also used based on particular problems and other issues (e.g. memory complexity). Effect of the basis functions on the algorithm performance is shown in Table 4. As in the small size tests 256 Thomson points were selected as the centers of the RBFs. Comparison of the performance obtained Table 2: Performance for different _λ_ for tolerance _ϵtol,_ 2 = 5 _·_ 10 <sup>_−_</sup> <sup>7</sup> at _N_ = 27 _,_ 000, _pFMM_ = 16 _._ _λ_ _p_ min _T_ <sup>(</sup> <sup>_get_</sup> <sup>)</sup> _,_ s _T_ <u>(</u> <sup>(</sup> _<u>no</u>_ <sup>_get_</sup> _<u>mean</u>_ <sup>)</sup> <u>)</u> <sup>_,_</sup> <sup>s</sup> _T_ <sup>(</sup> <sup>_F MM_</sup> <sup>)</sup> _,_ s _Nb_ _N_ + 2 _L_ _T_ <sup>(</sup> <sup>_set_</sup> <sup>)</sup> _,_ s <u>1.1</u> <u>80</u> <u>2.81</u> <u>2.64</u> <u>2.03</u> <u>97,780</u> <u>52,440</u> <u>150</u> <u>1.2</u> <u>44</u> <u>1.95</u> <u>1.73</u> <u>1.58</u> <u>126,744</u> <u>34,656</u> <u>5.31</u> <u>1.3</u> <u>34</u> <u>2.03</u> <u>1.78</u> <u>1.66</u> <u>161,072</u> <u>31,556</u> <u>1.27</u> <u>1.5</u> <u>24</u> <u>2.21</u> <u>1.77</u> <u>1.69</u> <u>247,742</u> <u>29,256</u> <u>0.29</u> <u>1.7</u> <u>19</u> <u>2.53</u> <u>1.98</u> <u>1.90</u> <u>360,640</u> <u>28,406</u> <u>0.13</u> 16 Table 3: Performance for different _λ_ for tolerance _ϵtol,_ 2 = 5 _·_ 10 <sup>_−_</sup> <sup>7</sup> at _N_ = 216 _,_ 000, _pFMM_ = 16 _._ _λ_ _p_ min _T_ <sup>(</sup> <sup>_get_</sup> <sup>)</sup> _,_ s _T_ <u>(</u> <sup>(</sup> _<u>no</u>_ <sup>_get_</sup> _<u>mean</u>_ <sup>)</sup> <u>)</u> <sup>_,_</sup> <sup>s</sup> _T_ <sup>(</sup> <sup>_F MM_</sup> <sup>)</sup> _,_ s _Nb_ _N_ + 2 _L_ _T_ <sup>(</sup> <sup>_set_</sup> <sup>)</sup> _,_ s <u>1.1</u> <u>80</u> <u>15.7</u> <u>14.6</u> <u>11.5</u> <u>782,131</u> <u>241,440</u> <u>150</u> <u>1.2</u> <u>44</u> <u>12.6</u> <u>11.2</u> <u>10.2</u> <u>1,015,037</u> <u>223,656</u> <u>5.31</u> <u>1.3</u> <u>34</u> <u>12.8</u> <u>11.1</u> <u>10.3</u> <u>1,291,247</u> <u>220,556</u> <u>1.27</u> <u>1.5</u> <u>25</u> <u>15.0</u> <u>12.3</u> <u>11.7</u> <u>1,983,665</u> <u>218,450</u> <u>0.32</u> <u>1.7</u> <u>19</u> <u>18.7</u> <u>14.7</u> <u>14.1</u> <u>2,887,393</u> <u>217,406</u> <u>0.13</u> using the RBFs vs the spherical basis functions, show that the latter choice is beneficial in terms of the accuracy, while the speed is approximately the same. Nonetheless, the errors for both bases are of the same order, while the RBF implementation is slightly simpler. Table 4: Performance for different basis functions at _λ_ = 1 _._ 5 _, p_ = 16, _pFMM_ = 12 _._ _N_ Basis _ϵ_ 2 _T_ <sup>(</sup> <sup>_get_</sup> <sup>)</sup> _,_ s _T_ <u>(</u> <sup>(</sup> _<u>no</u>_ <sup>_get_</sup> _~~<u>m</u>~~_ <sup>)</sup> _<u>ean</u>_ <u>)</u> <sup>_,_</sup> <sup>s</sup> _T_ <sup>(</sup> <sup>_set_</sup> <sup>)</sup> _,_ s <u>27,000</u> <u>Spherical</u> <u>1.3(-5)</u> <u>1.67</u> <u>1.30</u> <u>0.08</u> <u>RBF</u> <u>2.6(-5)</u> <u>1.74</u> <u>1.35</u> <u>0.06</u> <u>216,000</u> <u>Spherical</u> <u>1.6(-5)</u> <u>12.3</u> <u>9.57</u> <u>0.08</u> <u>RBF</u> <u>2.6(-5)</u> <u>12.7</u> <u>9.95</u> <u>0.06</u> Figure 5 illustrates scaling of the algorithm with the problem size. In this test _N_ sources were distributed randomly in the unit box and both _φ_ (with zero mean) and _∇φ_ were computed at the source locations. Here only the time for the “get” part is displayed. For comparison we also plotted the wall clock time for solution of the same non-periodic problem, where the FMM with the same _pFMM_ was used. (The discussion of GPU times is below). While for the non-periodic case the FMM is scaled approximately as _O_ ( _N_ ) (with some small _N_ log _N_ addition due to data structures), the present algorithm is scaled sublinearly at small _N_, while it approaches the same scaling as the regular FMM. Qualitatively this can be explained by complexity of the FMM as it used in the present algorithm for periodization (see Eq. (33), where for simplicity two last terms due to generation and evaluation of expansions are neglected). So the ratio of the FMM time in the present algorithm and the FMM for non-periodic problem can be estimated as _TFMM_ <sup>(</sup> <sup>_per_</sup> <sup>)</sup> _∼_ <u>�</u> _._ (42) _<u>FMM</u>_ _TFMM_ <sup>(</sup> <sup>_non_</sup> <sup>)</sup> ~~�~~ _Agf_ _Bgf_ <u>�1 +</u> <sup><u>2</u></sup> <sup>_<u>L</u>_</sup> <sup><u>(</u></sup> <sup>_<u>λ</u>_</sup> <sup><u>)</u></sup> _N_ _FMM_ This ratio for different _λ_ along with the experimentally measured time ratio of the “get” part of the algorithm and its FMM portion to the FMM for non-periodic problem is plotted in Fig. 6. For each _λ_ we presented theoretical ratios (42) computed for limiting cases _Bgf_ = 1 and _Bgf_ = _Agf_ (for cubic boxes _Agf_ _≈_ 2 _._ 72, see Eq. (32)). It is seen that qualitatively this explains the observed results, and at relatively small _N_ the wall clock time of the present algorithm requires is several times larger than the time of nonperiodic FMM. At larger times the ratio should come to an asymptotic limit depending on _λ_ . Despite Eq. (33) predicts that _λ_ = 1 _._ 1 limit should be somehow smaller than _λ_ = 1 _._ 3 limit, we found that in the range of experiments they are approximately the same (time ratio about 2, while can be 1.5 or so). The reason why the experimental data deviate from Eq. (42) is that there are some _O_ ( _N_ ), _O_ ( _PN_ ) _,_ and _O_ ( _P_ <sup>2</sup> ) overheads in the periodization algorithm. The contribution of these overheads is seen from the difference of the FMM 17 Non−periodic FMM/CPU λ = 1.3, p = 34 103 102 101 100 Periodic Non−periodic Periodic Bruteforce/CPU Periodic Bruteforce/GPU Non−periodic linear 10−1103 104 105 106 107 Number of sources, N Figure 5: Wall clock times of the present algorithm with the FMM as FSA for _λ_ = 1 _._ 3, _p_ = 34 (filled squares), and with brute-force 4 core CPU summation (filled triangles), and Tesla C2050 GPU summation (filled circles), for a periodic system replicating distribution of _N_ random sources in a unit cube (potential and gradient computations, Laplacian kernel in three dimensions). The corresponding empty squares, triangles and circles, connected by a solid line show performance of the particular FSA for the non-periodic problem with the same source distribution in the unit cube and the same truncation number _pFMM_ = 16. The dashed lines continue the trendlines to indicate performance, if memory resources had not been exceeded. The quadratic scaling of the brute-force summation, and the linear scaling for the FMM are seen. Brute force GPU sums for this case are faster till about _N_ _≃_ 40 _,_ 000. part of the get algorithm and the total cost. We also profiled the FMM, measured performance constants, and found that at large _N_ ≳ 10 <sup>6</sup> cost approximation (33) at _Bgf_ = _Agf_ is good enough and the FMM part approaches the asymptotic constant, which for cubic domains can be, say, 1.2 ( _pFMM_ = 16). As the present algorithm can easily treat periodicity for non-cubic domains we conducted accuracy and perfromance tests for periodic boxes of different aspect ratios. The accuracy tests were performed by comparison of the obtained solutions with the results of the Ewald summation in the same way as described above in the range of _N_ from 1000 to 50000. It was found that for fixed _λ_ and respective _p_ ( _λ_ ) the box aspect ratio practically does not affect the accuracy. At large aspect ratios like 5:1:1 we found that conditioning of the system matrix A (see Eq. (11)) can be poor, but this does not affect the accuracy of the final results and a good algorithm for computing of pseudoinverse can handle that. Some results of performance tests for are shown in Table 5. Ideally, the time for non-periodic FMM at large _l_ max should not depend on the box aspect ratio. However, some variation in time is seen, which can be refered to non-perfect (discrete) optimization. For large box aspect ratios one can get _Nb_ orders of magnitude larger than _N_ (e.g. two orders for the case 10:1:1). For 18 9 8 7 6 5 4 3 2 λ=1.1 exp total λ=1.3 exp total λ=1.3 exp FMM part λ=1.1 theory, Bgf=Agf λ=1.1 theory, Bgf=1 λ=1.3 theory, Bgf=Agf λ=1.3 theory, Bgf=1 101 3 104 105 106 107 Number of sources, N Figure 6: The ratio of the solution times of the periodic and non-periodic problems using the FMM for the cases shown in Fig. 5. Experimental results for the total time for the two cases, and the time taken by the FMM alone for the case _λ_ = 1 _._ 3 are shown. Also shown as continuous lines are theoretical estimates via Eq. (42) for the same values, and different geometric factors. such cases the cost of computation of the mean, which depends on _Nb_ becomes substantial. If these optional computations are not needed, then performance improves, but anyway, solution of periodic problem can be several times more expensive than solution of non-periodic problem. For the cases presented in the table the ratio of these times is well correlated with factor _A_ <sup>1</sup> <sup>_/_</sup> <sup>2</sup> _gf_ <sup>.</sup> <sup>This is consistent with the principal term of the</sup> FMM cost (33) at _Bgf_ = 1 _._ Finally we note that it is not an easy task to compare the absolute performance of the present methods with the smooth particle mesh Ewald (SPME) and other algorithms for periodic summation due to a difference in implementation, accuracy, what is actually computed (potential and gradient), hardware, etc. However, some comparison with that approaches can be done using published data [17] comparing performance of the SPME and FMM-type PWA implementation for clusters, for relatively small size problems ( _N_ = 10 <sup>4</sup> and _N_ = 10 <sup>5</sup> ). The absolute figures indicate that the wall clock time of the present algorithm for these sizes is of the same order as the reported times for those methods, while we are able to perform computations with larger problem sizes on relatively modest hardware. 4.3 Using graphics processing units (GPUs) for summation GPUs are often used to accelerate molecular dynamics simulations where periodization may be required. We implemented the “get” part of the algorithm completely on the GPU. Using “brute-force” summation on the GPU and on a multicore CPU as the FSA, we did the same performance tests as for the FMM, see Fig. 5. The ”set” part can be executed on CPU and transferred to the GPU. All parts of the algorithm are highly 19 Table 5: Performance for different box aspect ratios at _N_ = 10 <sup>5</sup>, _λ_ = 1 _._ 3, _p_ = 34 _, pFMM_ = 16 _._ _<u>d</u>_ <u>1</u> <u>:</u> _<u>d</u>_ <u>2</u> <u>:</u> _<u>d</u>_ <u>3</u> <u>1:1:1</u> <u>2:1:1</u> <u>5:1:1</u> <u>10:1:1</u> <u>2:2:1</u> <u>5:5:1</u> <u>10:2:1</u> _<u>Agf</u>_ <u>2.72</u> <u>3.85</u> <u>14.7</u> <u>53.9</u> <u>3.53</u> <u>7.63</u> <u>28.2</u> _<u>Nb</u>_ <u>597,625</u> <u>845,188</u> <u>3,228,941</u> <u>11,849,769</u> <u>776,783</u> <u>1,675,371</u> <u>6,192,751</u> _<u>T</u>_ <sup>(</sup> <sup>_get_</sup> <sup>)</sup> _<u>,</u>_ <u>s</u> <u>9.08</u> <u>9.86</u> <u>20.8</u> <u>44.5</u> <u>9.92</u> <u>13.9</u> <u>29.8</u> _T_ <u>(</u> <sup>(</sup> _<u>no</u>_ <sup>_get_</sup> _~~<u>m</u>~~_ <sup>)</sup> _<u>ean</u>_ <u>)</u> <sup>_,_</sup> <sup>s</sup> 8.22 8.77 16.6 29.0 8.92 11.7 21.8 <u>(</u> <sup>(</sup> _<u>no</u>_ <sup>_get_</sup> _~~<u>m</u>~~_ <sup>)</sup> _<u>ean</u>_ <u>)</u> <sup>_/A_</sup> <sup>1</sup> _<u>gf</u>_ <sup>_/_</sup> <sup>2</sup> _T_ <u>(</u> <sup>(</sup> _<u>no</u>_ <sup>_get_</sup> _~~<u>m</u>~~_ <sup>)</sup> <sup>1</sup> _<u>gf</u>_ <sup>_/_</sup> <sup>2</sup> <sup>_,_</sup> <sup>s</sup> 4.98 4.47 4.33 3.94 4.74 4.24 4.11 _<u>TF MM</u>_ <sup>(</sup> <sup>_non_</sup> <sup>)</sup> <sup>_<u>,</u>_</sup> <sup><u>s</u></sup> <u>3.76</u> <u>4.71</u> <u>4.03</u> <u>3.40</u> <u>3.45</u> <u>5.65</u> <u>4.79</u> parallelizable and so while the scaling of the algorithm is quadratic, it is up to two orders of magnitude faster than the multicore CPU version. Our tests reveal that at large truncation numbers _p_ (typically _p_ ≳ 30) single precision GPU computations cannot be used for spherical basis function evaluation due to loss of precision in least-squares solution. Double-precision computations provide accurate results with _L_ 2-norm relative errors of the order 10 <sup>_−_</sup> <sup>13</sup> _−_ 10 <sup>_−_</sup> <sup>15</sup> in potential and gradient computations compared to the double precision CPU computations. Accordingly Fig. 5, only shows double precision times. High performance implementation of the bruteforce summation is described in [19] and was used in the present tests with single and double precision, and run on a single NVIDIA Tesla C2050 card. The CPU wall clock times used for comparisons were measured for algorithm parallelized for 4 core PC described before. Fig. 5 shows the results of tests. It is seen that despite the asymptotic quadratic scaling of the algorithm the GPU implementation can be faster or comparable in speed with the FMM running on CPU at _pFMM_ = 16 for problems of size _N_ ≲ 10 <sup>5</sup> . The ratio of times for solution of periodic and non-periodic problems for brute force computations at large _N_ tends to theoretical limit _Tbrute_ <sup>(</sup> <sup>_per_</sup> <sup>)</sup> <sup>_/T_</sup> <sup>(</sup> _brute_ <sup>_non_</sup> <sup>)</sup> <sup>=</sup> <sup>_π_</sup> <u>34</u> <sup>_λ_</sup> <sup>3, which for</sup> <sup>_λ_</sup> <sup>= 1</sup> <sup>_._</sup> <sup>3</sup> used for illustrations is about 6 times. Of course, this ratio can be reduced by decreasing _λ_ . However, in the range _N_ ≲ 10 <sup>5</sup> reduction of _λ_ below 1.1 does not benefit the overall performance due to increase of the size of the expansion and reduction of the performance of evaluation of the far field on the GPU, where the local memory is substantially smaller than the CPU cache. One of the advantages of brute force double precision GPU computing for problems of relatively small size ( _N_ ≲ 10 <sup>5</sup> ) is that besides the roundoff errors the accuracy is controlled only by parameters _p_ and _λ_, while for the FSA=FMM the error is controlled also by _pFMM_ . For efficient FMM implementations on GPU this number is usually small [19] while the efficiency of the FMM on GPU for high accuracy simulations is a subject for a separate study. brute force computations at large _N_ tends to theoretical limit _Tbrute_ <sup>(</sup> <sup>_per_</sup> <sup>)</sup> _brute_ <sup>(</sup> <sup>_per_</sup> <sup>)</sup> <sup>_/T_</sup> <sup>(</sup> _brute_ <sup>_non_</sup> <sup>)</sup> <sup>(</sup> _brute_ <sup>_non_</sup> <sup>)</sup> <sup>=</sup> <sup>_π_</sup> ### 5 Discussion By proposing a method for computation of periodic sums we do not mind to compete with or diminish the role of the existing methods, such as based on Ewald summation or the FMM for periodic functions for well-studied kernels. We realize that a variety of problems with periodic boundary conditions and practical concerns of researchers may require some solutions different from the existing approaches, as any of them, including the present one has some advantages and disadvantages. Such problems are not limited with Laplacian kernels. However, development of specialized approaches which usually are more efficient than generic approaches (kernel-independent FMM is an example), also have some cost and availablity of a method which turns an available FSA to its periodic version without any intervention to the basic FSA algorith, in our opinion, is useful. The “cons” and “pros” of the FFT vs FMM were discussed in the literature, including performance 20 and scaling at large _N_ (e.g. [22]) and application to solution of molecular dynamics problems (e.g. [41]). Particularly, some difficulties for the use of the FMM for the MD simulations were reported as a long term energy drift was observed in some computations using four or six term expansion in the FMM [42] (perhaps, _pFMM_ = 4 or 6, which provides _p_ <sup>2</sup> _FMM_ <sup>=</sup> <sup>16</sup> <sup>and</sup> <sup>36</sup> <sup>terms</sup> <sup>of</sup> <sup>expansion,</sup> <sup>respectively)</sup> <sup>_._</sup> <sup>Of</sup> <sup>course,</sup> <sup>the</sup> number of terms should be evaluated carefully and the FMM and other errors should be consistent with the integration schemes used (particularly, the FMM errors in gradients are higher than in the potential [39]). In this context, we can mention that in the present algorithm one can enforce some conditions (such as setting the mean of the potential to zero, similarly to the Ewald scheme), which is normally is not controlled in the FMM-based algorithms. It can be more stable or not in terms of the energy drift if applied to the MD simulations, but this requires an additional study, which, certainly, goes beyond the scope of the present work, where not only the MD applications are envisioned. Another advantage of not requiring the FFT may arise for very large problems, which have to be implemented on distributed architectures, where the communication costs of the FMM are smaller than the FFT. As far as comparing the present approach with an FMM algorithm implemented using periodic kernel functions is considered, we perform this comparison on three sizes of problems: with small _N_ (say, _N_ ≲ 10 <sup>3</sup> ), moderate _N_ (say, 10 <sup>4</sup> ≲ _N_ ≲ 10 <sup>5</sup> ) and large _N_ (say, _N_ ≳ 10 <sup>6</sup> ). The first class may not require the FMM at all, as direct sums may be done faster and be more accurate, and the present algorithm can work efficiently and accurately (choosing proper _p_ ) with direct sums. The second and the third types of the problems require a fast summation algorithm such as the FMM. In this case some authors claim that the overheads for solution of periodic problems are negligibly small compared to solution of the non-periodic problem. For example, Ref. [12] claims that periodization of requires only 0.1% of the total computational time. This statement _does_ _not_ _mean_ that the periodic version of the sum is 1.001 times slower than the solution of the non-periodic sum, as was remarked on an early draft of this paper. Indeed, in [12] (page 1084 and Table V) it is stated “ _The time spent on dealing with periodicity ranged from about 0.3 to 2.6 times_ _of that of the free boundary computations,_ _depending on the values of p and L and the type of the FMM._ ” (Here _L_ = _l_ max in our notation). This shows that actual measured time ratios, such as reported in Fig. 6, were in the range 1.3 to 3.6. The overhead comes from the fact that the periodic FMM is the FMM executed in the extended domain, which is not the original cell Ω0, but in Ω0 with its 26 neighbors, which is Ω _b_ in our notation, see Fig. 1. The difference between the present and periodic FMMs is that, first, the periodic FMM saves on generation of multipole expansions and multipole-to-multipole translations for the replicated domains, which is not implemented in the present algorithm, and, second, that for the present FMM some relatively small amount of receivers (“check points”) are added. Discussions of the FMM costs and simplifications in Appendix A and around Eqs (33) and (42) show that asymptotically as _N_ _→∞_ the second modification brings a negligible overhead, while the overhead due to the first modification is non-zero, and in practice can be several percents for cubic Ω0 to tens of percents for non-cubic Ω0 (due to the geometric factor _Agf_ ), which is the price of use of the FMM as a black box FSA. At _N_ _→∞_ the costs of the periodic and non-periodic FMMs are the same. The difference in costs of periodic and non-periodic FMMs comes from two factors – the difference in the multipole-to-local translations and direct summations for the boxes near the boundaries of Ω0, due to the difference in the neighborhoods. We carefully counted these numbers accounting for the boundary effects, and found that for levels _l_ max = 3 and 4 (midsize problems) used in [12], the ratios of numbers of translations in periodic and non-periodic FMMs is 1.96 and 1.38, while the ratios of the numbers of direct summations is 1.30 and 1.14, respectively. At levels _l_ max = 5 and 6 one can expect time ratios in a range 1.05-1.20. One of the features of the present algorithm, which may be of practical interest, is the capability to obtain periodic solutions for non-cubic domains easily, which can be an issue for some other algorithms. These were illustrated in Table 5. Performance for moderate box aspect ratio is comparable to the cubic case. For high aspect ratios, the algorithm works, but some issues, which could be the subject of future study must be 21 noted. There is a substantial increase in the amount of sources added because of the enclosure of the whole domain in a sphere. Because of this, both the memory needed and the computational time are relatively large, while still scaled as expected. Possible ways to address this would be to devise more check point sets located not on a sphere, but on surface that are more conformal to the boundaries, and also a reduction of the size of domain Ω0. The latter can be achieved in a few ways including distribution of RBF centers not too far from the boundaries of Ω0 or to use basis functions, which are better suited for boxes of high aspect ratios than the spherical basis functions. ### 6 Conclusion We have presented a kernel-independent method for the periodization of finite sums. The technique was presented in a general setting, and then applied to the particular case of the Laplacian kernel using different expansion bases. Tests showed that the method can be tuned to compute periodic sums with arbitrary prescribed accuracy. In the case of use of the FMM as the fast summation algorithm the complexity of the method at large _N_ is the same as the FMM. The computational time for large _N_ (in tests up to _N_ = 2 <sup>23</sup> ) is about twice that for the finite box sum using the FMM. Similar results are seen for GPU based FSA, though here the scaling is quadratic, and the largest problem size that can be reasonably treated is about 10 <sup>5</sup> . The ease of implementation of the periodization method, its performance, and capability to “retrofit” any available black box FSA without any modification makes it practical. This method may also be valuable on distributed architectures on which communication costs of an algorithm are as important as computational complexity. FMM-based approaches are known to be much more communication efficient than FFT-based approaches for solution of the same large problems on distributed architectures. Additional speedups of the method can be achieved by specialization of the FMM - these were specifically avoided in this paper to demonstrate the ability to use a blackbox sum algorithm, and should be investigated if the method is to be used in a “production” environment. Application to other kernels should be straightforward, though details will have to be worked out for them. ### References [1] P. Ewald, Die Berechnung optischer und elektrostatischer Gitterpotentiale, Ann. Phys. 369 (1921) 253 287. [2] T. Darden, D. York, and L. Pedersen, Particle mesh Ewald - an Nlog(N) method for Ewald sums in large systems, J. Chem. Phys. 98 (1993) 10089-10092. [3] U. Essmann, L. Perera, M.L. Berkowitz, T. Darden, H. Lee, and L.G. Pedersen, A smooth particle mesh Ewald method, J. Chem. Phys. 103 (1995) 8577-8593. [4] D. Lindbo and A.-K. Tornberg, Spectrally accurate fast summation for periodic Stokes potentials, J. Comput. Phys. 229 (2010) 8994-9010. [5] D. Lindbo and A.-K. Tornberg, Spectral accuracy in fast Ewald-based method for particle simulations, J. Comput. Phys. 230 (2011) 8744-8761. [6] L. Greengard and V. Rokhlin, A fast algorithm for particle simulations, J. Comput. Phys. 73 (1987) 325-348. [7] K.E. Schmidt and M.A. Lee, Implementing the fast multipole method in three dimensions, J. Stat. Phys. 63 (1991) 1223-1235. 22 [8] D. Christiansen, J.W. Perram, and H.G. Petersen, On the fast multipole method for computing the energy of periodic assemblies of charged and dipolar particles, J. Comput. Phys. 107 (1993) 403-405. [9] J.T. Hamilton and G. Majda, On the Rokhlin-Greengard method with vortex blobs for problems posed in all space or periodic in one direction, J. Comput. Phys 121 (1995) 29-50. [10] C.G. Lambert, T.A. Darden, and J.A. Board, Jr., A multipole-based algorithm for efficient calculation of forces and potentials in macroscopic periodic assemblies of particles, J. Comput. Phys. 126 (1996) 274-285. [11] F. Figueirido, R.M. Levy, R. Zhou, and B.J. Berne, Large scale simulation of macromolecules in solution: Combining the periodic fast multipole method with multiple step integrators, J. Chem. Phys. 106 (1997) 9835-9849. [12] T. Amisaki, Precise and efficient Ewald summation for periodic fast multipole method, J. Comput. Chemistry 21 (2000) 1075-1087. [13] Y. Otani and N. Nishimura, A fast multipole boundary integral equation method for periodic bound ary value problems in three-dimensional elastostatics and its application to homogenization, Int. J. Multiscale Computational Eng. 4 (2006) 487-500. [14] Y. Otani and N. Nishimura, A periodic FMM for Maxwell’s equations in 3D and its application to problems related to photonic crystals, J. Comput. Phys. 227 (2008) 4630-4652. [15] A. Barnett and L. Greengard, A new integral representation for quasi-periodic fields and its application to two-dimensional band structure calculations, J. Comput. Phys 229 (2010) 6898-6914. [16] M.H. Langston, L. Greengard, and D. Zorin, A free-space adaptive FMM-based PDE solver in three dimensions, Comm. Appl Math and Comput. Sci. 6 (2011) 79-122. [17] A. Kia, D. Kim, and E. Darve, Fast electrostatic force calculation on parallel computer clusters, J. Comput. Phys 227 (2008) 8551-8567. [18] J.E. Stone, J.C. Phillips, P.L. Freddolino, D.J. Hardy, L.G. Trabuco, and K. Schulten. Accelerating molecular modeling applications with graphics processors. J. Comput. Chem., 28 (2007) 2618-2640. [19] N.A. Gumerov and R. Duraiswami, Fast multipole methods on graphics processors, J. Comput. Phys. 227 (2008) 8290-8313. [20] T. Hamada, R. Yakota, K. Nitadori, T. Narumi, K. Yasuoka, and M. Taiji, 42 TFlops hierarchical N-body simulations on GPUs with applications in both astrophysics and turbulence, Proceedings of International Conference for High Performance Computing, Networking, Storage, and Analysis, ser. SC’09. New York, NY:ACM, 2009, Article No. 62. [21] Q. Hu, N.A. Gumerov, and R. Duraiswami, Scalable fast multipole methods on distributed hetero geneous architectures, Proceedings of International Conference for High Performance Computing, Networking, Storage, and Analysis, ser. SC’11. New York, NY:ACM, 2011, pp. 36:1–36:12. [22] R. Yokota, L.A. Barba, T. Narumi, and K. Yasuoka, Petascale turbulence simulation using a highly parallel fast multipole method on GPUs, Computer Phys. Communications 184 (2013) 445-455. [23] N.A. Gumerov and R. Duraiswami, Fast multipole method for the biharmonic equation in three dimen sions, J. Comput. Phys. 215 (2006) 363-383. 23 [24] M. Buhmann, Radial Basis Functions: Theory and Implementations, Cambridge, 2003. [25] Z. Gimbutas and V. Rokhlin, A generalized fast multipole method for nonoscillatory kernels, SIAM J. Sci. Comput. 24 (2003) 796-817. [26] L. Ying, G. Biros, and D. Zorin, A kernel-independent adaptive fast multipole algorithm in two and three dimensions, J. Comput. Phys. 196 (2004) 591-626. [27] L. Ying, A kernel independent fast multipole algorithm for radial basis functions, J. Comput. Phys. 213 (2006) 451-457. [28] A. Barnett and L. Greengard, A new integral representation for quasi-periodic scattering problems in two dimensions, BIT Numer. Math. 51 (2011) 67-90. [29] W. Fong and E. Darve, The black-box fast multipole method, J. Comput. Phys. 228 (2009) 8712-9725. [30] B. Zhang, J. Huang, N.P. Pitsianis, and X. Sun, A Fourier-series-based kernel independent fast multi pole method, J. Comput. Phys. 230 (2011) 5807-5821. [31] M. Messner, M. Schanz, and E. Darve, Fast directional multilevel summation for oscillatory kernels based on Chebyshev interpolation, J. Comput. Phys. 231 (2012) 1175-1196. [32] G.H. Golub and C.F. Van Loan, Matrix Computations, 3rd edition, John Hopkins University Press, Baltimore, 1996. [33] M. Abramowitz and I.A. Stegun, Handbook of Mathematical Functions, National Bureau of Standards, Washington, D.C., 1964. [34] J. J. Thomson, On the structure of the atom: an investigation of the stability and periods of oscilla tion of a number of corpuscles arranged at equal intervals around the circumference of a circle; with application of the results to the theory of atomic structure, Phil. Mag. 7 (1904), 237-265. [35] J. Fliege and U. Maier, The distribution of points on the sphere and corresponding cubature formulae, [IMA J. Numer. Analysis 19 (1999) 317-334 (data available at http://www.personal.soton.](http://www.personal.soton.ac.uk/jf1w07/nodes/nodes.html) [ac.uk/jf1w07/nodes/nodes.html ).](http://www.personal.soton.ac.uk/jf1w07/nodes/nodes.html) [36] N.A. Gumerov and R. Duraiswami, Fast Multipole Methods for the Helmholtz Equation in Three Dimensions, Elsevier, Oxford, 2005. [37] M.A. Epton and B. Dembart, Multipole translation theory for the three-dimensional Laplace and Helmholtz equations, SIAM J. Sci. Comput., 16 (1995) 865-897. [38] E. Madelung, Das elektrische Feld in Systemen von regelm¨aßig angeordneten Punktladungen. Phys. Zs,, XIX (1918) 524-533. [39] N.A. Gumerov and R. Duraiswami, Efficient FMM accelerated vortex methods in three dimensions via the Lamb-Helmholtz decomposition, J. Comput. Phys. 240 (2013) 310-328. [40] N.A. Gumerov and R. Duraiswami, Comparison of the efficiency of translation operators used in the fast multipole method for the 3D Laplace equation, Technical Report CS-TR 4701 and UMIACSTR 2005-09, University of Maryland Department of Computer Science and Institute for Advanced Computer Studies, College Park, November 2005. 24 [41] R.D. Skeel, Fast N-body methods: why, what, and which, Proceedings of International Conference on Numerical Analysis and Applied Mathematics, ICNAAM, CP1281, I, (2010) (AIP Conference Proceedings 1281, 27 (2010); doi: 10.1063/1.3498450). [42] T.C.Bishop, R.D. Skeel, and K. Schulten, Difficulties with multiple time stepping and fast multipole algorithm in molecular dynamics, J. Comput. Chem. 18 (1997) 1785-1791. ### A Complexity of the FMM There are many papers evaluating complexity of the FMM in basic settings (mostly for the cases when the sources and receivers are the same and uniformly occupy all computational domain, which can be thougth as a unit cubic box, e.g. [40]). Here, we consider the FMM for Laplace-like kernels and modify the problem by assuming that _Nb_ sources are located in the domain Ω _b_ of volume _Vb_ and _M_ receivers are distributed inside the domain Ω _r_ _⊂_ Ω _b_ of volume _Vr._ Let now _U_ be a minimal cube which includes Ω _b_ and presents the zero level of the octree. The cube is partitioned via the octree down to level _l_ max, in which case the maximum number of sources in a box is _s_ . Assuming more or less uniform source point distribution in Ω _b_ and that any box in Ω _r_ contains at least one receiver point, we can determine the number of source and receiver boxes at this level as _Bs_ = _Nb/s_ and _Br_ = _BsVr/Vs_, respectively. The latter estimate comes from the observation that for large enough _l_ max the ratio of the numbers of source and receiver boxes is approximately the same as the ratio of volumes of the domains occupied by the sources and receivers. In a standard FMM in three dimensions the number of multipole-to-local translations to each receiver box located far enough from the boundary of Ω _b_ is _K_ = 189 (this number can be reduced, e.g. as in [19], but anyway, _K_ _≫_ 1). When counting the total number of translations _K_ should be increased to account for one local-to-local transaltion per receiver box and 1 multipole-to-multipole translation per source box. It can be noted then that the amount of translations at the _l_ th level of the octree increases geometrically with the level (8 times in three dimensions), so the total number of translations, _Ntrans_, will have factor 8 _/_ 7 compared to the number of translations at level _l_ max and we have _Vs_ - _≈_ <sup><u>8</u></sup> <sup>_<u>Nb</u>_</sup> _Ntrans_ _∼_ 7 <sup><u>8</u></sup> <sup>(</sup> <sup>_Bs_</sup> <sup>+</sup> <sup>_KBr_</sup> <sup>) =</sup> <sup><u>8</u></sup> 7 <sup>_<u>N</u>_</sup> _s_ <sup>_<u>b</u>_</sup> �1 + _K_ <sup>_<u>Vr</u>_</sup> _Vs_ <sup>_<u>Nb</u>_</sup> _<u>KVr</u>_ 7 _s_ _Vs_ _._ (43) Here the latter approximate equality holds when _K_ _≫_ _Vs/Vr_ . The number of direct summations per receiver is 27 _s_, if we assume that the neighborhood of the receiever box consists of 27 boxes, which yields the total number of direct summations, _Ndir_ = 27 _Ms._ Hence, denoting _Ctrans_ the cost of a single translation and _Cdir_ the cost of a single direct evaluation, we obtain the part of the total cost, which depends on _s_ in the form _Cs_ = <sup><u>8</u></sup> <sup>_<u>Nb</u>_</sup> <sup>_<u>Nb</u>_</sup> _<u>KVr</u>_ 7 _s_ _Vs_ _Vs_ _Ctrans_ + 27 _sMCdir._ (44) This function can be minimized with respect to _s_, and the minimum cost denoted as, _Cs,_ min, at _s_ = _sopt_, where from _dCs/ds_ = 0, we have ~~�~~ <u>54</u> _<u>K</u>_ _,_ _Ctd_ = 4 _CtransCdir_ (45) 7 _<u>Vr</u>_ _Vs_ _sopt_ = ~~�~~ <u>8</u> _<u>KCtrans</u>_ 189 _Cdir_ _<u>Nb</u>_ _M_ _,_ _Cs,_ min = _Ctd_ ~~�~~ _<u>Vr</u>_ _MNb_ _Vs_ To get the total cost of the FMM, we need to add here the cost of generation of multipole expansions, _CgenNb_ and the cost of evaluation of local expansions, _CevM_, where _Cgen_ and _Cev_ are the costs of generation and evaluation of single expansions, which does not depend on _s_, or the depth of hte octree _l_ max. Hence, the 25 total cost of the FMM used in the present algorithm, which neglects the cost of generation of data structure is ~~�~~ _C_ <sup>(</sup> <sup>_FMM_</sup> <sup>)</sup> = _Ctd_ _MNb_ _<u>Vr</u>_ _Vs_ + _CgenNb_ + _CevM._ (46) Here the last estimate comes from the fact that usually translations and direct summations are the major contributors to the overall cost of the FMM (e.g. see profiling of the algorithm [19]). Also note the dependence of the FMM cost on the number of terms in the multipole and local expansions used in the FMM, _PFMM_ . We have _Cgen_ _∼_ _Cgen_ = _O_ ( _PFMM_ ), _Ctrans_ = _O_ ( _PFMM_ <sup>_α_</sup> <sup>)</sup> <sup>_,_</sup> <sup>and</sup> <sup>_Ctd_</sup> <sup>=</sup> <sup>_O_</sup> - _PFMM_ <sup>_α/_</sup> <sup>2</sup> - where _α_ is some _FMM_ <sup>_α_</sup> <sup>)</sup> <sup>_,_</sup> <sup>and</sup> <sup>_Ctd_</sup> <sup>=</sup> <sup>_O_</sup> - _P_ <sup>_α/_</sup> <sup>2</sup> _FMM_ where _α_ is some translation methods, _α_ = 3 _/_ 2). number (e.g. for _O_ - _p_ <sup>3�</sup> ### B Box integrals of the basis functions Basis functions _Rn_ <sup>_m_</sup> <sup>(</sup> <sup>y</sup> <sup>) are homogeneous polynomials of degree</sup> <sup>_n_</sup> <sup>(sums of monomials</sup> <sup>_xn_</sup> <sup>1</sup> <sup>_yn_</sup> <sup>2</sup> <sup>_zn_</sup> <sup>3</sup> <sup>_, n_</sup> <sup>1</sup> <sup>+</sup> _n_ 2 + _n_ 3 = 1). We can compute the integrals as - _d_ 2 _/_ 2 _−d_ 2 _/_ 2 - _d_ 3 _/_ 2 _−d_ 3 _/_ 2 <u>1</u> _Rt_ <sup>(0)</sup> = _V_ 0 Ω0 <u>1</u> _Rt_ ( y ) _dV_ ( y ) = _d_ 1 _d_ 2 _d_ 3 - _d_ 1 _/_ 2 _−d_ 1 _/_ 2 _Rt_ ( _x, y, z_ ) _dxdydz_ (47) _Nq_ _j_ =1 _Nq_ _k_ =1 <u>1</u> = 8 _Nq_ _i_ =1 _wiwjwkRt_ - <u>1</u> _,_ 2 <sup>_d_</sup> <sup>1</sup> <sup>_xi,_</sup> <sup><u>1</u></sup> 2 <sup>_d_</sup> <sup>2</sup> <sup>_xj,_</sup> 2 <sup><u>1</u></sup> <sup>_d_</sup> <sup>3</sup> <sup>_xk_</sup> where _wi_ and _xi_ are the standard weights and abscissas of the Gauss quadrature of order _Nq_ [33]. Since this integration is exact for polynomials of degree _n <_ 2 _Nq_ and the maximum degree of the polynomials in the sum is _p −_ 1 _,_ the choice + 1 _,_ _p_ = _P_ <sup>1</sup> <sup>_/_</sup> <sup>2</sup> _,_ (48) _Nq_ = - _<u>p −</u>_ <u>1</u> 2 _n_ provides an exact result. For evaluation of all _P_ required coefficients _R_ <sup>�</sup> <sup>_m_</sup> <sup>(0)</sup> _n_ the computational cost of this provides an exact result. For evaluation of all _P_ required coefficients _R_ <sup>�</sup> <sup>_m_</sup> <sup>(0)</sup> procedure is _O_ - _P_ <sup>5</sup> <sup>_/_</sup> <sup>2�</sup> _._ Note that faster methods may be proposed for computation of this step. However, this is not crucial, as this integration is performed in the “set” part of the algorithm, which overall cost is _O_ - _P_ <sup>3�</sup>, and this cost is amortized over the rest of the algorithm. - _P_ <sup>5</sup> <sup>_/_</sup> <sup>2�</sup> - _P_ <sup>3�</sup> , and this cost is amortized over the rest of the algorithm. ### C Mean computations To compute the integral (39) for the kernel (2), we first apply the Gauss divergence theorem to reduce the volume integral to a surface integral: - <u>1</u> _dV_ ( y ) = 2 _V_ 0 _∂_ Ω0 <u>n</u> _<u>·</u>_ <u>(</u> <u>y</u> _<u>−</u>_ <u>x</u> <u>)</u> _dS_ ( y ) _,_ (49) _|_ y _−_ x _|_ Φ0 ( x ) = <sup><u>1</u></sup> _V_ 0 Ω0 _<u>dV</u>_ <u>(</u> <u>y</u> <u>)</u> <u>1</u> _|_ y _−_ x _|_ <sup>=</sup> 2 _V_ 0 Ω0 _∇_ y _·_ - <u>y</u> _<u>−</u>_ <u>x</u> _|_ y _−_ x _|_ where n is the outward normal to Ω0 _._ This result is valid for an arbitrary point x including when x is located in Ω0 or on its boundary _∂_ Ω0. This can be checked by consideration of _ϵ_ -vicinities of singularities, which are integrable. The surface integral can be decomposed into integrals over the box faces, _Sk_, _k_ = 1 _, ...,_ 6 _._ <u>n</u> _<u>k ·</u>_ <u>(</u> <u>y</u> _<u>−</u>_ <u>x</u> <u>)</u> <u>1</u> Φ0 ( x ) = 2 _V_ 0 _Lk_ ( x _k_ ) = _Sk_ _<u>dS</u>_ <u>(</u> <u>y</u> _<u>k</u>_ <u>)</u> _|_ y _k −_ x _k|_ <sup>_,_</sup> y _k_ = y _−_ y _k_ 0 _,_ x _k_ = x _−_ y _k_ 0 _,_ 26 6 _k_ =1 _Sk_ _<u>·</u>_ <u>(</u> <u>y</u> _<u>−</u>_ <u>x</u> <u>)</u> _dS_ ( y ) = _−_ <sup><u>1</u></sup> _|_ y _−_ x _|_ 2 _V_ 2 _V_ 0 6 _k_ =1 ( n _k ·_ x _k_ ) _Lk_ ( x _k_ ) _,_ (50) where n _k_ and y _k_ 0 are the normal and the center of the _k_ th face, while y _k_ and x _k_ are coordinates in the reference frame with the origin at the _k_ th face center. The surface integral then can be reduced to the contour integral using, e.g. the Gauss divergence theorem in the plane of a particular face. Indeed, consider function F _k_ ( r _k_ ) = r _kfk_ ( _rk_ ; _hk_ ) _,_ _fk_ ( _rk_ ; _hk_ ) = <sup>_<u>ρk −</u>_</sup> <sup>_<u>hk</u>_</sup> <sup>2</sup> _k_ <sup>(=</sup> <sup>_|_</sup> <sup>y</sup> <sup>_k −_</sup> <sup>x</sup> <sup>_k|_</sup> <sup>)</sup> <sup>_,_</sup> (51) ~~�~~ _rk_ <sup>2</sup> _k_ <sup>2</sup> <sup>+</sup> <sup>_h_</sup> <sup>2</sup> _k_ _rk_ <sup>2</sup> _,_ _ρk_ = _k_ r _k_ = y _k −_ x <sup>_′_</sup> _k_ <sup>_′_</sup> _k_ <sup>=</sup> <sup>x</sup> <sup>_k_</sup> <sup>_−_</sup> <sup>n</sup> <sup>_khk,_</sup> _hk_ = n _k ·_ x _k._ <sup>_′_</sup> _k_ <sup>_,_</sup> x <sup>_′_</sup> The 2D divergence of this function in the plane of the _k_ th face is 1 _/ρk_ . So _∇_ - r _k_ _·_ F _k_ ( r _k_ ) _dS_ ( r _k_ ) = _Ck_ _Lk_ ( x _k_ ) = _Sk_ _∇_ - r _k_ _·_ F _k_ ( r _k_ ) _dS_ ( r _k_ ) = n <sup>_′_</sup> _k_ <sup>_·_</sup> <sup>F</sup> <sup>_k_</sup> <sup>(</sup> <sup>r</sup> <sup>_k_</sup> <sup>)</sup> <sup>_dl_</sup> <sup>(</sup> <sup>r</sup> <sup>_k_</sup> <sup>)</sup> <sup>_,_</sup> (52) n <sup>_′_</sup> where n <sup>_′_</sup> _k_ <sup>is the outer normal to the contour</sup> <sup>_Ck_</sup> <sup>=</sup> <sup>_∂_</sup> <sup>Ω</sup> <sup>_k_</sup> <sup>.</sup> <sup>This integral can be decomposed into four integrals</sup> over the face edges. So _<u>ρk −</u>_ _<u>hk</u>_ _rk_ <sup>2</sup> _Lk_ ( x _k_ ) = 4 _j_ =1 _Ikj_ ( x _k_ ) _,_ _Ikj_ ( x _k_ ) = _Ckj_ n <sup>_′_</sup> _kj_ <sup>_·_</sup> <sup>r</sup> <sup>_k_</sup> _dl._ (53) The latter integrals can be found analytically. Indeed, consider for the _j_ th edge a local right hand oriented reference frame centered at its endpoint y _kj_ 0 from which integration starts, and unit basis vectors i <sup>_′_</sup> _kjx_ directed along the integration path, i <sup>_′_</sup> _kjy_ <sup>=</sup> <sup>n</sup> <sup>_k_</sup> <sup>and</sup> <sup>i</sup> <sup>_′_</sup> _kjz_ <sup>=</sup> <sup>n</sup> <sup>_′_</sup> _kj_ <sup>=</sup> <sup>i</sup> <sup>_′_</sup> _kjx_ <sup>_×_</sup> <sup>i</sup> _kjy_ <sup>_′_</sup> <sup>_._</sup> <sup>Denoting coordinates of</sup> <sup>x</sup> <sup>in</sup> this reference frame as <sup>_′_</sup> _kjy_ <sup>=</sup> <sup>n</sup> <sup>_k_</sup> <sup>and</sup> <sup>i</sup> <sup>_′_</sup> <sup>_′_</sup> _kjz_ <sup>=</sup> <sup>n</sup> <sup>_′_</sup> <sup>_′_</sup> _kj_ <sup>=</sup> <sup>i</sup> <sup>_′_</sup> <sup>_′_</sup> _kjx_ <sup>_×_</sup> <sup>i</sup> <sup>_′_</sup> _xkj_ = ( x _k −_ y _kj_ 0) _·_ i <sup>_′_</sup> <sup>_′_</sup> _kjx_ <sup>_,_</sup> _ykj_ = ( x _k −_ y _kj_ 0) _·_ i <sup>_′_</sup> <sup>_′_</sup> _kjy_ <sup>_,_</sup> _zkj_ = ( x _k −_ y _kj_ 0) _·_ i <sup>_′_</sup> <sup>_′_</sup> _kjz_ <sup>_,_</sup> (54) we obtain _Ikj_ ( x _k_ ) = _−zkj_ - _lkj_ _−xkj_ _−xkj_ _f_ ( _rkj_ ; _|ykj|_ ) _dx_ = _H_ ( _lkj_ _−_ _xkj, |ykj|, zkj_ ) _−_ _H_ ( _−xkj, |ykj|, zkj_ ) _,_ (55) _kj_ <sup>2</sup> <sup>=</sup> <sup>_x_</sup> <sup>2 +</sup> <sup>_z_</sup> _kj_ <sup>2</sup> where _r_ <sup>2</sup> _kj_ <sup>2</sup> <sup>,</sup> <sup>_lkj_</sup> <sup>is the length of edge</sup> <sup>_Ckj_</sup> <sup>, and</sup> <sup>_H_</sup> <sup>(</sup> <sup>_x, y, z_</sup> <sup>) is the primitive,</sup> _H_ ( _x, y, z_ ) = _−z_ _f_ ( _r_ ; _|y|_ ) _dx,_ _f_ ( _r_ ; _y_ ) = <sup>_<u>ρ −|y|</u>_</sup> _,_ _r_ <sup>2</sup> = _x_ <sup>2</sup> + _z_ <sup>2</sup> _,_ _ρ_ = _r_ <sup>2</sup> ~~�~~ _r_ <sup>2</sup> + _y_ <sup>2</sup> _,_ (56) which can be computed analytically as �arctan <sup>_<u>x</u>_</sup> _z_ _zρ_ _H_ ( _x, y, z_ ) = _|y|_ <sup>_<u>x</u>_</sup> _z_ <sup>_−_</sup> <sup>arctan</sup> <sup>_<u>|y</u>_</sup> _zρ_ <sup>_<u>| x</u>_</sup> _−_ _z_ ln _|ρ_ + _x|_ + _C_ ( _y, z_ ) _._ (57) The integration constant _C_ ( _y, z_ ) can be selected arbitrarily to eliminate possible singularities. Particularly for _y̸_ = 0 _, z_ = 0 one can set _H_ = 0. The above formulae are sufficient for numerical implementation, which in the simplest form can program the primitive (57) and implement the above decompositions. There exist some box symmetries (e.g. all local coordinates are nothing but permuted and shifted original Cartesian coordinates), which can be exploited to achieve better performance. 27 ### D Ewald summation The Ewald summation method is based on decomposition of kernel (2) _K_ ( y _−_ x ) = _K_ 1 ( y _−_ x ; _ξ_ ) + _K_ 2 ( y _−_ x ; _ξ_ ) _,_ (58) <u>erfc (</u> _<u>ξ |</u>_ <u>y</u> _<u>−</u>_ <u>x</u> _<u>|</u>_ <u>)</u> _K_ 1 ( y _−_ x ; _ξ_ ) = _,_ y _̸_ = x ; _K_ 1 ( 0 ; _ξ_ ) = _−_ <sup><u>2</u></sup> <sup>_<u>ξ</u>_</sup> _|_ y _−_ x _|_ _~~√~~_ _<u>π</u>_ _,_ _,_ <u>erf (</u> _<u>ξ |</u>_ <u>y</u> _<u>−</u>_ <u>x</u> _<u>|</u>_ <u>)</u> _K_ 2 ( y _−_ x ; _ξ_ ) = _,_ _∀_ y _,_ x _∈_ R <sup>3</sup> _,_ _|_ y _−_ x _|_ - _K_ 2 ( 0 ; _ξ_ ) = <sup><u>2</u></sup> <sup>_<u>ξ</u>_</sup> _~~√~~_ _<u>π</u>_ which is exact for any value of parameter _ξ_, since by definition of the error function, erf( _x_ ), and the complimentary error function, erfc( _x_ ), we have erf( _x_ ) +erfc( _x_ ) = 1 and the value of _K_ 1 ( 0 ; _ξ_ ) is set due to by definition _K_ ( 0 ) = 0 _._ So for the total potential (2) we have _N_ _i_ =1 _φ_ ( y ) = _φ_ 1 ( y ) + _φ_ 2 ( y ) _,_ _φ_ 1 ( y ) = p _qiK_ 1 ( y _−_ x _i_ + p ; _ξ_ ) _,_ _N_ _i_ =1 _φ_ 2 ( y ) = p _qiK_ 2 ( y _−_ x _i_ + p ; _ξ_ ) _._ (59) Both functions _φ_ 1 ( y ) and _φ_ 2 ( y ) are periodic. Due to fast decay of erfc( _x_ ) computation of _φ_ 1 ( y ) for y _∈_ Ω0 can be done only using the sources in some neighborhood of Ω0, namely in Ω1 _⊃_ Ω0 such that the minimum distance, _a_, between the points on the boundaries _∂_ Ω0 and _∂_ Ω1 is much larger than 1 _/ξ_ . Hence, this can be computed directly by evaluation of a finite sum with a controllable error as - _e_ <sup>_−ξ_</sup> <sup>2</sup> <sup>_a_</sup> <sup>2�</sup> _φ_ 1 ( y ) = x _j_ _∈_ Ω1( _ξ_ ) _qjK_ 1 ( y _−_ x _j_ ; _ξ_ ) + _O_ _._ (60) For computation of _φ_ 2 ( y ) one can notice that _K_ 2 is a solution of the Poisson equation _<u>ξ</u>_ <sup>3</sup> _∇_ <sup>2</sup> _K_ 2 ( y _−_ x ; _ξ_ ) = _−_ 4 _πδξ_ ( y _−_ x ) _,_ _δξ_ ( y _−_ x ) = (61) _π_ <sup>3</sup> <sup>_/_</sup> <sup>2</sup> <sup>_e−ξ_</sup> <sup>2</sup> <sup>_|_</sup> <sup>y</sup> <sup>_−_</sup> <sup>x</sup> <sup>_|_</sup> <sup>2</sup> <sup>_,_</sup> where _δξ_ ( y _−_ x ) is a compactly supported function, which turns to the Dirac delta-function as _ξ_ _→∞_ . Periodic solution of the Poisson equation can be obtained via the FFT. For this purpose, we grid the domain Ω0 and select _ξ_ in a way that _ξ_ _≪_ 1 _/h_, and _ξ_ _≫_ 1 _/_ max ( _d_ 1 _, d_ 2 _, d_ 3) (an optimal setting can be found from analysis of the error bounds), where _h_ is the minimum spatial step of the grid. This enables sampling of _δξ_ ( y _−_ x ) for source x = x _i_ at several grid points around x _i_ . The number of these grid points determines the accuracy of the method (at optimal settings), so we introduce additional parameter _Nr_, so _δξ_ ( y ) is sampled in a box (2 _Nr_ + 1) _×_ (2 _Nr_ + 1) _×_ (2 _Nr_ + 1). We also take care about the points x _i_ located near the boundary of Ω0 by periodization (so we construct a periodic function _δ_ <sup>(</sup> _ξ_ <sup>p</sup> <sup>)</sup> ( y _−_ x )). Further, we apply the forward 3D FFT to _f_ 2 ( y ) = _∇_ <sup>2</sup> _φ_ 2 ( y ) = _−_ 4 _π_ _N_ _i_ =1 _qiδ_ <sup>(</sup> _ξ_ <sup>p</sup> <sup>)</sup> ( y _−_ x _i_ ) _,_ (62) and zero the harmonic of the Fourier image _f_ 2 <sup>_∗_</sup> and zero the harmonic of the Fourier image _f_ 2 <sup>_∗_</sup> <sup>(</sup> <sup>k</sup> <sup>) corresponding to the wavenumber</sup> <sup>_k_</sup> <sup>= 0</sup> <sup>_._</sup> <sup>The inverse 3D</sup> FFT of _φ_ <sup>_∗_</sup> 2 <sup>(</sup> <sup>k</sup> <sup>)</sup> <sup>=</sup> <sup>_−k−_</sup> <sup>2</sup> <sup>_f_</sup> 2 <sup>_∗_</sup> <sup>(</sup> <sup>k</sup> <sup>),</sup> <sup>produces</sup> <sup>the</sup> <sup>required</sup> <sup>solution</sup> <sup>_φ_</sup> 2 <sup>(</sup> <sup>y</sup> <sup>)</sup> <sup>with</sup> <sup>zero</sup> <sup>mean</sup> <sup>at</sup> <sup>grid</sup> <sup>points.</sup> <sup>Note</sup> FFT of _φ_ <sup>_∗_</sup> 2 <sup>(</sup> <sup>k</sup> <sup>)</sup> <sup>=</sup> <sup>_−k−_</sup> <sup>2</sup> <sup>_f_</sup> 2 <sup>_∗_</sup> <sup>(</sup> <sup>k</sup> <sup>),</sup> <sup>produces</sup> <sup>the</sup> <sup>required</sup> <sup>solution</sup> <sup>_φ_</sup> 2 <sup>(</sup> <sup>y</sup> <sup>)</sup> <sup>with</sup> <sup>zero</sup> <sup>mean</sup> <sup>at</sup> <sup>grid</sup> <sup>points.</sup> <sup>Note</sup> then that solution obtained in this way has the following mean _K_ 1 ( y _−_ x _j_ ; _ξ_ ) _dV_ _≈_ 0 _._ (63) 28 _φmean_ ( _ξ_ ) = _⟨φ_ ( y ) _⟩_ Ω0 = <sup><u>1</u></sup> _V_ 0 x _j_ _∈_ Ω1( _ξ_ ) _qj_ Ω0 The zero mean here is due to the compact support of the kernel _K_ 1 and charge neutrality. This mean can be computed using decomposition _K_ 1 ( y _−_ x _j_ ; _ξ_ ) = _K_ ( y _−_ x _j_ ; _ξ_ ) _−_ _K_ 2 ( y _−_ x _j_ ; _ξ_ ), where the integral with the first kernel can be computed analytically (see Appendix C), while the integral with the second kernel is regular and can be computed using, say, the trapezoidal rule (in the FFT-based method the space is gridded). To avoid interpolation errors, in the numerical tests where we compared our method for accuracy with the Ewald summation method, we used only cases when the source and evaluation points are located at the grid nodes. 29

섹션 본문

섹션 본문이 없습니다.

참고문헌

참고문헌 정보가 없습니다.