Theory of abrupt heterojunctions in equilibrium