First-Principles Calculations On The Thermodynamic And Electronic Properties Of Defective Semiconductors And Semiconductor Alloys