First-Principles Studies of Electronic, Optical and Defect Properties of Photovoltaic Materials