# Developers Manual:Ion-Ion interaction

The following description works, but it is slow due to the interpolation required and less modular. So now this term is implemented using an standard Ewald sum; see here for the formalism.

## Energy

The ion-ion interaction term is tricky to treat, as it is an infinite sum with a finite result. The standard way to handle it is through an Ewald sum; however in Octopus this is done in a slightly different way (formally equivalent).

The energy term (per volume unit) is:

is a sum over atoms inside the cell, only over atoms outside and is over all the atoms.

The first separation that is

the first term is the energy of a finite system, the second can be seen as the interaction of the particles in the cell with the potential generated by the particles outside, we will call it .

Now, as in the case of the Ewald sum we will separate the potential in two parts:

with chosen to match the separation of the pseudo-potential. Now

As is short-ranged (i.e. exists such that for ) the first term is a finite sum and can be calculated directly by including periodic copies of the atoms in the cell up to an radius.

To obtain the second term we first see that

can be obtained by solving the Poisson equation

and can be calculated directly because , the charge distribution that generates , is short ranged (it is a gaussian). Actually this is the same way that the long range part of the pseudopotential is calculated, so we already have to calculate .

From here is direct that

So the second term of can be calculated by evaluating in the atomic positions.

In the case of Octopus this means we have to interpolate the function, as the atoms are not always over a grid point. Currently this is quite slow, if we want to do dynamics with periodic systems this has to be improved.

## Forces

The forces are the gradients of the previous terms with respect to the positions of the atoms **in** the cell.

The in-in term is as usual for finite systems:

the short range part of the in-out term is similar:

while the long range part is simply:

.