Chris Collins

Tools · medical

Test lung and breathing mechanics

A simulated test lung: pressure, flow and volume waveforms from the equation of motion in volume and pressure control, time constants and breath stacking, a lung-volumes spirogram, dead space, airway radius to the fourth power, and Laplace's law. Educational simulation only.

Added

How to use it

Companion to chapters 9, 12 and 17 of Human Biology for the Medical Maker: Circulation, breathing, and the wider body, Across the lifespan, and the mind and Treatment and life-support devices. Chapter 17 says of respiratory mechanics simulators that "writing your own from the equation of motion is an excellent exercise"; this is one.

Educational — not a medical device. Not for diagnosis, treatment, monitoring or dosing. Simulation only: the settings are invented and are not ventilator settings, doses or targets for anybody. Never connect anything you built to a person.

How to use it

Ventilator waveforms. Set resistance R (cmH2O per L/s), compliance C (L per cmH2O), PEEP, rate and the I:E ratio, then choose a mode:

  • Volume control pushes a constant flow for the inspiratory time, delivering the set tidal volume whatever pressure that takes.

  • Pressure control holds the airway at PEEP plus the set pressure; flow starts high and decays as the lung fills, so the volume delivered depends on R, C and time.

Both follow the equation of motion P = V/C + R × flow + PEEP. Expiration is passive: the volume falls as e−t/τ with τ = R × C, about 95% gone after 3τ. The three plots share a time axis — hover or tap to read values, or press Play to watch the bellows fill and empty in real time (the status shows Paused or Running · simulated). The summary gives τ, 3τ, the expiratory time Te, the share of each exhalation completed, and the steady-state trapped volume and auto-PEEP.

Load Book: narrowed airways, R 30 with the default 20 breaths/min at 1:2 (2 s to breathe out): τ = 1.5 s, so the lung cannot empty, volume stacks breath by breath to about 179 mL trapped, and every pressure in volume control rises by about 3.6 cmH2O. Change R and C part-way answers chapter 17’s question "what happens if the lungs suddenly stiffen?" for each mode. The chapter 17 question example (R 20, C 0.04) gives τ = 0.8 s and about 2.4 s to empty.

⛶ Full screen (or F) gives the three waveforms and the bellows the whole screen, with Play above them — the browser’s full screen where it is allowed, otherwise a full-window layer (iPhone); the plots are redrawn to the window’s height. The settings and summary start hidden; ◫ Panels shows them. Escape leaves.

Lung volumes. A drawn spirogram — quiet breaths, a maximal breath in and out — with the volumes (VT, IRV, ERV, RV) and capacities (VC = IRV + VT + ERV, TLC = VC + RV, FRC, IC). Defaults are chapter 9’s typical young-adult figures, for orientation only.

Dead space. Two breathing patterns side by side with the same dead space: minute ventilation, alveolar volume per breath, and alveolar ventilation per minute, with a strip of breaths showing how much of each one never reaches the alveoli. The book’s example (150 mL dead space; 500 mL at 12/min against 250 mL at 24/min): minute ventilation is 6,000 mL/min both ways; alveolar volume falls from 350 to 100 mL per breath, and alveolar ventilation from 4,200 to 2,400 mL per minute.

Airway radius. Resistance ∝ 1/r4. Chapter 12’s example: 1 mm of swelling takes an infant airway from radius 2 mm to 1 mm, 16× the resistance; the same swelling in an adult airway (8 → 7 mm) is ≈ 1.7×. The plot is chapter 12’s workshop exercise: resistance against radius from 1 to 10 mm, normalised to 10 mm, on a log scale.

Laplace & surfactant. P = 2γ/r for two connected alveoli: with the same surface tension, the smaller one has the higher pressure and would empty into the larger; when tension falls with radius (the surfactant-like mode) the pressures equalise.

Inputs outside the simulator’s range are rejected with a message, never clamped, and nothing is calculated until they are fixed. Every number carries its unit.

Limits

  • The model is a single linear compartment: one R, one C, no inertance, no chest-wall/lung split, no leaks, no patient effort and no ventilator triggering. Real lungs are non-linear (compliance falls at high volume) and inhomogeneous — regions with different time constants empty at different rates.

  • Waveforms are idealised: real ventilators shape flow, ramp pressure and have valve delays.

  • Auto-PEEP here is the elastic pressure of the trapped volume; nothing about its effect on the circulation is modelled.

  • The dead-space model is VT − VD (plug flow); it says nothing useful near or below the dead space.

  • Poiseuille’s law assumes steady laminar flow in a rigid tube; use the radius tab for sensitivity to radius, not to compute an airway’s resistance.

  • The book’s answer to "why is shallow rapid breathing inefficient?" (chapter 9) says alveolar ventilation falls "from 350 to 200 mL per minute-equivalent"; that is the alveolar gas delivered in the time the slower pattern takes for one breath (two breaths of 100 mL), shown as the last row of the dead-space table. Per breath it is 350 → 100 mL; per minute 4,200 → 2,400 mL.

Sources: equation of motion, time constants and the R 30 example from chapter 17; lung volumes and dead space from chapter 9 (OpenStax Anatomy and Physiology figures); airway radii from chapter 12; Laplace’s law from chapter 9; surface tension of water at 37 °C (≈ 70 mN/m) from the CRC Handbook of Chemistry and Physics.

Related: heart, vessels and oxygen, diffusion, dialysis and clearance, fluid flow and pipe pressure drop, discharge curves (its bleeder-resistor tab is the bench RC lung: a capacitor emptying through a resistor, t = RC·ln(V1/V2)).

Sharing

Share link (under the title) copies a URL that reopens this tool exactly as you have it — every tab’s inputs, with the current tab selected. Opening such a link replaces the inputs this browser had saved for the tool. Link to a tab with its name after #: /tools/test-lung/#airway (or #mechanics, #volumes, #deadspace, #laplace).

Runs entirely in your browser; nothing you type leaves this page.