Skip to content

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

CardioHemodynamics

CI Python 3.10+ License: MIT

CardioHemodynamics is a high-performance computational medicine and biomechanical AI simulation library for 1D pulsatile cardiovascular hemodynamics, compliant arterial networks, terminal Windkessel vascular beds, and vascular disease risk stratification.


Table of Contents


1. Physiological Background & Overview

Cardiovascular disease (CVD) remains the leading cause of global morbidity and mortality. Hemodynamic forces—specifically pulsatile pressure waveforms, pulse wave velocity (PWV), wave reflection, wall shear stress (WSS), and tensile wall stress—dictate the progression of arteriosclerosis, isolated systolic hypertension, and abdominal aortic aneurysm (AAA) rupture.

CardioHemodynamics implements:

  1. 1D Cross-Sectional Pulsatile Fluid Dynamics: Non-linear Navier-Stokes conservation laws discretized with a two-step predictor-corrector MacCormack finite difference scheme.
  2. Coupled Boundary Models: Left-ventricular varying elastance $E(t)$ ejection inflow and 3-element Windkessel ($R_c$-$C$-$R_p$) peripheral vascular beds.
  3. Arterial Bifurcations: Multivariate Newton-Raphson solvers satisfying conservation of mass, total Bernoulli stagnation pressure, and characteristic Riemann invariants across branching arteries.
  4. Vascular Biomechanics: Fluid wall shear stress, circumferential hoop stress (Laplace's law), equivalent Von Mises stress, and non-dimensional Rupture Risk Indices (RRI).
  5. Cardiovascular AI: Calibrated multi-class arterial stiffness classifier and sub-millisecond polynomial ridge regression surrogates for instantaneous clinical screening.

2. Mathematical & Hemodynamic Foundations

1D Pulsatile Navier-Stokes Equations

Blood flow in compliant cylindrical arterial vessels is governed by the 1D area-averaged conservation equations of mass and axial momentum:

$$\frac{\partial A}{\partial t} + \frac{\partial Q}{\partial z} = 0$$

$$\frac{\partial Q}{\partial t} + \frac{\partial}{\partial z}\left(\alpha \frac{Q^2}{A}\right) + \frac{A}{\rho}\frac{\partial P}{\partial z} + K_r \frac{Q}{A} = 0$$

Where:

  • $A(z, t)$: Local cross-sectional lumen area ($m^2$).
  • $Q(z, t)$: Volumetric blood flow rate ($m^3/s$).
  • $P(z, t)$: Transmural blood pressure ($Pa$).
  • $\rho$: Blood density ($\approx 1050 \text{ kg/m}^3$).
  • $\alpha$: Velocity profile momentum correction factor ($\alpha = 1.0$ for plug flow; $\alpha = 1.33$ for parabolic Poiseuille flow).
  • $K_r = \frac{8 \pi \mu}{\rho}$: Viscous friction parameter, where $\mu \approx 0.0035 \text{ Pa}\cdot\text{s}$ is dynamic blood viscosity.

Elastodynamic Arterial Tube Law

The pressure-area constitutive relationship couples fluid pressure to the elastic deformation of the vessel wall:

$$P(A) = P_{ext} + \beta \left(\sqrt{A} - \sqrt{A_0}\right)$$

$$\beta = \frac{4}{3}\frac{\sqrt{\pi} E h_0}{A_0}$$

Where:

  • $A_0 = \pi r_0^2$: Unstressed reference cross-sectional area.
  • $h_0$: Vessel wall thickness ($m$).
  • $E$: Arterial wall Young's elastic modulus ($Pa$).
  • The local pulse wave propagation velocity $c(A)$ (Moens-Korteweg speed) is:

$$c(A) = \sqrt{\frac{A}{\rho}\frac{\partial P}{\partial A}} = \sqrt{\frac{\beta \sqrt{A}}{2\rho}}$$

Three-Element Windkessel (RCR) Model

Distal terminal boundaries terminate into microvascular arteriole and capillary networks modeled by the 3-element Windkessel differential equation:

$$Q(t)\left(1 + \frac{R_c}{R_p}\right) + C R_c \frac{dQ}{dt} = \frac{P(t) - P_v}{R_p} + C \frac{dP}{dt}$$

Expressed as internal compliance state $P_c(t)$:

$$P(t) = P_c(t) + Q(t) R_c$$

$$\frac{d P_c}{dt} = \frac{Q(t) - \frac{P_c(t) - P_v}{R_p}}{C}$$

Integrated using a second-order trapezoidal Crank-Nicolson rule.

Bifurcation Junction Coupling

At arterial junctions (e.g., abdominal aorta bifurcating into bilateral common iliac arteries), six non-linear equations are solved simultaneously:

  1. Conservation of flow rate: $$Q_p = Q_{d1} + Q_{d2}$$
  2. Continuity of total stagnation pressure: $$P_p + \frac{1}{2}\rho u_p^2 = P_{d1} + \frac{1}{2}\rho u_{d1}^2 = P_{d2} + \frac{1}{2}\rho u_{d2}^2$$
  3. Characteristic compatibility along outgoing and incoming Riemann invariants: $$W_{1, p} = u_p + 4 c_p(A_p)$$ $$W_{2, d1} = u_{d1} - 4 c_{d1}(A_{d1})$$ $$W_{2, d2} = u_{d2} - 4 c_{d2}(A_{d2})$$

Biomechanical Wall Stress & Rupture Risk

  1. Wall Shear Stress (WSS): $$\tau_w = \frac{4 \sqrt{\pi} \mu |Q|}{A^{3/2}}$$

  2. Circumferential Tensile Hoop Stress ($\sigma_\theta$): $$\sigma_\theta = \frac{P \cdot r}{h_0} = \frac{P \sqrt{A/\pi}}{h_0}$$

  3. Equivalent Von Mises Stress ($\sigma_{vm}$): $$\sigma_z = \frac{1}{2}\sigma_\theta \implies \sigma_{vm} = \sqrt{\sigma_\theta^2 - \sigma_\theta \sigma_z + \sigma_z^2} = \frac{\sqrt{3}}{2}\sigma_\theta$$

  4. Rupture Risk Index (RRI): $$RRI = \frac{\sigma_{vm}}{\sigma_{failure}}$$ Where $\sigma_{failure} \approx 1.5 \text{ MPa}$ for human aortic tissue. Interventions are recommended when $RRI \ge 0.40$.


3. System Architecture

flowchart TD
    LV["Left Ventricle Inflow<br/>Q_in(t) or E(t) Varying Elastance"] --> |Inflow Q_0| Aorta["Ascending / Thoracic Aorta<br/>1D Compliant Vessel (MacCormack)"]
    Aorta --> |P_p, Q_p| Bifurcation["Arterial Bifurcation Junction<br/>6x6 Characteristic Newton Solver"]
    Bifurcation --> |Q_d1| Branch1["Right Iliac / Carotid Artery"]
    Bifurcation --> |Q_d2| Branch2["Left Iliac / Subclavian Artery"]
    Branch1 --> WK1["Terminal 3-Element Windkessel<br/>Rc, C, Rp (Microvascular Bed)"]
    Branch2 --> WK2["Terminal 3-Element Windkessel<br/>Rc, C, Rp (Microvascular Bed)"]

    Aorta -.-> Biomech["Biomechanical Analysis Engine"]
    Biomech --> WSS["Wall Shear Stress (WSS)<br/>& OSI Analysis"]
    Biomech --> Stress["Circumferential & Von Mises<br/>Aortic Wall Stress"]
    Biomech --> PWV["Foot-to-Foot PWV<br/>& Westerhof Wave Separation"]
    Biomech --> Metrics["Clinical Biomarkers<br/>SBP, DBP, PP, MAP, AIx, SEVR"]

    Metrics --> AI["AI / ML Diagnostics"]
    AI --> Classifier["Vascular Stiffness Classifier<br/>(Normotensive vs Severe Stiffness)"]
    AI --> Surrogate["Instantaneous Neural/Ridge Surrogate<br/>Peak Stress & PWV Prediction"]
Loading

4. Installation

# Clone repository
git clone https://github.com/ZengLLQ/cardio-hemodynamics.git
cd cardio-hemodynamics

# Install package with developer test dependencies
pip install -e .[dev]

5. Quick Start & Python API

Simulating Aortic Pulse Wave Propagation

from cardio_hemodynamics.models.vessel import ArterialSegment
from cardio_hemodynamics.models.windkessel import WindkesselRCR
from cardio_hemodynamics.models.ventricle import CardiacInflowProfile
from cardio_hemodynamics.models.network import ArterialNetwork
from cardio_hemodynamics.biomechanics.pulse_wave import PulseWaveAnalyzer
from cardio_hemodynamics.biomechanics.biomarkers import HemodynamicBiomarkers

# 1. Setup human thoracic aorta
aorta = ArterialSegment(
    name="Aorta",
    length=0.30,           # 30 cm
    radius_proximal=0.015, # 15 mm root
    radius_distal=0.012,   # 12 mm distal
    wall_thickness=0.0016, # 1.6 mm wall thickness
    young_modulus=0.5e6,   # 0.5 MPa
    num_points=61,
)
aorta.A = aorta.area_from_pressure(10665.0)  # Diastolic 80 mmHg

# 2. 3-Element Windkessel peripheral resistance and compliance
wk = WindkesselRCR(
    characteristic_impedance=0.9e7,
    compliance=1.2e-8,
    peripheral_resistance=1.1e8,
    venous_pressure=666.6,
    initial_pressure=10665.0,
)

# 3. Left ventricular ejection profile (72 bpm, 75 mL stroke volume)
inflow = CardiacInflowProfile(heart_rate_bpm=72.0, stroke_volume_ml=75.0)

# 4. Integrate network
net = ArterialNetwork()
net.add_vessel(aorta)
net.set_root_inflow("Aorta", inflow)
net.set_terminal_windkessel("Aorta", wk)

results = net.simulate(duration=1.67, record_interval=0.005)
print(f"Simulation completed across {len(results['time'])} time steps.")

Aneurysm Wall Stress & Rupture Risk Analysis

from cardio_hemodynamics.models.vessel import ArterialSegment
from cardio_hemodynamics.biomechanics.wall_stress import BiomechanicalStressAnalyzer

# Abdominal aortic aneurysm model (28 mm diameter dilation)
aneurysm = ArterialSegment(
    name="AAA",
    length=0.10,
    radius_proximal=0.028,
    radius_distal=0.028,
    wall_thickness=0.0015,
    young_modulus=1.2e6,
    num_points=21,
)

analyzer = BiomechanicalStressAnalyzer(aneurysm, wall_failure_strength_pa=1.5e6)
peak_p_pa = 150.0 * 133.322  # 150 mmHg systolic pressure

vm_stress_kpa = analyzer.von_mises_stress(P=peak_p_pa, A=aneurysm.A0)[0] / 1000.0
rri = analyzer.rupture_risk_index(P=peak_p_pa, A=aneurysm.A0)[0]

print(f"Peak Von Mises Wall Stress: {vm_stress_kpa:.1f} kPa")
print(f"Rupture Risk Index (RRI):   {rri:.3f} ({'CRITICAL' if rri >= 0.4 else 'MONITORED'})")

Fast AI Hemodynamic Surrogate Evaluation

from cardio_hemodynamics.ml.surrogate_model import HemodynamicSurrogateModel

surrogate = HemodynamicSurrogateModel()
patient_params = {
    "radius_mm": 16.0,
    "thickness_mm": 1.5,
    "young_modulus_mpa": 0.8,
    "heart_rate_bpm": 80.0,
    "stroke_volume_ml": 75.0,
    "peripheral_resistance": 1.1,
}

predictions = surrogate.predict_dict(patient_params)
print(predictions)
# {'peak_von_mises_kpa': 142.3, 'pwv_m_s': 7.82, 'systolic_bp_mmhg': 138.4}

6. Command-Line Interface (CLI)

The cardio-sim command line tool provides terminal simulation, ASCII waveform plotting, clinical reporting, and aneurysm analysis:

# 1. Run pulsatile simulation with ASCII waveforms and full diagnostics
cardio-sim simulate --hr 75 --sv 70 --emod 0.6 --duration 1.6

# 2. Evaluate abdominal aortic aneurysm rupture risk across pressures
cardio-sim aneurysm --dilation-mm 28.0 --sbp 155.0

# 3. Instantaneous AI surrogate prediction
cardio-sim surrogate --radius 15.0 --emod 0.7 --hr 80 --sv 75

Sample CLI output:

=== Aortic Root Pressure [mmHg] ===
  115.4 |       *******                                     
  110.8 |      *       **                                   
  106.3 |                *                                  
  101.7 |     *           ********                          
   97.2 |    *                    ****                      
   92.6 |                             *****                 
   88.0 |   *                              *****            
   83.5 |  *                                    ******      
   78.9 | *                                           ***** 
   74.4 |                                                  *
        +--------------------------------------------------
        0.0s                                        0.80s (Time)

==================================================================
           CARDIOVASCULAR HEMODYNAMICS CLINICAL REPORT            
==================================================================
 1. HEMODYNAMIC BIOMARKERS
    - Systolic BP:              115.42 mmHg
    - Diastolic BP:             74.36 mmHg
    - Pulse Pressure:           41.06 mmHg
    - Mean Arterial Pressure:   93.60 mmHg
    - Augmentation Index (AIx): 43.57 %
    - Buckberg Ratio (SEVR):    1.98
    - Cardiac Output:           5.27 L/min

7. Verification & Multi-Platform CI

The test suite validates:

  • Mass and volume conservation during pulsatile cardiac cycles ($&lt; 0.1%$ error).
  • 3-Element Windkessel analytical exponential decay match ($P(t) = P_v + (P_0 - P_v) e^{-t/\tau}$).
  • Wave speed agreement with the Moens-Korteweg theoretical formula.
  • Characteristic Riemann invariant compatibility across bifurcations.
  • Multi-class AI stiffness classification and surrogate regression convergence.

Run the test suite:

pytest -v --tb=short

8. References

  1. Alastruey, J., et al. (2012). Pulse wave propagation in a model of the human arterial network. Journal of Biomechanics, 45(11), 1957–1964.
  2. Westerhof, N., et al. (2009). Snapshots of hemodynamics: An aid for clinical research and graduate education. Springer.
  3. Vlachopoulos, C., et al. (2015). Prediction of cardiovascular events and all-cause mortality with arterial stiffness: A systematic review and meta-analysis. JACC, 55(13), 1318–1327.
  4. Fillinger, M. F., et al. (2003). Prediction of abdominal aortic aneurysm rupture based on mechanical stress. Annals of Surgery, 237(5), 726–735.

9. License

This project is licensed under the MIT License - see the LICENSE file for details.