The Thermodynamics of Charged Defects in Ionic Crystals