Grand canonical simulations of ions between charged conducting surfaces using exact 3D Ewald summations †

We present a useful methodology to simulate ionic fluids confined by two charged and perfectly conducting surfaces. Electrostatic interactions are treated using a modified 3D Ewald sum, which accounts for all image charges across the conductors, as well as the 2D periodicity, parallel to the surfaces. The energy expression is exact, and the method is trivial to implement in existing Ewald codes. We furthermore invoke a grand canonical scheme that utilizes a bias potential, that regulates the surface charge density. The applied bias potential also enables us to calculate individual chemical potentials of the ions. Finally, we argue that our approach leads to a pedagogically appealing description of the Donnan potential, and what it measures in these systems.


Introduction
Mechanisms underlying different electrochemical properties of ionic systems confined by polarizable surfaces has attracted much attention recently due to their application in electric double layers capacitors. [1][2][3] Simulating such systems provides a number of challenges, associated mainly with treating the long-range electrostatic interactions that are used to obtain electrochemical properties such as surface potentials and capacitance. Many different methods have been developed to manage electrostatic interactions in ionic fluids confined between two flat conducting electrodes. Examples include solutions to the Poisson equation using expansion methods, 4 the ICMMM2D method, 5 the ELCIC method, 6 mapping schemes, 7 direct summations of the image charges 8,9 and Gaussian representation of the surface charges. 10 However, generally such methods can be difficult to implement with slow convergence. Instead, in this work we implement a different approach which utilizes a double cell that includes the ions and their nearest images to simulate the manyreflected full system via Ewald summation. The Ewald summation has a long history in the simulation of coulombic fluids and has been developed over many decades to become an efficient and valuable tool for researchers. As such, optimized implementations, such as particle mesh Ewald 11 and smooth particle mesh Ewald 12 can be put to good use to efficiently treat the problem of charged fluids confined by conducting surfaces.
One of the difficulties associated with calculating properties such as the capacitance in these systems is that knowledge of the electrode potential relative to a fixed reference is required. While the latter is often chosen to be the bulk fluid, this is not a requirement. Here we show that a generalization of the Ewald approach, 13,14 utilizing a grand canonical treatment with single ion insertions and deletions, allows us to maintain a given surface potential relative to a fixed reference, which will generally not be that of the bulk fluid. Single ion insertion and deletions are not usual in grand canonical schemes for charged fluids, due to obvious problems associated with non-electroneutrality. However, this is avoided in the presence of conducting surfaces by the counterbalancing charge of the images.
A specific example, where we expect our method to be particularly useful, is the theoretical study of electric double layer capacitors, sometimes called ''supercapacitors''. [15][16][17][18][19] This area has attracted substantial experimental and theoretical work. 3,[15][16][17][18][19][20][21][22][23][24][25][26][27][28][29][30][31] Some experimental data 20,21 support the existence of an electrode pore size (typically of the order of nanometers), which maximizes the capacitance of the system. However, controlling and measuring size distributions of nanoporous electrodes is difficult, and the measurements would strongly benefit by complementing theoretical modelling. Mean-field analyses have indeed suggested the presence of ''superionic states'' in these systems, whereby a very strong electrostatic screening in narrow pores of conducting materials might facilitate dense packing of equally charged species, which in turn can generate a huge capacitance. 32 Still, such simple mean-field predictions need validation by more exact treatments, such as simulations. Simulation studies of porous electrodes are notoriously difficult due to the presence of multiple image charges. Dudka et al. have made attempts to circumvent these problems by simulating lattice models of ionic liquids, where interactions are restricted to nearest-neighbours. 31 While such models certainly can generate interesting insight, it is nevertheless of considerable interest to be able to utilize a continuum space fluid model, in which Coulomb interactions (including surface polarization) are properly treated.
In the next section, we describe the Ewald method we use to treat the ionic fluid between two conducting surfaces. The original derivation of this model was given by Hautman et al. 33 some three decades earlier, but it seems not to have been widely adopted in recent treatments of these systems. The description contained here has some slight differences, in particular, we define a different unit cell which is useful for charged electrodes. Furthermore, as mentioned earlier, we describe the use of a grand canonical ensemble simulation scheme to create charged electrodes with a potential relative to a well-defined reference.

