Opening and closing of single-wall carbon nanotubes