Ab initio study of gap opening and screening effects in gated bilayer graphene