Method
Our system consists of an ionic fluid confined between two infinite and flat perfectly conducting surfaces (electrodes), parallel to the (x, y) plane, and positioned at z = AEh/2. The electrode surface is defined by the dielectric discontinuity, which is assumed to be sharp. In simulations we necessarily restrict the system size to a unit cell, C 0 , defined by |x| r L x /2 and | y| r L y /2, containing a finite number of ions. The simulation box need not be electro-neutral.
Periodic boundary conditions (PBC) in the (x, y) directions give an infinite number of adjacent replicas of C 0 parallel to the confining electrodes (see Fig. 1(a)), which can be treated using a suitable 2-dimensional (2D) Ewald scheme. The polarization of the two conducting electrodes can be described with image charges, resulting in an infinite number of reflections 34 in the two subspaces z 4 h/2 and z o Àh/2. These images give rise to a perpendicular electrostatic field at the dielectric discontinuity, which mimics the equilibrium response of electrons in the conductors. The electrodes thus have a constant potential over their surfaces. The combination of a 2D Ewald scheme with a very large number of explicit image reflections, amounts to a significant computational task for most reasonably sized systems and alternatives to such a straightforward approach are desirable. For example, Santos et al. 4 have recently described a more efficient but complex treatment for this system, which utilizes periodic Greens functions and a modified 3D Ewald summation, combined with a separate evaluation of the contribution from surface polarizations.
We now consider the basic isolated unit cell C 0 (without images). The images are reintroduced by defining a complementary unit cell, C 0 0 , which consists of the mirror image of C 0 reflected in say the left-hand electrode surface. This process not only reflects the particle positions but also reverses the sign of the charges, so the total charge of both cells always add to zero. A similar complementary cell can be obtained by reflection in the right hand surface of C 0 , see Fig. 1(b). We now define a symmetric electroneutral super-cell, C, consisting of the central cell C 0 and the nearest halves of the adjacent complementary cells, see Fig. 1(c). Thus C contains open boundaries, but possesses internal bounding surfaces which correspond to the positions of the original electrodes. Furthermore, though C contains 2N particles, only N are independent, therefore we can write the energy of particles in C as a function of the co-ordinates of particles in the sub-cell C 0 . An infinite 3-dimensional array of replicas of C reproduces the original ionic fluid, between two conducting electrodes, and with PBCs along the (x, y) directions. Such an array can be easily treated with usual 3D Ewald methods to obtain the energy of the ions in C, which is numerically equal to the sum of the energy of a sub-cell C 0 and a complementary cell, C 0 0 , i.e., where U C 0 is the energy of a configuration r N of ions in C 0 and is the corresponding energy of the complementary cell with reflected co-ordinates R[r N ] and oppositely signed charges. Due to symmetry, and we therefore obtain the simple result for the required energy, U C 0 , We shall denote this approach as the ''Image Ewald'' method (IE). We note that in the direction parallel to the surfaces the periodicity may induce crystal artifacts, yet by utilizing isotropic periodic boundary conditions 35 in these directions such effects will be mitigated. A direct effect from such a scheme is that the reciprocal-space Ewald forces in the xy-directions will be zero, yet there will be a long-range contribution to the total energy. In our simulations, however, we did not use isotropic boundary conditions. The total Ewald energy for the cell C will have the general form  where U C 0 (r N ) is a shape-independent part and U surf (r N ) is the dipolar contribution that gives rise to a shape-dependent surface term. The shape-independent term will give rise to a potential of exactly zero at each electrode, due to the symmetry created by the image charges. When the cells are summed over a spherical geometry, for example, the surface term can be eliminated via tin-foil boundary conditions, which is appropriate in a system of neutral electrodes, that has now been mapped onto a properly three-dimensional lattice. However, for the general case of charged electrodes, one needs to take cognizance of the slab geometry. This is because, the surface term will be responsible for creating a potential difference between electrodes. For the slab geometry the surface term is given by, where M z is the total instantaneous dipole moment in the z-direction (perpendicular to the electrodes) and V cell is the cell volume. This result applies irrespective of the dielectric constant of the medium in which the system is imbedded. That is, the surface term remains even in the presence of tin-foil boundary conditions. We should note, however, that the presence of this uniform polarization field does not violate the condition that each electrode is an equipotential surface. In the case where the charged electrodes are identical, symmetry dictates that C has zero average dipole moment hM z i = 0. For a large enough cell, we expect the majority of configurations to have M z E 0 and therefore it makes physical sense to ignore the surface term in our calculations, as in the case of neutral electrodes. These will be the types of systems considered in this study. As an aside, we also note that the use of 3D Ewald with an inserted slab of vacuum in order to simulate 2D boundary conditions, does require the presence of this surface energy in order to eliminate unwanted electrostatic contributions from neighboring fluid layers. This is not required in the present case where adjacent layers are required to interact. In the case of asymmetric electrodes we will have that, hM z i a 0, and we will need to properly account for the potential difference between electrodes that the averaged surface term will bring about. The IE method described here offers significant computational advantages over many other recent approaches that have been used to deal with such systems, both in terms of efficiency and simplicity of coding. As mentioned earlier, Hautman et al. 33 originally described this approach some years ago, however, that work seems not to have gained wide recognition. Since we developed the methodology without prior knowledge of the earlier work by Hautman et al., 33 there are actually some conceptual differences. For example, Hautman et al. used a different type of unit cell consisting of C 0 and its adjacent complement C 0 0 . It is clear that even for symmetric, charged electrodes the average dipole moment in such a cell is not zero, giving a non-zero average surface energy in the slab geometry. This would lead to a spurious electric field within the cell that would need to be removed in an ad hoc fashion. We therefore, argue that our choice of unit cell is conceptually preferable. Furthermore, as far as we are aware, the method of Hautman et al.
has not been applied to the case of electrodes with a net total surface charge. This is likely because the original formulation uses a Hamiltonian wherein the electrode potentials are specified. Such an approach is precluded when these potentials (relative to a fixed reference) are unknown. We will now show how the IE can be used in a grand canonical ensemble simulation, which naturally gives rise to net charged electrodes and solves the problem of specifying a fixed reference potential.

