How WebGCM works
Part 1: Air

A guided tour of a climate model, starting from one parcel of air.

WebGCM is a global climate model that runs in a browser tab. Everything it produces, from the jet stream, the river of fast wind that steers weather across the middle latitudes, to the monsoon, the seasonal reversal of wind and rain over the tropics, comes out of a small number of rules applied to a great many parcels of air. This series builds the model the way you might build it yourself: one parcel first, then a column of them, then a row of columns, and eventually the whole sphere. Every figure is live. Drag the sliders.

A parcel of air

Take some air and trap it in a cylinder under a piston. The weight on the piston sets the pressure. The air pushes back because its molecules keep hitting the piston, and how hard they hit depends on how fast they move, which is what temperature measures. Pressure, volume and temperature are tied together by the ideal gas law, in which n is how much air is in the cylinder and R is a constant.

p V = n R T

Pressure here is in hectopascals, hPa. The air at sea level presses with about 1000 hPa, the weight of a kilogram on every square centimeter, and that is where the figure starts.

Add weight and the piston drops, but something else happens too. Squeezing the air does work on it, and that work shows up as heat. If the cylinder is insulated the air warms as it is compressed and cools as it expands, and when you return the piston to where it started the temperature returns exactly as well. If the cylinder leaks heat to the room, the warmth drains away, and the air has no memory of what was done to it.

The insulated case is the one that matters outdoors. Air is a poor conductor, and a parcel the size of a cloud takes hours to days to trade heat with its surroundings, far longer than it takes to rise or sink. So to a first approximation a parcel of air keeps its heat to itself. The word for that is adiabatic.

Lifting it

Now take the parcel outside and lift it. The air around it thins with height, so the pressure on it falls, and the parcel expands and cools exactly as it did under the piston. The rate is fixed by gravity and the heat capacity of air: about 9.8 °C for every kilometer, the dry adiabatic lapse rate, as long as the parcel stays near the temperature of the air around it.

The second thermometer reads something that never changes as the parcel moves: the temperature it would have if you brought it back down to the surface. That number is the parcel's potential temperature, written θ.

θ = T (p0 / p)R/cp

Here p0 is a standard surface pressure, 1000 hPa, the same for every parcel. The exponent is the gas constant R from the ideal gas law, taken per kilogram of air, divided by cp, the specific heat capacity of air: the heat it takes to warm a kilogram by one degree while it is free to expand. Their ratio, written κ and known as the Poisson constant, is almost exactly 2/7 for air, about 0.29, as it is for any gas whose molecules come in pairs of atoms, and the formula is Poisson's equation. Two parcels with the same θ are the same air, whatever height they happen to be at. θ changes only when heat is actually added or taken away: by sunlight, by radiation, by condensing water, or by mixing with different air. The model keeps track of θ rather than temperature for exactly this reason. Moving air around must not change it, and on a grid that is a rule you can enforce to the last digit.

A column of air

Stack parcels on top of one another and you have a column of atmosphere. Each slab of air is held up by the air beneath it pushing harder than the air above pushes down, and the difference is exactly the slab's weight. This is hydrostatic balance, and it is why pressure falls with height: the pressure at any level is the weight of everything above it.

Because pressure is weight, it is a natural way to say how far up you are. Half of the air is below the 500 hPa level, about five and a half kilometers up; nine tenths is below 100 hPa. But the height of a pressure level is not fixed. Warm air is thinner and takes up more room, so a warm column is a tall column. Slide the temperature and watch every level rise.

That is why the model measures height with geopotential, Φ, the energy it takes to lift one kilogram from sea level, which is the strength of gravity, g, times the height. In the model, height is not something you know in advance. It is something you compute by adding up the thickness of each layer from the ground upward, and the thickness of a layer is set by its temperature. The height of the 500 hPa surface is one of the first things a forecaster looks at, and now you know why: where it is high, the air below is warm.

Bobbing

Take one parcel from the column, lift it a little, and let go. It arrives colder than its new neighbors, because it cooled at 9.8 °C per kilometer on the way up while the surrounding air usually cools more slowly with height. Colder means denser, and a parcel denser than the air it displaces is pulled downward, just as a lighter one is pushed up. That is buoyancy, the force that floats a balloon, and at any height it is proportional to the difference between the parcel's θ and the θ of the air around it.

b = g (θparcel − θair) / θair

Here b is the acceleration the parcel feels, upward when it is positive, and it is exactly what the figure integrates: a parcel 3 °C warmer than air at 300 K is pushed upward at about a hundredth of g. So the parcel sinks, overshoots, arrives warmer than its surroundings, and rises again. It bobs, or in the language of physics it oscillates, and the motion is called a buoyancy oscillation. The first slider sets how the θ of the surrounding air changes with height, and the readout translates that into how quickly the air cools, for comparison with the parcel's 9.8 °C per kilometer, the dry adiabatic lapse rate; the chart on the right records where the parcel has been. The second slider makes the parcel warmer or cooler than the air it started in. Give it a few degrees and it climbs until it reaches the height where its θ matches the air's, its level of neutral buoyancy, and bobs about that level instead. That is how a hot-air balloon, or the plume from a chimney, finds its ceiling.

