Abstract A procedure for calculating the electrostatic potential and the electrostatic energy of an ion in a crystal is presented. It is based on a mixed direct and reciprocal space approach, and it takes into account the detailed charge density distribution in the crystal which can be obtained from accurate X-ray diffraction measurements.