|MLA Citation:||Bloomfield, Louis A. "Question 1561: Will shaking a container of gas warm it up?"|
How Everything Works 16 Jul 2018. 16 Jul 2018 <http://howeverythingworks.org/print1.php?QNum=1561>.
A simple way to see why that's the case is to picture the gas as composed of many little bouncing balls inside the container. Those balls are perfectly elastic so they rebound from a stationary wall without changing their speeds at all. But the walls of the container aren't stationary, they move back and forth as you shake the container. Because of the moving walls, the balls change their speeds as they rebound. A ball that bounces off a wall that is moving toward it gains speed during its bounce, like a pitched ball rebounding from a swung bat. On the other hand, a ball that bounces off a wall that is moving away from it loses speed during its bounce, like a pitched ball rebounding from a bat during a bunt. If both types of bounces were equally common in every way then, on average, the balls (or actually the gas molecules) would neither gain nor lose speed as the result of bounces off the walls and the gas temperature would remain unchanged.
But the bounces aren't equally common. It's more likely that a moving ball will hit a wall that is moving toward it than that it will hit a wall that is moving away from it. It's a geometry problem; you get wet faster when you run toward a sprinkler than when you run away from the sprinkler. So, on average, the balls (or gas molecules) gain speed as the result of bounces off the walls and the gas temperature increases.
How large this effect is depends on the relative speeds of the gas molecules and the walls. The effect becomes enormous when the walls move as fast or faster than the gas molecules but is quite subtle when the gas molecules move faster than the walls. Since air molecules typically move at about 500 meters per second (more than 1000 mph) at room temperature, you'll have to shake the container pretty violently to see a substantial heating of the gas.