Whether it bobs, stays or runs away depends entirely on θ. When θ increases with height, a displaced parcel always finds itself out of place and is pulled back; the air is stable, and the parcel oscillates with a period of about ten minutes. When θ is the same at every height, the parcel is indifferent to where it is put. When θ decreases with height, the parcel keeps going. That is convection, and it is how heat gets from the ground to the top of the troposphere, the lowest ten to fifteen kilometers of the atmosphere, where nearly all weather happens. Convection also limits itself. Every parcel that runs away carries high-θ air up and lets lower-θ air sink into its place, which raises θ aloft and lowers it below, and the running stops only when θ is the same at every height and no parcel has anywhere better to be.

So why is the atmosphere not like that everywhere? If convection erases any decrease of θ with height, you might expect the air to settle at one θ throughout. Instead θ usually increases upward, the stable case, and the air cools more slowly than the parcel's 9.8 °C per kilometer. On a sunny afternoon the lowest kilometer or two really does end up with one θ throughout, a mixed layer, and you can watch one form in the last figure of this part by sending the heat into the ground. Two things stop it there. Air that rises far enough forms cloud, and the water condensing inside it releases heat, so a cloudy parcel cools at only about 6 °C per kilometer and arrives aloft with a higher θ than it left the ground with. And the column is not insulated the way a parcel is: sunlight warms the ground while the air radiates heat to space from every level, and the balance between that heating and cooling, with convection carrying heat up from below, settles on a column that is stable overall. Radiation and water each get a part of their own later. For now the slider stands in for both.

The slider's two ends are worth a visit. Push θ to decrease with height and the column is unstable: every parcel runs away, and the figure's parcel reaches the top within minutes. A whole column like that never lasts in nature, because the running is the cure. It overturns and mixes itself to a single θ before the figure's clock has gone far. What does exist is a thin unstable layer in the lowest few tens of meters over sun-baked ground, where the surface heats the air faster than convection can carry it away. That layer is the engine of the mixed layer above it, and the cause of the shimmer over a hot road.

The other extreme is air whose temperature rises with height instead of falling: an inversion. Real ones are layers rather than whole columns, so the figure gives you a lid. Set its height and a layer appears in which θ jumps by eight degrees over a few hundred meters, and the column's color shows the step. Now give the parcel a few degrees of extra warmth. It climbs, reaches the layer, and stops dead beneath it, because above the lid the air is warmer still. Inversions are lids. One forms over the ground on a clear, calm night, when the surface cools by radiation faster than the air above it, and it traps the night's fog and smoke until the morning sun burns it away. Another sits a kilometer or two above the subtropical oceans, where air sinking from aloft warms by compression, the piston once more, and caps the clouds below into the flat sheets you see from an airliner. The biggest of all is the tropopause. Above it, ozone absorbs sunlight and the stratosphere warms with height for tens of kilometers, which is why thunderstorms flatten into anvils when they reach it and why nearly all weather stays below.

You will have noticed that the bobbing dies away after a few cycles. A real parcel does not oscillate on its own. As it rises and sinks it pushes on the air around it, and that air pushes on its neighbors in turn, so the energy of the bob leaks away sideways, and meanwhile the parcel slowly mixes with its surroundings and loses its identity. The figure stands in for both with a simple drag that halves the swing about every half hour. The leak is the seed of something larger: nudge a whole layer of air instead of one parcel and it bobs the same way, and the motion spreads outward as a wave. These gravity waves, so called because gravity is what pulls the displaced air back, and nothing to do with the gravitational waves of astronomy, are everywhere in the atmosphere, and they return in the last figure of this part.

Pushed by the pressure

So far the air has only gone up and down. Pressure pushes on a parcel from every side, though, not just from above and below. Vertically it carries the weight of the air above, the hydrostatic balance of the column. Sideways there is nothing to balance it: gravity pulls only downward, and while the air is still, nothing else pushes back. So wherever the pressure along a level is higher on one side than the other, the difference is left over, and it sets the air moving from high pressure toward low. That push is the pressure gradient force. For each kilogram of air it is the difference in pressure divided by the distance over which it changes, and divided again by the air's density, since the same difference moves thin air more easily than dense air.

a = −(1/ρ) ∂p/∂x

Here a is the push per kilogram, ρ is the density, x is the distance along the level, ∂p/∂x is how fast the pressure changes along it, and the minus sign points the push toward lower pressure.

The differences that drive the weather are small. Along the ground a typical one is about 1 hPa every 100 km, a tenth of a percent of the pressure itself. One hectopascal is 100 pascals, so in air of 1.2 kg/m³ the push is 100 divided by 100,000 m and by 1.2, about 0.83 × 10⁻³ m/s², less than a ten-thousandth of g. But it does not let up. It adds 3.0 m/s to the air's speed every hour, so after six hours air that felt only this push would be moving at 18 m/s and would have traveled 194 km. Close to a deep storm the difference can reach 10 hPa every 100 km, and the push is ten times as strong: 30 m/s more every hour, 180 m/s after six hours.

