Skip to content
Terrero Labs

Quantitative Physiology Models

Seven physiology systems modelled as differential equations in MATLAB/Simulink, then rebuilt as interactive browser simulations — from cardiac pressure–volume loops to Hodgkin–Huxley action potentials.

CompletedPhysiology for Engineers I & II · live on GitHub Pages
Division
Engineering
Role
Coursework models solved by me; browser ports built independently
Timeline
2025 – 2026

Physiology treated as an engineering system: every organ-level behaviour here is a set of ODEs with parameters you can change. Each browser page reuses the course model’s equations, parameters, and numerical scheme, so a slider change gives the same answer the MATLAB file would.

  • MATLAB
  • Simulink
  • JavaScript
  • Plotly.js
  • GitHub Pages

01Problem / user need

Physiology is usually taught as description. Engineering it means writing each system as conservation laws and rate equations, then asking what happens when a parameter changes: stiffer arteries, a leaky valve, lower insulin sensitivity, a different extracellular potassium. The course models answer that in MATLAB/Simulink, which most readers can’t open.

The goal of the browser ports: anyone can run the same models, with the same equations, without MATLAB.

02Requirements

#RequirementAcceptance criterionStatus
R1Model fidelityEach page uses the source model’s equations, parameters, and numerical schemeDocumented per model in the repo’s fidelity notes
R2Reference reproductionGlucose–insulin model reproduces the course fasting steady state (0.81 mg/ml glucose, 0.057 IU/ml insulin)Stated in the fidelity notes
R3Numerical parityBrowser output matches MATLAB/Simulink output at identical parametersNot yet measured
R4Zero installRuns in a browser with no MATLAB, server, or build stepMet

03Architecture

One page per assignment. Each page is self-contained HTML + JavaScript; Plotly.js loads from a CDN.

04Design decisions

Port the exact numerical scheme, not just the equations

Chosen
Each page reproduces the course code’s time-stepping — for example the semi-implicit Euler update in Psa_new.m, and Peskin’s semi-implicit gate and voltage updates at dt = 0.01 ms for Hodgkin–Huxley.
Alternative
Re-solve the same equations with a generic high-accuracy solver.
Tradeoff
Matching the scheme means a page and the MATLAB file agree step for step, so the port can be checked against the original. Cost: it inherits the original scheme’s step-size error — which the cell-population page shows deliberately, by solving logistic growth at three time steps.

Scenario presets tied to clinical conditions

Chosen
Presets such as arteriosclerosis, second-degree heart block, aortic stenosis, aortic insufficiency, Type 1 vs. Type 2 diabetes, and IV potassium.
Tradeoff
Each preset is one parameter change with a physiological meaning, so a reader sees cause and effect. Cost: the presets are illustrative parameter values from the course, not fitted to patient data.

Self-contained pages instead of an app

Chosen
One HTML file per model, with no build step.
Tradeoff
Opens anywhere and stays runnable for years. Cost: duplicated plotting code across pages. It’s the same choice made in BME Visualizations, for the same reason.

4.5Scope & role

The models and their parameters come from the Physiology for Engineers I and II course assignments. I solved the assignments in MATLAB and Simulink, and built the browser ports and the catalog independently.

05Implementation

ModelWhat it computes
Blood pressure (Windkessel)Arterial pressure from a triangular systolic flow pulse: C·dP/dt = Q_Ao − P/R. Presets for arteriosclerosis, obesity, exercise, and second-degree heart block; live pressure and cardiac-output readouts
Left heart & aortaTime-varying ventricular compliance (Hoppensteadt–Peskin), diode valves, and an aortic-backflow term. Pressure–volume loops, stroke volume, cardiac output, and stroke work under stenosis and regurgitation
Glucose–insulinKhoo’s minimal model, with fasting levels found by pre-running to steady state. Oral glucose tolerance test, Type 1 / Type 2 severity gains, and one-compartment drug pharmacokinetics including metformin. MATLAB scripts classify OGTT results
Cell populationLogistic growth with forward-Euler step-size error analysis, predator–prey phase planes, and a stiff three-species bacteria/phage model
Diffusion & membrane potentialMass-action kinetics against analytic solutions, diffusion with product feedback inhibition, and resting potential by chord conductance — why IV potassium is lethal
Enzyme kineticsFull E + S ⇌ C → E + P dynamics against the Michaelis–Menten approximation, plus Lineweaver–Burk and Hill fits
Hodgkin–HuxleyNa⁺/K⁺/leak conductances with m, h, n gating; action potentials under applied current

06Verification

  • Fidelity notes in the repo record, per model, which source file each page transcribes and which constants it uses.
  • The glucose–insulin page reproduces the course’s fasting steady state, and the mass-action page plots the Euler solution against the exact analytic solution.

PendingNext: a parity check — run each browser model and its MATLAB/Simulink source at identical parameters and report the maximum difference. Any nonzero result is a bug in one of them.

07Failures / iterations

PendingNot yet written up: where the first port of each model disagreed with MATLAB, and why.

08Limitations

  • Teaching models with textbook parameters — not fitted to any patient, and not for clinical use.
  • Lumped-parameter simplifications throughout: single-compartment arteries, ideal valves, a minimal two-state glucose–insulin system, and a space-clamped axon.
  • Disease presets are single-parameter illustrations, not models of the full pathophysiology.