Confined space design by nanoparticle self-assembly