Every law the simulator uses
The complete constitutive basis of the model, with the source for each. Nothing here is proprietary — this is the physics, and it is meant to be checked.
The model is built so that a reader can disagree with it precisely. Every flux below is one constitutive law taken from the literature, applied to pools that conserve mass by construction. None of them is tuned to produce an expected outcome; where a constant could not be sourced, it is labelled as such on the calibration table rather than presented as if it were measured.
Conservation
V_src −= v ; V_dst += v ; n_s,src −= c_s·v ; n_s,dst += c_s·vEvery process that moves water moves its carried solute in the SAME atomic update, clamped to the source pool. Water and each solute are therefore invariant under any sequence of transfers — mass cannot be created or destroyed by a modelling error, only sent to the wrong place. Measured residual across a 30-day ten-patient cohort: order 1e-8.
n_s,src −= m ; n_s,dst += m, clamped so neither pool goes negativeDiffusive transport moves solute without water, by the same atomic rule.
Peritoneal membrane
J_v,i = K_f·a_i·w·(ΔP_i + Δπ_i)·dtWater crosses the membrane driven by the hydrostatic difference between capillary and intraperitoneal pressure plus the summed osmotic terms. a_i is the slab's share of wall area; w scales transport to zero on a near-dry cavity.
Rippe three-pore; Starling 1896
Δπ_cryst = Σ_s σ_s·R·T·(C_s,dialysate − C_s,serum)Van't Hoff, valid for small solutes at these concentrations. R·T = 19.34 mmHg per mmol/L at 310.15 K. σ is the osmotic reflection coefficient.
Rippe et al., Perit Dial Int 2004;24(1):10-27, PMID 15104333
COP = 2.1·C + 0.16·C² + 0.009·C³, C = total plasma protein g/dLPlasma protein is strongly non-ideal, so van't Hoff underestimates its osmotic pressure by about 40% at physiologic concentration. Applied to albumin plus globulin, evaluated on each side and differenced, then weighted by a mass-weighted protein reflection coefficient.
Landis & Pappenheimer, Handbook of Physiology Sect 2 Vol II, 1963, p.975
ṅ_s = S_s·C_s,serum·J_vSolute swept through the pores with the ultrafiltrate. S is the convective sieving coefficient and is independent of σ: water crossing aquaporin-1 carries no solute at all, which is why the small-solute class is discounted by the free-water fraction.
Rippe 2001, PMID 11687943; free-water transport 40–50% — Bernardo 2012, Helman 2024 PMC10914194
J_s = MTAC_s·a_i·w·(C_s,serum − r^z·C_s,dialysate)·dtFick across the membrane, scaled by the slab's area share. The Gibbs–Donnan factor r applies because albumin cannot cross: anions equilibrate to r×dialysate and cations to dialysate/r.
Smit 2003; Rippe. Donnan charge from Figge, Mydosh & Fencl, J Lab Clin Med 1992;120:713
J_abs,i = L·(V_i/V_perit)·w·dt, L = 1.07 mL/minApportioned by slab volume fraction. This is TOTAL absorption, not lymphatic flow alone — true lymph is 0.2–0.3 mL/min; the name in the source should not be read as claiming otherwise.
Imholz et al., Kidney Int 1993;44:1078-85, PMID 8264138
IAP(V) = IAP_base + 4.0·V [cmH₂O], plus the standing water column per slabLinear in intraperitoneal volume, anchored so that 2.82 L gives 13 cmH₂O supine.
Durand 1993, PMID 8105960 (13 cmH₂O at 2.82 L, 34 CAPD patients); linearity to 5 L, Durand 1994, PMID 7999866
A(V) ∝ V^0.437Effective peritoneal area grows sub-linearly with intraperitoneal volume, so MTAC and K_f track the current dwell volume rather than being frozen at the prescribed fill.
Cavity geometry and mixing
V_i, A_wall,i, z_i from the ovoid section at fluid height h(V)The cavity is divided into horizontal slabs, each with its own volume, wall area and hydrostatic depth. Fresh dialysate enters the top slab and drains from the floor, so a real vertical concentration gradient forms.
implicit backward-Euler tridiagonal solve on dz = h/NAdjacent slabs exchange solute by diffusion, solved implicitly so clearance is independent of the number of slabs. The dispersion coefficient is an EDDY parameter, not a molecular diffusivity — no in-vivo value exists.
Dedrick & Flessner, PMID 9086004, describe intraperitoneal mixing as an open knowledge gap
Whole-body physiology
V_serum* = A·(V_serum+V_ICF)/(A+B), A = 2·Na + glucose, B = ICF osmolesWater redistributes so serum and intracellular fluid are iso-tonic at the current effective osmolality. Placed at equilibrium each step, so it cannot oscillate or drain the cell. Rising serum glucose pulls water out of cells — translocational hyponatraemia.
Katz; Hillier
aldosterone-gated renal secretion + transcellular bufferIntracellular potassium is a real reservoir with an intercompartmental clearance; renal secretion is gated by an aldosterone factor rising with serum potassium.
J = k_bone·(C_serum − C_setpoint)Calcium, phosphate and magnesium exchange with a bone pool. Applied on the per-solute distribution volume, not the whole serum volume.
0.8 mmol/kg/day, delivered as retained anionNet endogenous acid production on a Western diet, which is part of why ESRD is a high-anion-gap acidosis.
Remer & Manz 1995, PMID 7797810; Frassetto 1998, PMID 9734733
first-order restoration toward baseline, capped at a physiologic net synthesis reserveAlbumin and globulin are both lost to the effluent and both replaced. Without this, protein falls monotonically and the oncotic opposition to ultrafiltration collapses.
intake = clamp(0.8 + deficit/0.5, 0.5, 6.0) L/day, deficit = TBW·(osm−285)/285Drinking is driven by the free-water deficit and clamped at a physiologic ceiling. Osmotic thirst drinks ~free water, not saline — the sodium load is diet-driven and independent of it.
per-solute clearance scaled by the residual GFR fraction, with urine concentrating factorsWhere present, the remaining kidney clears solute and water alongside the device.
1 lactate → 1 bicarbonateLactate absorbed from the dialysate is metabolised to bicarbonate, charge-paired.
Dialysate regeneration
J_w = A·(ΔP − β·π_bulk)Solution–diffusion. The wall, not the bulk, sets the opposing osmotic pressure, so concentration polarisation is solved together with the flux.
Wijmans & Baker, J Membr Sci 1995;107:1
R_s = 1 − B_s/(B_s + J_w) ; c_permeate = β·c_feed·(1 − R_s)Per-solute rejection from the solution–diffusion model. The feed is fully partitioned into permeate plus reject, so the regeneration circuit conserves mass by construction.
β = exp(J_w/k)Film theory. β = 1 by default, which reproduces the unpolarised engine exactly, so enabling it is opt-in and no published number moves until it is switched on.
Wijmans & Baker; Baker, Membrane Technology and Applications
Safety limits
serum concentration outside its physiologic band, BUN > 150 mg/dL, or |Δ body water| > 10% of body weightChecked every step. The volume trip is computed on body water EXCLUDING the device-instilled dwell, so a normal fill cannot trigger it, and it catches iso-tonic overload that leaves every concentration normal.
Cl = Na + K + 2Ca + 2Mg − (HCO₃ + lactate), asserted within a safe bandThe prescribed chloride is DERIVED, never chosen. The assertion is enforcing: it has stopped a prescription before a single patient was simulated.
Not modelled — stated so that absence is not mistaken for a claim
- The unstirred boundary layer, which is lumped into the diffusive coefficients rather than resolved.
- Parathyroid hormone and vitamin D, so calcium and phosphate are short-horizon balance species here rather than a full mineral-bone model.
- Phosphate binders.
- Gastric acid loss in the vomiting model.
- Appetite feedback — intake does not respond to how the patient feels.
- Pressure-dependence of peritoneal fluid absorption.
The source implementing every law above is published in full on the source code page.