Pulmonary Ventilation, Pulmonary Circulation, Pulmonary Edema, and Pleural Fluid , Principles of Gas Exchange; Diffusion of Oxygen and Carbon Dioxide Through Respiratory Membranes , Transport of Oxygen and Carbon Dioxide in Blood and Tissue Fluids, Regulation of Respiration, Respiratory Insufficiency—Pathophysiology, Diagnosis, Oxygen Therapy , Physiology with diagram and flow chart with clinical physiology

Reading File
This is a large syllabus-style request covering five major respiratory physiology chapters. Given the scope, I'll outline the topics and give a brief overview first, then we can go deep on whichever section you need most (with diagrams, flowcharts, and clinical correlations).

Topic Map

  1. Pulmonary Ventilation - mechanics of breathing (inspiration/expiration muscles), lung compliance, surfactant, airway resistance, lung volumes/capacities (spirometry), alveolar ventilation, work of breathing.
  2. Pulmonary Circulation, Pulmonary Edema, and Pleural Fluid - dual blood supply, low-pressure pulmonary circuit, pulmonary capillary dynamics, zones of blood flow (West zones), causes/mechanisms of pulmonary edema, pleural space physiology and fluid dynamics.
  3. Principles of Gas Exchange; Diffusion of O2 and CO2 Through Respiratory Membranes - Dalton's law, partial pressures, diffusion across the alveolar-capillary membrane, factors affecting diffusing capacity, ventilation-perfusion (V/Q) ratio and mismatch.
  4. Transport of O2 and CO2 in Blood and Tissue Fluids - oxygen-hemoglobin dissociation curve, factors shifting the curve (Bohr effect), CO2 transport forms (bicarbonate, carbaminohemoglobin, dissolved), Haldane effect, respiratory exchange ratio.
  5. Regulation of Respiration - the respiratory center (medulla/pons), chemical control via central and peripheral chemoreceptors (CO2, O2, H+), the Hering-Breuer reflex, and integration during exercise.
  6. Respiratory Insufficiency - Pathophysiology, Diagnosis, Oxygen Therapy - COPD, restrictive lung disease, pulmonary function testing, hypoxia types, hypoxemia vs. hypercapnia, cyanosis, and principles/hazards of oxygen therapy.

Brief Overview

Ventilation moves air in and out of alveoli through pressure gradients created by respiratory muscles, governed by lung compliance and surfactant (which reduces alveolar surface tension and prevents collapse). Pulmonary circulation is a low-pressure, high-flow system distinct from systemic circulation; imbalances in capillary hydrostatic/oncotic pressures or lymphatic drainage cause pulmonary edema, while the pleural space maintains a small negative-pressure fluid film that couples lung and chest wall.
Gas exchange depends on partial pressure gradients across the thin alveolar-capillary membrane, following Fick's law of diffusion, with efficiency measured by diffusing capacity and matched (or mismatched) by regional ventilation-perfusion ratios. Once in blood, oxygen is carried mostly bound to hemoglobin (per the sigmoid O2-Hb dissociation curve) and CO2 is carried mainly as bicarbonate, with reciprocal Bohr/Haldane effects linking the two gases' transport.
Respiration is automatically regulated by medullary and pontine centers, fine-tuned by chemoreceptors sensing CO2/pH (central) and O2 (peripheral, carotid/aortic bodies), enabling adaptation during exercise or altitude. When any of these systems fail, respiratory insufficiency results, classified by pathophysiology (obstructive vs. restrictive, ventilatory vs. diffusion vs. V/Q defects), assessed via pulmonary function tests and blood gases, and managed with oxygen therapy tailored to the underlying mechanism (with caution in chronic hypercapnic patients).
Which topic would you like me to go deep into first, with diagrams, flowcharts, and clinical physiology correlations?
Asking for Preferences

Which topic should I cover in full depth first (with diagrams/flowcharts and clinical correlations)?

This is a large syllabus-style request covering five major respiratory physiology chapters. Given the scope, I'll outline the topics and give a brief overview first, then we can go deep on whichever section you need most (with diagrams, flowcharts, and clinical correlations).

Topic Map

  1. Pulmonary Ventilation - mechanics of breathing (inspiration/expiration muscles), lung compliance, surfactant, airway resistance, lung volumes/capacities (spirometry), alveolar ventilation, work of breathing.
  2. Pulmonary Circulation, Pulmonary Edema, and Pleural Fluid - dual blood supply, low-pressure pulmonary circuit, pulmonary capillary dynamics, zones of blood flow (West zones), causes/mechanisms of pulmonary edema, pleural space physiology and fluid dynamics.
  3. Principles of Gas Exchange; Diffusion of O2 and CO2 Through Respiratory Membranes - Dalton's law, partial pressures, diffusion across the alveolar-capillary membrane, factors affecting diffusing capacity, ventilation-perfusion (V/Q) ratio and mismatch.
  4. Transport of O2 and CO2 in Blood and Tissue Fluids - oxygen-hemoglobin dissociation curve, factors shifting the curve (Bohr effect), CO2 transport forms (bicarbonate, carbaminohemoglobin, dissolved), Haldane effect, respiratory exchange ratio.
  5. Regulation of Respiration - the respiratory center (medulla/pons), chemical control via central and peripheral chemoreceptors (CO2, O2, H+), the Hering-Breuer reflex, and integration during exercise.
  6. Respiratory Insufficiency - Pathophysiology, Diagnosis, Oxygen Therapy - COPD, restrictive lung disease, pulmonary function testing, hypoxia types, hypoxemia vs. hypercapnia, cyanosis, and principles/hazards of oxygen therapy.

Brief Overview

Ventilation moves air in and out of alveoli through pressure gradients created by respiratory muscles, governed by lung compliance and surfactant (which reduces alveolar surface tension and prevents collapse). Pulmonary circulation is a low-pressure, high-flow system distinct from systemic circulation; imbalances in capillary hydrostatic/oncotic pressures or lymphatic drainage cause pulmonary edema, while the pleural space maintains a small negative-pressure fluid film that couples lung and chest wall.
Gas exchange depends on partial pressure gradients across the thin alveolar-capillary membrane, following Fick's law of diffusion, with efficiency measured by diffusing capacity and matched (or mismatched) by regional ventilation-perfusion ratios. Once in blood, oxygen is carried mostly bound to hemoglobin (per the sigmoid O2-Hb dissociation curve) and CO2 is carried mainly as bicarbonate, with reciprocal Bohr/Haldane effects linking the two gases' transport.
Respiration is automatically regulated by medullary and pontine centers, fine-tuned by chemoreceptors sensing CO2/pH (central) and O2 (peripheral, carotid/aortic bodies), enabling adaptation during exercise or altitude. When any of these systems fail, respiratory insufficiency results, classified by pathophysiology (obstructive vs. restrictive, ventilatory vs. diffusion vs. V/Q defects), assessed via pulmonary function tests and blood gases, and managed with oxygen therapy tailored to the underlying mechanism (with caution in chronic hypercapnic patients).
Which topic would you like me to go deep into first, with diagrams, flowcharts, and clinical physiology correlations?
Finding Sources
Finding Sources
Finding Sources
Searching Images

lung volumes and capacities spirometry diagram

Searching Images

mechanics of respiration diaphragm and chest wall movement during inspiration expiration

Reading File
Reading File
Searching Images

alveolar surfactant surface tension diagram

Finding Sources
Finding Sources

Pulmonary Ventilation

(First deep-dive topic from the respiratory physiology series — Guyton & Hall, Costanzo, and other library sources cross-referenced below. Ask for any of the remaining five topics next.)

1. Overview: The Four Components of Respiration

Guyton frames respiration in four sequential steps:
[1] Pulmonary Ventilation  →  [2] Diffusion (O2/CO2 across alveolar-capillary membrane)
         ↓                              ↓
[4] Regulation of Respiration  ←  [3] Transport of O2/CO2 in blood & tissue fluid
  • Guyton and Hall Textbook of Medical Physiology, p. 492
Ventilation is the mechanical step: moving air between the atmosphere and the alveoli.

2. Mechanics of Breathing — Muscles and Pressure Changes

