Schottky barrier formation and band bending revealed by first- principles calculations