When heat is said to rise, we are referring to only one of the ways that heat can be transmitted—convection. Focusing exclusively on convection is what creates the conundrum. But what is convection? The warmer molecules of a fluid like air will move apart and become less dense. As a result their weight will be supported by cooler, more bunched-up molecules. This is why cold air or cold water (as long as it’s 4oC or higher) sinks while the warmer counterpart rises.
As warm air rises, things get a little complicated. It encounters progressively thinner air and the rising air expands at the expense of its own internal energy, which cools it. That’s similar to what happens when you open a beer bottle and see a little genie-like cloud near the top of the bottle. The pressurized carbon dioxide from the fermentation cools as it expands, causing condensation of the air’s water vapor. But place your hand in the vapor and just like when you pass your fingers through the cloud above dry ice, the cloud does not feel cooler. That’s because cloud formation releases heat as gaseous molecules bond into tiny little water droplets.
So the above does not really explain why we encounter colder air on mountain tops and outside of flying airplanes. The key to understanding why temperature decreases with altitude in a fairly steady fashion— for the first 10 to 15 km is that, compared to more dense air that is closer to the earth, more distant and thinner air cannot hang on to heat that is radiating away from the surface. As the sun warms the earth, water and rock particles start to jiggle. As they cool atoms and molecules return to more stable states, releasing the energy they absorbed in the form of infrared. With the exception of the greenhouse gases such as water vapor, carbon dioxide and methane, most atmospheric gases are not great at reabsorbing infrared. So the heat escapes into outer space. The escape is facilitated when air is not as dense. Having less molecules at higher altitudes creates more gaps, more escape routes, and the surrounding area is cooler.
But why is the air less dense at higher altitudes?
Gravity acts on all states of matter including the gases of the atmosphere. Imagine a circus act where a few men successively stand on each other’s shoulders. The man at the bottom experiences the most weight. So do the air molecules closer to the surface; they are squished closer together than those above them. For those who do not fear math, we can create a model that predicts pressure to test these ideas. Then we can compare the estimates to measurements of the pressure at various altitudes to see if the math is realistic.
The higher you roll a stone up a mountain, the more work it takes to reach that elevation. Then if you release the rock, it will convert its energy on the way down to kinetic energy, heat friction and sound. The higher you go the faster it will get at the bottom of the hill and the louder its crashing sound. But let’s just focus on the energy given to the rock before it moves down. We call it potential energy and it’s simply the product of its height, (h), mass (m), the Earth’s gravitational acceleration (g).
E = mgh.
The mg part of mgh is the force of gravity, F, so we can say that F*h = mgh.
If we compare the calculated pressures to the actual measurements, they are accurate to 0.1% up to the first 15000 km. Afterwards the formula breaks down because of the way, as we mentioned, the ozone layer offsets the relationship between temperature and altitude.