Modeling Pharmacology - CVUT 2026 presentation
Created by Tomas Kulhanek
pharmacolibrary
#modelica, #pharmacolibrary

Modeling Pharmacology
Tomáš Kulhánek, Ph.D.
VITO, 1.LF UK
Filip Ježek, Ph.D.
Univ of Michigan, 1.LFUK
Agenda seminar:
00:00 - interactive intro - do it yourself
3 patients - same diagnosis, same pharmacotherapy, but ...



find optimal dose for each of them, continue at:
https://digital-biosystems.github.io/pharma/
and do Patient1, Patient2 and Patient 3 - not Patient 4
equation models and basic simulation, pharmacokinetics of gentamicin, dose adjustment / change regimen, caffeine → effect
Agenda lecture: Pharmacokinetics, PHarmacodynamics, Pharmacogenomics
Try patient 4: https://digital-biosystems.github.io/pharma/
PRIBE - personal reference intervals

RAIDO

DigiTwin4PH - PGx digital twin

VITO
Flemish Institute for Technological Research
Mol, Belgium
Environmental unit
Digital Precision Health group

ONCOSCREEN

Pharmacology
Pharmacokinetics (PK) body → drug
Pharmacodynamics (PD) drug → body
Pharmacogenomics (PGx) genetics→drug&body
pharmacokinetics(PK): body → drug
Administration(absorption), Distribution, Metabolism, Elimination(excretion)
observation - concentration of a drug during time among different patients

1-compartment PK model

or derivative form:


2-compartment PK model



3-compartment PK model

standard Modelica language


Commercial tools:
Dymola,

, …
Open-source:

software engineering principles in mathematical modeling
can write equations

can plug & play with well defined components
why Modelica?
model of complex system may lead to implementation errors

A C Guyton, T G Coleman, H J Granger, Circulation: overall regulation, Annu Rev Physiol.1972;34:13-46.doi: 10.1146/annurev.ph.34.030172.000305.
Correction of schema after reimplementation in 2010

J.Kofránek, et al., Restoration of Guyton‘s Diagram for Regulation of the Circulation ...Physiol Res. 2010;59(6):897-908.doi: 10.33549/physiolres.931838.
Guyton's original scheme part of circulatory dynamics

equivalent implementation in component and acausal modeling language

.
Frank-Starling law is much more visible in component model - "force of the heart muscle depends on pressure of incoming blood".
small models - equation based

Readability & Plausability
medium/complex models- composition of smaller models as components (icons) in diagrams

pk1
model pk1
Real C;
Real M(start=dosage);
parameter Real dosage = 400 / 1000000;
parameter Real Vd = 17.5 / 1000;
parameter Real Cl = 0.1 / 1000 / 60 ;
parameter Real MIC = 2 / 1000000 * 1000; //mg/l -> kg/m3
equation
C = M / Vd;
der(M) = -Cl * C;
end pk1;
pk2
model pk2
Real C;
Real M(start=dosage);
parameter Real dosage = 500 / 1000000;
parameter Real t1 = 8 * 3600; //hour -> seconds
parameter Real Vd = 17.5 / 1000;
parameter Real Cl = 0.1 / 1000 / 60 ;
parameter Real MIC = 2 / 1000000 * 1000; //mg/l -> kg/m3
equation
C = M / Vd;
der(M) = -Cl * C;
when sample(t1,t1) then
reinit(M,pre(M)+dosage);
end when;
end pk2;
seminar task 1
create pharmacokinetic model pk1 of gentamicin (1 dosage=400mg, Vd=17.5 l, Cl=0.1 l/min)
- one dosage - simulate 24h (86400 s)
- create copy pk2 with dosage every 8 hours
- what regimen/dosage lead the C > MIC (2mg/l) during treatment
- simulate 10 days of treatment (864 000 s)
pk2
dosage> 400mg - e.g. 500
t1 = 8 hours
standard Modelica library 4.0.0

custom libraries for specific domains

Physiolibrary - for modeling physiology (v1.0.0 won 1st library award at Modelica conference, Lund, 2014)
Mateják, M. (2023, December). Creating cardiovascular and respiratory models using Physiolibrary 3.0. In Modelica Conferences (pp. 463-468). https://doi.org/10.3384/ecp204463

