In sea turtles the sex of an embryo is set by the temperature of the sand it develops in. Drive a sand column with the daily temperature wave, bury the clutch and read off the outcome.
Orange: surface. White: nest centre. Dashed: pivotal temperature. Shaded band: thermosensitive period (middle third of development).
Both experiments run the same solver off-screen (about a second).
The science
Heat in sand. The 1-D heat equation dT/dt = alpha d2T/dz2 + q/(rho c) is solved with an explicit finite-difference scheme (dz = 1.25 cm, dt kept below 0.4 dz2/alpha). The surface follows T_s = T_mean + A sin(2 pi (t - 8 h)/24 h); the bottom boundary (3 m) is held at T_mean. Dry sand has alpha of roughly 2-3 x 10-7 m2/s, damper sand more (typical values, they vary with moisture and grain size).
Why depth matters. A sinusoidal surface wave decays as A(z) = A0 exp(-z/d) and lags by z/d radians, with the damping depth d = sqrt(2 alpha/omega) (about 8 cm for the daily wave). At 50 cm the daily swing is far below 0.1 K, so deep nests feel only the mean beach temperature; shallow nests feel the full day-night cycle.
Metabolic heat. Late in development the clutch warms itself. A heat source proportional to (development)3 with a peak of 12 mW per egg (illustrative, not a measurement) is spread over a 28 cm thick slab of area 0.126 m2. Heat leaks away vertically by conduction and sideways at a rate alpha*5.8/R2 (R = 0.3 m, a lumped stand-in for 3-D conduction). The nest ends up 1-2 K warmer than undisturbed sand late in development, in line with the 1-3 K reported in the literature (typical range, check species).
Development and sex. Development speed is 1/D(T) with D(T) = 55 d x 2.8^(-(T-29)/10) (a Q10 rule; 55 d at 29 C is a typical value for green turtles, not a species fit). Sex is fixed in the middle third of development (the thermosensitive period). The female fraction is a logistic P = 1/(1 + exp(-(T_TSP - T_piv)/w)) with a pivotal temperature T_piv near 29 C and w = 0.6 K. Hatch success falls above about 34.5 C (illustrative). Real sex-ratio curves, thresholds and incubation lengths differ between species and populations.
Simplifications. No seasonal drift, no evaporation or tides in the equations (the rain preset only lowers the surface temperature for four days and raises alpha), no moisture-dependent alpha, one homogeneous sand layer, uniform clutch temperature (the nest centre is used). This is a teaching model, not a forecast for any real beach.