The stomach lumen holds acid strong enough to dissolve steel (pH ≈ 1–2) plus the protease pepsin, yet the epithelium one millimetre below sits near pH 7. The gap is bridged by a ~200 μm gel layer of mucus in which epithelial cells secrete bicarbonate (HCO₃⁻), neutralising H⁺ as it diffuses down before it ever reaches a cell membrane. This sim solves a 1D reaction-diffusion system across that gel, discretised into layers i = 0…N−1 (lumen → epithelium), drawn here as a vertical depth strip:
∂H/∂t = D_eff · ∂²H/∂x² − k·H·B (acid diffusing + being neutralised)
∂B/∂t = D_eff · ∂²B/∂x² − k·H·B (bicarbonate diffusing + consumed)
D_eff ∝ 1 / mucus_thickness (a thin barrier lets acid through faster)
Mucus thickness itself obeys its own balance: prostaglandin-driven secretion (which NSAIDs suppress by inhibiting COX-1) rebuilds it, while pepsin activity and H. pylori's cytotoxins (CagA/VacA) and urease-driven ammonia degrade it. Once the barrier thins past a critical point, acid reaches the epithelium directly and integrity falls — visualised as a growing crater in the tissue floor. Below ~30% integrity the status reads "erosion"; near 0% it reads "peptic ulcer".
Fix applied in this build: in the original model, H. pylori's local ammonia-neutralization near the epithelium (representing the bacterium buffering acid around itself to survive) was gated only by colonization density, not by how intact the mucus gel still was. At full colonization plus zero defense it numerically formed an acid curtain strong enough to block essentially all acid from ever reaching the epithelium — so cranking H. pylori to maximum, holding every other risk factor at its worst, left the tissue almost perfectly healthy (integrity ≈ 0.98 after 400 simulated seconds), the opposite of the real relationship (H. pylori causes ~80% of duodenal ulcers) and of this page's own theory text. Verified numerically (standalone Node script, not shipped): with the original term, integrity at acid=100/pylori=100/nsaid=100/defense=0 settled near 0.976 (no ulcer), while acid=100/pylori=0/nsaid=100/defense=0 correctly reached 0 (ulcer). This build multiplies that local sink by the current mucus thickness, so the bacterium can only buffer acid while it still has an intact gel to survive in — once the barrier itself is gone, the false protection disappears and higher colonization can no longer shield the tissue.
- Gastric acid secretion — parietal-cell H⁺ output; sets the lumen boundary concentration.
- H. pylori colonization — the bacterium burrows into the mucus layer, using urease to hydrolyse urea into ammonia (locally raising pH to survive) while its toxins erode the gel and tight junctions — the mechanism behind ~80% of duodenal ulcers.
- NSAID exposure — models COX-1 inhibition: less prostaglandin, so less mucus and bicarbonate get made, independent of acid load — the mechanism behind NSAID-associated gastric ulcers.
- Mucus / bicarbonate secretion — the epithelium's own defensive output; raising it can outpace even fairly high acid secretion.
- Give PPI — a proton-pump inhibitor pulse that drops acid secretion sharply, letting a damaged barrier recover, exactly as omeprazole-class drugs are used clinically to heal ulcers.
The strip chart below the depth view scrolls integrity, mucus barrier and pH over time — drag across it to scrub back through recent history and read exact values at any past moment.