Simulation of electrostatic systems in periodic boundary conditions. I. Lattice sums and dielectric constants | Synapse