Two mechanisms expand the thoracic cage:
MechanismActionMuscles
Diaphragm movementDownward pull lengthens chest cavity (quiet breathing)Diaphragm (contracts on inspiration, relaxes passively on expiration)
Rib cage elevation/depressionIncreases/decreases anteroposterior chest diameterInspiration: external intercostals, sternocleidomastoids, anterior serrati, scaleni. Expiration (forced): abdominal recti, internal intercostals
  • Guyton and Hall Textbook of Medical Physiology, p. 492-493
Flowchart — pressure gradient driving airflow:
Inspiratory muscles contract
        ↓
Thoracic cavity volume ↑
        ↓
Intrapleural pressure ↓ (becomes more negative, ~ -5 to -8 cm H2O)
        ↓
Transpulmonary pressure (Palv - Ppl) ↑
        ↓
Alveolar pressure ↓ (slightly below atmospheric, ~ -1 cm H2O)
        ↓
Air flows IN (down the pressure gradient) → tidal volume delivered
        ↓
Elastic recoil + relaxation of muscles → alveolar pressure rises above atmospheric (~+1 cm H2O)
        ↓
Air flows OUT (expiration)

3. Lung Compliance

Compliance = change in lung volume per unit change in transpulmonary pressure (ΔV/ΔP). It reflects the "stretchability" of the lung-chest wall system.
  • Guyton and Hall Textbook of Medical Physiology, "Compliance of the Lungs," p. 494
Determined by two factors:
  1. Elastic forces of lung tissue (elastin/collagen fibers)
  2. Surface tension of the fluid lining the alveoli (the larger contributor)
Compliance curve behavior: compliance is greater at low lung volumes and flattens near total lung capacity (the curve is sigmoid, not linear) — this is why alveoli in different lung regions (apex vs. base) sit on different parts of the curve and ventilate unevenly (regional ventilation distribution).

4. Surfactant and the Law of Laplace

Alveoli are modeled as spheres. The Law of Laplace:
P = 2T / r
where P = collapsing pressure, T = surface tension, r = alveolar radius.
  • Costanzo Physiology 7th Edition, "Surface Tension of Alveoli," p. ~1918-1935; Morgan & Mikhail's Clinical Anesthesiology, 7e, "Surface Tension Forces"
Without surfactant, smaller alveoli (smaller r) would generate higher collapsing pressure than larger alveoli for the same surface tension, so small alveoli would empty into large ones and collapse (instability). Surfactant (dipalmitoylphosphatidylcholine, secreted by Type II alveolar cells) lowers surface tension disproportionately more in smaller alveoli, equalizing pressures and stabilizing alveoli of different sizes.
Clinical correlation: Neonatal (infant) Respiratory Distress Syndrome occurs when surfactant production is insufficient (surfactant appears around 24-28 weeks gestation, matures by ~35 weeks). Low surfactant → high surface tension → alveolar collapse (atelectasis) → reduced compliance → increased work of breathing. Treated with exogenous surfactant and antenatal corticosteroids to accelerate fetal lung maturity.

5. Lung Volumes and Capacities

Measured by spirometry (except residual volume and anything containing it):
                     ┌── Inspiratory Reserve Volume (~3000 mL) ──┐
Total Lung Capacity  │                                            ├── Inspiratory Capacity (~3500 mL)
   (~5900 mL)         ├── Tidal Volume (~500 mL) ─────────────────┘
                     │
                     ├── Expiratory Reserve Volume (~1200 mL) ──┐
                     │                                           ├── Functional Residual Capacity (~2400 mL)
                     └── Residual Volume (~1200 mL) ─────────────┘

