Skip to main content

pkpdsim: PBPK/PD models in SBML using python

GitHub Actions CI/CD Status Documentation Version Python Versions MIT License DOI

pkpdsim is a library for physiologically based pharmacokinetic and pharmacodynamic (PBPK/PD) models in SBML: a standard physiology at its centre, the substances, chemistry, routes and observers of a model on top of it, and the simulation experiments, fits, scans, uncertainty and credibility of sbmlsim on top of those. A model package writes one definition of what is specific to its substances; the library adds the body and writes the SBML with the factory of sbmlutils, a comp model with one submodel per organ and the flat model which is simulated. The models of pkdb_models are being rebuilt from it, each in a repository of its own.

The anatomical figure of a PBPK model of glimepiride built with pkpdsim

The anatomical figure of the glimepiride-like model of the tutorial, generated from its definition: the male and the female build with the organs sized by their volumes, the substances of every organ, the submodels of the liver and the kidney, the routes and the blood sample. The interactive figure shows the details of every element on hover.

Features

The physiology

  • the standard physiology - the reference individual of ICRP 89 per sex and the covariates of an individual (BW, HEIGHT, AGE), from which the organ masses and volumes, the blood volume, the cardiac output, the blood flows and the GFR follow, from the newborn to 100 years, see the physiology
  • species and populations - the same definition on the physiology of the rat, the mouse or the pig, and the virtual populations drawn over age from the distributions of NHANES
  • impaired organ function - liver cirrhosis, chronic kidney disease and heart failure as parameter vectors on the physiology, never a structurally different model, by the clinical classes the studies report (Child-Pugh, the GFR categories of CKD, NYHA)
  • pregnancy, circadian rhythms and obesity - the physiology over the gestational age with the fetoplacental unit, the clock time of a model for chronopharmacokinetics, and the adipose tissue of an individual with its visceral and subcutaneous depots
  • organs and their variants - the four-compartment standard organ of PK-Sim (plasma, blood cells, interstitial and intracellular space), of which only the parts a substance needs are built, and the variants behind the same boundary: the zonated liver from periportal to pericentral, the nephron kidney with filtration, secretion and reabsorption, and the segmented intestine with dissolution, regional absorption and bile; swapping a variant changes nothing outside the organ
  • tissue and perfusion - the zonated liver of n zones with flow and diffusion along the sinusoid, and the SBML of an ex vivo machine perfusion circuit with one mounted organ from a definition, as the library builds a body: the reservoir, the tubing, the pump, the oxygenator, the temperature, the perfusate and the organ as a chain of zones with the cellular core, the liver with its bile and the kidney with its filtration and urine

The building blocks

  • model building - build(definition, output_dir) validates a definition and composes the whole-body model: a top model with the physiology, the blood pools, the substances, the sinks, the dose states and the observers, and one comp submodel per organ, written as the comp model <sid>.xml and the flat model which is simulated. Every port and every replacement is generated; a model package never writes a ReplacedElement and restates no equation of the library
  • substances and chemistry - a substance is a molecular weight and the mechanism flags which decide the equations built for it (binding to plasma proteins, erythrocytes, distribution, excretion, an endogenous baseline, a slow pool, inhibition and induction), and its chemistry is written once per organ and placed into the parts of whatever variant the organ uses; the steady state of a declared process is generated, so an endogenous substance starts stationary
  • routes and the intestine - the intravenous, oral tablet and oral solution routes, the lumen segments with their dissolution and absorption, the mucosa, the bile and the enterohepatic circulation
  • observers - the sampling sites of a study as assignment rules which conserve mass exactly: the arm vein of a blood sample, the hepatic vein, the free and the blood concentrations, the amount in urine, the readouts of the intestine (the absorbed fraction and the rates of a dose), the changes against the start and the observers a definition adds for its own readouts and PD components
  • annotation and templates - every compartment, species, parameter and reaction carries an SBO term and the ontology terms of what it is and where it is (FMA, BTO, NCIT, UBERON, GO, PBPKO), and the creators and terms of use of a model travel with it, with the license texts of its COMBINE archive
  • figures - the anatomical figure of the male and the female build, the schematic of the circulation, the one-page figure of a publication, the bodies of individuals and the pictograms of the impaired organs, all generated from the definition, pure python, SVG and deterministic, with an interactive page of each for the web
  • the parameter database - every number the libraries are built from with the publication it is taken from, its unit, its uncertainty and a remark, as tables next to the data of the studies they are integrated from; a number a library chooses where the literature gives none says so, and the uncertainty is written into the SBML as a distrib uncertainty of the parameter

The analysis

  • experiments and their metadata - the base class of the experiments of a model, a published study as code: the study data of PK-DB collected into the model, the dosing protocol as simulations, the data paired with the observables, the initial values which remove the distribution kinetics, the timecourses in parts, the presets of the impaired organ function and the vocabulary which describes a fit mapping
  • fits, identifiability and uncertainty - the fit of a parameter subset with its identifiability (profile likelihood, Fisher information), the adopted fits whose values the factory takes and whose confidence intervals become the distrib uncertainties of the SBML parameters, and the run of every experiment over draws of the fitted parameters with uncertainty bands
  • scans and sensitivity analyses - the PK observables of a non-compartmental analysis, the parameters of a model of the library and the local, sampling, FAST and Sobol analyses on the runner of sbmlsim, per sex and from the drug-free steady state of a condition
  • context of use and credibility - what a model is credible for, declared and assessed in the frame of ASME V&V 40: the contexts of use C1 to C5 with their quantities of interest, domains and evidence, the ratios of a special population, the temporal validation, the verification, the predictive check, the lock, the report and the scorecard
  • models and their commands - the model object of a package and the commands which work with every model package, the dotted name of the package as their first argument (run_simulation, run_fit, run_report, run_identifiability, run_credibility), the tests of a model as functions and the verification of a change, also across versions of sbmlsim (pkpdsim-verify)
  • release of a model repository - pkpd_release makes the complete release of the repository of a model (models, simulations, fit reports, release notes, docs, Docker image, GitHub release) from its package, with --no-publish for a review before the commit

