Statistical mechanics of granular gases in compartmentalized systems