Ab initio density functional theory applied to quasidegenerate problems.