There is a second way to see the same push, and it is the one the next section and Part 4 use. Where the pressure along a level is higher, there is more air overhead, so the pressure surface through that level, the surface through all the points at one pressure, stands higher there and slopes down toward the low side. Near the ground 1 hPa is the weight of 8.5 m of air, so a difference of 1 hPa every 100 km along a level is the same thing as a pressure surface that falls 8.5 m every 100 km, a slope of 1 in 12,000. On that surface the push is the downhill slope times g: 9.8 m/s² times 8.5 m per 100,000 m, which is 0.83 × 10⁻³ m/s² again. Air on a pressure surface is pushed downhill along it, like a puck on a tilted table, and downhill is toward low pressure. The figure is one slab of air 200 km across, with the higher pressure on the left and, to start, 2 hPa across it, the typical 1 hPa every 100 km. Press Launch to set a parcel loose from rest, and switch the view to see the same slab as a pressure surface.

With 2 hPa across the slab, the parcel at the ground feels 0.83 × 10⁻³ m/s², gains 3.0 m/s every hour, and reaches the low side after 5 hours 38 minutes at 16.8 m/s. The hourly dots spread farther apart each hour, because the speed keeps growing. Now raise the parcel to 5.5 km. The difference there is only 1.00 hPa, because the high side's extra air is spread up the column like the rest of it, and half of it lies below that height. But the air there is also little more than half as dense, so the push only drops to 0.72 × 10⁻³ m/s². Switch the view to the pressure surface and the same push appears as a slope: the 500 hPa surface falls 14.8 m across the slab, nearly as much as the 16.9 m of the 1000 hPa surface at the ground. Where the two columns have the same temperature, the push follows the temperature of the air, weakening only from 0.83 to 0.66 × 10⁻³ m/s² by 9.1 km.

Nothing in the figure holds the air back. Left alone, the typical push of 1 hPa every 100 km would have the air moving at 72 m/s after a day. Real wind is held back in two ways. Once the air moves, the turning planet bends it sideways until it runs along the lines of equal pressure instead of down them, which is the story of Part 2, and near the ground friction drags it back, which comes later. The columns in the next section are pushed by exactly this force.

Warming one column

Enough with one parcel. Here is a row of columns of air standing side by side, eleven of them on a wide screen, each one a slice of the real model: twelve layers, a θ in each, the geopotential of every layer computed from hydrostatic balance, and the push of the last section: where a pressure surface slopes, the air along it is pushed toward the lower side. The thin lines are the pressure surfaces. The dotted line is each column's tropopause, found from its own temperatures as the level where the air stops cooling with height, so it moves as the columns change. A switch under the figure replaces the pressure surfaces with isotherms, lines of equal temperature every ten degrees, which lift over warm air and sink over cold. Warm the three columns in the middle, a patch of ground 300 km across, and watch what the neighbors do.

Six things happen, in order.

  1. The warmed columns grow. Their layers thicken and the pressure surfaces bulge upward over them. Nothing has moved yet.
  2. Air leaves at the top. The bulge means the pressure surfaces slope down toward the neighbors, so the upper layers are pushed outward.
  3. Surface pressure falls in the middle. The neighbors receive the mass briefly and pass it outward, so the warmed columns stay lowest, and the bars underneath show it. A pressure difference now exists along the ground.
  4. Air returns at the bottom. The surface pressure difference pushes the low layers back in. You now have a closed cell: in at the bottom, up in the middle, out at the top, down in the neighbors.
  5. The neighbors warm by sinking. The air coming down in the columns next door is compressed, and its temperature rises while its θ does not. The piston again.
  6. The disturbance leaves the frame. The outer columns feel it later, as a pulse traveling outward: a gravity wave, the sideways cousin of the bobbing parcel. The tropopause line shows it best, rippling as the pulse passes, because the wave stretches and squeezes the layers it moves through and the line is drawn from their temperatures.

The cell does not settle smoothly. It overshoots and rings, with the wind aloft reversing a few times before it finds its rhythm, because a column pushed out of balance bobs just as the parcel did, and in one dimension the waves it sheds have nowhere to go but left and right. The friction switch slows every wind toward zero, removing most of it within an hour and a half, on top of the drag the ground always exerts on the lowest layer here. It is a crude stand-in for what slows real air down: turbulence, drag against a rough surface, and the fact that in three dimensions the waves spread out in every direction and weaken as they go. With it on, the ringing dies away and the steady cell is what remains. The real model handles these one by one, and the drag of the ground gets its own section later.

That cell is the sea breeze, the onshore wind that picks up on a sunny afternoon because land warms faster than the sea beside it. Scaled up to the planet it is a Hadley cell: air rises where the tropics are heated most, spreads toward the poles aloft, sinks in the subtropics, and returns along the surface as the trade winds, the steady easterlies of the tropical oceans. It is also the model's equations of motion in one dimension. The real model does the same thing in two horizontal dimensions on a sphere, with the Earth's rotation turning the outflow sideways, which is where the next parts pick up.

The columns are 100 km wide and time runs 600 times faster than real. Height changes are drawn twenty times larger than they are: the top of the warmed columns really rises by tens of meters, not kilometers.