Closed-loop control where a mistake is an emergency.
An artificial pancreas reads blood glucose and doses insulin automatically — a closed control loop on a living patient. What makes it hard isn't keeping glucose down after a meal; it's doing that without ever pushing it too low, because a hypoglycemic event isn't a missed setpoint, it's a medical emergency. This program models the physiology, builds the controller, walks straight into that safety trap, and shows the safety layer that gets out of it — then proves it across a virtual patient cohort.

A meal is a disturbance you can't reject in time.
Carbohydrate hits the bloodstream in minutes; injected insulin takes far longer to act. So a meal sends glucose spiking, and without control it climbs past 200 mg/dL and stays high for hours. The model — a Bergman minimal glucose-insulin system with a meal glucose-appearance term — reproduces that postprandial excursion exactly, and quantifies the damage: only 81% of the day inside the healthy 70-180 band, nearly a fifth of it hyperglycemic. That's the problem a closed loop is there to fix.


The harder you chase the highs, the closer you get to the lows.
It's tempting to turn the controller up: more aggressive insulin dosing flattens the post-meal peaks and pushes time-in-range higher still. But insulin keeps acting after glucose has already turned around, so a hot controller overshoots downward — straight into hypoglycemia. The program makes the trap explicit: chasing the last few points of time-in-range with gain alone causes hypo events. In a real device that's not a worse score, it's a 2 a.m. ambulance. The answer isn't a better gain — it's a safety layer.



Every number is one you can re-run.
The sign-off notebook re-derives each requirement from the same physiology model the program builds.
| Result | Requirement | |
|---|---|---|
| Open-loop time-in-range | 81% | baseline |
| Hybrid + safety TIR | 100% | R-03 |
| Hypoglycemic events (hybrid) | 0 | R-04 = 0 |
| Cohort TIR ≥ 80% | 40 / 40 | R-05 |
| Requirements verified | 6 / 6 | PASS |
A teaching & controls model, not a medical device.
The patient is the Bergman minimal model — glucose, insulin action and plasma insulin — not the high-fidelity UVA/Padova simulator used for regulatory work; the cohort is a simple spread of physiological parameters, and the CGM and pump are idealized. This is a controls and safety-engineering model, explicitly not a medical device or clinical advice. It is exactly the fidelity that builds the intuition and the control logic — the meal disturbance, the hypoglycemia trap, the value of a safety layer, and cohort robustness — on reproducible numbers, before a high-fidelity simulator and a regulated development process. And it pairs with the memory-safe-Rust path: a controller where 'verified' has to mean something.
Model your own physiological controller.
Book a walkthrough and we'll set up your patient model, disturbance and safety constraints, and run the closed-loop and cohort studies live.
