Ab Initio study of dopant insertion into carbon nanotubes