Systematic ab initio study of the optical properties of BN nanotubes