Feed a mesophilic digester with slurry, maize silage and food scraps. Watch loading rate, retention time, volatile fatty acids, pH and the CHP's electricity respond — overload it and the microbes stall.
Compares the code with closed-form results: Contois batch solution, a methane-equivalent energy balance, the analytic washout dilution rate with the Haldane steady state, and hand-computed loading numbers.
The science
Four steps in one tank. Hydrolysis and acidogenesis turn particulate volatile solids (VS) into volatile fatty acids (VFA); acetogenesis and methanogenesis turn VFA into CH4 and CO2. The first steps are fast, the methanogens are slow — the root of every overload.
Loading and retention.
OLR = Σ Fi·VSi / V [kg VS m−³ d−¹] HRT = V / ΣFi D = 1/HRT
V = 850 m³. Feed table (fresh matter): cow slurry 64 kg VS/t, pig slurry 45, maize silage 314, food scraps 225; BMP 0.20 / 0.30 / 0.34 / 0.45 Nm³ CH4 per kg VS (typical literature values).
Hydrolysis: Contois kinetics. Particulate substrate Si is degraded by acidogens Xa, with a rate that saturates in the substrate-to-biomass ratio:
ri = ki·fT(T)·Xa·Si / (KCXa + Si)
Only the biodegradable fraction βi of VS enters Si (0.50 / 0.65 / 0.85 / 0.90). Acidogen growth: dXa/dt = YaΣri(1−Xa/Xa,max) − (D+kd)Xa.
Methanogenesis: Andrews-Haldane (Monod with substrate inhibition).
μm = μmax·fT·fpH·fNH3 · VFA / (Ks + VFA + VFA²/KI)
dXm/dt = (μm(1−Xm/Xmax) − D − kd)Xm dVFA/dt = Σriyi/0.373 − D·VFA − μmXm/Ym
Each Nm³ of CH4 equals 2.86 kg COD, and 1 kg acetic acid carries 0.373 Nm³ CH4; Ks = 0.4, KI = 4 g/L, μmax = 0.32 d−¹ at the optimum. Only the undissociated acid is toxic, so KI (4 g/L at pH 7) is scaled by the acid fraction at the actual pH: low pH makes the same VFA far more inhibiting. Because μm peaks at VFA = √(KsKI) = 1.27 g/L (pH 7) and then falls, an overloaded tank passes a tipping point: VFA keeps rising although the microbes are starving.
Washout. A CSTR keeps methanogens only if D + kd < μm,peak. The model gives a theoretical minimum HRT near 5.7 d at pH 7; with pH and ammonia effects and the biomass carrying capacity the practical limit is 10–15 d, like real plants.
pH and alkalinity. Net cations C (eq/L) are carried in by the feed (slurry is buffered, maize silage is not) and released by protein mineralisation as NH4+. The carbonate system with CO2 partial pressure from the biogas gives
pH = 6.35 + log10( (C − VFA/60.05) / (KH·pCO2) )
VFA anions consume bicarbonate; once it is used up the pH collapses and methanogens (fpH below pH 7) stop. FOS/TAC = VFA(mg/L) / alkalinity(mg CaCO3/L): operators aim for 0.2–0.4 and worry above ~0.6. Free ammonia NH3 = TAN/(1+10pKa−pH) inhibits methanogens as 1/(1+NH3/0.25).
Temperature. Rosso's cardinal-temperature model with inflexion, normalised to 1 at the optimum: methanogens Tmin 8, Topt 38, Tmax 47 °C; hydrolysis 4 / 42 / 58 °C. Cold digesters make less gas, and too hot (>44 °C) kills the methanogens.
CHP. Biogas LHV = 9.97 kWh per Nm³ CH4 × CH4 fraction. A 150 kWe engine modulates on gas-holder level (ηel 38 % at full load, falling at part load; ηth 46 %); surplus gas is flared. Heat demand = heating the feed from ambient to digester temperature (4 kJ/kg/K) + wall losses (U = 0.45 W/m²K over 560 m²).
Honest simplifications. Two microbial groups instead of the 19-process ADM1; 4 lumped substrates; VFA lumped as acetate (no propionate/butyrate/H2); methanogen yield on VFA neglects biomass carbon; the carrying capacity Xmax is a stand-in for mixing, trace-element and biofilm limits; no trace-element deficiency, foaming, sulfide or solids settling; continuous feeding instead of portions; the pH model ignores ammonia and phosphate buffering and CO2 dissolution lag; parameters are plausible textbook magnitudes, not fitted to a plant. Indicative only, not for operating a real digester. Not affiliated with any manufacturer.
Baked 3D scene. Digester, tank, pipes, gas holder, CHP, clamp and animals come from Blender 5.2 (procedural materials baked to albedo and normal maps); the terrain, tree/rock/grass scatter and a lightmap baked by Unity 6's Progressive GPU lightmapper come from Unity; Three.js r160 runs the live part.