662 Energies and forces
As written, the sum over particles in eqn. (B.12) scales asO(N^2 ). However, the compu-
tational overhead of eqn. (B.12) can be reduced substantially witha few clever tricks.
First, consider writing eqn. (B.12) as
Ulong(r 1 ,...,rN) =
1
V
∑
i 6 =j
qiqj
∑
g∈S
4 π
|g|^2
e−|g|
(^2) / 4 α 2
eig·(ri−rj). (B.13)
Next, we add and subtract the term withi=jto yield
Ulong(r 1 ,...,rN) =
1
V
∑
i,j
qiqj
∑
g∈S
4 π
|g|^2
e−|g|
(^2) / 4 α 2
eig·(ri−rj)
−
1
V
∑
i
qi^2
∑
g∈S
4 π
|g|^2
e−|g|
(^2) / 4 α 2
. (B.14)
When this is done, the first term can be written as the square magnitude of a single
sum:
Ulong(r 1 ,...,rN) =
1
V
∑
g∈S
4 π
|g|^2
e−|g|
(^2) / 4 α 2
∣
∣
∣
∣
∣
∑
i
qieig·ri
∣
∣
∣
∣
∣
2
−
1
V
∑
i
qi^2
∑
g∈S
4 π
|g|^2
e−|g|
(^2) / 4 α 2
. (B.15)
Note the presence of the structure factorS(g) =
∑
iqiexp(ig·ri) in the first term of
eqn. (B.15). The reciprocal-space sum in the second term of eqn. (B.15) can either be
evaluated once in the beginning and stored, or it can also be performed analytically if
we extend the sum to all of reciprocal space. For the latter, we first write
Ulong(r 1 ,...,rN) =
1
V
∑
g∈S
4 π
|g|^2
e−|g|
(^2) / 4 α 2
|S(g)|^2
−
1
2 V
∑
i
qi^2
∑
g 6 =(0, 0 ,0)
4 π
|g|^2
e−|g|
(^2) / 4 α 2
. (B.16)
We now note that
1
V
∑
g
4 π
|g|^2
e−|g|
(^2) / 4 α 2
= lim
r→ 0
erf(αr)
r
. (B.17)
Sincerand erf(αr) are both zero atr= 0, the limit in eqn. (B.17) can be performed
using L’Hˆopital’s rule, so that
lim
r→ 0
erf(αr)
r
= lim
r→ 0
2
r
√
π
∫αr
0
e−t
2
dt= lim
r→ 0
2 α
√
π
e−α
(^2) r 2
2 α
√
π
. (B.18)
From this limit, eqn. (B.17) becomes