Skip to content

Lumped cardiovascular system

A closed lumped system of the systemic circulation.

  • Class: CardiovascularSystem
  • Import: from skcomplex.systems.biology.physiology import CardiovascularSystem
  • Field: biology/physiology
  • Topics: cardiovascular, circulation, lumped system, hybrid
  • References:
    • Suga and Sagawa 1974
    • Trzaska 2023

Use this system

The block imports the class and simulates the system with its default parameters and its tuned run settings.

from skcomplex.systems.biology.physiology import CardiovascularSystem

trajectory = CardiovascularSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
heart_rate 75.0
E_max 2.5
R_systemic 1.0
C_arterial 1.3
C_venous 50.0
volume 1500.0
solver 'auto'
backend 'auto'

Tags

The system with its default parameters has these capability tags, which solvers and analyses check.

Tag Values
Time continuous
Space none
Laws rate
Randomness deterministic
Domains real
Structure fixed

Class

The source of the class shows how it builds its components from its model parameters.

class CardiovascularSystem(BaseSystem):
    """A closed lumped system of the systemic circulation.

    A left ventricle of varying elastance drives it.

    Blood leaves the ventricle through the aortic valve into the compliant arteries, flows through the systemic
    resistance into the veins, and returns through the mitral valve. The ventricle stiffens in systole, so the system
    beats, the valves open and close, and the total volume of blood stays constant. With the defaults the arterial
    pressure swings between about 80 and 120 mmHg. The system has the volumes `ventricle.V`, `arteries.V`, and
    `veins.V`.

    Args:
        heart_rate:
            The number of beats per minute.

        E_max:
            The largest elastance of the ventricle in mmHg/ml.

        R_systemic:
            The systemic resistance in mmHg s/ml.

        C_arterial:
            The arterial compliance in ml/mmHg.

        C_venous:
            The venous compliance in ml/mmHg.

        volume:
            The total volume of blood in ml, split at the start among the ventricle, arteries, and veins.

        label:
            The label of the system, which names it when it is nested in another one.

        solver:
            The solver of the problem, or `'auto'` for the one the system chooses.

        backend:
            The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.

    Examples:
        >>> from skcomplex.systems.biology.physiology import CardiovascularSystem
        >>> sum(chamber.V for chamber in CardiovascularSystem().prepare().system_.elements)
        1500.0
    """

    field = 'biology/physiology'
    topics = ('cardiovascular', 'circulation', 'lumped system', 'hybrid')
    references = ('Suga and Sagawa 1974', 'Trzaska 2023')
    until = 8.0
    dt = 0.02

    def __init__(
        self,
        *,
        heart_rate: float = 75.0,
        E_max: float = 2.5,
        R_systemic: float = 1.0,
        C_arterial: float = 1.3,
        C_venous: float = 50.0,
        volume: float = 1500.0,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.heart_rate = heart_rate
        self.E_max = E_max
        self.R_systemic = R_systemic
        self.C_arterial = C_arterial
        self.C_venous = C_venous
        self.volume = volume

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set a closed lumped system of the systemic circulation.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.
        """
        super()._prepare(context)
        period = 60.0 / self.heart_rate
        systole = 0.375 * period
        ventricle = ChamberElement(
            'ventricle',
            V=0.1 * self.volume,
            V0=10.0,
            E_min=0.08,
            E_max=self.E_max,
            period=period,
            systole=systole,
        )
        arteries = ChamberElement(
            'arteries',
            V=0.3 * self.volume,
            V0=250.0,
            E_min=1 / self.C_arterial,
            E_max=1 / self.C_arterial,
            period=period,
            systole=systole,
        )
        veins = ChamberElement(
            'veins',
            V=0.6 * self.volume,
            V0=500.0,
            E_min=1 / self.C_venous,
            E_max=1 / self.C_venous,
            period=period,
            systole=systole,
        )
        flows = [
            ResistiveFlowInteraction('aortic_valve', source='ventricle', target='arteries', R=0.02, valve=True),
            ResistiveFlowInteraction('systemic', source='arteries', target='veins', R=self.R_systemic),
            ResistiveFlowInteraction('mitral_valve', source='veins', target='ventricle', R=0.02, valve=True),
        ]
        self.system_ = System(self.label, elements=[ventricle, arteries, veins], interactions=flows)

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

Interactions:

  • ResistiveFlowInteraction, from Interaction
class ChamberElement(Element):
    """Elastic compartment of blood, a heart chamber or a vascular bed.

    Its pressure is the elastance times the volume.

    The pressure is `E(t) (V - V0)`. The elastance of a heart chamber rises from `E_min` to `E_max` and back as a half
    sine during the systole that starts every `period`, and the elastance of a vessel stays at `E_min` when `E_max`
    equals it. Volumes are in ml, pressures in mmHg, and times in s.

    Args:
        label:
            The label of the chamber.

        V:
            The initial volume.

        V0:
            The unstressed volume.

        E_min:
            The elastance in diastole, the inverse of the compliance.

        E_max:
            The largest elastance in systole.

        period:
            The duration of a heartbeat.

        systole:
            The duration of the contraction.

    Examples:
        >>> from skcomplex.systems.biology.physiology import ChamberElement
        >>> ChamberElement('arteries', V=150.0, E_min=0.8, E_max=0.8).E_max
        0.8
    """

    def __init__(
        self,
        label: str,
        *,
        V: Annotated[float, RealSet.closed_open(0, oo)] = 100.0,
        V0: Annotated[float, RealSet.closed_open(0, oo)] = 0.0,
        E_min: Annotated[float, RealSet.open(0, oo)] = 1.0,
        E_max: Annotated[float, RealSet.open(0, oo)] = 1.0,
        period: Annotated[float, RealSet.open(0, oo)] = 0.8,
        systole: Annotated[float, RealSet.open(0, oo)] = 0.3,
    ) -> None:
        super().__init__(label)
        self.V = V
        self.V0 = V0
        self.E_min = E_min
        self.E_max = E_max
        self.period = period
        self.systole = systole

class ResistiveFlowInteraction(Interaction):
    """Flow of blood from one chamber to another through a resistance.

    The flow is `Q = (P_source - P_target) / R`.

    A valve lets blood pass forward only, so the flow is zero when the target pressure is higher.

    Args:
        label:
            The label of the interaction.

        source:
            The path of the chamber the blood leaves.

        target:
            The path of the chamber the blood enters.

        R:
            The resistance in mmHg s/ml.

        valve:
            Whether a valve prevents backward flow.

    Examples:
        >>> from skcomplex.systems.biology.physiology import ResistiveFlowInteraction
        >>> ResistiveFlowInteraction('aortic_valve', source='ventricle', target='arteries', valve=True).valve
        True
    """

    law_classes = (RateLaw,)

    def __init__(
        self,
        label: str,
        *,
        source: Role,
        target: Role,
        R: Annotated[float, RealSet.open(0, oo)] = 1.0,
        valve: bool = False,
    ) -> None:
        super().__init__(label)
        self.source = source
        self.target = target
        self.R = R
        self.valve = valve

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the flow of blood from the source chamber to the target chamber.

        Args:
            context:
                The namespace of the two chambers.
        """
        super()._prepare(context)
        flow = {context.source.V: -1, context.target.V: +1}
        self.laws_: list[BaseLaw] = [RateLaw(flow, self._get_flow(context), label='flow')]

    def _get_pressure(self, chamber: SimpleNamespace, t: Expression) -> Expression:
        """Return the pressure of a chamber.

        It is its elastance times its volume above the unstressed volume.
        """
        phase = mod(t, chamber.period)
        activation = where(phase < chamber.systole, sin(math.pi * phase / chamber.systole), 0)
        return (chamber.E_min + (chamber.E_max - chamber.E_min) * activation) * (chamber.V - chamber.V0)

    def _get_flow(self, s: SimpleNamespace) -> Expression:
        """Return the flow of the pressure drop through the resistance.

        It is zero backwards through a valve.
        """
        drop = self._get_pressure(s.source, s.t) - self._get_pressure(s.target, s.t)
        return where(drop > 0, drop / s.R, 0) if self.valve else drop / s.R

Equations

The equations are those that symbolic returns for the system with its default parameters.

ventricle.V: diff(V_ventricle(t), t) == where(-((E_max_veins - E_min_veins)*where(mod(t, period_veins) < systole_veins, sin(3.141592653589793*mod(t, period_veins)/systole_veins), 0) + E_min_veins)*(V0_veins - V_veins(t)) + ((E_max_ventricle - E_min_ventricle)*where(mod(t, period_ventricle) < systole_ventricle, sin(3.141592653589793*mod(t, period_ventricle)/systole_ventricle), 0) + E_min_ventricle)*(V0_ventricle - V_ventricle(t)) > 0, -(((E_max_veins - E_min_veins)*where(mod(t, period_veins) < systole_veins, sin(3.141592653589793*mod(t, period_veins)/systole_veins), 0) + E_min_veins)*(V0_veins - V_veins(t)) - ((E_max_ventricle - E_min_ventricle)*where(mod(t, period_ventricle) < systole_ventricle, sin(3.141592653589793*mod(t, period_ventricle)/systole_ventricle), 0) + E_min_ventricle)*(V0_ventricle - V_ventricle(t)))/R_mitral_valve, 0) - where(((E_max_arteries - E_min_arteries)*where(mod(t, period_arteries) < systole_arteries, sin(3.141592653589793*mod(t, period_arteries)/systole_arteries), 0) + E_min_arteries)*(V0_arteries - V_arteries(t)) - ((E_max_ventricle - E_min_ventricle)*where(mod(t, period_ventricle) < systole_ventricle, sin(3.141592653589793*mod(t, period_ventricle)/systole_ventricle), 0) + E_min_ventricle)*(V0_ventricle - V_ventricle(t)) > 0, (((E_max_arteries - E_min_arteries)*where(mod(t, period_arteries) < systole_arteries, sin(3.141592653589793*mod(t, period_arteries)/systole_arteries), 0) + E_min_arteries)*(V0_arteries - V_arteries(t)) - ((E_max_ventricle - E_min_ventricle)*where(mod(t, period_ventricle) < systole_ventricle, sin(3.141592653589793*mod(t, period_ventricle)/systole_ventricle), 0) + E_min_ventricle)*(V0_ventricle - V_ventricle(t)))/R_aortic_valve, 0)
arteries.V: diff(V_arteries(t), t) == (((E_max_arteries - E_min_arteries)*where(mod(t, period_arteries) < systole_arteries, sin(3.141592653589793*mod(t, period_arteries)/systole_arteries), 0) + E_min_arteries)*(V0_arteries - V_arteries(t)) - ((E_max_veins - E_min_veins)*where(mod(t, period_veins) < systole_veins, sin(3.141592653589793*mod(t, period_veins)/systole_veins), 0) + E_min_veins)*(V0_veins - V_veins(t)))/R_systemic + where(((E_max_arteries - E_min_arteries)*where(mod(t, period_arteries) < systole_arteries, sin(3.141592653589793*mod(t, period_arteries)/systole_arteries), 0) + E_min_arteries)*(V0_arteries - V_arteries(t)) - ((E_max_ventricle - E_min_ventricle)*where(mod(t, period_ventricle) < systole_ventricle, sin(3.141592653589793*mod(t, period_ventricle)/systole_ventricle), 0) + E_min_ventricle)*(V0_ventricle - V_ventricle(t)) > 0, (((E_max_arteries - E_min_arteries)*where(mod(t, period_arteries) < systole_arteries, sin(3.141592653589793*mod(t, period_arteries)/systole_arteries), 0) + E_min_arteries)*(V0_arteries - V_arteries(t)) - ((E_max_ventricle - E_min_ventricle)*where(mod(t, period_ventricle) < systole_ventricle, sin(3.141592653589793*mod(t, period_ventricle)/systole_ventricle), 0) + E_min_ventricle)*(V0_ventricle - V_ventricle(t)))/R_aortic_valve, 0)
veins.V: diff(V_veins(t), t) == -(((E_max_arteries - E_min_arteries)*where(mod(t, period_arteries) < systole_arteries, sin(3.141592653589793*mod(t, period_arteries)/systole_arteries), 0) + E_min_arteries)*(V0_arteries - V_arteries(t)) - ((E_max_veins - E_min_veins)*where(mod(t, period_veins) < systole_veins, sin(3.141592653589793*mod(t, period_veins)/systole_veins), 0) + E_min_veins)*(V0_veins - V_veins(t)))/R_systemic - where(-((E_max_veins - E_min_veins)*where(mod(t, period_veins) < systole_veins, sin(3.141592653589793*mod(t, period_veins)/systole_veins), 0) + E_min_veins)*(V0_veins - V_veins(t)) + ((E_max_ventricle - E_min_ventricle)*where(mod(t, period_ventricle) < systole_ventricle, sin(3.141592653589793*mod(t, period_ventricle)/systole_ventricle), 0) + E_min_ventricle)*(V0_ventricle - V_ventricle(t)) > 0, -(((E_max_veins - E_min_veins)*where(mod(t, period_veins) < systole_veins, sin(3.141592653589793*mod(t, period_veins)/systole_veins), 0) + E_min_veins)*(V0_veins - V_veins(t)) - ((E_max_ventricle - E_min_ventricle)*where(mod(t, period_ventricle) < systole_ventricle, sin(3.141592653589793*mod(t, period_ventricle)/systole_ventricle), 0) + E_min_ventricle)*(V0_ventricle - V_ventricle(t)))/R_mitral_valve, 0)