First-principles analysis of photocurrent in graphene P N junctions