Surface and bulk energies of dipolar lattices.