Build a windrow from manure, straw, food scraps and grass. The mix sets the carbon:nitrogen ratio and the moisture; microbes then heat the pile, oxygen runs short, the edge stays cold — turn, water and aerate it until the whole heap has been hot long enough to be safe.
Probe: tap the cut face of the heap.
Question 1: which carbon:nitrogen ratio keeps a 3 × 1.5 m windrow in the thermophilic range longest? Question 2: which moisture?
Compares the code with hand calculations and closed-form solutions: C:N and water arithmetic, the cardinal-temperature function, first-order decay and adiabatic heating (RK4 reference), and the pathogen D/z kill law.
The science
Carbon : nitrogen. Microbes build cells with C:N of about 8:1 and burn roughly two thirds of the carbon they eat for energy, so the feedstock should supply about 25–30 parts carbon per part nitrogen.
C:N = Σ midiCi / Σ midiNi (m fresh mass, d dry fraction, C and N per kg dry)
Too much carbon (straw, C:N 77) leaves the microbes starved of nitrogen: slow and cool. Too much nitrogen (grass 14, scraps 15) wastes the surplus as ammonia (the smell). In the model the rate is scaled by a log-normal bell centred on 27, fCN = exp(−½(ln(CN/27)/0.5)²), evaluated per cell with its current C:N as carbon leaves as CO2.
Moisture and air. Water carries nutrients but fills the pores. Below about 30 % microbes dry out; above about 65 % the pores flood and oxygen cannot get in. fM rises from 25 to 50 % and falls from 62 to 78 %. Oxygen follows a balance per cell, dO/dt = λ(21 − O) − consumption, with λ proportional to Deff/d2 (d = distance to the surface); Deff grows with air-filled porosity and with the chimney draught of a hot core. A Monod factor O/(3+O) throttles the microbes when oxygen runs out.
Heat. The degradable organic matter B decays first-order and releases about 12 MJ per kg of volatile solids:
dB/dt = −kmax fCN fT fM fO B q = Hv · B0 ρdry · (−dB/dt)
The temperature factor fT is the Rosso cardinal model for two communities: mesophiles (0 / 38 / 56 °C) and thermophiles (33 / 58 / 75 °C, 92 % activity). The heap then balances heat on a 26×20 half cross-section grid:
ρc ∂T/∂t = ∇·(k∇T) + q − Lve − ρacaV (T − Ta)
Evaporation e = V (ρv,sat(T) − ρv,air) is the biggest loss, so a hot heap dries out and has to be watered again. The phases emerge by themselves: slow mesophilic lag, self-heating to 55–70 °C (thermophilic), cooling as the easy food runs out, and curing near ambient.
Pathogen kill. Each cell accumulates decimal reductions, dL/dt = 1/D(T) with D(T) = D55 · 10(55−T)/z, D55 = 2.5 d and z = 7 °C, so 15 days at 55 °C give 6 log (the usual windrow rule of thumb: 55 °C for 15 days with several turns). The cold outer skin gets no kill; turning physically permutes the material and puts the skin into the core.
Honest simplifications: one lumped degradable pool and one rate constant tuned to give 15–25 K/day self-heating (not fitted to a data set); a symmetric 2-D cross-section, uniform along the windrow; a staircase boundary; water is spread evenly when added; the tarp is a multiplier on evaporation and surface loss; ingredient properties are typical textbook values and vary widely in reality; ammonia loss is a simple function of C:N, T and time; probe values are cell averages. A teaching model, not a design tool for regulated composting.
Baked 3D scene. The piles, compost turner, probe, tank, wheelbarrow, barn and trees are Blender 5.2 models with named parts; the compost, straw, grass, soil and wood textures (albedo, normal, and a baked ambient-occlusion map for the heap) were baked from procedural Cycles materials. Three.js r160 builds the heap geometry and the cut-face field and runs the model.