A sealed glass terrarium exchanges no matter with the outside — only light and heat cross the glass. Six coupled state variables (plant biomass P, herbivores H, leaf litter L, soil nutrients N, soil water W, glass condensation C) are integrated together with 4th-order Runge–Kutta at a fixed sub-step so the closed-loop cycles stay numerically stable:
light(t) = max(0, sin(2π·t))^0.6 // day/night
K = Kmax · N/(N+k_N) · W/(W+k_W) // Monod-limited carrying capacity
dP/dt = r·light·P·(1−P/K) − a·H·P/(k_g+P) // logistic growth − Holling-II grazing
dH/dt = e·a·H·P/(k_g+P) − m·H − m·H²/H_cap // grazing gain − mortality − crowding
dL/dt = turnover·P + (dead H) − decomp·L // litter fed by die-off
dN/dt = decomp·L − uptake·(growth term) // decomposers return nutrients
dW/dt = −evap(light,P,W) + drip·C
dC/dt = evap(light,P,W) − drip·C // evaporation ↔ condensation on the glass
Plants grow fastest in daylight when nutrients and soil moisture are both plentiful (Monod / Michaelis–Menten saturation, the same math used for enzyme kinetics and microbial growth). Herbivores graze with a saturating (Holling type II) response so a handful of insects cannot out-eat an entire meadow instantly. Dead plant matter and herbivores become litter, decomposers slowly return that mass to the soil as nutrients — the same closed nutrient loop that lets a sealed jar terrarium run for years without feeding. Water evaporates from wet soil fastest in daylight, condenses on the cooler glass, and drips back down at night when the temperature falls — the classic visible "rain cycle" of a bottle garden.
- Terrarium pane — grass height tracks plant biomass, dot count tracks herbivores, soil tint tracks nutrients, and droplets on the glass arc track condensation.
- Population pane — P, H and N traced over time; a real predator–prey pair should oscillate with H lagging P, not settle instantly.
- Water-cycle pane — soil moisture W and glass condensation C over time; W and C should trade off roughly in antiphase with the light cycle.