Grand canonical simulations
To Hence, the IE provides a method to determine m ind (Z i ), as we will explicitly demonstrate below, where we also compare IE results with those from the established modified Widom technique. 36 In our simulation method, electroneutrality is always maintained by the correlated presence of oppositely charged ions in the complementary C 0 0 sub-cell. This is physically equivalent to the creation of counter-balancing image charges in the conducting electrodes and allows us to perform simulations at constant electrode potential, rather than constant electrode charge, using single ion insertions and deletions. Constant potential systems are arguably more relevant to real experimental scenarios. The fluctuating electrode surface charge density, s S , will have an average value hs S i that can be regulated by application of a constant potential that will bias either anions or cations via the chemical potentials. With a m salt for a given bulk electrolyte, ''effective'' individual ion chemical potentials are constructed using m eff (Z i ) = m salt À Z i eC bias (6) where the biasing potential is denoted C bias . Eqn (6) enters the grand canonical Boltzmann weights for the insertion/deletion moves for the individual ions.

Simulation details
The ionic fluid was modelled using the RPM wherein the solvent only enters via the dielectric constant, e r = 78.3. At a temperature of 298 K, this gives a Bjerrum length of about 7.16 Å. In order to highlight some interesting aspects of asymmetric electrolytes, we assumed a 2 : 1 salt, consisting of divalent and opposing monovalent charges embedded in hard spheres of diameter 5 Å. Generalization to other kinds of salt is straightforward. The Ewald sums used a minimum image cutoff in the real space sum. We set L x = L y = 200 Å, and used an equal number of reciprocal wave vectors in the Fourier sum along the reciprocal z as in the reciprocal (x, y) directions, with a suitable symmetrization in the latter case. 37 A total of 1800 vectors were used for the Fourier component. The Ewald splitting parameter, often denoted as a, was set to 7/L x . At least 2 Â 10 7 configurations were used for the final production runs, subsequent to equilibrations, which used even more configurations. For all simulation results presented in the main article, we have set bm salt = À10.7 where b is the inverse thermal energy. In the ESI, † we provide results for other scenarios, including a 3 : 1 salt, and a monovalent salt where the cations carry a non-central charge.

