Scalable Evaluation of Polarization Energy and Associated Forces in Polarizable Molecular Dynamics: II. Toward Massively Parallel Computations Using Smooth Particle Mesh Ewald
Journal of Chemical Theory and Computation 11(6), 2015 DOI
HAL
Abstract
In this article, we present a parallel implementation of point dipole-based polarizable force fields for molecular dynamics (MD) simulations with periodic boundary conditions (PBC). The smooth particle mesh Ewald technique is combined with two optimal iterative strategies, namely, a preconditioned conjugate gradient solver and a Jacobi solver in conjunction with the direct inversion in the iterative subspace for convergence acceleration, to solve the polarization equations. We show that both solvers exhibit very good parallel performances and overall very competitive timings in an energy and force computation needed to perform a MD step. Various tests on large systems are provided in the context of the polarizable amoeba force field as implemented in the newly developed Tinker-HP package, which is the first implementation of a polarizable model that makes large-scale experiments for massively parallel PBC point dipole models possible. We show that using a large number of cores offers a significant acceleration of the overall process involving the iterative methods within the context of spme and a noticeable improvement of the memory management, giving access to very large systems (hundreds of thousands of atoms) as the algorithm naturally distributes the data on different cores. Coupled with advanced MD techniques, gains ranging from 2 to 3 orders of magnitude in time are now possible compared to nonoptimized, sequential implementations, giving new directions for polarizable molecular dynamics with periodic boundary conditions using massively parallel implementations.
Research Summary We present a massively parallel implementation of the AMOEBA polarization energy and forces under periodic boundary conditions in Tinker-HP, coupling the PCG and JI/DIIS solvers to smooth particle mesh Ewald.
The cost of polarization
Point-dipole polarizable force fields such as AMOEBA solve, at each step of a molecular dynamics, a linear system for the induced dipoles, whose size grows with the number of polarizable sites. Direct solvers cost the cube of the number of atoms and quadratic storage; iterative ones need many matrix-vector products. An efficient implementation thus needs a fast-converging solver, a fast matrix-vector product, and an efficient parallel setup. A previous work found two suitable solvers without periodic boundaries: the preconditioned conjugate gradient (PCG), and Jacobi iterations accelerated by direct inversion in the iterative subspace (JI/DIIS).
The solvers on smooth particle mesh Ewald
We couple both solvers to smooth particle mesh Ewald (SPME) for distributed multipoles, which computes each matrix-vector product in O(N log N) operations instead of O(N²), and derive the associated forces. Both converge as in the non-periodic case, while plain Jacobi iterations do not converge. In parallel, the direct space is split into slabs among the processes, without Newton's third law, whose extra communication limits the parallel efficiency. The FFTs of the reciprocal space scale poorly, and at first no gain came beyond 64 to 128 cores: a separate group of processes now computes the reciprocal space while the others do the direct space, balanced so that both take the same time.
Hundreds of thousands of atoms
The implementation, in Tinker-HP, matches the public version of Tinker to machine precision when tightly converged. It is tested with AMOEBA on water systems of 60,000, 96,000 and 288,000 atoms on the Stampede supercomputer: the two solvers have similar timings, JI/DIIS scaling slightly better. With two OpenMP threads per MPI process, the polarization energy and forces of the 288,000-atom system take 0.7 s on 1,024 cores, and 0.4 s per time step of a molecular dynamics (the polarization part only) with the predictor of Kolafa's always stable predictor-corrector as the initial guess. Polarizable molecular dynamics under periodic boundary conditions thus becomes possible for systems of this size; better load balancing and other force fields, such as SIBFA and GEM, are the next steps.
1 Introduction
Polarizable force fields have been, in the past decade, the subject of intense development[1, 2, 3, 4, 5, 6, 7, 8]. The ability of anisotropic polarizable molecular mechanics (APMM) to model complex systems, including charged or very polar ones, biological substrates containing metal ions, weakly interacting molecules, or ionic liquids is of prime interest in the molecular dynamics community[8, 9, 10, 11, 12], as is its robustness and transferability[8]. Furthermore, such force fields have been recently successfully employed in conjunction with quantum mechanical models[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23] in order to accurately reproduce environmental effects on structural and photophysical properties of chromophores in complex biological substrates, expanding their use to the QM/MM community. Several strategies can be used to introduce polarization in a classical force field, including fluctuating charges[20, 24, 25, 26], Drude’s oscillators[23, 27], the Kriging method[28], and induced dipoles[29, 30, 31, 32, 33]. Polarizable force fields usually require one to solve a set of linear equations[34, 35]; furthermore, a polarization term is added to the energy and thus it is required to compute the associated forces. With respect to standard, additive force fields, such a characteristic introduces a heavy computational overhead, as for each step of a molecular dynamics simulation (or for each value of the QM density in a QM/MM computation) one needs to solve a linear system whose size depends on the number of the polarizable sites. A standard, direct approach, such as the use of LU or Cholesky decomposition, becomes rapidly unfeasible for large systems, as it requires a computational effort that scales as the cube of the number of atoms, together with quadratic storage: the development of efficient iterative techniques is therefore a mandatory step in extending the range of applicability of polarizable force fields to large and very large molecular systems.
Iterative techniques require one to perform several matrix–vector multiplications, representing a computational effort quadratic in the size of the system: an efficient implementation, therefore, has three different points to address: (i) a fast convergent iterative procedure, in order to limit as much as possible the number of matrix–vector multiplications; (ii) a fast matrix–vector multiplication technique, and in particular a linear scaling technique that allows one to overcome the quadratic bottleneck; and (iii) an efficient parallel setup, in order to distribute the computational work among as many processors as possible.
In a recent article[34], we focused on the various iterative techniques suitable to solve the polarization equations for dipole-based polarizable force fields, and we found that two algorithms, namely, the preconditioned conjugate gradient (PCG) method and Jacobi iterations with convergence acceleration based on Pulay’s direct inversion in the iterative subspace (JI/DIIS), were particularly suitable for the purpose, both in terms of convergence properties and in terms of parallel implementation, addressing, therefore, the first and the third points of an optimal implementation.
The aim of our article is to introduce new algorithmic strategies to solve the polarization equations for polarizable molecular dynamics with periodic boundary conditions, for which we present a new and tailored parallel implementation together with the specific procedure to compute the associated forces. We first analyze the coupling of previously proposed iterative solvers for polarization, which we studied only in the case of direct space computations, to the smooth particle mesh Ewald (spme) technique. This technique allows one to compute the involved matrix–vector products required to determine the induced dipoles in iterative procedures with a computational effort, addressing, therefore, the need for an efficient and scalable implementation. Indeed, spme for distributed multipoles was introduced by Sagui et al. [36], and Wang and Skeel [35] demonstrated that PCG was compatible with spme, but the study was limited to the case of permanent point charges. We then propose to assemble such ingredients into a new parallel implementation using spme for distributed multipoles and improved polarization solvers including the newly developed JI/DIIS. This strategy is oriented toward the needs of massive parallelism, allowing one to tackle large systems by distributing both computation and memory on a large number of cores and resorting to a newly developed module of Tinker called Tinker-HP. In fact, the spme method computes the electrostatic interactions as the sum of a direct space contribution, which is limited to close neighbors, plus a reciprocal (Fourier) space sum, which can be efficiently computed thanks to the fast Fourier transform (fft). However, the heavy cost in communication of any parallel fft implementation makes achieving a scalable parallel global implementation a more complex task than for direct space simulations. Such an issue is expected to be the main bottleneck for the parallel efficiency of the presented iterative solvers and will be addressed in our study. To limit the impact of this cost, our parallel implementation exploits the independence of the direct and reciprocal sums by assigning them to two separate groups of processes. Moreover, the data is distributed following a 1D spatial decomposition in both direct and reciprocal space, with the latter being imposed by the fft library we are using (FFTW) and the former having been chosen for the simplicity of its implementation and its compatibility with the reciprocal space 1D decomposition. Also, our implementation does not exploit Newton’s third law for direct space, as we have observed that it limits its parallel efficiency.
The article is organized as follows. In Section 2, we introduce the spme formalism in the general context of APMM using distributed point multipoles. In Section 3, we explicitly formulate the polarization energy and introduce the different iterative methods to solve the polarization equations. In Section 4, we explore the parallel behavior of the different iterative algorithms as well as the parallel behavior of the computation of the forces. In Section 5, some numerical results are provided. We conclude the article in Section 6 with some conclusions and perspectives.
2 PME with Multipolar Interactions
The use of periodic boundary conditions is a natural choice when simulating intrinsically periodic systems, such as crystals or pure liquids, and is a commonly used procedure to simulate solvated systems with explicit solvent molecules including proteins, ions, etc. Notice that an alternative approach, based on nonperiodic boundary conditions and polarizable continuum solvation models, has also been recently proposed for APMM[37, 38].
When PBC are employed, the use of the particle mesh Ewald method becomes particularly interesting because of both its computational efficiency and the physical accuracy of the results it provides. The PME method is based on the Ewald summation [39] introduced to compute the electrostatic energy of a system in PBC and has been originally formulated by Darden et al. [40]. This first formulation, that involved Lagrange polynomials, introduced forces that were not analytical derivatives of the energy and another formulation using B-splines, the spme, was given by Essmann et al. [41], allowing analytical differentiation to obtain the forces and so ensuring energy conservation. Such an approach, first developed for distributed point charges only, was extended to distributed multipoles by Sagui et al. [36] and to distributed Hermite Gaussian densities by Cisneros et al. [42].
2.1 Notation
In this article, we will use the same notation as that in our previous article[34]. Let be the system composed of a neutral unit cell containing atoms at positions replicated in all directions. Let be the vectors defining the unit cell so that its volume is . We will indicate vector quantities by using an arrow if the vectors are in and with bold font if they represent a collection of three-dimensional vectors. For instance, will be a -dimensional column vector , where each is a three-dimensional column vector (in particular, a dipole). We will use Latin indexes as a subscript to refer to different atomic sites and Greek indexes as superscripts to indicate the Cartesian component of a vector so that denotes the th Cartesian component () of the vector ().
For any integers and , we will denote
where is the dual basis of (i.e., ). Hence, in what follows, will always be in the direct space and in the reciprocal space, and we shall identify with and with .
Furthermore, we will call fractional coordinates of the atoms the quantities
| (1) |
In the amoeba polarizable force field with which we have been working, the charge density of a system is approximated by a set of permanent atomic multipoles (up to quadrupoles) located at the atomic positions , which we will denote as follows: for .
2.2 Ewald Summation and Smooth Particle Mesh Ewald
In this subsection, we will review how to compute electrostatic interactions between permanent multipoles in periodic boundary conditions by using the Ewald summation and the smooth particle mesh Ewald method. The idea is to split the electrostatic energy into three terms: two being sums with good convergence properties and the third one being independent of the atomic positions.
The electrostatic potential at a point created by the permanent multipoles is obtained by applying the associated multipole operator to , where, for
| (2) |
where is the matrix defined by . Let us define the multipole structure factor
| (3) |
with being the Fourier transform of the multipole operator associated with site
| (4) |
where .
The electrostatic potentials generated by the permanent multipoles at site and the corresponding electrostatic energy are formally given by
| (5) | ||||
| (6) |
where the exponent means that the terms are not summed when . The Ewald summation technique [39, 43] allows one to decompose the electrostatic energy of the geometric configuration (eq 6) into three components: a contribution consisting of short-range interactions computed in the real space, a global contribution computed in the reciprocal space and a self-energy term , which is a bias arising from the Ewald summation. These contributions are given by
| (7) | ||||
| (8) | ||||
| (9) |
We therefore have
| (10) |
This formulation introduces a positive parameter that controls the range of the direct term and conversely the importance of the reciprocal term. The direct term is computed using a cutoff (that depends on ) as the function in this term decreases to zero on a characteristic distance that depends on this parameter. Note that, as done by Wang and Skeel [35], we neglect the surface term that arises during the derivation of the Ewald summation. We have thus chosen to use the self-energy that is commonly used in the literature[31, 44, 45, 46], and this does not change the associated forces in molecular dynamics. However, as will be shown by some of us, other forms can be considered for this term.
Scaling factors and damping functions[30, 31, 47] are often used in force fields to parametrize electrostatic interactions at short range, for instance, in order to exclude close (1–2, 1–3, 1–4) neighbors; here, we assume that the only interactions concerned are between atoms within the unit cell. As the Ewald summation corresponds to unscaled interactions, one has to take this into account by adding a correction to the energy computed with this method. Suppose that the interaction between multipoles of sites and is scaled and/or damped by a factor (), then the correction
| (11) |
has to be added to the total energy. Let us define the sum of all these terms
| (12) |
where is the list of atom sites for which the multipolar interactions between sites and are scaled. For the case of the computation of the polarization energy, where all dipole–dipole interactions are included, such scaling parameters originate from Thole’s damping, which is introduced in order to avoid the so-called polarization catastrophe[30, 47].
As explained in ref 45, the total electrostatic potential can be split into four contributions , , and , with
| (13) |
In the context of the spme method, the fractional coordinates of the atoms that appear in the reciprocal term are scaled by three factors (one for each coordinate). Indeed, let be positive integers; then, the corresponding scaled fractional coordinates of atom are given by
| (14) |
In consequence, the complex exponential functions present in the reciprocal potential and the structure factor can be written
| (15) |
The spme consists in replacing each of the complex exponentials , as a function of , by a B-spline interpolation of degree on a grid of size . Using B-splines makes the spme approximation of the reciprocal potential differentiable and allows one to derive forces that are analytical derivatives of the spme approximation of . Furthermore, the sums appearing in the reciprocal potential when using the approximation through B-spline interpolation can be interpreted as discrete Fourier transformations, allowing one to use the fft summation technique. After some cumbersome algebra[48], the reciprocal potential can be approximated by
| (16) |
where are the B-splines of degree of Sagui et al. [48], is the influence function defined by its Fourier transform in Sagui et al. [48], and is the real space multipolar array associated with the atomic multipoles of the system given by
| (17) |
Thus, two sets of parameters control the approximation level of the spme algorithm: , which define the size of the interpolation grid along each axis, and , the degree of the B-splines with which these complex exponentials are interpolated.
From a computational point of view, the standard spme algorithm follows these steps:
- 1.
Compute the real space potential. The derivatives of the function can be computed recursively, as shown in ref 49.
- 2.
Compute the correction potential due to scaling factors of the electrostatic interactions (usually done at the same time as the computation of the real space potential).
- 3.
Compute the reciprocal potential:
- (a)
Build the multipolar array associated with the atomic multipoles of the system;
- (b)
compute the fft of this array ;
- (c)
multiply with , i.e., the Fourier transform of , which corresponds to a convolution in direct space;
- (d)
compute the backward fft of the result to get the convolution of and ;
- (e)
multiply the result with the values of the B-splines at the position where the potential is to be evaluated following eq 16.
- (a)
3 Evaluation of the Polarization Energy and Its Derivatives in Periodic Boundary Conditions
In this section, we will see how the previously described methods, i.e., the Ewald summation and smooth particle mesh Ewald, can be used in order to compute the polarization energy and the associated forces in a dipole-based polarizable force field.
The static multipoles create, at each atom , an electric field that is responsible for an induced dipole moment , the unknown of the polarization problem, in such a way that the (favorable) interaction between the induced dipoles and the inducing field is maximized while the sum of the work to polarize each site and the repulsion between the induced dipoles is minimized. In other words, the electrostatic equilibrium is reached when the total polarization energy (defined below) is minimized.
3.1 The Polarization Energy
Let us introduce the vectors
| (18) |
where collects the electric fields created by the permanent multipoles on the atom sites and , the induced dipoles. The polarization energy functional can be written in a compact way
| (19) |
where the first term represents the interactions between the dipoles and the inducing field and the second one, the interactions between dipoles expressed through the polarization matrix that will be introduced below. The minimizer of eq 19 is the total vector of the induced dipole moments we introduced above; it satisfies the optimality condition
| (20) |
3.1.1 Permanent Fields
One can apply the Ewald summation to the electric fields for in a similar fashion to what was described in the last section
| (21) |
where
| (22) | ||||
| (23) | ||||
| (24) | ||||
| (25) |
The field is a bias arising from the Ewald summation. Applying the spme method, one can approximate by
| (26) |
as explained in Section 2.
3.1.2 The Polarization Matrix
One can also apply the Ewald summation to the electric fields at site generated by the other induced dipoles and their images and by the images of , which leads to the expression of the off-diagonal term of the polarization matrix
| (27) |
The expressions of the three terms of the right-hand side of eq 27 are
| (28) | ||||
| (29) | ||||
| (30) |
Applying the spme method, we then have
| (31) |
where is the multipolar array associated with the component of the th induced dipole
| (32) |
From the Ewald summation, the self-fields , where
| (33) |
also have to be included to the expression of the polarization energy that reads
| (34) |
where the polarizabilities describe the linear response to an electric field of the contribution of atom to the density of charge. Recall that the first term represents the interactions between the inducing field and the dipoles, and the others, the interactions between dipoles. Finally, the polarization matrix takes the form
| (35) |
3.2 Forces
The forces associated with the polarization energy are obtained by differentiating the latter with respect to the positions of the atoms. At this point, we should remind the reader that not only does depends on the atomic positions but also the minimizer . We thus obtain
where we have exploited the variational formulation of the polarization energy. More precisely, we can develop
| (36) |
The second term of the right-hand side of eq 36 originates from the fact that the polarizability tensor needs to be first defined in some molecular frame and then rotated in the lab frame; similar contributions are also present in the first term due to the static dipoles and quadrupoles. Such contributions to the forces require one to take the derivatives of the rotation matrices used to switch from the local frame, where the polarizabilities and multipoles are expressed, to the global frame into account. A complete derivation of these terms, which is straightforward but very cumbersome, can be found in ref 34.
3.3 Iterative Schemes To Solve the Polarization Equations
In Section 3.1, we introduced the polarization equations (20), which require the polarization matrix to be inverted to compute the induced dipoles. As can be very large, it is usually not possible to use exact methods such as LU or Cholesky factorizations, whose computational cost scales as (for a matrix) and that require quadratic storage. A more convenient strategy is to use an iterative method. In a recent article[34], we explored various iterative strategies to solve the polarization equations. We suggested that two methods seem to be especially suitable for the computation of the induced dipoles within a parallel implementation: the preconditioned conjugate gradient (PCG) method and the Jacobi method coupled with direct inversions in the iterative subspace (DIIS).
We observed that the spectrum of the polarization matrix with periodic boundary conditions computed with spme has, in general, almost the same structure as for nonperiodic boundary conditions; both methods have the same rate of convergence for our particular problem as what was described in our previous article. The convergence of such methods is shown in Figure 1 in comparison with the Jacobi over-relaxation method (JOR), which has traditionally been used in conjunction with the amoeba force field. Similarly to what was observed in direct space computation, both the JI/DIIS and PCG exhibit good convergence properties. Notice that the simple Jacobi iterations are not convergent. Although the rate of convergence is the same as for the previously studied direct space case, the decomposition of the polarization matrix in three matrices (four with the diagonal) with particular properties makes the parallel implementation of the solvers different.

