Doping-induced phase transitions in ferroelectric BaTiO 3 from first-principles calculations