Expansion of ideal gases