4 Parallel Implementation
Let us recall the steps of both the PCG and JI/DIIS iterative methods in order to comment their parallel implementations with MPI.
Starting from an initial guess , they define a new set of induced dipoles at each iteration. In the case of the JI/DIIS solver, the new induced dipoles are obtained after one block-type Jacobi iteration followed by a DIIS extrapolation. This extrapolation requires one to assemble the so-called DIIS matrix, which is done by making scalar products of the past increments with the newest one[50].
Let be the convergence threshold and the maximum number of iterations. Also, let be the off-diagonal part of the polarization matrix and be the () block-diagonal matrix with the polarizability tensors of the atoms of the system on its diagonal. Furthermore, let be the () block-diagonal matrix collecting the self-terms, and the () block-diagonal part of given by so that . Then JI/DIIS can be summarized as follows
The procedure is slightly more complicated for the conjugate gradient method because the new set of induced dipoles is obtained by updating them using a descent direction.
Let be such a descent direction at iteration , is the residual at the same iteration, and . Then, the conjugate gradient is described by the following pseudocode (the preconditioned conjugate gradient differs only by the fact that is replaced by and by )
In both cases, matrix–vector products are required at each iteration; these involve the current values of the dipoles for the JI/DIIS and the descent direction for the conjugate gradient.
In terms of a parallel implementation, the parts that require communication between processes are these matrix–vector products (communication of the dipoles or of the descent direction) and the scalar products (reductions). A detailed discussion on the different aspects of the parallel implementation of the two solvers can be found in the Supporting Information. Note that we have improved our last parallel implementation of the solvers (which was coupled with direct space computations only) so that the only important difference between them is an additional round of communications (of the converged induced dipoles) in the case of the PCG. For this reason, we expect them to have a similar parallel behavior.
4.1 Direct Part (Real Space)
In this section, we first recall the main steps of the previously studied parallel implementation of the polarization solvers without periodic boundary conditions and then explain the differences with respect to the case of the direct part of the interactions when spme is used.
When no periodic boundary conditions are imposed, as studied in ref 34, no cutoff is used so that global communications of the current dipoles (JI/DIIS) or descent direction (PCG) are mandatory and a particle decomposition, where the atoms are distributed among processes without taking into account their positions, is suitable. These global communications, whose number grows quadratically with the number of processes, are then the obvious bottleneck to the effectiveness of the parallel implementation.
Things are more complicated for spme computations. First, the use of a cutoff for the short-range real space part of the interactions makes the broadcast of all of the dipoles at each iteration unnecessary: at each iteration, each process has to receive only the values of the induced dipoles that are at a distance inferior to the real space cutoff.
To take advantage of this, we choose to use a spatial decomposition load balancing, where each process is assigned to a region of the elementary cell. This implies that each process computes the induced dipoles arising on every atomic site lying in its part of the elementary cell. For now, our algorithm considers only a spatial decomposition into slabs using a 1D decomposition of one of the three directions, and an iterative procedure has been implemented in order to adapt the size of these domains in the case of non homogeneous systems. More advanced load balancing procedures have been proposed in the literature (ref 51). Further developments and the tuning of these techniques for the polarization problem are under active investigation by our team, and they will be included in future implementations. To reduce the total number of messages, a good strategy is to send the induced dipoles by block: a process receives the whole part of the induced dipoles vector treated by another process as long as it needs to receive at least one of its values.
Also, we have observed that using Newton’s third law, that is, to compute the distance involving a pair of atom sites only once, is an important obstacle to a scalable implementation. Indeed, although it allows one to reduce the computations of such distances by half, one has to make additional communication between the processes when using this technique, which has a great impact on the parallel efficiency of the algorithm for large systems and/or when a large number of cores is employed. Furthermore, we observed that the loss in efficiency for a few cores is quickly compensated by the gain in parallel efficiency when a larger number of cores is used.
4.2 Reciprocal Space Part
The computation of the reciprocal polarization matrix/induced dipoles matrix vector product can be divided in four steps, as explained in Section 2.
- 1.
The first one is to fill the multipolar array : this can be easily distributed among the processes.
- 2.
The second one is to compute the fft of this array. We use the parallel version of the FFTW library[52] to perform this task. As with all of the other parallel fft libraries, the large number of communications that it requires limits its parallel scaling to a relatively low number of cores for the 3D grids normally used for the PME method (up to , for example). The impact of this can be limited by increasing the real space cutoff while decreasing the size of the fft grid in order to keep the same accuracy for the PME while limiting the proportional time spent doing FFTS. Furthermore, as a 1D decomposition is used again to split the work among the processors (but this time the reciprocal space is divided into slabs), no performance gain can be obtained by using slabs smaller than one. Note also that the amoeba force field [53] requires one to compute two sets of induced dipoles, which correspond to two sets of electric fields created by the permanent multipoles on the atom sites with different scaling parameters[37]. However, with the arrays involved in the fft being all real, it is possible to obtain all of the results by calling only one complex to complex fft calculation. As mentioned above, the grid points are distributed among the processes with a 1D decomposition when using the MPI version of the FFTW library. Suppose that , and are the sizes of the grid axis on the three dimensions on which the fft has to be done. Then, each MPI process treats slabs of data of size , where the variation of the values of is as small as possible between processes in order for the computational load to be well-distributed. We require each process to compute the contribution to the grid of the dipoles whose scaled fractional coordinate belongs to the portion of the grid treated by this process. Depending on how the spatial decomposition is made initially, this may require a few communications between neighboring processes. Because the B-splines are nonzero only on a small portion of the grid around the scaled fractional coordinates () of the corresponding atoms, only processes treating a neighboring portion of the grid may have contributions to the array representing the dipoles that overlap each other grids domain. In terms of communication, this means that before calling the fft routine each process needs to receive the contributions of its neighboring processes to its part of the grid and send its contribution to the part of the grid of its neighboring processes. Thus, these local communications are not a limiting factor in terms of parallel scaling.
- 3.
Then, the convolution in Fourier space is easily distributed among the processes, and the backward fft can be directly computed in parallel as each process already has its whole portion of the grid.
- 4.
Finally, for the same reasons as given above, processes have to communicate their part of the grid to neighboring processes in order to extract the reciprocal potentials by multiplying the grid values with the appropriate B-spline values.
As explained above, reductions have to be done during the iterative procedure. This can be done without affecting the parallel scaling by using the nonblocking collective operations from the MPI3 standard that allow one to cover efficiently communications with computations.
4.3 Forces
Things are less complicated for the computation of the forces associated with the polarization energy: no iterative procedure is necessary, and one can make use of previous computations in order to limit the number of calls to the fft routines. Indeed, as the first step of the computation of the induced dipoles is to compute the electric fields due to the permanent multipoles of the system , the associated multipolar grid can be stored and reused to get the derivatives of the reciprocal part of this electric fields by just multiplying this grid by the appropriate derivative of the B-splines at the appropriate grid points. This cannot be done to get the electric fields created by the induced dipoles, as the only associated grid that could be stored would be the one associated with the dipoles one iteration before convergence. Thus, it needs to be computed.
5 Numerical Results
5.1 Computational Details
The new solvers were included in our Tinker-HP code that is a stand alone module based on elements of Tinker 6.3 and 7.0 that includes new developments introduced by our lab. The parallel implementation was tested on the Stampede supercomputer of the TACC (Texas Advanced Computing Center) whose architecture consists, for the part on which we did our tests, of 6400 nodes with two intel Xeon E5-2680 CPUs with eight cores at 2.7 GHz and 32 GB of DDR3 DIMM RAM. These nodes communicate within a 56 GB/s InfiniBand network. The following numerical results are all based on computations made on this supercomputer. To benchmark our algorithms, we considered three water molecule clusters of different sizes: one of 20 000 molecules (60 000 atoms), one of 32 000 molecules (96 000 atoms), and one of 96 000 molecules (288 000 atoms). A nonperfect solution to the polarization equations gives rise to small errors that, by accumulating, can spoil the long time energy conservation. Furthermore, the use of a predictor guess introduces an element of non time reversibility that contributes to possible long time energy drifts. However, as shown in our previous publication[34], the choice of a tight enough convergence criterion guarantees a reasonable long time energy conservation during a MD. Also, the virtual absence of short time fluctuations makes the use of a weakly coupled thermostat sufficient to control the long time behavior of the simulation. That is why we used a tight convergence criterion ( on the rms increment) in all three test cases. We used B-splines of degree 5 and a real space cutoff parameter of 1 nm. The AMOEBA09 force field was used for every computation. The characteristics of these test systems, together with the PME grid sizes used and the size of the elementary cubic cell, are given in Table 1. In view of using many processors, notice that the PME parameters are chosen in order to increase the computational cost of the direct part of the interactions (with better parallel scaling) and to decrease the importance of the reciprocal part while keeping a good accuracy of the global results. From our tests, we observed that with these parameters the computation of the polarization energy and of the associated forces represents more than 70% of a full force field single-point calculation.
We tested our implementation of both solvers and of the forces on the Stampede cluster and verified that we obtained the same results as the public version of TINKER up to the machine precision when the convergence criterion was pushed to extremely small values. A first implementation showed that the poor parallel scaling of the 3D fft routines limited the global parallel scaling of the algorithm: no gain could be obtained by using more than 64–128 cores. To limit and compensate the impact of the poor parallel scaling of the fft routines, a popular strategy is to take advantage of the independence of the direct and reciprocal contributions by assigning their treatment to separate group of processes[51, 54] in a heteregenous scheme. The reciprocal space part is faster than the direct space one (by a factor that depends on the parameter used); however, the latter has better parallel scaling: it is therefore possible to use more processors for the better scaling part by balancing the distribution of cores in such away that the reciprocal and direct space computations each take the same time doing their part of the matrix–vector products. The heterogeneous strategy allows us to increase the scalability of our code up to 512 cores.
| system | no. of atoms | box size | grid size |
|---|---|---|---|
| S1 | 60 000 | 8.40 | |
| S2 | 96 000 | 9.85 | |
| S3 | 288 000 | 14.30 |
aBox size is the size of the edge of the cubic box, in nanometers.



