  Doing work    Let’s think of some gas in, for example, a bicycle pump. If you were to push the pump in quickly, then the gas would heat up – this is because you are doing work on the gas. If you pull the pump out quickly, then the gas will cool down. This is the reverse effect – you are getting the gas to do work for you. Let’s look at the same situations on a molecular scale.     
  Speeding particles    The gas particles are moving with a speed that is determined by the temperature of the gas. Now let’s imagine pushing the pump in. What effect does this have on the speed of the particles? The answer is that they will speed up. When they collide with the oncoming piston, they will rebound more quickly. Let’s see why.     
 Picture 2.13. Elephant and tennis ball    Bouncing speeds    Imagine you throw a tennis ball at a stationary elephant (not so hard that it hurts her). Also, imagine that the collision is perfectly elastic. Let’s say that you throw the ball at 10 m s^{1}. What will its speed be after the collision? Simple: 10 m s^{1}.
Now imagine that the elephant is running towards you at 2 m s^{1}. Certainly it will rebound more quickly, but what will its speed be? The answer is 14 m s^{1} (see box). So, with the elephant coming towards you, the ball rebounds more quickly. In the same way, gas particles will speed up when they rebound off the approaching piston. And therefore the temperature of the gas will go up.      Running away    Now imagine that the elephant is running away from you at 2 m s^{1} and you throw the tennis ball at her. This time, the ball will come back more slowly (6 m s^{1}  think about why). Similarly, gas particles that bounce off a piston that is being pulled out will bounce back more slowly – making the gas cool down.     
 Picture 2.14. Relative velocities
    Relative velocities  Here’s how we can work out the speed of the deflected tennis ball. The relative speed of the ball and the elephant doesn’t change. If the ball is coming towards the elephant at 10 m s^{1} and the elephant is moving at 2 m s^{1}, then their relative velocity is 12 m s^{1}. So it bounces off at a relative velocity of 12 m s^{1}. Given that the elephant is still moving at 2 m s^{1}, the ball’s actual velovity is 14 m s^{1}.       

  Free expansion    The same reasoning will work for a gas that is expanding freely. Rather than bouncing off a container, the particles bounce off each other. But they are all moving outwards. So any collisions at the edges of the gas will have the effect of taking some of the speed off the expanding molecules. You can also think of it that some of the kinetic energy of the particles is being taken away to push the gas into a bigger volume. I.e. the gas particles have to do work to expand. This reduces the average KE and therefore the gas cools.     
 