Results
A quantity of interest is the average electrostatic potential, C(z), which can be evaluated by integration of the average charge density profile, as described in the ESI. † This calculation simply adds the direct contributions from the charge densities and (due to symmetry) will always give a value of zero, for the potential at the electrode surfaces. Fig. 2(a) and (b) shows the average electrostatic potential C(z) profiles from our GCMC simulations, using IE, with a slit of width, h = 145 Å. This is obviously large enough to produce a bulk fluid in the mid-plane region as evidenced by the flat profile there. Two different C bias are chosen, and these are compared with the result for C bias = 0. Normally, we measure C(z) relative to the bulk, which requires addition of a constant potential correction, called the ''Donnan potential'', 38 C Donn , due to charge distributions external to the slit. Due to the asymmetry of the electrolyte model, C Donn is not simply equal to C bias , since there is a finite C ref in the bulk. From eqn (6) and (5) can write, Therefore we have, C Donn = C bias À C ref . We note that C Donn is then also equal to the surface potential of the electrodes relative to the bulk fluid. But while C bias is chosen a priori, C ref remains undetermined. It can be obtained, however, by noting that the mid-plane potential behaves as, as h-N. That is, the potential (relative to the bulk) at the center of the slit should be zero for wide slits as one has effectively a bulk fluid there. From C(z) in Fig. 2 for the case C bias = 0, we obtain a mid-plane value essentially equal to C ref , which follows from eqn (8). We then verify that the mid-plane values for the other C(z) do approach ÀC Donn . We evaluated the IE by comparing it with a more straightforward approach, where we use GCMC simulations, as discussed above, but explicitly evaluate a finite number of multiple image reflections between the electrodes. Previous work has noted that convergence of the sum of reflected images is facilitated by using an even number of terms. 9 Further details are also provided in the ESI. † We also used the minimum image (MI) convention to treat the PBC in the x, y directions, rather than Ewald sums. Hence we use the acronym MI to denote this approach. In the MI method, long-range interactions outside the MI truncation were estimated by an ''external'' mean-field potential, 39,40 from previously established average charge densities, appropriately symmetrized, and adjusted so that the external potential vanishes at the surfaces. It should be noted that the inclusion of this long-range correction only had a small influence on the properties investigated here, i.e. the results were very similar to those obtained with a simple MI truncation, without any longrange correction. Fig. 3 summarizes our comparisons between the IE and MI approaches for bC bias e = À2 and h = 145 Å. As noted above this width is sufficient to produce bulk conditions in the center of the slit. In Fig. 3(a), we note how the MI method gives a surface value of C(z), which varies significantly from zero, with the number of reflections used. The potential difference between the midplane and the surface in the MI does approach the IE result asymptotically but the convergence is quite slow. Surprisingly, these results indicate that the mid-plane potential from the MI actually displays only a modest variation with the number of image reflections, and is in all cases rather close to the value obtained by the IE. One could then be tempted to just assume that C(z) is zero at the surface and use the mid-plane value to set the surface potential relative to the bulk (recall that the negative of the mid-plane value is equal to the proper reference surface potential). However, such a strategy belies other serious errors obtained with too few reflections. For example, in Fig. 3(b), we see that the average surface charge density varies strongly with the number of image reflections, only slowly converging towards the IE value. In Fig. 3(c), we compare predictions of the integral capacitance C I . Using Image Ewald, this is simply obtained as C I = hDs S i/C bias , where hDs S i is the difference between the average surface charge density at C bias and the average surface charge density at with a vanishing bias potential (i.e. C bias = 0). However, with the MI approach, we have to account for truncation errors, which leads to a finite (local) surface potential. Interestingly enough, the capacitance converges faster towards the Image Ewald value than the net potential, or the average surface charge density. This is obviously due to a cancellation of errors. It should be emphasized that since we generally would define the differential capacitance (C D ) as C D = Ds s /DC Donn = Ds s /DC bias , we do not need to establish C ref , to generate a C D curve. This is a significant advantage for narrow pores (slits).
We now turn our attention to the individual chemical potentials, m ind . Using eqn (5) we calculate m ind for the 2 : 1 Fig. 3 Comparisons between Image Ewald results, and MI simulations with a limited number of image reflections, using bC bias e = À2. (a) Locally measured mid plane and surface potentials, C mid , and C surf . In the MI approach, these are randomly sampled during the simulations. With the Image Ewald method, C surf = 0, and C mid is obtained by integration of the average charge density profile. (b) The average surface charge density, hs S i. (c) Integral capacitances, C I . RPM salt using our method, by setting C bias = 0 and measuring C ref . We compare with results from the modified Widom technique using canonical bulk simulations, a cubic box, and Coulomb interactions that are truncated by the minimum image convention. The canonical densities were given by the mid-plane density from grand canonical IE simulations, at zero applied bias potential. Size convergence was estimated by simulating three different simulation box sizes, using the modified Widom method. The results are summarized in Fig. 4, where the standard deviations from the canonical simulations are smaller than the size of the symbols, and therefore not indicated. We note a modest but significant size dependence of the modified Widom simulations, but also that the large size limit seems to approach the Image Ewald result.

Conclusions
In summary, we have utilized a simple and effective way to manage long-range interactions, using an exact model of infinite image reflections, in systems where an ionic fluid is confined between two charged (in general), planar, and perfectly conducting surfaces, or electrodes. Note that ''confined'' should be interpreted with some care, since our grand canonical method ensures that the fluid is in chemical equilibrium with a bulk solution, at some prescribed chemical potential. Using wide surface separations, our system will accurately approximate the behaviours at a single electrode surface and we are able to calculate the individual chemical potentials. An important advantage is that we are also able to model a porous electrode, by utilizing a short surface separation. Our method relies on straightforward 3D Ewald techniques, which are wide-spread, and can therefore be highly optimized using particle-mesh Ewald, smooth particle-mesh Ewald etc., to achieve a computational scaling of O (N log N), where N is the number of charges in the system. Hence, the Image Ewald method is suitable for a multitude of system setups. One such case is the study of electrochemical behaviours of salt solutions and ionic liquids, in the presence of nanoporous electrodes. Finally, we note that while we have utilized the Metropolis Monte Carlo technique in this work, the IE method can naturally be directly implemented in molecular dynamics codes.

Conflicts of interest
There are no conflicts to declare.