Chemical - for modeling chemical processes (v1.0.0 won 1st library award at Modelica conference, 2015)
Mateják, M., Tribula, M., Ježek, F., & Kofránek, J. (2015, September). Free modelica library for chemical and electrochemical processes. In 11th International Modelica Conference, Versailles, France (Vol. 118, pp. 359-66). http://dx.doi.org/10.3384/ecp15118359
Pharmacolibrary
for modeling Pharmacology (v25.09 wan 1st library award at Modelica conference,Luzerne, 2025)

Kulhanek, T., Jezek, F., Kofránek, J., Mateják, M., & Rommes, S. (2025, October). Pharmacolibrary-Free Library to Model Pharmacology. In Modelica Conferences (pp. 61-72). https://doi.org/10.3384/ecp21861
class for compartment

class for elimination

class for administration

creating model = composing components

model of pharmacokinetics

1-compartment model Gentamicin (aminoglycoside antibacterials)

gentamicin - 1 day simulation

Hodiamont, Caspar J et al. (2022-08). “Clinical pharmacokinetics of gentamicin in various patient populations and consequences for optimal dosing for Gram-negative infections: An updated review”. en. In: Clin. Pharmacokinet. 61.8, pp. 1075–1094. ISSN: 0312-5963,1179-1926. DOI: 10.1007/s40262 - 022 - 01143 - 0. URL: http://dx.doi.org/10.1007/s40262-022-01143-0
gentamicin - 1 day simulation logscale

2-compartment model Midazolam (hypnotics and sedatives)

midazolam - 12 h simulation

logscale - 12h with peripheral

Heizmann, P., Eckert, M. and Ziegler, W. (1983), Pharmacokinetics and bioavailability of midazolam in man.. British Journal of Clinical Pharmacology, 16: 43S-49S. https://doi.org/10.1111/j.1365-2125.1983.tb02270.x
3-compartment model Fentanyl (anesthetics)

fentanyl - 10h simulation

fentanyl - 10h simulation logscale

Kaneda, Kotaro and Tae-Hyung Han (2009-09). “Comparative population pharmacokinetics of fentanyl using non-linear mixed effect modeling: burns vs. non-burns”. en. In: Burns 35.6, pp. 790–797. ISSN: 0305-4179,1879-1409. DOI: 10.1016/j.burns.2008.12.006. URL: http://dx.doi.org/10.1016/j.burns.2008.12.006
class for compartment with blood flow

follows more physiology and anatomy of body parts and tissues
physiology based PK model - propranolol (beta blocker)

PBPK simulation - propranolol (beta-blocker)

5496 models of drugs by Anatomical Therapeutical Chemical (ATC) classification - knowledge base extracted and combined from Pubmed, Drugbank using LLM

ATC level 1

ATC level 3

ATC level 5

Drug model variants

caffeine

1-compartment model - caffeine

1 cup = 100 mg of caffeine in 8 hours
caffeine in 24 hours

seminar task
create model of pk of caffeine - using components fom Pharmacolibrary
oral intake - 95 mg(coffee) and 50 mg(tea)
Vd = 35 l Cl = 6.8 l/h ka=0.1 /min Tlag= 10 min
What is relation between concentration and effect?
linear effect


Emax effect


pharmacodynamics (PD): drug → body
What effect has a drug to body
dose/response relation ~ effect
irreversible effect
time dependent (R response, C concentration, k rate of irreversible effect)

with recovery growth factor ks

sigmoid Emax effect


seminar task 3
create model of dose response effect for caffein
behavioural (excitacy) 0 - 100%
EC50 = 10ug/ml, hill coeff = 1.85
cardiac effect (increased heart rate) 0-100%
EC50 = 20ug/ml, ...
- model/simulate effect curve after 1 cup of coffee (95mg) (12 hours)
- model/simulate effect curve after 1 cup of black tea (50mg) (12 hours)
PK PD model digoxin on hemodynamics of cardiovascular system

pressure volume (PV) diagram

simulation 2
Go to https://digital-biosystems.github.io/pharma/#hemo/hemo2.md
Can we predict individual drug dose → blood plasma concentration → effect/response?
individual co-variates:
age, weight, height, sex, ethnicity, …, genomics
Pharmacogenomics (PGx)
What is individual variability of PK and PD based on genotype and phenotype?
PK PGx model metoprolol - illustrative influence CYP2D6 & CYP3A4

metoprolol
PK PGx population of 4 different patients

PK PGx simulation (metoprolol)

