A Python script for computing the Madelung potential (MP) and total electrostatic energy of crystal systems from VASP geometry files.
Created :: 14/05/2020
Updated :: 08/04/2026
Author :: Asif Iqbal (@AIB_EM)
The script computes the electrostatic potential based on the classical Coulomb interaction within a periodic framework.
The Madelung potential at a specific atomic site
Where:
-
$q_j$ is the partial charge of atom$j$ (provided in the 4th column). -
$\mathbf{r}_{ij}$ is the distance vector between atom$i$ and atom$j$ within the primary cell. -
$\mathbf{R}$ is the lattice translation vector:$\mathbf{R} = n_1\mathbf{a} + n_2\mathbf{b} + n_3\mathbf{c}$ (where$n$ are integers). - The term where
$j=i$ and$\mathbf{R}=0$ is strictly excluded to avoid self-interaction.
The total Madelung energy of the unit cell is calculated using the following summation:
The factor of
To provide results in standard units (Volts and electron-Volts), the script uses the following conversion:
The conversion factor from internal units (
- Ensure your structure file is named
CONTCARorPOSCAR. - Append your partial charges as a 4th column in the coordinate section.