The absolute best timings for the solvers are reported in Table 2. The best timings obtained with the 6.3 version of TINKER, which is parallelized with OpenMP routines and uses a different implementation of the PCG solver, are also reported in Supporting Information for comparison. Both the JI/DIIS and the PCG solvers share a similar parallel behavior; the JI/DIIS solver exhibits a small edge in terms of parallel efficiency, which is explained in Section 4, due to the additional communications happening after convergence in order to compute the forces. Nevertheless, the absolute best timings of the two solvers are comparable.
| system | PCG | JI/DIIS |
|---|---|---|
| S1 | 0.45 (128) | 0.44 (128) |
| S2 | 0.50 (192) | 0.47 (192) |
| S3 | 0.92 (512) | 0.88 (512) |
The parallel computation of the forces associated with the polarization energy also naturally benefits from the separate calculation of the direct and reciprocal contributions. The scaling of our implementation is reported in Figure 5. The absolute best timings are also reported in Table 3, and a comparison with the best timings obtained with the 6.3 version of TINKER can be found in the Supporting Information.

| system | TINKER-HP |
|---|---|
| S1 | 0.07 (256) |
| S2 | 0.10 (256) |
| S3 | 0.20 (512) |
5.2 Further Performance Improvements
All of the loops involved in the solvers and in the computation of the forces can be parallelized with OpenMP within each MPI process in order to limit the number of necessary communications for a given number of cores and to take advantage of the shared memory architecture within each node of the supercomputer. Furthermore, the FFTW library also enables to use such a computational paradigm. We found experimentally that the best results using this hybrid OpenMP/MPI paradigm were obtained by using two OpenMP threads per MPI process, allowing the overall best timing of the solvers and of the computation of the forces to be improved. Notice that this hybrid paradigm can be used to extend the range of scalability of the MPI implementation; however, whenever the MPI implementation has not reached its scaling plateau, the pure MPI code is always more efficient than the hybrid one. Nevertheless, the hybrid implementation allows one to take advantage of a larger number of processors, when available.
The best overall timings obtained with the hybrid implementation are given in Table 4 for both solvers and for the forces. The total best timings (energy + forces) are also reported. The numbers in the last column of Table 4 give a measure of the overall computational overhead introduced by the use of polarizable force field in a PBC MD simulation: even for a system as large as S3 (almost 300 000 atoms), such an overhead can be reduced to less than a second of wall time by using the JI/DIIS solver together with the new parallel implementation. However, such numbers were computed by using a guess for the dipoles that does not take advantage of previous information, for instance, the values of the dipoles at previous steps of the simulation. As discussed in a recent publication[34], the results can be further improved by using as a guess the predictor step of Kolafa’s always stable predictor corrector[55]: we report in Table 5 the results obtained by using such a guess, which represents our default choice for MD simulations.
| solver | |||||
|---|---|---|---|---|---|
| system | cores | PCG | JI/DIIS | forces | total |
| S1 | 256 | 0.32 | 0.30 | 0.04 | 0.34 |
| S2 | 512 | 0.35 | 0.35 | 0.08 | 0.43 |
| S3 | 1024 | 0.61 | 0.60 | 0.10 | 0.70 |
aThe overall dipoles plus forces best timings are also reported.
| solver | |||||
|---|---|---|---|---|---|
| system | cores | PCG | JI/DIIS | forces | total |
| S1 | 256 | 0.16 | 0.15 | 0.04 | 0.19 |
| S2 | 414 | 0.18 | 0.18 | 0.08 | 0.26 |
| S3 | 1024 | 0.32 | 0.30 | 0.10 | 0.40 |
aThe overall dipoles plus forces best timings are also reported.
In conclusion, our new implementation allows one to treat systems as large as S3 by introducing an overhead as little as 0.7 s on 1024 cores, which can be further reduced to 0.4 s per time step during a MD simulation by using better initial guesses, allowing polarizable MD simulations in PBC to be performed on large and very large systems.
6 Conclusions
In this article, we presented a new implementation of the polarization energy and associated forces for the amoeba force field that is suited to perform polarizable MD simulations using periodic boundary conditions on parallel computers. To do so, we studied the coupling of the PCG and JI/DIIS iterative solvers for polarization to spme for distributed multipoles and discussed their optimal parallel implementation. We stated in the introduction that three ingredients are needed in order to achieve an efficient implementation of a polarizable force field: a fast convergent iterative solver, a fast matrix–vector multiplication technique, and an efficient parallel setup. The three points have been addressed in this article, and the resulting implementation has been tested on large to very large systems. Let us recapitulate the main results of this work. The first two points have been addressed by extending PCG and JI/DIIS[34] to the context of PBC simulations with spme. Indeed, spme transforms the involved quantities avoiding the computational bottleneck and replacing it by a calculation.
Finally, this article addresses the third point with an extended discussion of the various technical issues that affect the specific polarization problems. The two iterative solvers have been analyzed in a real-life context, i.e., MD simulations, when the forces have to be computed after the linear equations have been solved. Both solvers are well-suited for a parallel implementation; however, JI/DIIS appears to be slightly superior to PCG for very scalable implementations. Finally, the use of only a portion of the available CPUs to do the various reciprocal space computations while employing the other processors for the more scalable direct space ones in order to compensate the nonoptimal parallel scaling of the FFTs has been addressed. This nonoptimal parallel behavior is the main bottleneck of our parallel implementation, which is the first to address such issues in a production code for polarizable MD.
The scaling of our implementation is overall quite good up to as many as 512–1024 cores; we would like to point out that a parallel implementation of polarizable force fields is much more challenging than that for additive force fields, as solving the polarization linear systems implies a large number of synchronization barriers, one per iteration, in particular, the effect of which can be only partially mitigated by covering communication with computation.
Overall, we illustrated how our new implementation is well-suited to treat large and very large systems, thus extending the range of applicability of dipole-based polarizable force fields such as amoeba to very large systems; by using 1024 cores, as little as 0.4 s per time step is needed to handle the polarization energy and forces for a system composed of as much as 288 000 atoms when Kolafa’s predictor step is used to provide a guess for the iterative solver.
There are still various open challenges and improvements that need to be addressed for polarizable MD simulations. The use of more advanced load balancing techniques, in the spirit of what was done for example in GROMACS[51, 56], certainly deserves future investigation. The extension of the presented machinery to other advanced force fields, such as SIBFA[8] and GEM[42], is another interesting development that is being actively investigated in our groups. On a different note, we have recently proposed a complementary approach, that is, the use of polarizable continuum solvation methods instead of PBC: a comparison between the two approaches, especially for difficult systems such as highly charged metal ions or biological molecules, as well as a comparison of the performances of the two approaches is in progress. The presented methods will also be included in the FFX package[57]. We will present in an upcoming paper an improved global scaling of the amoeba force field within the massively parallel Tinker-HP package based on Tinker 7.
Supporting Information
Technical discussion regarding parallelization of JI/DIIS and PCG; timing comparison between Tinker-HP and Tinker 6.3.
Funding
This work was supported in part by French state funds managed by CalSimLab and the ANR within the Investissements d’Avenir program under reference ANR-11-IDEX-0004-02. Pengyu Ren is grateful for support by the Robert A. Welch Foundation (F-1691) and the National Institutes of Health (GM106137), as well as the high performance computing resources provided by TACC and XSEDE (TG-MCB100057). Funding from French CNRS through a PICS grant between UPMC and UT Austin is acknowldeged. Filippo Lipparini gratefully acknowledges the Alexander von Humboldt foundation for funding. Etienne Polack and Jean-Philip Piquemal are grateful for support by the Direction Générale de l’Armement (DGA) - Maîtrise NRBC of the French Ministry of Defense.
Acknowledgments
We wish to thank Marie-France Couret for technical support.
References
- [1] Jorgensen, W. L. J. Chem. Theory Comput. 2007, 3, 1877–1877, and references therein.
- [2] Warshel, A.; Kato, M.; Pisliakov, A. V. J. Chem. Theory Comput. 2007, 3, 2034–2045.
- [3] Cieplak, P.; Dupradeau, F.-Y.; Duan, Y.; Wang, J. J. Phys.: Condens. Matter. 2009, 21, 333102.
- [4] Lopes, P. E.; Roux, B.; MacKerell, A. D., Jr. Theor. Chem. Acc. 2009, 124, 11–28.
- [5] Piquemal, J.-P.; Jordan, K. D. Theor. Chem. Acc. 2012, 131, 1–2.
- [6] Ji, C.; Mei, Y. Acc. Chem. Res. 2014, 47, 2795–2803.
- [7] Cisneros, G. A.; Karttunen, M.; Ren, P.; Sagui, C. Chem. Rev. 2014, 114, 779–814.
- [8] Gresh, N.; Cisneros, G. A.; Darden, T. A.; Piquemal, J.-P. J. Chem. Theory Comput. 2007, 3, 1960–1986.
- [9] Freddolino, P. L.; Harrison, C. B.; Liu, Y.; Schulten, K. Nat. Phys. 2010, 6, 751–758.
- [10] Tong, Y.; Mei, Y.; Li, Y. L.; Ji, C. G.; Zhang, J. Z. H. J. Am. Chem. Soc. 2010, 132, 5137–5142.
- [11] Luo, Y.; Jiang, W.; Yu, H.; MacKerell, A. D.; Roux, B. Faraday Discuss. 2013, 160, 135–149.
- [12] Huang, J.; Lopes, P. E. M.; Roux, B.; MacKerell, A. D. J. Phys. Chem. Lett. 2014, 5, 3144–3150.
- [13] Nielsen, C. B.; Christiansen, O.; Mikkelsen, K. V.; Kongsted, J. J. Chem. Phys. 2007, 126, 154112.
- [14] Kongsted, J.; Osted, A.; Mikkelsen, K. V.; Christiansen, O. J. Chem. Phys. 2003, 118, 1620–1633.
- [15] Steindal, A. H.; Olsen, J. M. H.; Ruud, K.; Frediani, L.; Kongsted, J. Phys. Chem. Chem. Phys. 2012, 14, 5440–5451.
- [16] Marini, A.; Muñoz-Losa, A.; Biancardi, A.; Mennucci, B. J. Phys. Chem. B 2010, 114, 17128–17135.
- [17] Jacobson, L. D.; Herbert, J. M. J. Chem. Phys. 2010, 133, 154506.
- [18] Arora, P.; Slipchenko, L. V.; Webb, S. P.; DeFusco, A.; Gordon, M. S. J. Phys. Chem. A 2010, 114, 6742–6750.
- [19] Caprasecca, S.; Curutchet, C.; Mennucci, B. J. Chem. Theory Comput. 2012, 8, 4462–4473.
- [20] Lipparini, F.; Barone, V. J. Chem. Theory Comput. 2011, 7, 3711–3724.
- [21] Lipparini, F.; Cappelli, C.; Barone, V. J. Chem. Theory Comput. 2012, 8, 4153–4165.
- [22] Lipparini, F.; Cappelli, C.; Barone, V. J. Chem. Phys. 2013, 138, 234108.
- [23] Boulanger, E.; Thiel, W. J. Chem. Theory Comput. 2012, 8, 4527–4538.
- [24] Rick, S. W.; Stuart, S. J.; Berne, B. J. J. Chem. Phys. 1994, 101, 6141–6156.
- [25] Verstraelen, T.; Speybroeck, V. V.; Waroquier, M. J. Chem. Phys. 2009, 131, 044127.
- [26] Piquemal, J.-P.; Chelli, R.; Procacci, P.; Gresh, N. J. Phys. Chem. A 2007, 111, 8170–8176.
- [27] Lamoureux, G.; Roux, B. J. Chem. Phys. 2003, 119, 3025–3039.
- [28] Mills, M. J.; Popelier, P. L. Comput. Theor. Chem. 2011, 975, 42–51.
- [29] Applequist, J.; Carl, J. R.; Fung, K.-K. J. Am. Chem. Soc. 1972, 94, 2952–2960.
- [30] Thole, B. Chem. Phys. 1981, 59, 341–350.
- [31] Wang, J.; Cieplak, P.; Li, J.; Wang, J.; Cai, Q.; Hsieh, M.; Lei, H.; Luo, R.; Duan, Y. J. Phys. Chem. B 2011, 115, 3100–3111.
- [32] Ponder, J. W.; Wu, C.; Ren, P.; Pande, V. S.; Chodera, J. D.; Schnieders, M. J.; Haque, I.; Mobley, D. L.; Lambrecht, D. S.; DiStasio, R. A.; Head-Gordon, M.; Clark, G. N. I.; Johnson, M. E.; Head-Gordon, T. J. Phys. Chem. B 2010, 114, 2549–2564.
- [33] Gordon, M. S.; Slipchenko, L.; Li, H.; Jensen, J. H. Annu. Rep. Comput. Chem. 2007, 3, 177–193.
- [34] Lipparini, F.; Lagardère, L.; Stamm, B.; Cancès, E.; Schnieders, M.; Ren, P.; Maday, Y.; Piquemal, J.-P. J. Chem. Theory Comput. 2014, 10, 1638–1651.
- [35] Wang, W.; Skeel, R. D. J. Chem. Phys. 2005, 123, 164107.
- [36] Sagui, C.; Pedersen, L. G.; Darden, T. A. J. Chem. Phys. 2004, 120, 73–87.
- [37] Lipparini, F.; Lagardère, L.; Raynaud, C.; Stamm, B.; Cancès, E.; Mennucci, B.; Schnieders, M.; Ren, P.; Maday, Y.; Piquemal, J.-P. J. Chem. Theory Comput. 2015, 11, 623–634.
- [38] Caprasecca, S.; Jurinovich, S.; Lagardère, L.; Stamm, B.; Lipparini, F. J. Chem. Theory Comput. 2015, 11, 694–704.
- [39] Ewald, P. P. Ann. Phys. 1921, 369, 253.
- [40] Darden, T.; York, D.; Pedersen, L. J. Chem. Phys. 1993, 98, 10089–10092.
- [41] Essmann, U.; Perera, L.; Berkowitz, M. L.; Darden, T.; Lee, H.; Pedersen, L. G. J. Chem. Phys. 1995, 103, 8577–8593.
- [42] Cisneros, G. A.; Piquemal, J.-P.; Darden, T. A. J. Chem. Phys. 2006, 125, 184101.
- [43] Smith, E. R. Proc. R. Soc. A 1981, 375, 475–505.
- [44] Aguado, A.; Madden, P. A. J. Chem. Phys. 2003, 119, 7471–7483.
- [45] Toukmaji, A.; Sagui, C.; Board, J.; Darden, T. J. Chem. Phys. 2000, 113, 10913–10927.
- [46] Nymand, T. M.; Linse, P. J. Chem. Phys. 2000, 112, 6152–6160.
- [47] Sala, J.; Guàrdia, E.; Masia, M. J. Chem. Phys. 2010, 133, 234101.
- [48] Sagui, C.; Pedersen, L. G.; Darden, T. A. J. Chem. Phys. 2004, 120, 73–87.
- [49] Smith, W. CCP5 Newsletter 1998, 46, 18–30.
- [50] Rohwedder, T.; Schneider, R. J. Math. Chem. 2011, 49, 1889–1914.
- [51] Hess, B.; Kutzner, C.; van der Spoel, D.; Lindahl, E. J. Chem. Theory Comput. 2008, 4, 435–447.
- [52] Frigo, M.; Johnson, S. G. IEEE Trans. Acoust., Speech, Signal Process. 1998, 3, 1381–1384.
- [53] Ponder, J. W.; Wu, C.; Ren, P.; Pande, V. S.; Chodera, J. D.; Schnieders, M. J.; Haque, I.; Mobley, D. L.; Lambrecht, D. S.; DiStasio, R. A.; Head-Gordon, M.; Clark, G. N. I.; Johnson, M. E.; Head-Gordon, T. J. Phys. Chem. B 2010, 114, 2549–2564.
- [54] Phillips, J. C.; Braun, R.; Wang, W.; Gumbart, J.; Tajkhorshid, E.; Villa, E.; Chipot, C.; Skeel, R. D.; Kale, L.; Schulten, K. J. Comput. Chem. 2005, 26, 1781–1802.
- [55] Kolafa, J. J. Comput. Chem. 2004, 25, 335–342.
- [56] Pronk, S.; Páll, S.; Schulz, R.; Larsson, P.; Bjelkmar, P.; Apostolov, R.; Shirts, M. R.; Smith, J. C.; Kasson, P. M.; van der Spoel, D.; Hess, B.; Lindahl, E. Bioinformatics 2013, 29, 845–854.
- [57] Schnieders, M. J.; Fenn, T. D.; Pande, V. S. J. Chem. Theory Comput. 2011, 7, 1141–1156.
Supporting information for: Scalable Evaluation of Polarization Energy and Associated Forces in Polarizable Molecular Dynamics: II.Towards Massively Parallel Computations using Smooth Particle Mesh Ewald
This document contains information to support statements of the main article. We first report a discussion on the parallel implementation of the two solvers presented in the main article, we then report a comparison of the polarization solvers best timings as well as the best timing for the computation of the associated forces for the three systems presented in the paper, obtained with our implementation and with the 6.3 version of TINKER.
S1 Technical discussion about parallelization of JI/DIIS and PCG
A comparison between the two solvers reveals that, because of the global reductions needed to compute the DIIS matrix at each iteration, the JI/DIIS might in principle be less suited for parallelization than the PCG. There are two intertwined considerations that need to be stated. First, our implementation is based on non-blocking communication, both for the dipoles/descent directions and for the global reductions. This means that the MPI communication calls return immediately even if the processes involved are not complete: communication is performed while the computation is still going. Notice that a ”MPI_Wait” or ”MPI_Probe” has to be executed after the computation in order to make sure that all the processes received the needed information. The use of non-blocking communication allows one to efficiently cover the communication time, limiting thus the impact of assembling the DIIS matrix on the performances of the JI/DIIS. Second, as the communication is done before the convergence check, the converged dipoles/descent directions are always broadcast. As one needs to compute the forces in MD simulation, which require the converged dipoles to be assembled, one needs a further communication step in the PCG solver, i.e., the dipoles at convergence, whereas this is not necessary for the JI/DIIS, as the converged dipoles are already communicated. These two considerations combined explain the slightly superior performance of the JI/DIIS solver.
S2 Timing comparison between Tinker-HP and Tinker 6.3
This software uses another implementation of the PCG parallelized with OpenMP routines. Notice that no speedup could be obtained by using more than 4 OpenMP threads with this implementation of the solver on the systems described above, running on the TACC supercomputer. Note that for the computation of the forces, the number of cores that could be used with the public, OpenMP implementation was limited by memory requirements to respectively 4-8 threads for the system studied here.
| System | TINKER HP | TINKER 6.3 | |
|---|---|---|---|
| PCG | JI/DIIS | ||
| S1 | 0.45 (128) | 0.44 (128) | 6.48 (4) |
| S2 | 0.50 (192) | 0.47 (192) | 11.50 (4) |
| S3 | 0.92 (512) | 0.88 (512) | 37.80 (4) |
| System | TINKER HP | TINKER 6.3 |
|---|---|---|
| S1 | 0.07 (256) | 1.90 (8) |
| S2 | 0.10 (256) | 3.78 (6) |
| S3 | 0.20 (512) | 19.0 (4) |