Zamir, A., Hussain, I., ur Rehman, A. et al. Clinical Pharmacokinetics of Metoprolol: A Systematic Review. Clin Pharmacokinet 61, 1095–1114 (2022). https://doi.org/10.1007/s40262-022-01145-y
Metabolismus
obecně, první průchod (first pass) přes játerní buňky
aktivní lék → neaktivní lék (paracetamol)
neaktivní lék → aktivní lék (aspirin)
aktivní lék → více aktivní lék
více toxický (ethanol)
lék → více rozpustný ve vodě

paracetamol
acetaminophen → sulfate_conjugate
metabolism paracetamol

12h simulation - paracetamol metabolites (NAPQI is toxic)

most common pharmacogenes and mutation in Europe
omprehensive clinical pharmacogenomic (PGx) resource
https://www.clinpgx.org/
CYP2D6
- hepatic CYP450 enzyme, Metabolizes ~20–25% of drugs (antidepressants, antipsychotics, opioids like codeine/tramadol, beta‑blockers, antiarrhythmics)
- Key variants (by function)
- No function: 3, 4, 5, 6
- Decreased function: 9, 10, 14, 17, 29, 41
- Increased function: gene duplications 1xN, 2xN (ultra‑rapid)
- Drug consequences
- Poor metabolizers → toxicity risk for inactivated drugs; lack of effect for prodrugs (codeine, tramadol)
- Ultra‑rapid metabolizers → low effect for many substrates; codeine toxicity from rapid morphine formation
- Labels / guidelines
- EMA / EU labels: warnings or contraindication of codeine in CYP2D6 ultra‑rapid metabolizers
- CPIC, DPWG: phenotype‑based dosing / alternative drug recommendations for multiple CYP2D6 substrates (opioids, antidepressants, others)
CYP2C19
- Pharmacogene / function
- CYP2C19 → CYP450 enzyme
- Metabolizes: clopidogrel, PPIs, many SSRIs/TCAs, voriconazole
- Key variants (by function)
- No function: 2, 3
- Increased function: *17
- Drug consequences
- Poor metabolizers → clopidogrel treatment failure; ↑ exposure and side effects with PPIs, SSRIs, TCAs
- Rapid/ultra‑rapid metabolizers (*17) → reduced exposure for some substrates (e.g., PPIs)
- Labels / guidelines
- Labels: reduced clopidogrel effect in CYP2C19 loss‑of‑function carriers
- CPIC, DPWG: alternative to clopidogrel in poor metabolizers; dose/choice adjustments for PPIs, SSRIs, TCAs, voriconazole
CYP2C9
- Pharmacogene / function
- CYP2C9 → CYP450 enzyme
- Metabolizes: warfarin, phenytoin, some NSAIDs, some ARBs and sulfonylureas
- Key variants (by function)
- Reduced function: 2, 3 (Europe‑relevant)
- Other reduced‑function alleles more relevant outside Europe (e.g., 5, 6, 8, 11)
- Drug consequences
- Warfarin: 2/3 → lower dose requirement, ↑ bleeding risk at standard dosing
- Similar pattern (↑ exposure, toxicity risk) for several CYP2C9‑cleared drugs (e.g., phenytoin, some NSAIDs)
- Labels / guidelines
- Labels: acknowledge CYP2C9/VKORC1 influence on warfarin dosing
- CPIC, DPWG: genotype‑based warfarin dosing algorithms using CYP2C9 + VKORC1 (± CYP4F2)
DPYD
- Pharmacogene / function
- DPYD → dihydropyrimidine dehydrogenase (DPD)
- Catabolizes: fluoropyrimidines (5‑FU, capecitabine, tegafur)
- Key variants (by function)
- No / markedly reduced function: *2A (c.1905+1G>A), c.1679T>G
- Decreased function: c.2846A>T, c.1236G>A/HapB3
- Drug consequences
- Intermediate / poor metabolizers → massive ↑ exposure to 5‑FU/capecitabine → high risk of severe or fatal toxicity (myelosuppression, mucositis, neurotoxicity)
- Labels / guidelines
- Labels: EMA‑level warnings for DPYD variants and dose reduction/avoidance for fluoropyrimidines
- CPIC, DPWG: recommend large dose reductions or avoidance based on DPYD activity score; NCCN and EU oncology groups now endorse pre‑treatment testing
SLC01B1
- Pharmacogene / function
- SLCO1B1 → OATP1B1 hepatic uptake transporter
- Handles hepatic uptake of several statins (esp. simvastatin, atorvastatin)
- Key variants (by function)
- Decreased function: rs4149056 (c.521T>C, p.V174A, *5 allele)
- Drug consequences
- Decreased‑function genotypes (e.g., TC/CC) → ↑ simvastatin (and some other statins) plasma levels → ↑ risk of myopathy/rhabdomyolysis
- Labels / guidelines
- Labels: simvastatin product info highlights higher myopathy risk in rs4149056 carriers and suggests dose limitation
- CPIC, DPWG: recommend lower simvastatin doses or alternative statin in high‑risk genotypes
genetic impact for paracetamol
- Genetic impact
- UGT1A6, UGT1A9, CYP2E1 polymorphisms alter paracetamol clearance / NAPQI formation (interindividual variability, mostly research‑grade).
- Glutathione pathway capacity modulates toxicity risk more than any single pharmacogene.
- Guidelines
- No CPIC/DPWG pharmacogenetic dosing guideline for paracetamol.
- Existing guidelines: dose based on age, weight, liver function (not genotype)
Python workflow - fit to external data from PK-DB.com