Vital Capacity (~4700 mL) = IC + ERV
Total Lung Capacity (~5900 mL) = VC + RV
  • Costanzo Physiology 7th Edition, "Lung Volumes" and "Lung Capacities," p. ~1531-1546
  • Residual volume (RV) and any capacity containing it (FRC, TLC) cannot be measured by simple spirometry — they require helium dilution or body plethysmography (based on Boyle's Law, P×V = constant).
  • FRC is the lung's resting/equilibrium volume after a normal tidal expiration — clinically important because it determines the oxygen reserve available during apnea (e.g., pre-oxygenation before intubation).

6. Alveolar Ventilation vs. Dead Space

Not all inspired air reaches gas-exchanging alveoli.
  • Anatomic dead space (~150 mL): conducting airways (trachea to terminal bronchioles) where no gas exchange occurs.
  • Physiologic dead space: anatomic dead space + any alveoli that are ventilated but poorly perfused (functional, non-exchanging).
Alveolar ventilation (VA) = (Tidal Volume − Dead Space) × Respiratory Rate
This is why rapid, shallow breathing is less efficient than slow, deep breathing for the same minute ventilation — a larger fraction of shallow breaths is "wasted" on dead space.

7. Clinical Physiology Correlations

ConditionMechanismEffect on Ventilation
COPD/EmphysemaLoss of elastic recoil, destroyed alveolar septaeCompliance ↑ (lungs "too stretchy"), air trapping, ↑ RV/FRC, obstructive pattern on spirometry (↓FEV1/FVC)
Pulmonary fibrosis (restrictive disease)Stiff, scarred interstitiumCompliance ↓, ↓ all lung volumes, preserved or ↑ FEV1/FVC ratio
PneumothoraxAir enters pleural space, abolishing negative PplLoss of transpulmonary pressure gradient → lung collapses (elastic recoil unopposed)
Infant RDSSurfactant deficiency↓ compliance, alveolar collapse, ↑ work of breathing
Flail chest/neuromuscular diseaseImpaired chest wall/muscle mechanics↓ tidal volume, hypoventilation

Quick Reference: Normal Values

  • Tidal volume: ~500 mL
  • Respiratory rate: 12-16/min
  • Minute ventilation: ~6 L/min
  • Anatomic dead space: ~150 mL
  • Intrapleural pressure: -5 (expiration) to -8 cm H2O (inspiration)
  • FRC: ~2400 mL, TLC: ~5900 mL, VC: ~4700 mL

Evidence check: This is core, well-established physiology (unchanged over decades), so no PubMed contradiction search is needed here — the material is foundational rather than an area of active evidence revision.
Would you like me to go deep into the next topic — Pulmonary Circulation, Edema & Pleural Fluid, Gas Exchange & Diffusion, O2/CO2 Transport, Regulation of Respiration, or Respiratory Insufficiency & Oxygen Therapy?

Make pdf of this

Reading File
Reading File
Running Command

mkdir -p /tmp/workspace/pulmonary-physiology/output && ls -la /tmp/workspace/

Writing File

~/pulmonary-physiology/build_pdf.py

# -*- coding: utf-8 -*-
from reportlab.lib.pagesizes import LETTER
from reportlab.lib.units import inch
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    Preformatted, PageBreak, HRFlowable
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT

OUT = "/tmp/workspace/pulmonary-physiology/output/Pulmonary_Ventilation.pdf"

styles = getSampleStyleSheet()

title_style = ParagraphStyle(
    "TitleStyle", parent=styles["Title"], fontSize=22, spaceAfter=6,
    textColor=colors.HexColor("#1a3c6e")
)
subtitle_style = ParagraphStyle(
    "SubtitleStyle", parent=styles["Normal"], fontSize=10, spaceAfter=18,
    textColor=colors.HexColor("#555555"), alignment=TA_CENTER, fontName="Helvetica-Oblique"
)
h1_style = ParagraphStyle(
    "H1", parent=styles["Heading1"], fontSize=15, spaceBefore=16, spaceAfter=8,
    textColor=colors.HexColor("#1a3c6e"), fontName="Helvetica-Bold"
)
h2_style = ParagraphStyle(
    "H2", parent=styles["Heading2"], fontSize=12, spaceBefore=10, spaceAfter=6,
    textColor=colors.HexColor("#2e5b9c"), fontName="Helvetica-Bold"
)
body_style = ParagraphStyle(
    "Body", parent=styles["Normal"], fontSize=10.3, leading=15, spaceAfter=8,
    alignment=TA_LEFT
)
bullet_style = ParagraphStyle(
    "Bullet", parent=body_style, leftIndent=14, bulletIndent=4, spaceAfter=4
)
citation_style = ParagraphStyle(
    "Citation", parent=styles["Normal"], fontSize=8.5, leading=11,
    textColor=colors.HexColor("#555555"), fontName="Helvetica-Oblique", spaceAfter=10
)
flow_style = ParagraphStyle(
    "Flow", parent=styles["Normal"], fontName="Courier", fontSize=8.7, leading=11,
    backColor=colors.HexColor("#f2f5fa"), borderPadding=8, spaceAfter=10, spaceBefore=4
)
footer_note_style = ParagraphStyle(
    "FooterNote", parent=styles["Normal"], fontSize=9, leading=13,
    textColor=colors.HexColor("#333333")
)

def flow(text):
    return Preformatted(text, ParadumStyleFont) if False else Preformatted(text, flow_code_style)

flow_code_style = ParagraphStyle(
    "FlowCode", fontName="Courier", fontSize=8.3, leading=10.5,
    textColor=colors.HexColor("#1a1a1a"), backColor=colors.HexColor("#eef2f8")
)

def table_block(data, col_widths=None, header_bg="#1a3c6e"):
    t = Table(data, colWidths=col_widths, repeatRows=1)
    style = [
        ('BACKGROUND', (0, 0), (-1, 0), colors.HexColor(header_bg)),
        ('TEXTCOLOR', (0, 0), (-1, 0), colors.white),
        ('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
        ('FONTSIZE', (0, 0), (-1, -1), 8.7),
        ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ('GRID', (0, 0), (-1, -1), 0.5, colors.HexColor("#b5c4d9")),
        ('ROWBACKGROUNDS', (0, 1), (-1, -1), [colors.white, colors.HexColor("#f4f7fb")]),
        ('TOPPADDING', (0, 0), (-1, -1), 5),
        ('BOTTOMPADDING', (0, 0), (-1, -1), 5),
        ('LEFTPADDING', (0, 0), (-1, -1), 6),
        ('RIGHTPADDING', (0, 0), (-1, -1), 6),
    ]
    t.setStyle(TableStyle(style))
    return t

def wrap_cells(rows):
    """Convert plain strings in table cells into Paragraphs for wrapping."""
    cell_style = ParagraphStyle("Cell", fontSize=8.5, leading=10.8, fontName="Helvetica")
    header_style = ParagraphStyle("CellHead", fontSize=8.7, leading=11, fontName="Helvetica-Bold", textColor=colors.white)
    out = []
    for i, row in enumerate(rows):
        new_row = []
        for cell in row:
            st = header_style if i == 0 else cell_style
            new_row.append(Paragraph(str(cell), st))
        out.append(new_row)
    return out

story = []

# ---------- Title ----------
story.append(Paragraph("Pulmonary Ventilation", title_style))
story.append(Paragraph(
    "Physiology, Mechanics, and Clinical Correlations — "
    "Compiled from Guyton & Hall Textbook of Medical Physiology and Costanzo Physiology (7th Ed.)",
    subtitle_style
))
story.append(HRFlowable(width="100%", thickness=1, color=colors.HexColor("#1a3c6e")))
story.append(Spacer(1, 10))

# ---------- 1. Overview ----------
story.append(Paragraph("1. Overview: The Four Components of Respiration", h1_style))
story.append(Paragraph(
    "Guyton frames respiration in four sequential steps:", body_style))
story.append(Preformatted(
"""[1] Pulmonary Ventilation --> [2] Diffusion (O2/CO2 across
                                   alveolar-capillary membrane)
        |                              |
        v                              v
[4] Regulation of Respiration <-- [3] Transport of O2/CO2 in
                                   blood & tissue fluid""",
    flow_code_style))
story.append(Paragraph("Guyton and Hall Textbook of Medical Physiology, p. 492", citation_style))
story.append(Paragraph(
    "Ventilation is the mechanical step: moving air between the atmosphere and the alveoli.",
    body_style))

# ---------- 2. Mechanics ----------
story.append(Paragraph("2. Mechanics of Breathing &mdash; Muscles and Pressure Changes", h1_style))
story.append(Paragraph("Two mechanisms expand the thoracic cage:", body_style))

mech_data = wrap_cells([
    ["Mechanism", "Action", "Muscles"],
    ["Diaphragm movement", "Downward pull lengthens chest cavity (quiet breathing)",
     "Diaphragm (contracts on inspiration, relaxes passively on expiration)"],
    ["Rib cage elevation / depression", "Increases / decreases anteroposterior chest diameter",
     "Inspiration: external intercostals, sternocleidomastoids, anterior serrati, scaleni.<br/>Expiration (forced): abdominal recti, internal intercostals"],
])
story.append(table_block(mech_data, col_widths=[1.5*inch, 2.3*inch, 2.5*inch]))
story.append(Paragraph("Guyton and Hall Textbook of Medical Physiology, p. 492-493", citation_style))

story.append(Paragraph("Flowchart &mdash; pressure gradient driving airflow:", h2_style))
story.append(Preformatted(
"""Inspiratory muscles contract
        |
        v
Thoracic cavity volume increases
        |
        v
Intrapleural pressure decreases (more negative, ~ -5 to -8 cm H2O)
        |
        v
Transpulmonary pressure (P_alv - P_pl) increases
        |
        v
Alveolar pressure decreases (slightly below atmospheric, ~ -1 cm H2O)
        |
        v
Air flows IN (down the pressure gradient) -> tidal volume delivered
        |
        v
Elastic recoil + muscle relaxation -> alveolar pressure rises
above atmospheric (~ +1 cm H2O)
        |
        v
Air flows OUT (expiration)""",
    flow_code_style))

# ---------- 3. Compliance ----------
story.append(Paragraph("3. Lung Compliance", h1_style))
story.append(Paragraph(
    "Compliance = change in lung volume per unit change in transpulmonary pressure "
    "(&Delta;V/&Delta;P). It reflects the &ldquo;stretchability&rdquo; of the lung-chest wall system.",
    body_style))
story.append(Paragraph('Guyton and Hall Textbook of Medical Physiology, "Compliance of the Lungs," p. 494', citation_style))
story.append(Paragraph("Determined by two factors:", body_style))
story.append(Paragraph("1. Elastic forces of lung tissue (elastin/collagen fibers)", bullet_style))
story.append(Paragraph("2. Surface tension of the fluid lining the alveoli (the larger contributor)", bullet_style))
story.append(Paragraph(
    "<b>Compliance curve behavior:</b> compliance is greater at low lung volumes and flattens near "
    "total lung capacity (the curve is sigmoid, not linear) &mdash; this is why alveoli in different lung "
    "regions (apex vs. base) sit on different parts of the curve and ventilate unevenly (regional "
    "ventilation distribution).",
    body_style))

# ---------- 4. Surfactant ----------
story.append(Paragraph("4. Surfactant and the Law of Laplace", h1_style))
story.append(Paragraph(
    "Alveoli are modeled as spheres. The Law of Laplace:", body_style))
story.append(Paragraph("<b>P = 2T / r</b>", ParagraphStyle("eq", parent=body_style, alignment=TA_CENTER, fontSize=13, spaceAfter=8)))
story.append(Paragraph(
    "where P = collapsing pressure, T = surface tension, r = alveolar radius.", body_style))
story.append(Paragraph(
    'Costanzo Physiology 7th Edition, "Surface Tension of Alveoli"; Morgan &amp; Mikhail\'s Clinical '
    'Anesthesiology, 7e, "Surface Tension Forces"', citation_style))
story.append(Paragraph(
    "Without surfactant, smaller alveoli (smaller r) would generate higher collapsing pressure than "
    "larger alveoli for the same surface tension, so small alveoli would empty into large ones and "
    "collapse (instability). <b>Surfactant</b> (dipalmitoylphosphatidylcholine, secreted by Type II "
    "alveolar cells) lowers surface tension disproportionately more in smaller alveoli, equalizing "
    "pressures and stabilizing alveoli of different sizes.",
    body_style))

story.append(Paragraph("Clinical Correlation: Infant Respiratory Distress Syndrome", h2_style))
story.append(Paragraph(
    "Neonatal (infant) Respiratory Distress Syndrome occurs when surfactant production is insufficient "
    "(surfactant appears around 24-28 weeks gestation, matures by ~35 weeks). Low surfactant leads to high "
    "surface tension, alveolar collapse (atelectasis), reduced compliance, and increased work of breathing. "
    "Treated with exogenous surfactant and antenatal corticosteroids to accelerate fetal lung maturity.",
    body_style))

story.append(PageBreak())

# ---------- 5. Lung Volumes ----------
story.append(Paragraph("5. Lung Volumes and Capacities", h1_style))
story.append(Paragraph("Measured by spirometry (except residual volume and anything containing it):", body_style))
story.append(Preformatted(
"""                     +-- Inspiratory Reserve Volume (~3000 mL) --+
Total Lung Capacity  |                                            +-- Inspiratory Capacity (~3500 mL)
   (~5900 mL)         +-- Tidal Volume (~500 mL) ------------------+
                     |
                     +-- Expiratory Reserve Volume (~1200 mL) --+
                     |                                           +-- Functional Residual Capacity (~2400 mL)
                     +-- Residual Volume (~1200 mL) -------------+

Vital Capacity (~4700 mL)      = IC + ERV
Total Lung Capacity (~5900 mL) = VC + RV""",
    flow_code_style))
story.append(Paragraph('Costanzo Physiology 7th Edition, "Lung Volumes" and "Lung Capacities"', citation_style))
story.append(Paragraph(
    "<b>Residual volume (RV)</b> and any capacity containing it (<b>FRC</b>, <b>TLC</b>) cannot be measured "
    "by simple spirometry &mdash; they require <b>helium dilution</b> or <b>body plethysmography</b> "
    "(based on Boyle's Law, P&times;V = constant).",
    body_style))
story.append(Paragraph(
    "<b>FRC</b> is the lung's resting/equilibrium volume after a normal tidal expiration &mdash; clinically "
    "important because it determines the oxygen reserve available during apnea (e.g., pre-oxygenation "
    "before intubation).",
    body_style))

# ---------- 6. Dead space ----------
story.append(Paragraph("6. Alveolar Ventilation vs. Dead Space", h1_style))
story.append(Paragraph(
    "Not all inspired air reaches gas-exchanging alveoli.", body_style))
story.append(Paragraph(
    "<b>Anatomic dead space</b> (~150 mL): conducting airways (trachea to terminal bronchioles) where no "
    "gas exchange occurs.", bullet_style))
story.append(Paragraph(
    "<b>Physiologic dead space</b>: anatomic dead space + any alveoli that are ventilated but poorly "
    "perfused (functional, non-exchanging).", bullet_style))
story.append(Paragraph(
    "<b>Alveolar ventilation (V<sub>A</sub>) = (Tidal Volume &minus; Dead Space) &times; Respiratory Rate</b>",
    ParagraphStyle("eq2", parent=body_style, alignment=TA_CENTER, fontSize=11.5, spaceAfter=8, spaceBefore=6)))
story.append(Paragraph(
    "This is why rapid, shallow breathing is less efficient than slow, deep breathing for the same minute "
    "ventilation &mdash; a larger fraction of shallow breaths is &ldquo;wasted&rdquo; on dead space.",
    body_style))

# ---------- 7. Clinical correlations ----------
story.append(Paragraph("7. Clinical Physiology Correlations", h1_style))
clin_data = wrap_cells([
    ["Condition", "Mechanism", "Effect on Ventilation"],
    ["COPD / Emphysema", "Loss of elastic recoil, destroyed alveolar septae",
     "Compliance increases (lungs &ldquo;too stretchy&rdquo;), air trapping, increased RV/FRC, "
     "obstructive pattern on spirometry (decreased FEV1/FVC)"],
    ["Pulmonary fibrosis (restrictive disease)", "Stiff, scarred interstitium",
     "Compliance decreases, all lung volumes decrease, preserved or increased FEV1/FVC ratio"],
    ["Pneumothorax", "Air enters pleural space, abolishing negative P_pl",
     "Loss of transpulmonary pressure gradient &rarr; lung collapses (elastic recoil unopposed)"],
    ["Infant RDS", "Surfactant deficiency",
     "Decreased compliance, alveolar collapse, increased work of breathing"],
    ["Flail chest / neuromuscular disease", "Impaired chest wall / muscle mechanics",
     "Decreased tidal volume, hypoventilation"],
])
story.append(table_block(clin_data, col_widths=[1.6*inch, 2.2*inch, 2.5*inch]))

# ---------- 8. Quick reference ----------
story.append(Paragraph("8. Quick Reference: Normal Values", h1_style))
qr_data = wrap_cells([
    ["Parameter", "Normal Value"],
    ["Tidal volume", "~500 mL"],
    ["Respiratory rate", "12-16 / min"],
    ["Minute ventilation", "~6 L/min"],
    ["Anatomic dead space", "~150 mL"],
    ["Intrapleural pressure", "-5 (expiration) to -8 cm H2O (inspiration)"],
    ["Functional Residual Capacity (FRC)", "~2400 mL"],
    ["Total Lung Capacity (TLC)", "~5900 mL"],
    ["Vital Capacity (VC)", "~4700 mL"],
])
story.append(table_block(qr_data, col_widths=[3*inch, 3.3*inch]))

story.append(Spacer(1, 14))
story.append(HRFlowable(width="100%", thickness=0.75, color=colors.HexColor("#b5c4d9")))
story.append(Spacer(1, 6))
story.append(Paragraph(
    "<b>Note:</b> This is core, well-established physiology (largely unchanged over decades), so no "
    "PubMed contradiction search was required &mdash; the material is foundational rather than an area "
    "of active evidence revision.",
    footer_note_style))
story.append(Paragraph(
    "Sources: Guyton and Hall Textbook of Medical Physiology; Costanzo Physiology, 7th Edition; "
    "Morgan and Mikhail's Clinical Anesthesiology, 7e.",
    citation_style))

doc = SimpleDocTemplate(
    OUT, pagesize=LETTER,
    topMargin=0.75*inch, bottomMargin=0.75*inch,
    leftMargin=0.75*inch, rightMargin=0.75*inch,
    title="Pulmonary Ventilation - Physiology Notes"
)
doc.build(story)
print("PDF written to", OUT)
Running Command

cd /tmp/workspace/pulmonary-physiology && python3 build_pdf.py

Running Command

cd /tmp/workspace/pulmonary-physiology/output && python3 -c " from pypdf import PdfReader r = PdfReader('Pulmonary_Ventilation.pdf') print('Pages:', len(r.pages)) print('Size:', __import__('os').path.getsize('Pulmonary_Ventilation.pdf'), 'bytes') "

The PDF has been created successfully - 4 pages covering the full Pulmonary Ventilation topic with the flowcharts, tables, and citations.

Pulmonary Ventilation

PDF Document · PDF

It includes:
  1. Overview of the four components of respiration
  2. Mechanics of breathing (muscles + pressure-gradient flowchart)
  3. Lung compliance
  4. Surfactant and the Law of Laplace (with RDS clinical correlation)
  5. Lung volumes and capacities (with diagram)
  6. Alveolar ventilation vs. dead space
  7. Clinical physiology correlations table (COPD, fibrosis, pneumothorax, infant RDS, flail chest)
  8. Quick reference normal values table
Let me know if you'd like a PDF for any of the other topics (Pulmonary Circulation & Edema, Gas Exchange & Diffusion, O2/CO2 Transport, Regulation of Respiration, or Respiratory Insufficiency & Oxygen Therapy) next.

More detailed pdf

Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Searching Images

flow volume loop spirometry obstructive restrictive pattern

Searching Images

spirogram tidal volume inspiratory reserve expiratory reserve residual volume tracing

Writing File

~/pulmonary-physiology/build_pdf_v2.py

# -*- coding: utf-8 -*-
from reportlab.lib.pagesizes import LETTER
from reportlab.lib.units import inch
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    Preformatted, PageBreak, HRFlowable
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT

OUT = "/tmp/workspace/pulmonary-physiology/output/Pulmonary_Ventilation_Detailed.pdf"

styles = getSampleStyleSheet()

title_style = ParagraphStyle(
    "TitleStyle", parent=styles["Title"], fontSize=22, spaceAfter=6,
    textColor=colors.HexColor("#1a3c6e")
)
subtitle_style = ParagraphStyle(
    "SubtitleStyle", parent=styles["Normal"], fontSize=10, spaceAfter=18,
    textColor=colors.HexColor("#555555"), alignment=TA_CENTER, fontName="Helvetica-Oblique"
)
h1_style = ParagraphStyle(
    "H1", parent=styles["Heading1"], fontSize=15, spaceBefore=16, spaceAfter=8,
    textColor=colors.HexColor("#1a3c6e"), fontName="Helvetica-Bold"
)
h2_style = ParagraphStyle(
    "H2", parent=styles["Heading2"], fontSize=12, spaceBefore=10, spaceAfter=6,
    textColor=colors.HexColor("#2e5b9c"), fontName="Helvetica-Bold"
)
h3_style = ParagraphStyle(
    "H3", parent=styles["Heading3"], fontSize=10.8, spaceBefore=8, spaceAfter=4,
    textColor=colors.HexColor("#3f6bab"), fontName="Helvetica-BoldOblique"
)
body_style = ParagraphStyle(
    "Body", parent=styles["Normal"], fontSize=10.3, leading=15, spaceAfter=8,
    alignment=TA_LEFT
)
bullet_style = ParagraphStyle(
    "Bullet", parent=body_style, leftIndent=14, bulletIndent=4, spaceAfter=4
)
citation_style = ParagraphStyle(
    "Citation", parent=styles["Normal"], fontSize=8.5, leading=11,
    textColor=colors.HexColor("#555555"), fontName="Helvetica-Oblique", spaceAfter=10
)
flow_code_style = ParagraphStyle(
    "FlowCode", fontName="Courier", fontSize=8.2, leading=10.3,
    textColor=colors.HexColor("#1a1a1a"), backColor=colors.HexColor("#eef2f8")
)
footer_note_style = ParagraphStyle(
    "FooterNote", parent=styles["Normal"], fontSize=9, leading=13,
    textColor=colors.HexColor("#333333")
)
toc_style = ParagraphStyle(
    "TOC", parent=styles["Normal"], fontSize=10, leading=16
)

def table_block(data, col_widths=None, header_bg="#1a3c6e"):
    t = Table(data, colWidths=col_widths, repeatRows=1)
    style = [
        ('BACKGROUND', (0, 0), (-1, 0), colors.HexColor(header_bg)),
        ('TEXTCOLOR', (0, 0), (-1, 0), colors.white),
        ('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
        ('FONTSIZE', (0, 0), (-1, -1), 8.7),
        ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ('GRID', (0, 0), (-1, -1), 0.5, colors.HexColor("#b5c4d9")),
        ('ROWBACKGROUNDS', (0, 1), (-1, -1), [colors.white, colors.HexColor("#f4f7fb")]),
        ('TOPPADDING', (0, 0), (-1, -1), 5),
        ('BOTTOMPADDING', (0, 0), (-1, -1), 5),
        ('LEFTPADDING', (0, 0), (-1, -1), 6),
        ('RIGHTPADDING', (0, 0), (-1, -1), 6),
    ]
    t.setStyle(TableStyle(style))
    return t

def wrap_cells(rows):
    cell_style = ParagraphStyle("Cell", fontSize=8.4, leading=10.6, fontName="Helvetica")
    header_style = ParagraphStyle("CellHead", fontSize=8.6, leading=10.8, fontName="Helvetica-Bold", textColor=colors.white)
    out = []
    for i, row in enumerate(rows):
        new_row = []
        for cell in row:
            st = header_style if i == 0 else cell_style
            new_row.append(Paragraph(str(cell), st))
        out.append(new_row)
    return out

story = []

# ---------- Title ----------
story.append(Paragraph("Pulmonary Ventilation", title_style))
story.append(Paragraph(
    "Detailed Physiology, Mechanics, Pulmonary Function Testing, and Clinical Correlations &mdash; "
    "Compiled from Guyton &amp; Hall, Costanzo Physiology, Fishman's Pulmonary Diseases and Disorders, "
    "Murray &amp; Nadel's Textbook of Respiratory Medicine, and Morgan &amp; Mikhail's Clinical Anesthesiology",
    subtitle_style
))
story.append(HRFlowable(width="100%", thickness=1, color=colors.HexColor("#1a3c6e")))
story.append(Spacer(1, 10))

# ---------- Table of contents ----------
story.append(Paragraph("Contents", h1_style))
toc_items = [
    "1. Overview: The Four Components of Respiration",
    "2. Mechanics of Breathing &mdash; Muscles and Pressure Changes",
    "3. Lung Compliance (Static and Dynamic)",
    "4. Surfactant and the Law of Laplace",
    "5. Airway Resistance",
    "6. Work of Breathing",
    "7. Lung Volumes and Capacities",
    "8. Alveolar Ventilation vs. Dead Space",
    "9. Regional Differences in Ventilation (Gravity Effects)",
    "10. Closing Volume and Closing Capacity",
    "11. Pulmonary Function Testing: Flow-Volume Loops and Spirometric Patterns",
    "12. Clinical Physiology Correlations",
    "13. Quick Reference: Normal Values",
]
for item in toc_items:
    story.append(Paragraph(item, toc_style))
story.append(PageBreak())

# ---------- 1. Overview ----------
story.append(Paragraph("1. Overview: The Four Components of Respiration", h1_style))
story.append(Paragraph(
    "Guyton frames respiration in four sequential steps:", body_style))
story.append(Preformatted(
"""[1] Pulmonary Ventilation --> [2] Diffusion (O2/CO2 across
                                   alveolar-capillary membrane)
        |                              |
        v                              v
[4] Regulation of Respiration <-- [3] Transport of O2/CO2 in
                                   blood & tissue fluid""",
    flow_code_style))
story.append(Paragraph("Guyton and Hall Textbook of Medical Physiology, p. 492", citation_style))
story.append(Paragraph(
    "Ventilation is the mechanical step: moving air between the atmosphere and the alveoli. Its "
    "efficiency depends on the interplay of compliance (distensibility), resistance (to airflow), "
    "and the muscular forces that generate the driving pressure gradient. Each of these determinants "
    "is examined in turn below, followed by how they are measured clinically and how disease alters them.",
    body_style))

# ---------- 2. Mechanics ----------
story.append(Paragraph("2. Mechanics of Breathing &mdash; Muscles and Pressure Changes", h1_style))
story.append(Paragraph("Two mechanisms expand the thoracic cage:", body_style))

mech_data = wrap_cells([
    ["Mechanism", "Action", "Muscles"],
    ["Diaphragm movement", "Downward pull lengthens chest cavity (quiet breathing)",
     "Diaphragm (contracts on inspiration, relaxes passively on expiration)"],
    ["Rib cage elevation / depression", "Increases / decreases anteroposterior chest diameter",
     "Inspiration: external intercostals, sternocleidomastoids, anterior serrati, scaleni.<br/>Expiration (forced): abdominal recti, internal intercostals"],
])
story.append(table_block(mech_data, col_widths=[1.5*inch, 2.3*inch, 2.5*inch]))
story.append(Paragraph("Guyton and Hall Textbook of Medical Physiology, p. 492-493", citation_style))
story.append(Paragraph(
    "Normal quiet breathing is accomplished almost entirely by diaphragm movement; during heavy breathing, "
    "elastic recoil alone cannot generate expiratory flow fast enough, so abdominal muscle contraction adds "
    "active force. Raising the rib cage increases anteroposterior chest thickness by about 20% at maximal "
    "inspiration compared with expiration.",
    body_style))

story.append(Paragraph("Flowchart &mdash; pressure gradient driving airflow:", h2_style))
story.append(Preformatted(
"""Inspiratory muscles contract
        |
        v
Thoracic cavity volume increases
        |
        v
Intrapleural pressure decreases (more negative, ~ -5 to -8 cm H2O)
        |
        v
Transpulmonary pressure (P_alv - P_pl) increases
        |
        v
Alveolar pressure decreases (slightly below atmospheric, ~ -1 cm H2O)
        |
        v
Air flows IN (down the pressure gradient) -> tidal volume delivered
        |
        v
Elastic recoil + muscle relaxation -> alveolar pressure rises
above atmospheric (~ +1 cm H2O)
        |
        v
Air flows OUT (expiration)""",
    flow_code_style))

story.append(Paragraph("Key pressures defined:", h2_style))
press_data = wrap_cells([
    ["Pressure", "Definition", "Typical value"],
    ["Atmospheric pressure (P_atm)", "Reference pressure, set to 0 by convention", "0 cm H2O"],
    ["Alveolar pressure (P_alv)", "Pressure inside the alveoli", "-1 (inspiration) to +1 (expiration) cm H2O"],
    ["Intrapleural pressure (P_pl)", "Pressure in the potential space between visceral and parietal pleura", "-5 to -8 cm H2O (more negative on inspiration)"],
    ["Transpulmonary pressure (P_alv - P_pl)", "Distending pressure across the lung; keeps alveoli open", "+4 to +8 cm H2O"],
])
story.append(table_block(press_data, col_widths=[1.9*inch, 3*inch, 1.4*inch]))

# ---------- 3. Compliance ----------
story.append(Paragraph("3. Lung Compliance (Static and Dynamic)", h1_style))
story.append(Paragraph(
    "Compliance = change in lung volume per unit change in transpulmonary pressure "
    "(&Delta;V/&Delta;P). It reflects the &ldquo;stretchability&rdquo; of the lung-chest wall system.",
    body_style))
story.append(Paragraph('Guyton and Hall Textbook of Medical Physiology, "Compliance of the Lungs," p. 494', citation_style))
story.append(Paragraph("Determined by two factors:", body_style))
story.append(Paragraph("1. Elastic forces of lung tissue (elastin/collagen fibers)", bullet_style))
story.append(Paragraph("2. Surface tension of the fluid lining the alveoli (the larger contributor)", bullet_style))

story.append(Paragraph("Static vs. dynamic compliance", h2_style))
story.append(Paragraph(
    "<b>Static compliance</b> is measured under conditions of no airflow (volume held constant while "
    "pressure is recorded), isolating the pure elastic properties of the lung. <b>Dynamic compliance</b> "
    "is measured during ongoing breathing and additionally reflects airway resistance; it is normally "
    "similar to static compliance but falls with increasing respiratory rate in patients with small-airway "
    "disease (frequency dependence of compliance) &mdash; a sensitive early marker of peripheral airway "
    "obstruction.",
    body_style))
story.append(Paragraph(
    'Fishman\'s Pulmonary Diseases and Disorders, "Dynamic Compliance"; "Volume-Pressure Relationships"',
    citation_style))

story.append(Paragraph(
    "<b>Compliance curve behavior:</b> compliance is greatest in the mid-range of lung volume and flattens "
    "near total lung capacity (the curve is sigmoid, not linear) &mdash; this is why alveoli in different "
    "lung regions (apex vs. base) sit on different parts of the curve and ventilate unevenly (see Section 9). "
    "Chest wall compliance combines in series with lung compliance; total (respiratory system) compliance "
    "is lower than either individual component.",
    body_style))

# ---------- 4. Surfactant ----------
story.append(Paragraph("4. Surfactant and the Law of Laplace", h1_style))
story.append(Paragraph(
    "Alveoli are modeled as spheres. The Law of Laplace:", body_style))
story.append(Paragraph("<b>P = 2T / r</b>", ParagraphStyle("eq", parent=body_style, alignment=TA_CENTER, fontSize=13, spaceAfter=8)))
story.append(Paragraph(
    "where P = collapsing pressure, T = surface tension, r = alveolar radius.", body_style))
story.append(Paragraph(
    'Costanzo Physiology 7th Edition, "Surface Tension of Alveoli"; Morgan &amp; Mikhail\'s Clinical '
    'Anesthesiology, 7e, "Surface Tension Forces"', citation_style))
story.append(Paragraph(
    "Without surfactant, smaller alveoli (smaller r) would generate higher collapsing pressure than "
    "larger alveoli for the same surface tension, so small alveoli would empty into large ones and "
    "collapse (instability). <b>Surfactant</b> (dipalmitoylphosphatidylcholine, secreted by Type II "
    "alveolar cells) lowers surface tension disproportionately more in smaller alveoli, equalizing "
    "pressures and stabilizing alveoli of different sizes.",
    body_style))
story.append(Paragraph(
    "Surfactant also lowers the work needed to re-inflate collapsed alveoli on each breath and reduces "
    "the tendency for transudation of fluid into alveoli by lowering the net force drawing fluid out of "
    "capillaries (the surface-tension component of interstitial hydrostatic pressure).",
    body_style))

story.append(Paragraph("Clinical Correlation: Infant Respiratory Distress Syndrome", h2_style))
story.append(Paragraph(
    "Neonatal (infant) Respiratory Distress Syndrome occurs when surfactant production is insufficient "
    "(surfactant appears around 24-28 weeks gestation, matures by ~35 weeks). Low surfactant leads to high "
    "surface tension, alveolar collapse (atelectasis), reduced compliance, and increased work of breathing. "
    "Treated with exogenous surfactant and antenatal corticosteroids to accelerate fetal lung maturity.",
    body_style))

story.append(PageBreak())

# ---------- 5. Airway resistance ----------
story.append(Paragraph("5. Airway Resistance", h1_style))
story.append(Paragraph(
    "Resistance to airflow follows the Hagen-Poiseuille equation for laminar flow through a tube:",
    body_style))
story.append(Preformatted("R = (8 * eta * L) / (pi * r^4)", flow_code_style))
story.append(Paragraph(
    "where R = resistance, &eta; = viscosity of the gas, L = length of the airway, and r = airway radius.",
    body_style))
story.append(Paragraph(
    'Costanzo Physiology 7th Edition, "Changes in Airway Resistance"; Scott-Brown\'s Otorhinolaryngology '
    'Head and Neck Surgery, "Airway Dynamics"',
    citation_style))
story.append(Paragraph(
    "Because resistance is inversely proportional to the <b>fourth power</b> of the radius, even a small "
    "decrease in airway diameter (bronchospasm, mucosal edema, secretions) produces a disproportionately "
    "large increase in resistance and work of breathing. The greatest total cross-sectional resistance "
    "actually arises in the medium-sized bronchi, not the very narrow terminal bronchioles, because the "
    "enormous total cross-sectional area of the many parallel small airways lowers their combined resistance.",
    body_style))
story.append(Paragraph(
    "Flow is laminar in small peripheral airways but becomes turbulent in the trachea and large bronchi, "
    "especially during forced expiration or with high gas density. Turbulent flow resistance depends more "
    "on gas density than viscosity, which is why breathing a low-density helium-oxygen mixture (heliox) "
    "reduces resistance and work of breathing in severe upper-airway obstruction (e.g., croup, tracheal "
    "stenosis).",
    body_style))

story.append(Paragraph("Determinants of airway resistance", h2_style))
resist_data = wrap_cells([
    ["Factor", "Effect"],
    ["Bronchial smooth muscle tone", "Parasympathetic (vagal) stimulation and histamine constrict airways, increasing resistance; sympathetic (beta-2) stimulation dilates airways, decreasing resistance"],
    ["Lung volume", "Higher lung volume stretches airways open (radial traction) and reduces resistance; resistance rises sharply near residual volume"],
    ["Mucosal edema / secretions", "Reduces luminal radius, raising resistance by r^-4"],
    ["Gas density and viscosity", "Higher density favors turbulence; higher viscosity raises laminar resistance"],
])
story.append(table_block(resist_data, col_widths=[2.1*inch, 4.2*inch]))

# ---------- 6. Work of breathing ----------
story.append(Paragraph("6. Work of Breathing", h1_style))
story.append(Paragraph(
    "During breathing the respiratory muscles work against three types of forces:", body_style))
story.append(Paragraph("<b>1. Elastic (compliance) work</b> &mdash; needed to expand the lungs and chest wall against their elastic recoil and alveolar surface tension.", bullet_style))
story.append(Paragraph("<b>2. Resistive (airway/tissue viscance) work</b> &mdash; needed to overcome frictional resistance to airflow and tissue deformation.", bullet_style))
story.append(Paragraph("<b>3. Inertial work</b> &mdash; needed to accelerate air and tissue (normally negligible at rest).", bullet_style))
story.append(Paragraph(
    'Fishman\'s Pulmonary Diseases and Disorders, "Work of Breathing"; GOLDMAN-CECIL MEDICINE, '
    '"Measuring Work of Breathing"',
    citation_style))
story.append(Paragraph(
    "In <b>restrictive</b> lung disease, inspiratory work increases mainly because of reduced compliance "
    "(stiff lungs require more pressure per unit volume). In <b>obstructive</b> lung disease, work increases "
    "mainly because of increased airway resistance (more pressure needed to generate the same flow), and "
    "expiratory work rises disproportionately. Normally the oxygen cost of quiet breathing is only 1-3% of "
    "total body oxygen consumption, but this can rise to 25-30% or more in severe obstructive or restrictive "
    "disease, precipitating respiratory muscle fatigue and ventilatory failure.",
    body_style))

# ---------- 7. Lung Volumes ----------
story.append(Paragraph("7. Lung Volumes and Capacities", h1_style))
story.append(Paragraph("Measured by spirometry (except residual volume and anything containing it):", body_style))
story.append(Preformatted(
"""                     +-- Inspiratory Reserve Volume (~3000 mL) --+
Total Lung Capacity  |                                            +-- Inspiratory Capacity (~3500 mL)
   (~5900 mL)         +-- Tidal Volume (~500 mL) ------------------+
                     |
                     +-- Expiratory Reserve Volume (~1200 mL) --+
                     |                                           +-- Functional Residual Capacity (~2400 mL)
                     +-- Residual Volume (~1200 mL) -------------+

Vital Capacity (~4700 mL)      = IC + ERV
Total Lung Capacity (~5900 mL) = VC + RV""",
    flow_code_style))
story.append(Paragraph('Costanzo Physiology 7th Edition, "Lung Volumes" and "Lung Capacities"', citation_style))
story.append(Paragraph(
    "<b>Residual volume (RV)</b> and any capacity containing it (<b>FRC</b>, <b>TLC</b>) cannot be measured "
    "by simple spirometry &mdash; they require <b>helium dilution</b> (subject re-breathes a known amount of "
    "insoluble helium until concentration equilibrates, then back-calculates volume) or <b>body "
    "plethysmography</b> (applies Boyle's Law, P&times;V = constant, from pressure changes in an airtight box "
    "as the subject breathes against a closed mouthpiece).",
    body_style))
story.append(Paragraph(
    "<b>FRC</b> is the lung's resting/equilibrium volume after a normal tidal expiration, the point at which "
    "the inward elastic recoil of the lung exactly balances the outward recoil of the chest wall. It is "
    "clinically important because it determines the oxygen reserve available during apnea (e.g., "
    "pre-oxygenation before intubation) and because it can be measured by plethysmography even when airways "
    "are obstructed (unlike helium dilution, which underestimates trapped gas behind closed airways).",
    body_style))

story.append(PageBreak())

# ---------- 8. Dead space ----------
story.append(Paragraph("8. Alveolar Ventilation vs. Dead Space", h1_style))
story.append(Paragraph(
    "Not all inspired air reaches gas-exchanging alveoli.", body_style))
story.append(Paragraph(
    "<b>Anatomic dead space</b> (~150 mL): conducting airways (trachea to terminal bronchioles) where no "
    "gas exchange occurs.", bullet_style))
story.append(Paragraph(
    "<b>Physiologic (alveolar) dead space</b>: anatomic dead space + any alveoli that are ventilated but "
    "poorly perfused (functional, non-exchanging). In healthy lungs the alveolar component is negligible, so "
    "physiologic dead space approximates anatomic dead space; it rises sharply in diseases with V/Q mismatch "
    "(e.g., pulmonary embolism, emphysema).", bullet_style))
story.append(Paragraph(
    "<b>Alveolar ventilation (V<sub>A</sub>) = (Tidal Volume &minus; Dead Space) &times; Respiratory Rate</b>",
    ParagraphStyle("eq2", parent=body_style, alignment=TA_CENTER, fontSize=11.5, spaceAfter=8, spaceBefore=6)))
story.append(Paragraph(
    "This is why rapid, shallow breathing is less efficient than slow, deep breathing for the same minute "
    "ventilation &mdash; a larger fraction of shallow breaths is &ldquo;wasted&rdquo; on dead space. "
    "Physiologic dead space is calculated clinically using the <b>Bohr equation</b>: "
    "V<sub>D</sub>/V<sub>T</sub> = (PaCO2 &minus; PECO2) / PaCO2, comparing arterial and mixed expired CO2.",
    body_style))

# ---------- 9. Regional differences ----------
story.append(Paragraph("9. Regional Differences in Ventilation (Gravity Effects)", h1_style))
story.append(Paragraph(
    "In the upright lung, gravity causes intrapleural pressure to be more negative (more sub-atmospheric) "
    "at the apex than at the base. Consequently, apical alveoli are relatively more expanded at rest and sit "
    "higher on the (sigmoid) compliance curve, where they are stiffer and receive less additional volume per "
    "breath. Basal alveoli start smaller, sit on the steeper part of the curve, and therefore expand more per "
    "breath (i.e., ventilation per unit volume is greater at the base than the apex).",
    body_style))
story.append(Paragraph(
    'Morgan and Mikhail\'s Clinical Anesthesiology, 7e, "Distribution of Ventilation"; Medical Physiology '
    '(Ethan Nadel), "Regional differences in ventilation"',
    citation_style))
story.append(Paragraph(
    "This regional ventilation gradient combines with the well-known regional perfusion gradient (blood "
    "flow is also greatest at the base due to gravity) to create the classic <b>ventilation/perfusion (V/Q) "
    "ratio gradient</b>: V/Q is highest at the apex (~3.3, relatively more ventilated than perfused) and "
    "lowest at the base (~0.63, relatively more perfused than ventilated) in the upright lung. This explains "
    "why apical alveolar gas has relatively higher PO2 and lower PCO2 than basal alveolar gas.",
    body_style))

# ---------- 10. Closing volume ----------
story.append(Paragraph("10. Closing Volume and Closing Capacity", h1_style))
story.append(Paragraph(
    "During a slow forced expiration, small dependent (basal) airways &mdash; which lack cartilage and rely "
    "on radial traction from surrounding lung tissue to stay open &mdash; begin to close before the rest of "
    "the lung when lung volume falls low enough that tissue elastic recoil can no longer hold them open.",
    body_style))
story.append(Paragraph(
    "The lung volume (above RV) at which this small-airway closure begins is the <b>closing volume (CV)</b>; "
    "closing volume plus RV is the <b>closing capacity (CC)</b>. It is detected using the single-breath "
    "nitrogen washout test (identifying &ldquo;phase IV&rdquo;, the abrupt rise in expired nitrogen "
    "concentration as dependent, poorly-ventilated alveoli begin to contribute disproportionately to expired "
    "gas).",
    body_style))
story.append(Paragraph(
    'Fishman\'s Pulmonary Diseases and Disorders, "Single-Breath Nitrogen Washout... and Closing Volume"',
    citation_style))
story.append(Paragraph(
    "Closing volume increases linearly with age (small airways lose elastic support) and is increased "
    "further by small-airway disease (e.g., early COPD, chronic bronchitis). When closing capacity rises to "
    "meet or exceed FRC, dependent airways close during part or all of normal tidal breathing, causing "
    "regional hypoventilation, V/Q mismatch, and a tendency toward hypoxemia &mdash; this is a common "
    "mechanism of perioperative atelectasis and hypoxemia in elderly, obese, or supine anesthetized patients.",
    body_style))

story.append(PageBreak())

# ---------- 11. PFTs ----------
story.append(Paragraph("11. Pulmonary Function Testing: Flow-Volume Loops and Spirometric Patterns", h1_style))
story.append(Paragraph(
    "Spirometry plots either volume-time or flow-volume during a forced vital capacity (FVC) maneuver "
    "(maximal inspiration followed by maximal forced expiration). Key measured/derived parameters:",
    body_style))
pft_data = wrap_cells([
    ["Parameter", "Definition"],
    ["FVC", "Total volume forcibly exhaled after maximal inspiration"],
    ["FEV1", "Forced expiratory volume in the first second of the FVC maneuver"],
    ["FEV1/FVC ratio", "Normally &ge;0.70-0.80; the key index distinguishing obstructive from restrictive disease"],
    ["PEFR", "Peak expiratory flow rate, reached early in forced expiration"],
    ["FEF25-75%", "Forced expiratory flow over the middle half of FVC; sensitive to small-airway disease"],
])
story.append(table_block(pft_data, col_widths=[1.6*inch, 4.7*inch]))

story.append(Paragraph("Obstructive vs. restrictive patterns", h2_style))
pattern_data = wrap_cells([
    ["Feature", "Obstructive (e.g., COPD, asthma)", "Restrictive (e.g., pulmonary fibrosis)"],
    ["FEV1", "Reduced (often markedly)", "Reduced proportionally to FVC"],
    ["FVC", "Reduced or near-normal", "Reduced"],
    ["FEV1/FVC ratio", "Decreased (&lt;0.70)", "Normal or increased"],
    ["TLC", "Normal or increased (air trapping/hyperinflation)", "Decreased"],
    ["RV / FRC", "Increased", "Decreased"],
    ["Flow-volume loop shape", "Scooped-out (concave) descending limb; reduced peak flow", "Narrow loop shifted toward lower volumes; normal or steep descending limb; often supranormal flow rates relative to lung volume"],
])
story.append(table_block(pattern_data, col_widths=[1.5*inch, 2.6*inch, 2.2*inch]))
story.append(Paragraph(
    "Guyton and Hall Textbook of Medical Physiology; Fishman's Pulmonary Diseases and Disorders, "
    "\"Flow-Volume Loop Analysis\"", citation_style))
story.append(Paragraph(
    "On a flow-volume loop, healthy expiration rises rapidly to peak flow then declines nearly linearly to "
    "residual volume. In obstructive disease, dynamic airway collapse during forced expiration produces a "
    "characteristic concave (&ldquo;scooped-out&rdquo;) descending limb, and the curve is shifted left "
    "(toward higher lung volumes) with air trapping. In restrictive disease, the entire loop is smaller and "
    "shifted right (toward lower absolute lung volumes) but retains a relatively normal, convex shape because "
    "airway function itself is preserved.",
    body_style))

# ---------- 12. Clinical correlations ----------
story.append(Paragraph("12. Clinical Physiology Correlations", h1_style))
clin_data = wrap_cells([
    ["Condition", "Mechanism", "Effect on Ventilation"],
    ["COPD / Emphysema", "Loss of elastic recoil, destroyed alveolar septae, small-airway narrowing",
     "Compliance increases (lungs &ldquo;too stretchy&rdquo;), air trapping, increased RV/FRC/TLC, "
     "obstructive spirometry pattern (decreased FEV1/FVC), increased closing volume, increased work of breathing"],
    ["Asthma", "Reversible bronchial smooth muscle constriction, mucosal edema, mucus plugging",
     "Acutely increased airway resistance (r^-4 relationship), scooped flow-volume loop, may normalize with bronchodilator (reversibility testing)"],
    ["Pulmonary fibrosis (restrictive disease)", "Stiff, scarred interstitium",
     "Compliance decreases, all lung volumes decrease, preserved or increased FEV1/FVC ratio, increased elastic work of breathing"],
    ["Pneumothorax", "Air enters pleural space, abolishing negative P_pl",
     "Loss of transpulmonary pressure gradient, lung collapses (elastic recoil unopposed)"],
    ["Infant RDS", "Surfactant deficiency",
     "Decreased compliance, alveolar collapse (atelectasis), increased work of breathing, grunting/retractions"],
    ["Flail chest / neuromuscular disease", "Impaired chest wall or respiratory muscle mechanics",
     "Decreased tidal volume, hypoventilation, paradoxical chest wall movement (flail segment)"],
    ["Obesity / supine position / general anesthesia", "Reduced FRC toward or below closing capacity",
     "Dependent small-airway closure during tidal breathing, V/Q mismatch, atelectasis, hypoxemia"],
])
story.append(table_block(clin_data, col_widths=[1.5*inch, 2.4*inch, 2.4*inch]))

# ---------- 13. Quick reference ----------
story.append(Paragraph("13. Quick Reference: Normal Values", h1_style))
qr_data = wrap_cells([
    ["Parameter", "Normal Value"],
    ["Tidal volume", "~500 mL"],
    ["Respiratory rate", "12-16 / min"],
    ["Minute ventilation", "~6 L/min"],
    ["Anatomic dead space", "~150 mL"],
    ["Alveolar ventilation", "~4.2 L/min"],
    ["Intrapleural pressure", "-5 (expiration) to -8 cm H2O (inspiration)"],
    ["Transpulmonary pressure", "+4 to +8 cm H2O"],
    ["Functional Residual Capacity (FRC)", "~2400 mL"],
    ["Total Lung Capacity (TLC)", "~5900 mL"],
    ["Vital Capacity (VC)", "~4700 mL"],
    ["FEV1/FVC ratio", "&ge;0.70-0.80"],
    ["Oxygen cost of quiet breathing", "1-3% of total body O2 consumption"],
])
story.append(table_block(qr_data, col_widths=[3*inch, 3.3*inch]))

story.append(Spacer(1, 14))
story.append(HRFlowable(width="100%", thickness=0.75, color=colors.HexColor("#b5c4d9")))
story.append(Spacer(1, 6))
story.append(Paragraph(
    "<b>Note:</b> This is core, well-established physiology (largely unchanged over decades), so no "
    "PubMed contradiction search was required &mdash; the material is foundational rather than an area "
    "of active evidence revision.",
    footer_note_style))
story.append(Paragraph(
    "Sources: Guyton and Hall Textbook of Medical Physiology; Costanzo Physiology, 7th Edition; "
    "Fishman's Pulmonary Diseases and Disorders, 2-Volume Set; Murray &amp; Nadel's Textbook of "
    "Respiratory Medicine; Morgan and Mikhail's Clinical Anesthesiology, 7e; Scott-Brown's "
    "Otorhinolaryngology Head and Neck Surgery; Medical Physiology (Ethan Nadel, contributor); "
    "GOLDMAN-CECIL MEDICINE.",
    citation_style))

doc = SimpleDocTemplate(
    OUT, pagesize=LETTER,
    topMargin=0.75*inch, bottomMargin=0.75*inch,
    leftMargin=0.75*inch, rightMargin=0.75*inch,
    title="Pulmonary Ventilation - Detailed Physiology Notes"
)
doc.build(story)
print("PDF written to", OUT)
Running Command

cd /tmp/workspace/pulmonary-physiology && python3 build_pdf_v2.py && python3 -c " from pypdf import PdfReader r = PdfReader('output/Pulmonary_Ventilation_Detailed.pdf') print('Pages:', len(r.pages)) import os print('Size:', os.path.getsize('output/Pulmonary_Ventilation_Detailed.pdf'), 'bytes') "

I've expanded the PDF into a full 11-page detailed physiology document covering:
  1. Overview of the four components of respiration
  2. Mechanics of breathing (muscles, pressure gradient flowchart, key pressures table)
  3. Lung compliance (static vs. dynamic, frequency dependence)
  4. Surfactant and Law of Laplace (with RDS correlation)
  5. Airway resistance (Poiseuille's law, laminar vs. turbulent flow, heliox rationale)
  6. Work of breathing (elastic vs. resistive vs. inertial work, oxygen cost)
  7. Lung volumes and capacities (with measurement methods)
  8. Alveolar ventilation vs. dead space (Bohr equation)
  9. Regional ventilation differences (gravity effects, V/Q gradient apex vs. base)
  10. Closing volume/capacity (nitrogen washout test, clinical relevance to atelectasis)
  11. Pulmonary function testing (flow-volume loops, obstructive vs. restrictive spirometry patterns table)
  12. Expanded clinical correlations table (COPD, asthma, fibrosis, pneumothorax, RDS, flail chest, obesity/supine/anesthesia)
  13. Quick reference values

Pulmonary Ventilation Detailed

PDF Document · PDF

All content is cross-referenced to Guyton & Hall, Costanzo Physiology, Fishman's Pulmonary Diseases and Disorders, Murray & Nadel's Textbook of Respiratory Medicine, Morgan & Mikhail's Clinical Anesthesiology, Scott-Brown's Otorhinolaryngology, and Goldman-Cecil Medicine.
Let me know if you'd like this same level of detail for any of the remaining topics: Pulmonary Circulation/Edema/Pleural Fluid, Gas Exchange & Diffusion, O2/CO2 Transport, Regulation of Respiration, or Respiratory Insufficiency & Oxygen Therapy.
This is a shared conversation. Sign in to Orris to start your own chat.