Ab Initio Modeling of MultiWall: A General Algorithm First Applied to Carbon Nanotubes