The documentation is available at https://matthiaskoenig.github.io/pkpdsim, where the PBPK library links every component of the three layers; the tutorial builds a PBPK model from its definition step by step.

If you have any questions or issues please open an issue.

Quickstart

A definition of what is specific to the substance, and the library writes the whole-body model: the organs with their volumes and blood flows, the oral route, the kidney which clears the drug and the observers it is read at. The numbers are illustrative.

from pathlib import Path
from tempfile import mkdtemp

from sbmlsim.model.model_roadrunner import load_roadrunner

from pkpdsim.pbpk import Binding, Excretion, Kp, PBPKDefinition, Route, Substance, build

# what is specific to the substance: an oral drug which the kidney clears
definition = PBPKDefinition(
    sid="drg_body",
    substances=[
        Substance(
            "drg",
            name="drug",
            mr=450.0,
            binding=Binding(fu=0.1, protein="albumin"),
            distribution=Kp(1.5, ftissue=5.0),
            excretion=Excretion(urine=True),
        )
    ],
    routes=[Route.oral("drg")],
)

# the library adds the physiology, the organs, the routes and the observers
model = build(definition, Path(mkdtemp()))

r = load_roadrunner(model.flat_path)
r.timeCourseSelections = ["time", "Carm_drg"]
r["PODOSE_drg"] = 10.0  # mg
s = r.simulate(0, 24 * 60, 1441)  # min

carm = 1000 * s["Carm_drg"]  # µM
print(f"BW {r['BW']:.0f} kg, Vli {r['Vli']:.2f} l, Qh {r['Qh']:.2f} l/min")
print(f"Cmax {carm.max():.3f} µM, C(24 h) {carm[-1]:.3f} µM")
BW 73 kg, Vli 2.33 l, Qh 1.79 l/min
Cmax 0.445 µM, C(24 h) 0.169 µM

The tutorial builds such a model step by step and adds what this example leaves out: the hepatic chemistry with its metabolites, the individual of a study, the impairment of an organ and the figures of the model. Every page of the documentation describes its part with a snippet which runs.

How to cite

DOI

If you use pkpdsim please cite the archived software on Zenodo:

König, M. (2026). pkpdsim: building blocks of physiologically based pharmacokinetic and pharmacodynamic models in SBML (Version 0.23.0) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.23297325

@software{konig_pkpdsim,
  author    = {König, Matthias},
  title     = {pkpdsim: building blocks of physiologically based pharmacokinetic and pharmacodynamic models in SBML},
  year      = {2026},
  month     = nov,
  version   = {0.23.0},
  publisher = {Zenodo},
  doi       = {10.5281/zenodo.23297325},
  url       = {https://doi.org/10.5281/zenodo.23297325},
}

Installation

pkpdsim requires python >= 3.14, simulates with sbmlsim 0.22 (sbmlsim>=0.22.0, installed with it) and is available from pypi. sbmlsim needs a build of the develop branch of libroadrunner, which the package index roadrunner-wheels serves, see Installation:

uv add pkpdsim

or with pip

pip install pkpdsim

See Installation for details and Development for working on the repository.

License

Funding

Matthias König is supported by the German Research Foundation (DFG) within the Research Unit Programme FOR 5151 "QuaLiPerF (Quantifying Liver Perfusion-Function Relationship in Complex Resection - A Systems Medicine Approach)" by grant number 436883643 and by grant number 465194077 (Priority Programme SPP 2311, Subproject SimLivA).

Matthias König was supported by the Federal Ministry of Education and Research (BMBF, Germany) within the research network Systems Medicine of the Liver (LiSyM, grant number 031L0054).

© 2026 Matthias König.

Metadata

Release files for pkpdsim 0.26.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pkpdsim 0.26.0
File Size Uploaded Provenance Actions
pkpdsim-0.26.0.tar.gz 4.9 MB With provenance Details for pkpdsim-0.26.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pkpdsim 0.26.0
File Interpreter ABI Platform Actions
pkpdsim-0.26.0-py3-none-any.whl Python 3 none any Details for pkpdsim-0.26.0-py3-none-any.whl

Total release size: 6.0 MB

Release files / pkpdsim-0.26.0.tar.gz

Download URL pkpdsim-0.26.0.tar.gz
Size 4.9 MB
Tags Source
SHA-256 checksum
How to use checksums
eb95139098080e0defbd271ffae92238421d52a31f4dcfbc675e20faa7be1138
BLAKE2b-256 checksum
How to use checksums
7c30425d7ed717c7edb64c181065d31bb0aff9155b10a8824aab9f9aeb72cf8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / pkpdsim-0.26.0-py3-none-any.whl

Download URL pkpdsim-0.26.0-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
159821e316dc9f530ad2e1de779a90ac8c43613cce58ed239b2af603a1544db1
BLAKE2b-256 checksum
How to use checksums
8df4c68635ed1925b10d8b0a71446cc0d3e2ae67d17f6770f6d02cb046ae7e39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for pkpdsim 0.26.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pkpdsim-0.26.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.26.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page