howto find a drug

CA125 concentration based on tumor growth, interactive simulator - change growth factor (logistic function) and CA125 production rate
VR JIPKA - projekt 1.LFUK, FBMI ČVUT, VirtualLab s.r.o.

bring virtual reality to life


WebGL+WebXR Unity+WebView
VR JIPKA + eGolem monitor životních funkcí

léčiva podávána ve scénáři
- anestetikum a sedativum: Např. Propofol nebo Midazolam
- infůze fyziologického roztoku: Např. Lactated Ringer/Hartman solution
- antibiotika pro léčbu zánětu: např. piperacillin-tazobactam
blood-gas exchange

respiration

hemodynamics of cardiovascular system

Conclusion
Pharmacolibrary: https://github.com/digital-biosystems/Pharmacolibrary (fork)
components for modeling pharmacology
+ repository of drug models
pharmacokinetic: 5496 drugs models, 1st version parameters extracted from primary papers, Drugbank, Pubmed & LLM (GPT4.1)
pharmacodynamics: various effects <10 models
pharmacogenomics: various genotype/phenotype influence <10 models
near future:
- knowledge base from sources EMA, FDA, ClinPGx, Drugbank, Pubmed
- informed update of PK, PD and PGx models with evidence score powered by LLM (evaluating GPT 5, GPT-OSS, Claude 4.6, ...)
- integrate other modeling repos (SBML, physiomeproject, ...)
- add toxicology models, food, biomarkers
co-simulation of multiple models via FMI in static web app with bodylight.js
i
https://egolem.online/demo/
hemodynamics of cardiovascular system

blood-gas exchange

respiration

Physiomodel

Complex model of physiology in Modelica and Physiolibrary
https://physiomodel.org
1-compartment PK model in Modelica (text variant)

1-compartment PK model

or derivative form:


1-compartment PK model in component diagram
equations are behind each component

connecting components → equations among variables
compartment



elimination



connectors



logscale - 12h simulation

comprehensibility
Chemical 2.0
modeling physical chemistry

Physiolibrary 3.0.0
www.physiolibrary.org

Distribution
simplified - ideal mixing, no volume flow rate, compartment (Vd volume of distribution)



and 1st order kinetics


Metabolism
generally, first pass
active drug → inactive drug (paracetamol)
inactive drug → active drug (aspirin)
active drug → more active drug
make drug more toxic (ethanol)
make drug more water soluble
1st order kinetics between compartments

