pharmsol
A high-performance Rust library for pharmacokinetic/pharmacodynamic (PK/PD) simulation using analytical solutions, ordinary differential equations (ODEs), or stochastic differential equations (SDEs).
Installation
Add pharmsol to your Cargo.toml, either manually or using
Quick Start
use *;
// Create a subject with an IV infusion and observations
let subject = builder
.infusion // 500 units over 0.5 hours
.observation
.observation
.observation
.observation
.build;
// Define parameters: ke (elimination rate), v (volume)
let ke = 1.022;
let v = 194.0;
// Use the built-in one-compartment analytical solution
let analytical = new;
// Get predictions
let predictions = analytical.estimate_predictions.unwrap;
ODE-Based Models
For custom or complex models, define your own ODEs:
use *;
let ode = ODEnew;
Supported Analytical Models
- One-compartment with IV infusion
- One-compartment with IV infusion and oral absorption
- Two-compartment with IV infusion
- Two-compartment with IV infusion and oral absorption
- Three-compartment with IV infusion
- Three-compartment with IV infusion and oral absorption
Performance
Analytical solutions provide 20-33× speedups compared to equivalent ODE formulations. See benchmarks for details.