Many-body interactions among adsorbed atoms and molecules within carbon nanotubes and in free space