Electromechanical behavior of BaTiO3 from first principles