Compressing and Expanding Gases
As a star evolves, various parts of the star either contract or expand. When this happens, the gases behave in much the same way as gases here on Earth when they are forced to compress or allowed to expand.
When a gas is compressed, its temperature rises. You know this by personal experience if you have ever had to inflate a bicycle tire with a hand pump. As you pump, the compressed air gets warm and makes the pump warm to the touch. The same effect happens on a larger scale in southern California during Santa Ana winds or downwind from the Rocky Mountains when there are Chinook winds. Both of these strong winds blow from the mountains down to the lowlands. Even though the mountain air is cold, the winds that reach low elevations can be very hot. (Chinook winds have been known to raise the temperature by as much as 27°C, or 49°F, in only 2 minutes!) The explanation is compression. Air blown downhill by the winds is compressed by the greater air pressure at lower altitudes, and this compression raises the temperature of the air.
On the other hand, expanding gases tend to drop in temperature. When you open a bottle of carbonated beverage, the gases trapped in the bottle expand and cool down. The cooling can be so great that a little cloud forms within the neck of the bottle. Clouds form in the atmosphere in the same way. Rising air cools as it goes to higher altitudes, where the pressure is lower, and the cooling makes water in the air condense into droplets.
Here’s an experiment you can do to feel the cooling of expanding gases. Your breath is actually quite warm, as you can feel if you open your mouth wide, hold the back of your hand next to your mouth, and exhale. But if you bring your lips together to form a small “o” and again blow on your hand, your breath feels cool. In this second case, your exhaled breath has to expand as it passes between your lips to the outside, which makes its temperature drop.