Ab initio study of BaTiO 3 and PbTiO 3 surfaces in external electric fields