re: If air is compressed it heats up and if it is expanded it cools down.
There is a difference between the effects of temperature when applied to confined and unconfined gasses.
One good web site that explains those effects is the following:
http://www.chm.davidson.edu/ronutt/che115/PistCyl/PistCyl_Solutions.htm
