Quantum-mechanical description of ions in crystals: Electronic structure of magnesium oxide.