Snapshot / Computational Thinking Repo ↗

The greenhouse effect

CO₂ is transparent to incoming sunlight but absorbs the infrared heat the Earth radiates back toward space. More CO₂ means more of that outgoing heat is caught and re-emitted downward, so the surface must warm until balance is restored. That is the greenhouse effect.

There is a crucial wrinkle: the warming is logarithmic in CO₂. Each doubling adds about the same push (roughly +3.7 W/m², worth a couple of degrees), so going 280 → 560 ppm warms as much as 560 → 1120. The first molecules matter most; the curve bends over.

Below, sweep the CO₂ dial and watch the equilibrium-temperature curve, computed live in WebAssembly from the Energy Balance Model.

begin
    using PlutoUI, WasmMakie
end

CO₂ concentration (ppm) = 420

let
    # sweep CO2 from 280 to 1400 ppm and plot the equilibrium temperature of the Energy
    # Balance Model at each level (one flat loop). The equilibrium solves dT/dt = 0:
    #   T_eq = (absorbed - A + 5.35 ln(CO2/280)) / B
    absorbed = 239.4
    A = 214.6
    B = 1.77
    npts = 113
    cx = Vector{Float64}(undef, npts)
    ty = Vector{Float64}(undef, npts)
    for k in 1:npts
        co2 = 280.0 + 10.0 * Float64(k - 1)
        teq = 14.0                                          # at 280 ppm: no warming (avoids log(1))
        if co2 > 280.0
            teq = (absorbed - A + 5.35 * log(co2 / 280.0)) / B
        end
        cx[k] = co2
        ty[k] = teq
    end
    fig = Figure(size = (600, 350))
    ax = Axis(fig[1, 1])
    lines!(ax, [280.0, 1400.0], [14.0, 14.0])               # pre-industrial baseline
    lines!(ax, cx, ty)                                       # the warming curve (fixed)
    fig
end
gh_stats = let
    # equilibrium temperatures in a SEPARATE bond-dependent cell so the markdown below
    # interpolates them live (values inside a markdown cell's own `let` bake to the
    # slider defaults).
    absorbed = 239.4
    A = 214.6
    B = 1.77
    teq = (absorbed - A + 5.35 * log(Float64(co2ppm) / 280.0)) / B
    (floor(teq * 10.0) / 10.0, floor((teq - 14.0) * 10.0) / 10.0)
end;

At 420 ppm: equilibrium temperature is about 15.2 C – a warming of 1.2 C above the pre-industrial baseline. Because the warming is logarithmic, each doubling of CO2 adds about the same step in temperature, no matter where you start – the signature of the greenhouse effect.

The logarithm is good news and bad news

Good news: runaway is not automatic — because warming is logarithmic, you cannot get an arbitrarily large effect from a little more CO₂. Bad news: the flip side is that cutting emissions a little does little; only large reductions move the curve meaningfully, and the CO₂ we've added lingers for centuries.

This single curve sets the stakes for climate policy. The next lessons add what makes the real planet more sensitive than this bare model — feedbacks — and what could make it lurch to a completely different state — tipping points.

Appendix

Built from the same Energy Balance Model as the previous lesson, solved at equilibrium across a sweep of CO₂ values. Computed with an inline logarithm and drawn with WasmMakie, so the whole curve is in-browser WebAssembly — no Plots.jl, no server.