Optimal Dopant Control in Compound Semiconductors for Spintronic and Energy Applications