  Alignment of electrostatic potential between different atomic configurations
is necessary for first-principles calculations of band offsets across
interfaces and formation energies of charged defects. However, strong
oscillations of this potential at the atomic scale make alignment challenging,
especially when atomic geometries change considerably from bulk to the vicinity
of defects and interfaces. We introduce a method to suppress these strong
oscillations by eliminating the deep wells in the potential at each atom. We
demonstrate that this method considerably improves the system-size convergence
of a wide range of first-principles predictions that depend on alignment of
electrostatic potentials, including band offsets at solid-liquid interfaces,
and formation energies of charged vacancies in solids and at solid surfaces in
vacuum. Finally, we use this method in conjunction with continuum solvation
theories to investigate energetics of charged vacancies at solid-liquid
interfaces. We find that for the example of an NaCl (001) surface in water,
solvation reduces the formation energy of charged vacancies by 0.5 eV:
calculation of this important effect was previously impractical due to
computational cost in molecular-dynamics methods.
