Skip to content

perfusion

The machine perfusion library, see Machine perfusion: the definition of a circuit with its organ, the cellular core, the circuit and the observers, the build, the archive, the figures and the base of the simulation experiments.

The machine perfusion library: a circuit with a mounted organ (pkpdsim#146).

A model is built from a definition (pkpdsim.perfusion.definition: the circuit, the perfusate, the organ, the temperature) by pkpdsim.perfusion.builder.build, one SBML file; pkpdsim.perfusion.archive.create_archive writes it with its ODEs, its antimony, the figures of the circuit (pkpdsim.perfusion.figure, the schematic, and pkpdsim.perfusion.anatomy, the organ in its circuit) and the COMBINE archive; pkpdsim.perfusion.experiment is the base of the simulation experiments of a model, with the condition of a perfusion and its medium changes. An organ in a machine perfusion is a chain of zones, each a vascular space in series with the flow and its cells with the cellular core (pkpdsim.perfusion.core: the energy metabolism, the redox and the damage of the cells, the release of their enzymes and potassium, the bicarbonate buffer of the perfusate). The ids are those of pkpdsim.perfusion.ids.

The names of the modules are exported lazily (PEP 562), so import pkpdsim.perfusion imports neither sbmlutils nor the PBPK library.

definition

The definition of a machine perfusion: the circuit, the perfusate and the organ.

A machine perfusion model is built from a PerfusionDefinition, as a PBPK model from a pkpdsim.pbpk.PBPKDefinition: the circuit (Circuit, the reservoir, the tubing, the pump flow and the oxygenator), the perfusate (Perfusate, the fresh composition, the oxygenation target, the oxygen carrier and the inert tracers), the mounted organ (a chain of zones with the cellular core: LiverOrgan with bile, KidneyOrgan with the filtration and the urine, GenericOrgan without excretion; each releases its quantities of ids.RELEASABLE), the temperature and the constants of the cellular core (pkpdsim.perfusion.core.CoreParameters). pkpdsim.perfusion.builder.build writes its SBML.

The numbers of a definition are Values in the units an experimenter gives them (ml, ml/min, g, kPa, degC, pkpdsim.perfusion.units.PU), which the build converts into the units of the model; validate refuses a value in another unit. The defaults (Circuit.default, Perfusate.default, LiverOrgan.default, KidneyOrgan.default) are the numbers of the parameter database (tables/perfusion.toml), GenericOrgan.default those of an organ of the physiology table of the species.

PH_RANGE module-attribute

PH_RANGE = (6.0, 8.0)

The range of the pH of a fresh perfusate which validate accepts.

A perfusate is buffered near the physiological pH (7.4); a pH outside of 6 to 8 is a typo (a pH of 74 or of a hydrogen ion concentration) and not a perfusion, and the protons of the model would start far from any condition of the constants of the core.

Organ

The organs which a circuit mounts.

Perfusate dataclass

Perfusate(
    glucose,
    lactate,
    hco3,
    k,
    o2_target_kpa,
    ph,
    carrier="none",
    hct=None,
    tracers=(),
)

The fresh perfusate of a circuit.

The perfusate fills the reservoir, the tubing and the vascular space of the organ at the start, and a medium change brings it in again; the model has its composition as the constants <q>_fresh (mM) of every quantity of the perfusate (ids.PERFUSATE, the tracers), the free protons of its pH and the dissolved CO2 of the buffer equilibrium; the free oxygen is that of o2_target_kpa at the temperature.

Attributes:

Name Type Description
glucose Value

glucose (mM).

lactate Value

lactate (mM).

hco3 Value

bicarbonate (mM).

k Value

potassium (mM).

o2_target_kpa Value

the oxygen partial pressure which the oxygenator sets and of the fresh perfusate (kPa).

ph Value

the pH of the fresh perfusate, within PH_RANGE (6 to 8).

carrier Literal['none', 'rbc']

the oxygen carrier, none (an acellular perfusate, the free oxygen only) or rbc (red blood cells, declared and not built yet, validate refuses it).

hct Value | None

the hematocrit of a perfusate with red blood cells.

tracers Sequence[str]

inert quantities of the perfusate (SIds), which flow with it and do not enter the cells (a mass balance, a filtration marker); fresh at 0 mM.

default classmethod

default()

Get the perfusate of the perfusion table ([perfusate]).

problems

problems()

Get what is wrong with the perfusate.

Circuit dataclass

Circuit(
    reservoir,
    tubing_in,
    tubing_out,
    flow,
    oxygenator_k,
    oxygenator_k_co2=None,
    pco2_gas=None,
)

The circuit of a machine perfusion.

The pump drives the perfusate from the reservoir through the inflow tubing, in which the membrane oxygenator exchanges its oxygen and CO2 with the sweep gas, through the organ and the outflow tubing back into the reservoir; every site is well stirred.

Attributes:

Name Type Description
reservoir Value

the volume of the perfusate in the reservoir (ml).

tubing_in Value

the volume of the inflow tubing with the oxygenator (ml).

tubing_out Value

the volume of the outflow tubing (ml).

flow Value

the total flow of the pump (ml/min), the parameter Q_pump.

oxygenator_k Value

the first order rate constant with which the oxygenator sets the oxygen of the inflow tubing towards the target of the perfusate (1/min).

oxygenator_k_co2 Value | None

the first order rate constant of the exchange of CO2 with the gas (1/min), None for oxygenator_k.

pco2_gas Value | None

the partial pressure of CO2 of the sweep gas (kPa), None for the pCO2 of the fresh perfusate, at which the fresh perfusate stays at its pH.

default classmethod

default()

Get the circuit of the perfusion table ([circuit]).

The pCO2 of the gas is that of the fresh perfusate (None): the sweep gas of the study is not known.

problems

problems()

Get what is wrong with the circuit.

LiverOrgan dataclass

LiverOrgan(
    mass,
    zones=1,
    profiles=dict(),
    *,
    vascular_fraction=None,
    cell_fraction=None,
    density=None,
    released=None,
)

Bases: _Zonated

The liver, a chain of zones from periportal to pericentral, with bile.

The perfusate enters the first zone (a single portal inflow, the rat setup; a split between the hepatic artery and the portal vein is not built) and leaves the last one; each zone is a vascular space (the sinusoids) in series with the flow and its hepatocytes with the cellular core, so oxygen, glucose and the damage form gradients along the sinusoid, and secretes bile. The constants without a value are those of [liver_<species>] of the perfusion table; the liver releases ALT, AST, LDH and potassium.

Attributes:

Name Type Description
mass Value

the mass of the liver (g).

zones int

the number of zones (_Zonated, as the fields below).

profiles Mapping[str, Sequence[float] | _ProfileLike]

the zonal profiles of the processes.

vascular_fraction Value | None

the vascular fraction, None for the table.

cell_fraction Value | None

the cell fraction, None for the table.

density Value | None

the density (kg/l), None for the table.

released Sequence[str] | None

the released quantities, None for RELEASED.

key class-attribute

key = 'li'

The organ token of the ids (M_li).

default classmethod

default(zones=1, profiles=None, species=RAT)

Get the reference liver of a species ([liver_<species>]).

KidneyOrgan dataclass

KidneyOrgan(
    mass,
    zones=1,
    profiles=dict(),
    *,
    vascular_fraction=None,
    cell_fraction=None,
    density=None,
    released=None,
    gfr=None,
    reabsorption=None,
    ff_max=None,
)

Bases: _Zonated

The kidney, with the filtration of the perfusate and the urine.

The perfusate enters the kidney by the renal artery and leaves by the renal vein; the zones are in series with the flow (one zone, the cortex, by default). The glomeruli filter the water and the small solutes of the perfusate (ids.FILTERED, not the enzymes) at the GFR gfr*mass, capped at the fraction ff_max of the pump flow (so the filtration follows a low flow and stops with the pump), shared by the zones by their volume, and the tubules reabsorb the fraction reabsorption of the filtered water and small solutes, so the urine has the composition of the perfusate; the tracers are filtered and not reabsorbed (a filtration marker). The urine leaves the perfusate, so the flow after the kidney is the pump flow less the urine flow, at least (1 - ff_max) of it at any flow. The kidney releases LDH and potassium and secretes no bile. The constants without a value are those of [kidney_<species>] of the perfusion table.

Attributes:

Name Type Description
mass Value

the mass of the kidney (g).

zones int

the number of zones (_Zonated, as the fields below).

profiles Mapping[str, Sequence[float] | _ProfileLike]

the zonal profiles of the processes.

vascular_fraction Value | None

the vascular fraction, None for the table.

cell_fraction Value | None

the cell fraction, None for the table.

density Value | None

the density (kg/l), None for the table.

released Sequence[str] | None

the released quantities, None for RELEASED.

gfr Value | None

the glomerular filtration rate per g of kidney (ml/min/g), None for the table.

reabsorption Value | None

the fraction of the filtered water and small solutes which the tubules reabsorb, from 0 to below 1, None for the table.

ff_max Value | None

the largest fraction of the pump flow which the glomeruli filter, above 0 and at most 1, None for the table.

key class-attribute

key = 'ki'

The organ token of the ids (M_ki).

default classmethod

default(zones=1, profiles=None, species=RAT)

Get the reference kidney of a species ([kidney_<species>]).

problems

problems()

Get what is wrong with the kidney.

GenericOrgan dataclass

GenericOrgan(
    key,
    mass,
    zones=1,
    profiles=dict(),
    *,
    vascular_fraction=None,
    cell_fraction=None,
    density=None,
    released=None,
)

Bases: _Zonated

An organ with the cellular core and no excretion (no bile, no urine).

Another organ in a circuit is a definition and not a new model: the zones, the core and the release of LDH and potassium, with the constants of the core of the organ (core.CoreParameters, [core_generic] copies of the liver values by default). The constants without a value are those of the organ key of the physiology table of the species ([male.organs. <key>] of physiology_<species>.toml: the vascular fraction f_vas, the cell fraction 1 - f_vas - f_int and the density), so an organ of the PBPK library needs its mass only.

Attributes:

Name Type Description
key str

the organ token of the ids (M_<key>), lower case letters and digits, an organ of the physiology table (mu, he) or another.

mass Value

the mass of the organ (g).

zones int

the number of zones (_Zonated, as the fields below).

profiles Mapping[str, Sequence[float] | _ProfileLike]

the zonal profiles of the processes.

vascular_fraction Value | None

the vascular fraction, None for the table.

cell_fraction Value | None

the cell fraction, None for the table.

density Value | None

the density (kg/l), None for the table.

released Sequence[str] | None

the released quantities, None for RELEASED.

default classmethod

default(key, species=RAT)

Get an organ of the physiology table with its mass and fractions.

Parameters:

Name Type Description Default
key str

the organ of the physiology table (mu, he, br).

required
species Species

the species of the table.

RAT

Returns:

Type Description
GenericOrgan

The organ of the reference individual (male) of the species.

Raises:

Type Description
KeyError

if the table has no organ key.

token_problems

token_problems()

Get what is wrong with the token of the organ.

problems

problems()

Get what is wrong with the organ, its token included.

PerfusionDefinition dataclass

PerfusionDefinition(
    sid,
    name,
    species,
    organ,
    circuit,
    perfusate,
    temperature,
    core,
    creators=(),
    notes=None,
)

A machine perfusion: an organ mounted into a circuit.

Attributes:

Name Type Description
sid str

the id of the model, the name of its file.

name str

the name of the model.

species Species

the species of the organ, the taxon of the model.

organ Organ

the mounted organ.

circuit Circuit

the circuit.

perfusate Perfusate

the fresh perfusate.

temperature Value

the temperature of the perfusion (degC), the parameter T, which an experiment changes.

core CoreParameters

the constants of the cellular core of the organ.

creators Sequence[Creator]

the creators of the model (its model history).

notes str | None

further notes of the model (markdown), appended to the description of the circuit which the build writes, e.g. the terms of use of a model package (PBPKDefinition.notes is the whole notes of its model, this one is appended).

released property

released

The quantities which the necrotic cells of the organ release.

validate

validate()

Get what is wrong with the definition.

Returns:

Type Description
list[str]

The problems, empty for a definition which builds.

parameter_value

parameter_value(sid)

Get the number of a constant parameter of the model of the definition.

The experiments read a number of the model here (the flow, the fresh perfusate of a medium change), the one place of the number.

Parameters:

Name Type Description Default
sid str

the id of the parameter.

required

Returns:

Type Description
float

The number in the unit of the parameter of the model.

Raises:

Type Description
KeyError

if the model has no constant parameter of the id with a number (a parameter of an initial assignment or a rule).

table_value

table_value(section, key)

Get a number of the perfusion table with its unit, source and notes.

Parameters:

Name Type Description Default
section str

the section of tables/perfusion.toml.

required
key str

the key of the number.

required

Returns:

Type Description
Value

The value in the unit definition of its unit.

Raises:

Type Description
TypeError

if the entry is no number.

ValueError

if its unit is no unit of _TABLE_UNITS.

core

The cellular core of a zone of a perfused organ.

A zone of an organ in a machine perfusion is a vascular space, through which the perfusate flows (the circuit, not this module), and its cells. The core is what happens in the cells and between the cells and the vascular space: the import of glucose and oxygen, the energy metabolism (glycogenolysis, glycolysis, lactate dehydrogenase, TCA cycle, oxidative phosphorylation, ATP use), the reactive oxygen species (ROS) at low oxygen and their detoxification by glutathione, regenerated with NADPH of the pentose phosphate pathway, the death of the cells (necrosis) and the release of their enzymes (ALT, AST, LDH) and potassium into the vascular space, the secretion of bile, the export of lactate with a proton and the bicarbonate buffer and pH of the perfusate. The processes and their values are ported from the liver model of pkdb_models.misc.machine_perfusion (from the PVL liver model) with the defects of its TODO fixed: the rates are per litre of cells (no f_scale), the release moves amounts, the ATP inhibition of the glycolysis is defined at ATP 0, the glutathione is regenerated with NADPH, and every element has its own name.

The species of the cells are concentrations in mmole per l of cells, the species of the vascular space concentrations of the perfusate (mM); every rate is in mmole/min, a rate per volume of cells times the volume of the cells (cells) and the living fraction f_alive_<zone>. The ids are those of pkpdsim.perfusion.ids.

The constants of the core are ids of the whole model, shared by its zones (core_parameters, the numbers of the parameter database, the sections core_<organ> and core_<organ>_start of tables/perfusion.toml): a fit has one value per constant. A zonal profile weighs a process per zone (the pattern of the zonated liver of the PBPK library), the dimensionless factor p_<process>_<zone> in the rate of the process (core_objects(profile=)), which the organ normalises; a process without a profile has none. The temperature factor f_T (ids.F_T) and the constants of the buffer (buffer_parameters) are ids of the whole model as well; the circuit defines f_T as the Arrhenius factor of the temperature, and the start of the dissolved CO2 of the perfusate is the initial assignment of the buffer equilibrium, CO2 = h*HCO3/Ka_hco3, so it follows the one buffer of the model.

The rate laws, one choice each, with the reason:

  • Biological rates scale with f_T * f_alive: the temperature acts on the enzymes and transporters, only the living cells metabolise.
  • A Hill term reads the absolute value of its species, (|S|/K)^n, so it stays defined for the small negative values of the integrator at a non-integer n.
  • Glucose, oxygen import: the reversible facilitated transport of the ported model, Vmax/Km*(S_out - S_in)/(1 + S_out/Km + S_in/Km), saturable both ways.
  • Lactate export: the monocarboxylate transporter co-transports a proton, so the reverse term reads the perfusate protons over the cytosolic protons, (lac_in - lac_out*h_out/h_cell)/(...); the cytosolic pH is a constant (LACEX_h_cell, pH 7.2), not a state, and the protons of glycolysis leave the cell with the lactate; the reverse rate vanishes with the protons, so the protons stay positive.
  • Glycogenolysis: Michaelis-Menten in glycogen (glucosyl units), a new store, since the perfusate glucose of the study rises from 6 to 11 mM.
  • Glycolysis: glc + 2 ADP + 2 NAD -> 2 pyr + 2 ATP + 2 NADH, carbon balanced (the ported model made one pyruvate), Michaelis-Menten in glucose, ADP and NAD, inhibited by ATP with 1/(1 + (|ATP|/Ki)^n) instead of the singular (Ki/ATP)^n; both are about 0.06 at the start (ATP 3 mM).
  • LDH: pyr + NADH <-> lac + NAD, a reversible random bi-bi law Vmax/(Km_pyr*Km_nadh)*(pyr*NADH - lac*NAD/Keq)/((1 + pyr/Km_pyr + lac/Km_lac) *(1 + NADH/Km_nadh + NAD/Km_nad)), which consumes NADH (the ported model read it as an activator, so a reactant could become negative).
  • TCA: pyr + 5 NAD -> 5 NADH + 3 CO2, the pyruvate dehydrogenase and the cycle with FADH2 counted as NADH and the GTP left out; the CO2 goes to the perfusate directly, it crosses the membrane within seconds.
  • OXPHOS: NADH + 0.5 O2 + 3 ADP -> NAD + 3 ATP, the ported law and P/O ratio.
  • ATP use: Michaelis-Menten in ATP, ported.
  • ROS production: NADH + O2 -> NAD + ROS (ROS as H2O2), the electron leak of the respiratory chain at low oxygen; the ported step function of oxygen becomes O2/(Km + O2) * 1/(1 + (O2/Ki)^n), smooth, 0 without oxygen (which it consumes) and small at normoxia.
  • ROS detoxification: ROS + 2 GSH -> GSSG (glutathione peroxidase), the ported law k*GSH*ROS/(Km + ROS) with the stoichiometry of the enzyme.
  • Glutathione reductase: GSSG + NADPH -> 2 GSH + NADP, the ported law with NADPH, which the ported model replaced by NADH.
  • Pentose phosphate pathway: glc + 12 NADP -> 12 NADPH + 6 CO2, the net oxidative pathway with the recycling of the pentoses, Michaelis-Menten in glucose and NADP, the source of NADPH.
  • Necrosis: the living fraction dies at v_nec = NEC_k*f_T*(1 - (1 - s_atp)* (1 - s_h)), either drive alone gives the full rate: the energy failure s_atp = 1/(1 + (ATP/NEC_atp)^n) (a smooth threshold, instead of the instantaneous switch of the ported model) and the acidosis of the perfusate s_h = (h/NEC_h)^n/(1 + (h/NEC_h)^n). The acidosis drives the damage, and does not inhibit the energy metabolism, since the medium changes of the study protect the liver far beyond the dilution of the enzymes, at an outflow pO2 of 30 to 70 kPa which points at no energy deficit.
  • Necrotic cells: the dying cells move their enzymes and potassium at v_nec into the dead cells of the zone, which release them first order (PROTEINR_k, KR_k) into the vascular space, so the totals are conserved and a dead zone releases its whole content; the release is a leak of a ruptured membrane and does not scale with f_T.
  • Bile: the volume secreted at BILE_Vmax*ATP/(Km + ATP) per litre of living cells (the ATP-dependent export of the bile salts), a volume only, in an organ with bile (the liver).
  • Released quantities: an organ releases a subset of ids.RELEASABLE (core_objects(released=)), each with its content in the cells; an enzyme which the organ does not release is neither in its cells nor in the perfusate (ids.cell_quantities, ids.perfusate_quantities), and its content is None in the constants (the kidney, a generic organ).
  • Bicarbonate buffer of the perfusate: H+ + HCO3- <-> CO2 with the mass action k_co2*(h*hco3/Ka - CO2) (the dehydration of carbonic acid is fast, the hydration of CO2 sets the time), and the pH from the free protons, pH = 3 - log10(h/1 mM); the CO2 of the perfusate stands for CO2 and H2CO3 together, no further buffer is modelled.

PROCESSES module-attribute

PROCESSES = (
    "GLCIM",
    "O2IM",
    "LACEX",
    "GLGP",
    "GLC2PYR",
    "LDH",
    "ATPU",
    "TCA",
    "OXPHOS",
    "ROSP",
    "ROSDETOX",
    "GR",
    "PPP",
    "BILE",
)

The processes of the living cells which a zonal profile may weigh.

CoreObjects module-attribute

CoreObjects = SbmlObjects

The SBML objects of a part of a perfusion model.

The container is the SBML writing kit's (pkpdsim.sbml.objects.SbmlObjects), in which the zonation engine hands its observers over as well; this is the name of the perfusion library for it.

CoreParameters dataclass

CoreParameters(
    *,
    GLCIM_Vmax,
    GLCIM_Km_glc,
    O2IM_Vmax,
    O2IM_Km_o2,
    LACEX_Vmax,
    LACEX_Km_lac,
    LACEX_h_cell,
    GLGP_Vmax,
    GLGP_Km_glyc,
    GLC2PYR_Vmax,
    GLC2PYR_Km_glc,
    GLC2PYR_Km_adp,
    GLC2PYR_Km_nad,
    GLC2PYR_Ki_atp,
    GLC2PYR_n_atp,
    LDH_Vmax,
    LDH_Km_pyr,
    LDH_Km_lac,
    LDH_Km_nadh,
    LDH_Km_nad,
    LDH_Keq,
    ATPU_Vmax,
    ATPU_Km_atp,
    TCA_Vmax,
    TCA_Km_pyr,
    TCA_Km_nad,
    OXPHOS_Vmax,
    OXPHOS_Km_nadh,
    OXPHOS_Km_o2,
    OXPHOS_Km_adp,
    ROSP_Vmax,
    ROSP_Km_nadh,
    ROSP_Km_o2,
    ROSP_Ki_o2,
    ROSP_n_o2,
    ROSDETOX_k,
    ROSDETOX_Km_ros,
    GR_k,
    GR_Km_nadph,
    PPP_Vmax,
    PPP_Km_glc,
    PPP_Km_nadp,
    NEC_k,
    NEC_atp,
    NEC_n_atp,
    NEC_h,
    NEC_n_h,
    PROTEINR_k,
    KR_k,
    ALT_content=None,
    AST_content=None,
    LDH_content=None,
    K_content,
    BILE_Vmax=None,
    BILE_Km_atp=None,
    f_alive_start,
    starts,
)

The constants of the cellular core, shared by the zones of an organ.

Every field but starts is a constant of _SPECS, a parameter of the model under its name (core_parameters), in its unit: the maximal rates per litre of cells (mmole/min/l), the first order constants (1/min), the Michaelis and inhibition constants (mM), the Hill coefficients, the ATP threshold and rate of necrosis, the contents of the released quantities in mmole per litre of cells, the bile secretion in litre of bile per minute and litre of cells and the living fraction at the start. starts are the initial concentrations of the other species of the cells (mM) by quantity. The contents of the enzymes and the bile constants are None for an organ which does not release the enzyme or has no bile; the model has no parameter of a constant which is None.

default classmethod

default(organ='liver_rat')

Get the constants of an organ from the parameter database.

Parameters:

Name Type Description Default
organ str

the organ of the sections core_<organ> (the constants) and core_<organ>_start (the starts of the cells) of the perfusion table (liver_rat, kidney_rat, generic).

'liver_rat'

Returns:

Type Description
CoreParameters

The constants of the core; a constant which may be None is

CoreParameters

None when the section has none (the contents of the enzymes an

CoreParameters

organ does not release, the bile of an organ without). The bile

CoreParameters

secretion is derived from the bile rate of the study

CoreParameters

([<organ>] bile_rate, per g of organ) per litre of cells

CoreParameters

(cell_fraction, 1 kg/l) at the ATP of the start, for a section

CoreParameters

with BILE_Km_atp.

problems

problems(released, bile)

Get what the constants lack for an organ or give in a wrong unit.

Parameters:

Name Type Description Default
released tuple[str, ...]

the quantities which the organ releases.

required
bile bool

the organ secretes bile.

required

Returns:

Type Description
list[str]

A problem per missing content of a quantity of the cells, per missing

list[str]

bile constant, per constant (and start) whose unit is not the unit

list[str]

of the model (_SPECS, mM for the starts), per quantity of the

list[str]

cells of the organ without a start and per start of a quantity

list[str]

which is no quantity of the cells with a start (starts).

Buffer dataclass

Buffer(ka, k_hydration)

The constants of the bicarbonate buffer of the perfusate.

Attributes:

Name Type Description
ka Value

the apparent dissociation constant [H+]*[HCO3-]/[CO2] (mM).

k_hydration Value

the rate constant of the hydration of CO2 (1/min).

default classmethod

default()

Get the constants of the perfusion table (acid_base).

Composition dataclass

Composition(glc, o2, lac, hco3, k, ph)

The composition of a perfusate, the start of the perfusate species.

The free protons follow from the pH; the dissolved CO2 is the initial assignment of the buffer equilibrium (perfusate_objects); a fresh perfusate has no enzymes.

Attributes:

Name Type Description
glc Value

glucose (mM).

o2 Value

free oxygen (mM).

lac Value

lactate (mM).

hco3 Value

bicarbonate (mM).

k Value

potassium (mM).

ph Value

the pH.

default classmethod

default()

Get the perfusate of the perfusion table (perfusate).

concentrations

concentrations(released=RELEASABLE)

Get the start of every quantity of the perfusate (mM).

Parameters:

Name Type Description Default
released tuple[str, ...]

the quantities which the organ releases, whose enzymes are quantities of the perfusate (ids.perfusate_quantities).

RELEASABLE

Returns:

Type Description
dict[str, float | None]

The concentrations, None for the CO2, whose start is the

dict[str, float | None]

buffer equilibrium.

CoreNames dataclass

CoreNames(zone=None)

The ids and labels of the objects of the core of a zone or of a cell.

Attributes:

Name Type Description
zone str | None

the zone id; None for the standalone cell model, whose ids have no zone (atp_cell, GLCIM, f_alive) and whose vascular space is the external site (glc_ext, the port of a quantity).

where property

where

The zone or the cell model, for a message.

cell_site property

cell_site

The site of the living cells.

dead_site property

dead_site

The site of the necrotic cells.

vascular_site property

vascular_site

The site of the vascular space, ext of the cell model.

where_cells property

where_cells

The place of the cells in a name.

where_dead property

where_dead

The place of the necrotic cells in a name.

alive property

alive

The id of the living fraction.

necrosis_rate property

necrosis_rate

The id of the rate of necrosis.

bile property

bile

The id of the secreted bile volume.

profile

profile(process)

Get the id of the zonal factor of a process.

reaction

reaction(name)

Get the id of a reaction.

label

label(text)

Get a name with its zone.

core_parameters

core_parameters(params, *, released=RELEASABLE, bile=True)

Get the constants of the core, ids of the whole model.

Parameters:

Name Type Description Default
params CoreParameters

the constants.

required
released tuple[str, ...]

the quantities which the organ releases; the content of an enzyme it does not release is no constant of the model (potassium is in the cells of every organ).

RELEASABLE
bile bool

the organ secretes bile; without, the bile constants are no constants of the model.

True

Returns:

Type Description
list[Parameter]

A constant parameter of every field but starts, the fields which

list[Parameter]

are None and the constants the organ does not read, under its

list[Parameter]

name, with the citation of its source in the notes, and the start of

list[Parameter]

every quantity of the cells with a start, <q>_start (mM, starts),

list[Parameter]

which the initial assignments of the zones read.

Raises:

Type Description
TypeError

if the unit of a constant is no unit definition.

start_quantities

start_quantities(released=RELEASABLE)

Get the quantities of the cells with a start of CoreParameters.starts.

Parameters:

Name Type Description Default
released tuple[str, ...]

the quantities which the organ releases.

RELEASABLE

Returns:

Type Description
str

The quantities of the cells of the organ but those whose start is a

...

content (the released quantities).

buffer_parameters

buffer_parameters(buffer=None)

Get the constants of the bicarbonate buffer, ids of the whole model.

Parameters:

Name Type Description Default
buffer Buffer | None

the constants, Buffer.default() by default.

None

Returns:

Type Description
list[Parameter]

The parameters ids.BUFFER_KA and ids.BUFFER_K_HYDRATION.

perfusate_objects

perfusate_objects(
    site, compartment, composition=None, released=RELEASABLE
)

Get the perfusate species of a site, ids.species(quantity, site).

Parameters:

Name Type Description Default
site str

the site (a zone for its vascular space, res).

required
compartment str

the compartment of the perfusate at the site.

required
composition Composition | None

the start, Composition.default() by default.

None
released tuple[str, ...]

the quantities which the organ releases.

RELEASABLE

Returns:

Type Description
CoreObjects

A species of every quantity of the perfusate

CoreObjects

(ids.perfusate_quantities), in mM, and the

CoreObjects

initial assignment of the CO2 at the equilibrium of the buffer with

CoreObjects

the protons and the bicarbonate, CO2 = h*HCO3/Ka_hco3.

buffer_objects

buffer_objects(site, compartment)

Get the bicarbonate buffer and the pH of the perfusate at a site.

Parameters:

Name Type Description Default
site str

the site.

required
compartment str

the compartment of the perfusate at the site.

required

Returns:

Type Description
CoreObjects

The reaction BUF_<site>, H+ + HCO3- <-> CO2, and the pH

CoreObjects

pH_<site> with its assignment rule.

core_objects

core_objects(
    names,
    cells,
    vascular,
    params,
    *,
    profile,
    composition,
    bile,
    released,
)

Get the objects of the cellular core, the one emitter of its chemistry.

This is the seam between the cellular core and its placements: the zones of a perfusion organ without the engine (CoreNames(zone), the zones of the kidney) and the standalone cell model (cell_model.cell_model, CoreNames(), which the engine places in every zone of a liver) call it with their CoreNames, compartments and profile, and never write a value, a rate law or a unit of their own: every value, rate law and unit is written here once.

Parameters:

Name Type Description Default
names CoreNames

the ids of the objects (CoreNames).

required
cells str

the compartment of the cells.

required
vascular str

the compartment of the vascular space (the surroundings of the cells).

required
params CoreParameters

the constants of the core.

required
profile Mapping[str, float] | None

the factor of a process of PROCESSES, the constant p_<process> of names in its rate.

required
composition Composition | None

the start of the perfusate species.

required
bile bool

secrete bile.

required
released tuple[str, ...]

the quantities of ids.RELEASABLE which the dying cells release.

required

Returns:

Type Description
CoreObjects

The species of the cells, the necrotic cells and the vascular space,

CoreObjects

the reactions, the factors of the profile, the rules of the pH and of

CoreObjects

the rate of necrosis, the rate rules of the living fraction and of

CoreObjects

the bile, the initial assignments of the contents of the cells, of

CoreObjects

the living fraction and of the CO2 of the perfusate. The rate laws

CoreObjects

read the constants of the core, f_T and the buffer constants, which

CoreObjects

the model defines once.

Raises:

Type Description
ValueError

if the profile has a process which is not in PROCESSES or a factor which is negative, a released quantity is no quantity of ids.RELEASABLE, or the constants lack what the cells need (CoreParameters.problems).

quantity_name

quantity_name(quantity)

Get the name of a quantity of the core (glucose of glc).

Raises:

Type Description
KeyError

for a token which is no quantity of the core.

circuit

The circuit of a machine perfusion: the sites, the flow, the oxygenator and the temperature.

The pump drives the perfusate at the flow Q_pump (l/min) from the reservoir res through the inflow tubing in, the zones of the organ (z1 to zn) and the outflow tubing out back into the reservoir. Every site is a well-stirred volume, and the flow from a site to the next is the reaction FLOW_<q>_<site>_<next> of every quantity of the perfusate (the quantities of ids.perfusate_quantities of the released set of the organ and the tracers) at Q_pump * <q>_<site>, so the amount of the perfusate is conserved and a flow of 0 is defined (no rate divides by the flow). An organ which makes urine (the kidney) takes its water out of the perfusate: the flow out of its zones and of the outflow tubing is the pump flow less the urine of the zones up to there (Q_<site>), and the reservoir, whose volume is a rate rule, loses the urine, so the volume of the tubing and the organ is constant. The bicarbonate buffer acts at every site (core.buffer_objects).

The membrane oxygenator exchanges the gases of the inflow tubing with its sweep gas, first order: the reaction OXY_in sets the oxygen towards the target of the perfusate, k_oxy * V_in * (alpha_o2 * pO2_target - o2_in), and the reaction OXY_co2_in the dissolved CO2 towards the partial pressure of CO2 of the gas, k_oxy_co2 * V_in * (alpha_co2 * pCO2_gas - co2_in), so the CO2 which the cells produce and the bicarbonate buffer releases is vented and the bicarbonate buffer of the perfusate is open, as with a gas of fixed pCO2. Without a pCO2 of the gas in the definition it is that of the fresh perfusate (co2_fresh/alpha_co2), so the fresh perfusate is at its steady state in the oxygenator.

The temperature T (degC) is a constant which an experiment changes; the rates of the cellular core scale with the Arrhenius factor f_T = exp(Ea/R * (1/(T_ref + 273.15) - 1/(T + 273.15))), 1 at the reference temperature, and the solubility of oxygen is alpha_o2 = alpha_o2_ref * exp(k_alpha_o2 * (T - T_alpha_o2)), both initial assignments of T, so the free oxygen of a pO2 rises in the cold; the solubility of CO2 alpha_co2 is a constant (its value at 37 C). T takes effect as a change before the initialization of a simulation (the initial assignments of f_T, alpha_o2 and o2_fresh are evaluated then); a change of T during a timecourse does not evaluate them again, so it leaves the rates and the solubility at the earlier temperature.

The fresh perfusate is the constants <q>_fresh (mM), the start of every perfusate species at every site (an initial assignment); the free protons follow from its pH, the CO2 from the buffer equilibrium and the oxygen from the target at the temperature. A medium change of an experiment sets the reservoir towards them.

ABSOLUTE_ZERO module-attribute

ABSOLUTE_ZERO = 273.15

The absolute temperature of 0 degC (K), the definition of the scale.

quantities

quantities(perfusate, released=RELEASABLE)

Get the quantities of the perfusate and the tracers.

Parameters:

Name Type Description Default
perfusate Perfusate

the perfusate.

required
released tuple[str, ...]

the quantities which the organ releases, whose enzymes are quantities of the perfusate (ids.perfusate_quantities).

RELEASABLE

quantity_label

quantity_label(quantity)

Get the name of a quantity of the perfusate, a tracer by its token.

converted

converted(value, factor, unit, text)

Get a value in the unit of the model, the conversion in the notes.

Parameters:

Name Type Description Default
value Value

the value of the definition.

required
factor float

the factor of the unit of the definition in the unit of the model.

required
unit UnitType

the unit of the model.

required
text str

the unit of the definition, for the notes.

required

Returns:

Type Description
Value

The value with its source, in the unit of the model.

Raises:

Type Description
ValueError

if the value has an uncertainty, which would keep the unit of the definition (PerfusionDefinition.validate refuses it).

temperature_objects

temperature_objects(temperature, variable=TEMPERATURE)

Get the temperature and the Arrhenius factor f_T of the rates.

Parameters:

Name Type Description Default
temperature Value

the temperature of the perfusion (degC).

required
variable str

the id of the temperature parameter, T of a perfusion model and the port temperature of the cell model.

TEMPERATURE

Returns:

Type Description
CoreObjects

The constants T (variable), T_ref, R_gas and Ea (the activation energy

CoreObjects

f_Ea*R*T_ref of the database, a constant, so a change of the

CoreObjects

reference keeps it) and f_T with its initial assignment.

oxygen_objects

oxygen_objects()

Get the solubility of the gases in the perfusate at the temperature.

Returns:

Type Description
CoreObjects

The constants of the database, alpha_o2 with its initial

CoreObjects

assignment and the solubility of CO2 alpha_co2.

composition

composition(perfusate)

Get the composition of the core for the initial values of the species.

The initial assignments of the fresh perfusate (fresh_assignments) set the starts; the composition gives the initial values the same numbers at the reference temperature of the solubility.

perfusate_parameters

perfusate_parameters(perfusate, released=RELEASABLE)

Get the fresh perfusate, the constants <q>_fresh, and the oxygen target.

Parameters:

Name Type Description Default
perfusate Perfusate

the perfusate.

required
released tuple[str, ...]

the quantities which the organ releases.

RELEASABLE

Returns:

Type Description
CoreObjects

The constants pO2_target, pH_fresh and <q>_fresh of glucose,

CoreObjects

lactate, bicarbonate, potassium, the released enzymes (0) and the

CoreObjects

tracers (0);

CoreObjects

the free protons, the CO2 and the oxygen of the fresh perfusate as

CoreObjects

initial assignments.

fresh_assignments

fresh_assignments(site, perfusate, released=RELEASABLE)

Get the start of the perfusate species of a site, the fresh perfusate.

The CO2 keeps the initial assignment of the buffer equilibrium of its site (core.perfusate_objects), which is the fresh CO2.

tracer_species

tracer_species(tracer, site, compartment)

Get the species of an inert tracer of the perfusate at a site.

circuit_compartments

circuit_compartments(circuit, reservoir_constant=True)

Get the compartments of the reservoir and the tubing (l).

Parameters:

Name Type Description Default
circuit Circuit

the circuit.

required
reservoir_constant bool

the volume of the reservoir is constant; an organ which makes urine takes its water from the reservoir, a rate rule.

True

fresh_co2_pressure

fresh_co2_pressure(perfusate)

Get the partial pressure of CO2 of the fresh perfusate (kPa).

The CO2 of the buffer equilibrium at the pH and the bicarbonate of the fresh perfusate, 10^(3 - pH) mM * HCO3/Ka_hco3, over the solubility of CO2; the default pCO2 of the sweep gas, at which the fresh perfusate stays at its pH.

circuit_objects

circuit_objects(circuit, perfusate, released=RELEASABLE)

Get the perfusate of the reservoir and the tubing, the pump and the oxygenator.

Parameters:

Name Type Description Default
circuit Circuit

the circuit.

required
perfusate Perfusate

the perfusate.

required
released tuple[str, ...]

the quantities which the organ releases.

RELEASABLE

Returns:

Type Description
CoreObjects

The perfusate species, the buffer and the start of the fresh

CoreObjects

perfusate at the sites of the circuit, the constants Q_pump (l/min),

CoreObjects

k_oxy, k_oxy_co2 and pCO2_gas (without a pCO2 of the gas in the

CoreObjects

circuit the initial assignment co2_fresh/alpha_co2, so a change of

CoreObjects

the fresh perfusate before the initialization moves the gas with it),

CoreObjects

the reactions of the oxygenator (oxygen and CO2).

flow_objects

flow_objects(
    sites,
    perfusate,
    released=RELEASABLE,
    outflows=None,
    zone_flows=True,
)

Get the flow of the perfusate through the sites of the circuit.

Parameters:

Name Type Description Default
sites Sequence[str]

the sites in the order of the flow, the last flows into the first (the reservoir, the inflow, the zones, the outflow).

required
perfusate Perfusate

the perfusate.

required
released tuple[str, ...]

the quantities which the organ releases.

RELEASABLE
outflows Mapping[str, str] | None

the id of the flow out of a site (l/min) where it is not the pump flow, e.g. after a kidney, which takes the urine out of the perfusate (ids.outflow).

None
zone_flows bool

emit the flow from a zone into the next; False where the zonation engine chains the zones (the liver), which then emits it.

True

Returns:

Type Description
CoreObjects

The reaction FLOW_<q>_<site>_<next> of every quantity and site,

CoreObjects

Q_pump * <q>_<site> or the outflow of the site times <q>_<site>.

observers

The observers of a machine perfusion: every quantity at every site.

The perfusate quantities are species of every site, <q>_<site> (the reservoir res, the inflow in, the outflow out, the vascular space of every zone z<k>); the cells of a zone are the site z<k>_cell. The observers add what the species do not give, as assignment rules:

  • pO2_<site> (kPa), the free oxygen over its solubility at the temperature, o2_<site>/alpha_o2;
  • <e>_act_<site> (µkat/l), the catalytic activity of an enzyme of ids.ENZYMES which the organ releases, its concentration times its specific activity a_<e> (µkat/mmole, [enzymes] of the perfusion table), the unit of the data;
  • the periportal and pericentral means, the sites pp and pc (pp_cell for the cells): every concentration of a zone averaged over the first and the last third of the length of the sinusoid, each zone weighted by its overlap with that third (third_weights and weighted_mean of pkpdsim.zones, which every zonated model of pkpdsim shares; the zones have the same volume), and the pO2, the pH and the activities of these means as at any site. With one zone both means are the zone; with two zones the periportal mean is the first zone and the pericentral the second; with three zones the first and the last zone; with four zones the periportal mean is 3/4 of the first and 1/4 of the second zone;
  • pCO2_<site> (kPa), the dissolved CO2 over its solubility;
  • the bile of an organ with bile, the rate bile_rate (µl/min, the sum of the secretion of the zones), the volume bile (µl, the sum of the bile volumes of the zones) and the volume per gram of the organ bile_per_mass (µl/g, bile/(1000 g/kg * M_<o>), the unit of the data);
  • the urine of an organ with urine, the rate urine_rate (µl/min, the net urine flow Q_urine) and the volume urine (µl, the urine volume V_urine);
  • the oxygen uptake of the organ VO2 (mmole/min), the oxygen which the cells take up from the perfusate, the sum of the zones.

The parameter of an observer with its assignment rule (observer, RULE) is the SBML writing kit's (pkpdsim.sbml.parameters), which the zonation engine writes its observers with as well; this module re-exports them unchanged.

observer

observer(sid, formula, unit, name, sbo)

Get the parameter of an observer and its assignment rule.

third_weights

third_weights(n, periportal)

Get the weights of the zones in the mean of a third of the sinusoid.

Zone k of n covers [(k - 1)/n, k/n] of the length of the sinusoid; its weight is its overlap with the first (periportal) or the last (pericentral) third over the length of the third, so the weights sum to 1.

Parameters:

Name Type Description Default
n int

the number of zones.

required
periportal bool

the first third, else the last.

required

Returns:

Type Description
list[tuple[int, Fraction]]

The zones (from 1) with a weight above 0 and their weights.

weighted_mean

weighted_mean(of_zones, weights)

Get the weighted mean of an id of the zones (periportal first).

enzyme_parameters

enzyme_parameters(enzymes=ENZYMES)

Get the specific activity of every enzyme, a_<e> (µkat/mmole).

Parameters:

Name Type Description Default
enzymes Sequence[str]

the enzymes of the perfusate, those the organ releases.

ENZYMES

site_objects

site_objects(site, enzymes=ENZYMES)

Get the pO2, the pCO2 and the enzyme activities of the perfusate at a site.

Parameters:

Name Type Description Default
site str

the site.

required
enzymes Sequence[str]

the enzymes of the perfusate, those the organ releases.

ENZYMES

mean_objects

mean_objects(zones, perfusate, cells=CELL, enzymes=ENZYMES)

Get the periportal and pericentral means of the zones.

The means of the first and the last third of the zones of any organ; the periportal and the pericentral mean in the liver.

Parameters:

Name Type Description Default
zones Sequence[str]

the zones, periportal first.

required
perfusate Sequence[str]

the quantities of the perfusate (with the tracers).

required
cells Sequence[str]

the quantities of the cells.

CELL
enzymes Sequence[str]

the enzymes of the perfusate.

ENZYMES

Returns:

Type Description
CoreObjects

The means of the perfusate concentrations, the cell concentrations

CoreObjects

and the living fraction at the sites pp and pc, and their pO2,

CoreObjects

pH and enzyme activities.

bile_objects

bile_objects(rates, zones, mass)

Get the bile rate, the bile volume and the bile per mass of the organ.

Parameters:

Name Type Description Default
rates Sequence[str]

the formulas of the bile secretion of the zones (l/min), the rate rules of Vbile_<zone> of the core.

required
zones Sequence[str]

the zones.

required
mass str

the id of the mass of the organ (kg), M_<o>.

required

Returns:

Type Description
CoreObjects

bile_rate (µl/min), bile (µl), the sum of the bile volumes of

CoreObjects

the zones, and bile_per_mass (µl/g), the bile volume per gram of

CoreObjects

the organ, all assignment rules.

uptake_objects

uptake_objects(zones)

Get the oxygen uptake of the organ, VO2 (mmole/min).

Parameters:

Name Type Description Default
zones Sequence[str]

the zones.

required

urine_objects

urine_objects()

Get the urine rate and the urine volume of the organ.

Returns:

Type Description
CoreObjects

urine_rate (µl/min), the net urine flow Q_urine, and urine

CoreObjects

(µl), the urine volume V_urine, both assignment rules.

builder

The build of a machine perfusion model: one flat SBML model of a definition.

build validates a PerfusionDefinition, composes the model (compose) and writes <sid>.xml, SBML L3V2 (the level of the models of pkdb_models) (the flat model of a liver, its comp package resolved): the circuit (pkpdsim.perfusion.circuit), the zones of the organ with the cellular core (pkpdsim.perfusion.core) and the observers (pkpdsim.perfusion.observers). Every element has a name and an SBO term, every initial assignment its name; the written file is validated with the units.

The organ is a chain of zones in series with the flow, the first zone first (periportal in the liver). The zones of a liver are the zonation engine's (pkpdsim.zonation, _liver): the well-stirred geometry with the vascular space V_vas_<zone> and the cells V_cell_<zone> of the fractions of the organ, the flow between the zones (Q_li, the pump flow of the circuit, which is the boundary of the chain), the zonal factors of the profiles and the cellular core (pkpdsim.perfusion.cell_model) as a submodel M<kk> of every zone, composed through SBML comp and flattened (build writes both and the cell model; the flat model is simulated). The states of the cells which the liver observes are exposed under the ids of pkpdsim.perfusion.ids (atp_z1_cell, f_alive_z1, O2IM_z1, see compose(expose=) of the engine), the other elements of the cells are M<kk>__<id> in the flat model, the constants of the core are shared by the zones. The zones of the kidney and of a generic organ are emitted here, by the same core with the same ids, as are the circuit, the pump flow and the kidney. An organ with the token <o> (li the liver, ki the kidney, the key of a generic organ) has the mass M_<o> (kg), the density rho_<o>, and the volume V_<o> = M_<o>/rho_<o> and the vascular and cell fractions f_vas_<o> and f_cell_<o> as constants (the liver those of the engine, f_vas and f_cell, and V_li for reference); the vascular space and the cells of each of its n zones are the compartments V_vas_<zone> = f_vas_<o>*V_<o>/n and V_cell_<zone> = f_cell_<o>*V_<o>/n (initial assignments, so a change of the mass before a simulation sets the zones). A profile of a process (profiles of the organ) is normalised to the zonal factors p_<process>_<zone> = n*p/sum(p), so the total capacity of the organ, the rate per litre of cells times the cell volume of the zones, is that of one zone of the whole organ, as in the zonated liver of the PBPK library; a uniform profile is 1 in every zone. The cells release the quantities of the organ (PerfusionDefinition.released), and the enzymes of the cells, the perfusate and the observers are the released ones.

A package adds a mechanism of its own with a PerfusionExtension (build(extension=)): the cells of the mechanism are written into the cell model once, so the engine exposes its species and its reactions per zone under the ids of the perfusion, its constants are shared by the zones, and what the circuit or the zones hold is written into the composed model. The machine perfusion model of pkdb_models adds its reperfusion injury this way.

The liver secretes bile (bile, bile_rate). The kidney filters the perfusate (_kidney): the GFR GFR_ki is that of an ample flow, GFR_max_ki = gfr_ki*M_ki (gfr_ki in l/min/kg, numerically ml/min/g), at most the maximal filtration fraction FF_max_ki of the pump flow (a rule, so the kidney stops filtering with the pump), shared by the zones by their volume; the tubules reabsorb the fraction f_reab_ki of the filtered water and small solutes and none of a tracer, and the net urine flow Q_urine = (1 - f_reab_ki)*GFR_ki (a rule) leaves the perfusate. The volumes of the tubing and of the zones stay constant: the flow out of zone k of n is Q_pump - k/n*Q_urine, out of the outflow tubing Q_pump - Q_urine, and the reservoir loses the urine, its volume a rate rule -Q_urine, while the urine volume V_urine gains it, so the perfusate and the urine keep their water exactly. The urine holds the amounts <q>_urine (mmole, it starts empty) and gives the observers urine (µl) and urine_rate (µl/min). A generic organ has neither bile nor urine.

PerfusionExtension dataclass

PerfusionExtension(
    cell=None, shared=(), expose=(), composed=None
)

A mechanism which a package adds to the model of a definition.

The build composes the cellular core of a liver as a submodel of every zone, so a mechanism of the cells is written into the cell model once (cell) and not per zone: the engine exposes its species and reactions under the ids of pkpdsim.perfusion.ids, as it does those of the library (hmgb1_z1_cell, HMGB1R_z1), and the liver holds its constants (shared), one in the flat model instead of one per zone. A mechanism of the circuit or of the zones is written into the composed model (composed), after the build has placed the circuit, the zones and the observers.

Attributes:

Name Type Description
cell Callable[[Model], Model] | None

the extension of the cell model of the zones, in place, which returns it; None for a mechanism without cells of its own. A constant of the library whose law it replaces it removes from the cell model, and the liver shares it no more (composed removes it from the composed model as well).

shared tuple[str, ...]

the ids of the elements of cell which the liver holds once, its constants; every other element of the extension is one per zone. A shared element is a port of the cell model (which stays loadable alone, with its own value) and an element of the composed model, which replaces the port of every submodel: compose refuses an id which its model does not hold.

expose tuple[str, ...]

the ids of the elements of cell which the liver observes per zone, under <id>_<zone> as the perfusion names its own: a state of the cells which a figure draws or which the liver reads (the formula of the bile secretion of a zone). Every element the engine exposes of itself (a species of the cells, a reaction, the living fraction, the necrosis, the bile) is named without it.

composed Callable[[Model], Model] | None

the extension of the composed model, in place, which returns it; None for a mechanism of the cells alone.

zone_factors

zone_factors(organ)

Get the zonal factors of the processes with a profile, by zone.

Parameters:

Name Type Description Default
organ Organ

the organ.

required

Returns:

Name Type Description
dict[str, dict[str, float]]

The factor n*p/sum(p) of every process with a profile in every

zone `p_<process>_<zone>`

the factors of a profile sum to n, so

dict[str, dict[str, float]]

the zones of 1/n of the volume have the capacity of the organ.

zone_cell_model

zone_cell_model(definition, extension=None)

Get the cell model of the zones of the liver of a definition, None for no liver.

The cell model has the zonal factor of every process with a profile as a port and no bile compartment (the liver of the builder has no bile of the engine), and is named after the model (<sid>_core, the stem of its file), so that the models of two definitions in one folder have a file each.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition.

required
extension PerfusionExtension | None

a mechanism of the cells of a package, applied to the cell model (PerfusionExtension.cell).

None

tracer_ids

tracer_ids(definition, tracer)

Get the ids which a tracer adds to the model of a definition.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition.

required
tracer str

the token of the tracer.

required

Returns:

Type Description
set[str]

The species at every site and mean, the fresh concentration and the

set[str]

flows; in a kidney the urine and the filtration of every zone.

model_ids

model_ids(model)

Get the ids of the compartments, species, parameters and reactions of a model.

compose

compose(definition, extension=None)

Compose the model of a definition.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition.

required
extension PerfusionExtension | None

a mechanism of a package, its cells written into the cell model of the zones and the rest into the composed model (PerfusionExtension).

None

Returns:

Type Description
Model

The model: the circuit, the zones of the organ and the observers.

Raises:

Type Description
ValueError

if the definition is invalid (PerfusionDefinition.validate).

build

build(definition, output_dir, extension=None)

Build a definition: write the SBML model of the circuit.

The model of an organ without submodels is written as <sid>.xml. The liver has the cellular core as a submodel of every zone: the composed model <sid>.xml, the cell model <sid>_core.xml and the flat model, the composition resolved, <sid>_flat.xml (the model which is simulated), by pkpdsim.zonation.composition.write.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition.

required
output_dir Path

the folder of the model.

required
extension PerfusionExtension | None

a mechanism of a package, in the cell model of the zones and in the composed model (PerfusionExtension).

None

Returns:

Type Description
Path

The path of the model which is simulated: <sid>.xml, <sid>_flat.xml

Path

for a liver.

Raises:

Type Description
ValueError

if the definition is invalid or the model has SBML errors (the units included).

experiment

The simulation experiments of a machine perfusion: the condition and the medium changes.

PerfusionSimulationExperiment is the base of the experiments of a perfusion model, a pkpdsim.experiment.PKPDSimulationExperiment with the PerfusionDefinition of the model (definition), from which it takes the ids of the condition and of the medium changes, and the labels and units of the observables (observable_labels, observable_units, by the selection of sbmlsim: [<q>_<site>] the concentration of a species, the id of an assignment rule), which a subclass may replace.

The condition of a simulation is a change before the initialization (perfusion_changes): the pump flow Q_pump, the mass of the organ M_<o> (the volumes of its zones are initial assignments of it) and the temperature T (the Arrhenius factor f_T and the solubility of oxygen are initial assignments of it, so the temperature is a change before the initialization). The temperature of the model is in degC, a unit of the size of a kelvin without the offset (pkpdsim.perfusion.units), so the change is the number of the temperature in degC and not a quantity, which sbmlsim would convert to 310.15 for 37 degC; the initialization of an experiment refuses a simulation which sets T to a quantity (temperature_quantities).

A medium change replaces the fraction f of the perfusate of the reservoir with fresh perfusate: every perfusate species of the reservoir, the quantities of the perfusate which the organ has and the tracers, is set to (1 - f)*[X_res] + f*X_fresh (medium_change), with the fresh perfusate X_fresh of the model (the constants <q>_fresh); a Change of sbmlsim at the time of the change (PerfusionSimulationExperiment.medium_changes), so the model has no events and the times are a setting of the experiment. The change keeps the volume of the reservoir: as much fresh perfusate comes in as perfusate goes out. The reservoir of a kidney, which loses the urine (its volume a state), keeps the volume it has at the change, the urine is not made up. The tubing and the organ are not changed.

sbmlsim evaluates the values of a change with the state at its time and assigns them at once; an output time at the time of a change has two rows, the state before the change and the state after it, and a fit compares a data point at that time with the state before (pkpdsim.fit.default_fit_settings, data_at_change), the sample taken before the medium is changed.

PerfusionSimulationExperiment

PerfusionSimulationExperiment(
    sid=None,
    base_path=None,
    data_path=None,
    ureg=None,
    **kwargs,
)

Bases: PKPDSimulationExperiment

The base of the simulation experiments of a machine perfusion model.

The base of the experiments of a model sets the model object (pkpd_model) and the definition of the model (definition); a class with a definition gets the labels and units of its observables (observable_labels, observable_units) unless it sets its own. The condition of a simulation is perfusion_changes, its medium changes medium_changes, see the module.

Attributes:

Name Type Description
definition PerfusionDefinition

the definition of the model, from which its build is made.

initialize

initialize()

Initialize the experiment and check the temperature of its simulations.

Raises:

Type Description
ValueError

for a simulation which sets the temperature T to a quantity (see temperature_quantities); the runner reports the experiment as failed.

medium_changes classmethod

medium_changes(times, fraction, time_unit='min')

Get the medium changes of the reservoir at times.

Parameters:

Name Type Description Default
times Sequence[float]

the times of the changes.

required
fraction float

the fraction of the reservoir which each change replaces with fresh perfusate, in (0, 1].

required
time_unit str

the unit of the times.

'min'

Returns:

Type Description
list[Change]

One Change per time, every perfusate species of the reservoir

list[Change]

set towards the fresh perfusate (medium_change).

Raises:

Type Description
TypeError

if the experiment has no definition.

ValueError

for a fraction which is not in (0, 1].

perfusion_changes classmethod

perfusion_changes(flow, mass, temperature=None)

Get the condition of a perfusion, the preinit_changes of a simulation.

See the function perfusion_changes: the flow of the pump, the mass of the organ of the definition and the temperature.

Raises:

Type Description
TypeError

if the experiment has no definition.

ValueError

for a value which perfusion_changes refuses.

site_label

site_label(site)

Get the label of a site of the perfusate.

Parameters:

Name Type Description Default
site str

a site of the circuit (res, in, out), a zone (z3) or a mean of the zones (pp, pc).

required

Returns:

Type Description
str

The label, reservoir, inflow, outflow, zone 3, periportal,

str

pericentral.

Raises:

Type Description
KeyError

for another site.

medium_change

medium_change(definition, fraction)

Get the values of a medium change of the reservoir.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the model.

required
fraction float

the fraction of the reservoir which is replaced, in (0, 1].

required

Returns:

Type Description
dict[str, str]

The formula (1 - f)*[X_res] + f*X_fresh by the concentration

dict[str, str]

[X_res] of every perfusate species of the reservoir (the

dict[str, str]

quantities of the perfusate of the organ and the tracers), the values

dict[str, str]

of a Change of sbmlsim.

Raises:

Type Description
ValueError

for a fraction which is not in (0, 1].

perfusion_changes

perfusion_changes(definition, flow, mass, temperature=None)

Get the condition of a perfusion, the changes before the initialization.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the model.

required
flow Quantity

the total flow of the pump, Q_pump (a volume per time, 0 or more).

required
mass Quantity

the mass of the organ, M_<o> (positive).

required
temperature Quantity | None

the temperature, T, in degC, kelvin or any other unit of temperature; None keeps the temperature of the model.

None

Returns:

Type Description
dict[str, Quantity | float]

The flow in l/min and the mass in kg (quantities in the units of the

dict[str, Quantity | float]

model) and the temperature as its number in degC (the unit of T,

dict[str, Quantity | float]

see the module).

Raises:

Type Description
ValueError

for a quantity of another dimension, a negative flow, a mass which is not positive or a temperature below the absolute zero.

temperature_quantities

temperature_quantities(key, simulation)

Get where a simulation sets the temperature T to a quantity.

The temperature of a perfusion model is in degC, a unit of the size of a kelvin without the offset (pkpdsim.perfusion.units), and sbmlsim converts a quantity of a temperature to kelvin, Q(37, "degC") to 310.15, so the temperature is a number in degC (perfusion_changes).

Parameters:

Name Type Description Default
key str

the key of the simulation.

required
simulation object

a Simulation or a Scan (its simulation, the simulations and the values of its dimensions); anything else has no temperature.

required

Returns:

Type Description
list[str]

A text per place which sets T to a quantity: the changes before the

list[str]

initialization, of the presimulation, at a time, of a dimension.

observable_labels

observable_labels(definition)

Get the labels of the observables of a perfusion model, by selection.

The selections are those of roadrunner and sbmlsim: the concentration of a species [<q>_<site>] (the reservoir, the inflow, the zones, the outflow, the cells of a zone [<q>_<zone>_cell]), the amount of a species in the urine <q>_urine (its concentration is 0/0 in the empty urine at the start), the id of an assignment rule (the means <q>_pp, <q>_pc_cell, pO2_<site>, pH_<site>, alt_act_<site>, VO2). Every perfusate quantity, pO2, pCO2, pH and enzyme activity at every site (reservoir, inflow, every zone, outflow, the means periportal and pericentral), the quantities of the cells and the living fraction of every zone and mean, the rate of necrosis of a zone, the oxygen uptake, the bile of a liver and the urine of a kidney.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the model.

required

observable_units

observable_units(definition)

Get the units of the observables of a perfusion model, by selection.

The units of the observables of observable_labels as sbmlsim reads them (concentrations mM, partial pressures kPa, activities µkat/l, the bile and the urine µl and µl/min, the bile per mass µl/g, the amounts in the urine mmole).

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the model.

required

archive

The factory of a machine perfusion model in one call: the files and the COMBINE archive.

A model package builds its PerfusionDefinition with pkpdsim.perfusion.builder.build and writes next to the SBML the differential equations as markdown, the antimony of the model, the figures of the circuit, the two license texts and the COMBINE archive. create_archive does all of it, as pkpdsim.pbpk.archive.create_archive does for a PBPK model: it builds the definition, writes the schematic (pkpdsim.perfusion.figure.circuit_figure) and the organ in its circuit (pkpdsim.perfusion.anatomy.circuit_anatomy_figure), and the rest with the archive writer of sbmlsim, sbmlsim.release.archive.write_archive, which imports sbmlode and pymetadata when it writes. The model of a liver is composed of the cell model of its zones, so the archive ships the three SBML files the build writes: the comp model, the cell model, which stays loadable alone (it is the model a mesh or another architecture couples to), and the flat model, the master entry, which is the model that is simulated. The model of an organ without zones is its own flat model and the only entry. The interactive panels of the model (sbmlsim.panel.Panel, create_archive(..., panels=...)) are an annotation of that model, written before its ODEs, its antimony and the archive are.

create_archive

create_archive(
    definition,
    model_output_dir,
    *,
    model,
    copyright,
    readme=None,
    extension=None,
    panels=None,
)

Build a definition and write its files and the COMBINE archive.

Builds the definition into model_output_dir (<sid>.xml, and for a liver, whose zones are submodels, the cell model <sid>_core.xml and the flat model <sid>_flat.xml), writes the schematic of the circuit there (<sid>.svg, panel B), the anatomical figure of the organ in its circuit (<sid>_anatomy.svg, panel A), the ODEs of the flat model as markdown (<sid>.md, <sid>_flat.md for a liver, sbmlode) and its antimony (<sid>.ant, <sid>_flat.ant), the texts of CC BY-SA 4.0 and MIT (with the copyright) into the parent of the directory and the archive <model>_model.omex there, with the README, the licenses, every model the build writes (the flat model the master entry, and for a liver the comp model and the cell model, which stays loadable alone), the markdown, the antimony and the two figures (the schematic first). The interactive snippet of each figure is written beside it, <sid>.html and <sid>_anatomy.html (pkpdsim.perfusion.figure.interactive_circuit), which a page of the documentation of the model embeds; the snippets are no entry of the archive, which carries the figures as SVG. Every file of the archive lies below the parent of model_output_dir and is located at its path relative to it (./models/<sid>.xml for the directory models of a model package, the licenses ./mit.txt); the README alone is placed as ./README.md. With panels the interactive panels of the model are written into the flat model, the master entry (sbmlsim.panel_sbml.write_panels), before its markdown, its antimony and the archive are written.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the circuit.

required
model_output_dir Path

directory of the model; the licenses and the archive are written into its parent.

required
model str

name of the model, the archive is <model>_model.omex.

required
copyright str

copyright of the MIT license, e.g. 2026 Matthias König.

required
readme Path | None

the README of the model repository, left out of the archive if None.

None
extension PerfusionExtension | None

a mechanism of a package, in the cell model of the zones and in the composed model (pkpdsim.perfusion.PerfusionExtension).

None
panels Sequence[Panel] | None

the interactive panels of the model, the annotation of its flat model; None or none annotates nothing.

None

Returns:

Type Description
dict[str, dict[str, Any]]

The files with their entries in the COMBINE archive, by the keys of a

dict[str, dict[str, Any]]

factory, each {"path": Path, "entry": ManifestEntry}: README (with

dict[str, dict[str, Any]]

a README), cc-by, mit, <sid> of the model (the comp model for a

dict[str, dict[str, Any]]

liver), <sid>_md of its

dict[str, dict[str, Any]]

ODEs, <sid>_ant of its antimony (for a liver <sid>_flat of the flat

dict[str, dict[str, Any]]

model, <sid>_flat_md, <sid>_flat_ant and <sid>_core of the cell

dict[str, dict[str, Any]]

model), <sid>_svg of the schematic and

dict[str, dict[str, Any]]

<sid>_anatomy_svg of the anatomical figure.

Raises:

Type Description
ValueError

for a definition which does not build (build), for panels which repeat an id (before anything is written) and for panels which do not read back from the flat model as they were declared (write_panels).

TypeError

for panels which are no sbmlsim.panel.Panel (before anything is written).

figure

The figure of a machine perfusion: an SVG schematic of a circuit and its organ.

circuit_figure(definition, path) draws a PerfusionDefinition in the language of the figures of the PBPK library (pkpdsim.pbpk.figure: rows with an icon, a title, chips and process badges, monospace text placed by its width at CHAR_WIDTH, data-k keys for the hover cards of an interactive page), as the COMBINE archive of a model carries it (pkpdsim.perfusion.archive.create_archive):

  • the reservoir as a column on the left with a chip of every quantity of the perfusate (circuit.quantities, the tracers included) and its volume;
  • the circuit as rows in series, from the reservoir to the pump (its flow Q_pump), the inflow tubing with the oxygenator (its volume, the oxygen towards its target and the CO2 towards the pCO2 of the sweep gas, the gas as a compartment with O2 in and CO2 out), the organ and the outflow tubing back to the reservoir, the flow as arrows between them;
  • the organ with its grey icon (icons.organ, the generic tissue on a circle for an organ without an icon), its token, mass and zones; the zones as a strip in the order of the flow, from periportal to pericentral in the liver, from arterial to venous in the kidney and a generic organ, each zone with its hover card (zone:<zone>); a chip per quantity of the perfusate, filled where the cells hold it as well (ids.CELL), dashed where it stays in the perfusate (CO2, bicarbonate, the protons, the tracers); the processes of the cellular core of every zone as badges, read from the composed model (process_groups): transport (TRA), metabolism (MET), the redox (ROS), the necrosis and the release (NEC), the zonal profiles (ZON), the bile (BIL) or the filtration into the urine (URI); the bile of the liver or the urine of the kidney (with the filtered quantities) as a compartment at the right end of the row;
  • the temperature in the band above the rows, the legend (the title, the quantities of the perfusate with their fresh composition, the key of the chips and badges) in a column right of the diagram.

The figure is pure python and deterministic: the same definition gives the same text. The anatomical figure of the organ in its circuit (panel A) is pkpdsim.perfusion.anatomy. interactive_circuit writes the self-contained page of either figure with the hover cards of circuit_cards (volumes, flow, temperature, the processes of the core per zone, the released enzymes, the tracers) through pkpdsim.pbpk.visual.interactive.html_page.

BADGES module-attribute

BADGES = {
    "FLO": ("pump flow", "#eef6ff", "#0969da"),
    "OXY": ("oxygenator", "#e7f7f9", "#0e7c86"),
    "TRA": _BADGES["TRA"],
    "MET": _BADGES["MET"],
    "ROS": ("redox", "#fff0f6", "#bf3989"),
    "NEC": ("necrosis and release", "#fbe9e9", "#a40e26"),
    "ZON": ("zonal profile", "#f3f0ff", "#6639ba"),
    "BIL": _BADGES["BIL"],
    "URI": _BADGES["URI"],
}

The badges of the circuit and of the core, in the order of the key: the label of the key, fill and stroke (those of the PBPK library for its codes).

LIBRARY module-attribute

LIBRARY = (
    "https://matthiaskoenig.github.io/pkpdsim/perfusion/"
)

The docs page of the machine perfusion library, which its figures credit.

CREDIT module-attribute

CREDIT = figure_credit(
    "anatomy",
    library="machine perfusion library",
    url=LIBRARY,
)

The credit of the anatomical figure A of a circuit, for its legend (HTML): pkpdsim, the machine perfusion library and the anatomograms of its organ.

ICON_CREDIT module-attribute

ICON_CREDIT = figure_credit(
    "organ icons",
    library="machine perfusion library",
    url=LIBRARY,
)

The credit of the schematic B of a circuit, for its legend (HTML): its organ icons are the shapes of the anatomograms.

process_groups

process_groups(definition)

Get the reactions of the cells of a zone by the badge of their line.

The reactions are those of the first zone of the composed model (builder.compose), so the figure shows what the model has.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition.

required

Returns:

Type Description
dict[str, list[tuple[str, str]]]

The id (without the zone) and the name (without the zone) of every

dict[str, list[tuple[str, str]]]

reaction of the cells by badge: TRA, MET, ROS, NEC (the

dict[str, list[tuple[str, str]]]

death of the cells and the release of every released quantity) and,

dict[str, list[tuple[str, str]]]

for a kidney, URI (the filtration of every filtered quantity).

circuit_svg

circuit_svg(definition)

Get the SVG of the figure of a definition (see the module).

The figure is drawn twice: once wide to measure its content, then at the width the content needs.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the circuit.

required

Returns:

Type Description
str

The SVG, deterministic.

Raises:

Type Description
ValueError

for an invalid definition (PerfusionDefinition.validate).

circuit_figure

circuit_figure(definition, path)

Write the figure of a definition, an SVG schematic of the circuit.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the circuit.

required
path Path

the SVG file to write.

required

Returns:

Type Description
Path

The path of the figure.

Raises:

Type Description
ValueError

for an invalid definition (PerfusionDefinition.validate).

circuit_cards

circuit_cards(definition)

Get the hover cards of the figure of a definition by key, each a list of HTML lines.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the circuit.

required

Returns:

Type Description
dict[str, list[str]]

The cards of the reservoir, the pump, the inflow tubing and its

dict[str, list[str]]

sweep gas, the organ, every zone (zone:<zone>), the outflow

dict[str, list[str]]

tubing, every quantity of the perfusate (sub:<q>), the bile or the

dict[str, list[str]]

urine and the temperature.

Raises:

Type Description
ValueError

for an invalid definition (PerfusionDefinition.validate).

interactive_circuit

interactive_circuit(
    definition, path, *, figure="anatomy", snippet=False
)

Write the interactive page or snippet of a figure of a definition.

A figure with its hover cards, one self-contained HTML file (pkpdsim.pbpk.visual.interactive.html_page), which posts its height to the docs page which embeds it, or the snippet which a page embeds as it is (pkpdsim.pbpk.visual.interactive.html_snippet); the keywords and their defaults are those of pkpdsim.pbpk.visual.interactive.interactive_figure.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the circuit.

required
path Path

the HTML file to write.

required
figure str

anatomy (panel A, the organ in its circuit, pkpdsim.perfusion.anatomy.circuit_anatomy_svg, the default) or schematic (panel B, circuit_svg).

'anatomy'
snippet bool

write the snippet of the figure, the <div> which a page embeds, under the id pkf-<sid>-<figure>, instead of a whole page.

False

Returns:

Type Description
Path

The path of the file.

Raises:

Type Description
ValueError

for another figure or an invalid definition (PerfusionDefinition.validate).

anatomy

The anatomical figure of a machine perfusion: the organ in its circuit (panel A).

circuit_anatomy_figure(definition, path) draws the mounted organ and the apparatus around it, the companion of the schematic of pkpdsim.perfusion.figure (panel B), in the language of the anatomical figure of the PBPK library (pkpdsim.pbpk.visual.anatomy: the organ in its drawn form and tissue colour, circled grey icons, label columns with leader lines, the chips of the quantities):

  • in the middle the organ, large, its shape from the anatomy resources of the PBPK library (resources.anatomy("human", "male"), the human shape for every species as the PBPK figures of the animals have it; one kidney of the two, the largest part of a shape of several parts) in its colour of palette.ORGAN_COLORS, an organ without a shape as a neutral rounded shape;
  • the circuit as apparatus: the reservoir as a vessel with its perfusate, the pump, the oxygenator with the O2 of the sweep gas in and the CO2 out, the inflow tubing into the inflow of the organ (the portal vein of the liver, the renal artery of the kidney), the outflow (the hepatic vein, the renal vein) through the outflow tubing back into the reservoir, the flow as arrows, the bile duct into the bile collector of the liver or the ureter into the urine collector of the kidney, and the medium change as dashed arrows into and out of the reservoir;
  • two label columns, the apparatus on the left (right-aligned), the organ and its collector on the right, each label with its circled grey icon and a leader line: the reservoir with the chips of the perfusate, the pump, the oxygenator with its gases, the temperature, the organ with its chips (filled where the cells hold the quantity as well, dashed where it stays in the perfusate) and the inset of its zones, a strip in the order of the flow (from periportal to pericentral along the sinusoid of the liver; the zones of another organ when it has more than one), each zone a hover key zone:<zone>; the key of the lines and chips at the bottom.

Every text is monospace and start-anchored with its font size (the _Canvas.text of the PBPK schematic), so the label checks of the figures apply; the hover cards are figure.circuit_cards and the card of the medium change (anatomy_cards). Pure python and deterministic.

NEUTRAL module-attribute

NEUTRAL = '#d9d4cf'

The colour of an organ without a colour of the PBPK figures.

anatomy_cards

anatomy_cards(definition)

Get the hover cards of the anatomical figure by key, each a list of HTML lines.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the circuit.

required

Returns:

Type Description
dict[str, list[str]]

The cards of figure.circuit_cards and the card of the medium change

dict[str, list[str]]

(medium).

Raises:

Type Description
ValueError

for an invalid definition (PerfusionDefinition.validate).

circuit_anatomy_svg

circuit_anatomy_svg(definition)

Get the SVG of the anatomical figure of a definition (see the module).

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the circuit.

required

Returns:

Type Description
str

The SVG, deterministic.

Raises:

Type Description
ValueError

for an invalid definition (PerfusionDefinition.validate).

circuit_anatomy_figure

circuit_anatomy_figure(definition, path)

Write the anatomical figure of a definition, the organ in its circuit.

Parameters:

Name Type Description Default
definition PerfusionDefinition

the definition of the circuit.

required
path Path

the SVG file to write.

required

Returns:

Type Description
Path

The path of the figure.

Raises:

Type Description
ValueError

for an invalid definition (PerfusionDefinition.validate).

ids

The id scheme of the machine perfusion models.

Every id of a perfusion model is built here, so that the cellular core, the circuit and the observers agree on them.

A quantity at a site is <quantity>_<site> (species): the site of the vascular space of a zone is the zone (glc_z3, the glucose of the perfusate in the sinusoids of zone 3), the cells of a zone are the site <zone>_cell (cell_site, atp_z3_cell) and the necrotic cells of a zone the site <zone>_dead (dead_site, alt_z3_dead, the ALT which a dead cell has not released yet). A quantity which exists in the perfusate and in the cells (glucose, oxygen, lactate, potassium, the enzymes) has the same quantity token at both sites. The sites of the circuit are the reservoir res, the inflow tubing in (after the oxygenator, before the organ) and the outflow tubing out (after the organ); the periportal and pericentral means of the zones are the sites pp and pc (pp_cell for the cells), so every quantity of a zone has its means under the same pattern (glc_pp, atp_pc_cell, pO2_pc). The volume of a site is V_<site> (volume); the compartments of a zone are named by the engine which builds it, the vascular space of a zone V_vas_<zone> and its cells V_cell_<zone> (pkpdsim.zonation.ids).

The reactions and rules of the core of a zone carry the zone as suffix, <name>_<zone> (OXPHOS_z3, v_nec_z3). The constants of the core are shared by the zones and are ids of the whole model under their name (GLC2PYR_Vmax), as the constants of the perfusate (the bicarbonate buffer) and the temperature factor F_T; a zonal profile of a process is the factor p_<process>_<zone> (profile), the pattern of the zonated liver of the PBPK library.

The cells release the quantities of RELEASABLE; an organ releases a subset of them (released, the liver ALT, AST, LDH and potassium, the kidney and a generic organ LDH and potassium), and the enzymes of the perfusate and the cells are the released ones (perfusate_quantities, cell_quantities). The kidney filters the small solutes of the perfusate (FILTERED) and the tracers into the urine, the site urine (URINE_SITE) of the amounts <q>_urine in the urine volume V_urine; the filtration of a quantity in a zone is the reaction FILT_<q>_<zone> (filtration), the GFR of the organ GFR_<organ> (gfr), its GFR at an ample flow GFR_max_<organ> (gfr_max), its maximal filtration fraction FF_max_<organ> (ff_max), its GFR per mass gfr_<organ> (gfr_specific) and the reabsorbed fraction f_reab_<organ> (reabsorption); the water which leaves a site is Q_<site> (outflow) where it is not the pump flow.

The zone token and the reaction of a flow between two sites are the zonation engine's (pkpdsim.zonation.ids.is_zone, flow), which this module re-exports: the engine names the flows of the chain of zones of an organ and this module the flows of the circuit, with the same function, so the two agree. The engine is the lower layer, so its ids are imported here directly.

F_T module-attribute

F_T = 'f_T'

The temperature factor of the rates (dimensionless, 1 at the reference temperature), defined by the circuit (an Arrhenius initial assignment of the temperature) and read by the rate laws of the core.

TEMPERATURE module-attribute

TEMPERATURE = 'T'

The temperature of the perfusion (degC), a constant which an experiment changes.

TEMPERATURE_REF module-attribute

TEMPERATURE_REF = 'T_ref'

The reference temperature of the Arrhenius factor (degC).

ACTIVATION_ENERGY module-attribute

ACTIVATION_ENERGY = 'Ea'

The activation energy of the rates (J/mole).

GAS_CONSTANT module-attribute

GAS_CONSTANT = 'R_gas'

The molar gas constant (J/mole/K).

SOLUBILITY module-attribute

SOLUBILITY = 'alpha_o2'

The solubility of oxygen in the perfusate at the temperature (mM/kPa), the initial assignment of T.

SOLUBILITY_REF module-attribute

SOLUBILITY_REF = 'alpha_o2_ref'

The solubility of oxygen at T_alpha_o2 (mM/kPa).

SOLUBILITY_TEMPERATURE module-attribute

SOLUBILITY_TEMPERATURE = 'T_alpha_o2'

The temperature of alpha_o2_ref (degC).

SOLUBILITY_COEFFICIENT module-attribute

SOLUBILITY_COEFFICIENT = 'k_alpha_o2'

The relative change of the solubility of oxygen per K (1/K).

Q_PUMP module-attribute

Q_PUMP = 'Q_pump'

The total flow of the pump (l/min).

O2_TARGET module-attribute

O2_TARGET = 'pO2_target'

The oxygen partial pressure which the oxygenator sets (kPa).

OXYGENATOR_K module-attribute

OXYGENATOR_K = 'k_oxy'

The first order rate constant of the oxygenation of the inflow (1/min).

OXYGENATOR module-attribute

OXYGENATOR = 'OXY_in'

The reaction of the oxygenator, which sets the oxygen of the inflow.

CO2_SOLUBILITY module-attribute

CO2_SOLUBILITY = 'alpha_co2'

The solubility of CO2 in the perfusate (mM/kPa).

CO2_GAS module-attribute

CO2_GAS = 'pCO2_gas'

The partial pressure of CO2 of the sweep gas of the oxygenator (kPa).

OXYGENATOR_K_CO2 module-attribute

OXYGENATOR_K_CO2 = 'k_oxy_co2'

The first order rate constant of the exchange of CO2 with the gas (1/min).

OXYGENATOR_CO2 module-attribute

OXYGENATOR_CO2 = 'OXY_co2_in'

The reaction of the oxygenator, which sets the CO2 of the inflow.

BILE module-attribute

BILE = 'bile'

The volume of the bile of the organ (µl), an assignment rule: the sum of the bile volumes of the zones, the states Vbile_<zone> (l).

BILE_RATE module-attribute

BILE_RATE = 'bile_rate'

The bile secretion of the organ (µl/min), an assignment rule.

BILE_PER_MASS module-attribute

BILE_PER_MASS = 'bile_per_mass'

The volume of the bile per gram of the organ (µl/g), an assignment rule, the unit of the data.

VO2 module-attribute

VO2 = 'VO2'

The oxygen uptake of the organ from the perfusate (mmole/min).

RESERVOIR module-attribute

RESERVOIR = 'res'

The site of the reservoir.

INFLOW module-attribute

INFLOW = 'in'

The site of the inflow tubing, after the oxygenator and before the organ.

OUTFLOW module-attribute

OUTFLOW = 'out'

The site of the outflow tubing, after the organ and before the reservoir.

PERIPORTAL module-attribute

PERIPORTAL = 'pp'

The site of the periportal mean of the zones (the first third of the sinusoid).

PERICENTRAL module-attribute

PERICENTRAL = 'pc'

The site of the pericentral mean of the zones (the last third of the sinusoid).

ENZYMES module-attribute

ENZYMES = ('alt', 'ast', 'ldh')

The enzymes of the perfusate, whose catalytic activity is observed.

BUFFER_KA module-attribute

BUFFER_KA = 'Ka_hco3'

The apparent dissociation constant of the bicarbonate buffer (mM), [H+]*[HCO3-]/[CO2], a constant of the perfusate.

BUFFER_K_HYDRATION module-attribute

BUFFER_K_HYDRATION = 'k_co2'

The rate constant of the hydration of CO2 (1/min), a constant of the perfusate.

PERFUSATE module-attribute

PERFUSATE = (
    "glc",
    "o2",
    "lac",
    "co2",
    "hco3",
    "h",
    "k",
    "alt",
    "ast",
    "ldh",
)

The quantities of the perfusate at every site: glucose, oxygen, lactate, dissolved CO2, bicarbonate, free protons, potassium and the enzymes ALT, AST and LDH (in mM).

CELL module-attribute

CELL = (
    "glc",
    "glyc",
    "o2",
    "pyr",
    "lac",
    "atp",
    "adp",
    "nad",
    "nadh",
    "nadp",
    "nadph",
    "ros",
    "gsh",
    "gssg",
    "k",
    "alt",
    "ast",
    "ldh",
)

The quantities of the cells of a zone (in mmole per l of cells); glyc is glycogen in glucosyl units, ros the reactive oxygen species as H2O2 equivalents.

RELEASABLE module-attribute

RELEASABLE = ('alt', 'ast', 'ldh', 'k')

The quantities which necrotic cells may release into the vascular space; an organ releases a subset of them, each with its content in the cells.

FILTERED module-attribute

FILTERED = ('glc', 'o2', 'lac', 'co2', 'hco3', 'h', 'k')

The small solutes of the perfusate, which the kidney filters with the water (the enzymes are not filtered).

URINE module-attribute

URINE = 'urine'

The urine volume of the organ (µl), an assignment rule.

URINE_RATE module-attribute

URINE_RATE = 'urine_rate'

The urine flow of the organ (µl/min), an assignment rule.

URINE_SITE module-attribute

URINE_SITE = 'urine'

The site of the urine, the amounts <q>_urine in the volume V_urine.

Q_URINE module-attribute

Q_URINE = 'Q_urine'

The net urine flow of the organ (l/min), the filtrate which the tubules do not reabsorb.

LIVER module-attribute

LIVER = 'li'

The token of the liver, the organ whose zones the zonation engine builds.

flow

flow(quantity, source, target)

Get the reaction of the flow of a quantity between two sites.

The vascular space of a zone is the site vas_<zone> of the engine.

is_zone

is_zone(zone)

Check whether a text is a zone id (z1, z12).

perfusate_quantities

perfusate_quantities(released)

Get the quantities of the perfusate of an organ which releases released.

Parameters:

Name Type Description Default
released tuple[str, ...]

the released quantities of the organ (of RELEASABLE).

required

Returns:

Type Description
str

The quantities of PERFUSATE without the enzymes the organ does not

...

release.

cell_quantities

cell_quantities(released)

Get the quantities of the cells of an organ which releases released.

Parameters:

Name Type Description Default
released tuple[str, ...]

the released quantities of the organ (of RELEASABLE).

required

Returns:

Type Description
str

The quantities of CELL without the enzymes the organ does not

...

release.

zone_id

zone_id(k)

Get the id of a zone of an organ.

Parameters:

Name Type Description Default
k int

the number of the zone, from 1 (periportal) to n (pericentral).

required

Returns:

Type Description
str

The zone id, z<k>.

Raises:

Type Description
ValueError

if k is smaller than 1.

species

species(quantity, site)

Get the id of a quantity at a site, <quantity>_<site>.

The vascular space of a zone is the vascular site of the engine, <quantity>_vas_<zone>. The cells of a zone are <quantity>_<zone>_cell (<quantity>_<zone>_dead for the necrotic cells); the other sites are <quantity>_<site>. These are the ids of the flat model, whether the cells of a zone are the cell model of a submodel or not: the liver exposes them (pkpdsim.zonation.composition.compose(expose=)).

Parameters:

Name Type Description Default
quantity str

the quantity token (glc, o2, atp).

required
site str

the site (res, the zone z3 for its vascular space, the cells z3_cell).

required

Returns:

Type Description
str

The id of the species.

cell_site

cell_site(zone)

Get the site of the living cells of a zone, <zone>_cell.

dead_site

dead_site(zone)

Get the site of the necrotic cells of a zone, <zone>_dead.

profile

profile(process, zone)

Get the id of the zonal factor of a process, p_<process>_<zone>.

reaction

reaction(name, zone)

Get the id of a reaction of the core of a zone, <name>_<zone>.

buffer

buffer(site)

Get the id of the bicarbonate buffer reaction at a site, BUF_<site>.

alive

alive(zone)

Get the id of the living fraction of the cells of a zone, f_alive_<zone>.

necrosis_rate

necrosis_rate(zone)

Get the id of the rate of necrosis of the cells of a zone (1/min), v_nec_<zone>.

bile

bile(zone)

Get the id of the volume of bile which a zone has secreted (l), Vbile_<zone>.

volume

volume(site)

Get the volume of the perfusate at a site, V_<site> or V_vas_<zone>.

vascular

vascular(zone)

Get the compartment of the vascular space of a zone, V_vas_<zone>.

cells

cells(zone)

Get the compartment of the cells of a zone, V_cell_<zone>.

mass

mass(organ)

Get the mass of an organ (kg), M_<organ>.

density

density(organ)

Get the density of an organ (kg/l), rho_<organ>.

organ_volume

organ_volume(organ)

Get the volume of an organ (l), V_<organ>.

vascular_fraction

vascular_fraction(organ)

Get the vascular fraction of the volume of an organ, f_vas_<organ>.

The liver is the one of the engine, f_vas.

cell_fraction

cell_fraction(organ)

Get the cell fraction of the volume of an organ, f_cell_<organ>.

The liver is the one of the engine, f_cell.

gfr

gfr(organ)

Get the glomerular filtration rate of an organ (l/min), GFR_<organ>.

gfr_max

gfr_max(organ)

Get the GFR of an organ at an ample flow (l/min), GFR_max_<organ>.

ff_max

ff_max(organ)

Get the maximal filtration fraction of the flow of an organ, FF_max_<organ>.

gfr_specific

gfr_specific(organ)

Get the GFR per mass of an organ (l/min/kg = ml/min/g), gfr_<organ>.

reabsorption

reabsorption(organ)

Get the reabsorbed fraction of the filtrate of an organ, f_reab_<organ>.

filtration

filtration(quantity, zone)

Get the reaction of the net filtration of a quantity of a zone into the urine.

outflow

outflow(site)

Get the flow of the perfusate out of a site (l/min), Q_<site>.

start

start(quantity)

Get the start of a quantity of the cells, <q>_start (mM), shared by the zones.

fresh

fresh(quantity)

Get the concentration of a quantity in the fresh perfusate, <q>_fresh.

po2

po2(site)

Get the oxygen partial pressure of the perfusate at a site (kPa).

pco2

pco2(site)

Get the CO2 partial pressure of the perfusate at a site (kPa).

activity

activity(enzyme, site)

Get the catalytic activity of an enzyme at a site (µkat/l).

specific_activity

specific_activity(enzyme)

Get the specific activity of an enzyme (µkat/mmole), a_<enzyme>.

ph

ph(site)

Get the id of the pH of the perfusate at a site, pH_<site>.

units

PU, the units of every perfusion model, is the kit's OrganUnits under the name this library has always called it by, documented at sbml; pkpdsim.perfusion.units re-exports it and keeps the import path of the library. CoreObjects of the core above is the kit's SbmlObjects the same way.