Thermodynamic stability and structures of nanocrystal superlattices