Calculation of coulomb energies for uniform charge distributions of arbitrary shape