paracetamol
acetaminophen → sulfate_conjugate
for more complex - use Chemical library (https://www.physiolibrary.org)
equivalent 1-compartment model (in equations)

1-compartment model

parameters for intravenous administration of gentamicin, type of antibiotic against bacterial infections
2-compartment model

parameters for intravenous administration of midazolam, a short-acting benzodiazepine used for sedation, anesthesia, ...
Distribution - physiology based
compartment - with concentration mixing based on volumetric flow through organs and tissues:


fixed volumetric flow component:

Elimination
via kidney or liver using clearance rate Cl


computed half life

seminar task 2
create derived pharmacokinetic model of gentamicin.
Patient has chronic kidney disease (clearance is 20% of norm)
- what is maximum peak concentration
- adjust regimen/dosage so C>MIC(2mg/l) and C<Ctox (35 mg/l)
pk3, pk4
dosage < 400 mg or t1 = 24 hour or combination
Administration (absorption) - route
parenteral (e.g. intravenous, intraarterial (rare), main parameters: F bioavailability (almost 100%), adminMass, adminDuration):

enteral (e.g. oral, main parameters: F bioavailability, adminMass, Tlag, ka absorption rate)

Administration (absorption kinetics)
instanteous (e.g. intravenous, intraarterial, main parameters: bolus injection adminMass):

Zero-order (e.g. continuous infusion, main parameter: adminDuration):

First-order (rate proportional to the amount of drug remaining to be absorbed, main parameters: adminMass, ka (absorption rate))

3-compartment model

connectors


web simulator - 10 minutes
try by yourself https://digital-biosystems.github.io/pharma/
PK PD model Midazolam on EEG activity

midazolam
PK PD simulation

Pharmacolibrary / GITHUB
https://github.com/creative-connections/Pharmacolibrary

acknowledgment

ONCOSCREEN project, funded by the European Union’s Horizon Europe grant No. 101097036.
subaward to R01 HL173346. funded by NIH
RAIDO

PRIBE - personal reference intervals

RAIDO

PRIBE - personal reference intervals

PRIBE - personal reference intervals

RAIDO

optimal dose of lithium carbonate

VITO
Flemish Institute for Technological Research
Mol, Belgium
Environmental unit
Digital Precision Health group

DigiTwin4PH - PGx digital twin

VITO
Flemish Institute for Technological Research
Mol, Belgium
Environmental unit
Digital Precision Health group

VITO
Flemish Institute for Technological Research
Mol, Belgium
Environmental unit
Digital Precision Health group

DigiTwin4PH - PGx digital twin

ONCOSCREEN

ONCOSCREEN

DigiTwin4PH - PGx digital twin

ONCOSCREEN

iron metabolism visualisation

eGolem powered by bodylight.js
https://egolem.online/irm/ https://bodylight.physiome.cz
PRIBE - personal reference intervals

RAIDO

RAIDO

PRIBE - personal reference intervals

VITO
Flemish Institute for Technological Research
Mol, Belgium
Environmental unit
Digital Precision Health group

VITO
Flemish Institute for Technological Research
Mol, Belgium
Environmental unit
Digital Precision Health group

co-simulace a bodylight.js - simulace v prohlížeči (WebAssembly)
DigiTwin4PH - PGx digital twin

DigiTwin4PH - PGx digital twin

ONCOSCREEN

ONCOSCREEN

bring virtual reality to life


WebGL+WebXR Unity+WebView
bring virtual reality to life


WebGL+WebXR Unity+WebView
VR JIPKA - nastavení a připojení

VR JIPKA - nastavení a připojení

VR JIPKA + eGolem monitor životních funkcí

VITO
Flemish Institute for Technological Research
Mol, Belgium
Environmental unit
Digital Precision Health group

bring virtual reality to life


WebGL+WebXR Unity+WebView
VR JIPKA - nastavení a připojení

VR JIPKA + eGolem monitor životních funkcí

VR JIPKA + eGolem monitor životních funkcí

co-simulace a bodylight.js - simulace v prohlížeči (WebAssembly)
co-simulace a bodylight.js - simulace v prohlížeči (WebAssembly)
léčiva podávána ve scénáři
- anestetikum a sedativum: Např. Propofol nebo Midazolam
- infůze fyziologického roztoku: Např. Lactated Ringer/Hartman solution
- antibiotika pro léčbu zánětu: např. piperacillin-tazobactam
blood-gas exchange

blood-gas exchange

co-simulace a bodylight.js - simulace v prohlížeči (WebAssembly)
léčiva podávána ve scénáři
- anestetikum a sedativum: Např. Propofol nebo Midazolam
- infůze fyziologického roztoku: Např. Lactated Ringer/Hartman solution
- antibiotika pro léčbu zánětu: např. piperacillin-tazobactam
léčiva podávána ve scénáři
- anestetikum a sedativum: Např. Propofol nebo Midazolam
- infůze fyziologického roztoku: Např. Lactated Ringer/Hartman solution
- antibiotika pro léčbu zánětu: např. piperacillin-tazobactam
blood-gas exchange

respiration

respiration

hemodynamics of cardiovascular system

hemodynamics of cardiovascular system

respiration

hemodynamics of cardiovascular system
