# Concentrations of a one- or two-compartment model for a stated regimen, version 2.0.2

pk-compartment-simulate\@2.0.2: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.

## What this page can and cannot show

**Level: Checked against a reference; Bourne's Basic Pharmacokinetics ch. 4, 6, 8, 19; PKPDsim 1.4.1; superposition, 2-cpt infusion and oral our derivation. Reference kind: our own exact-arithmetic script and a hand-worked case; an outside program, PKPDsim, 1.4.1.**

Not fully recorded, and not independently reviewed. Items marked "Not recorded" are missing from this project's records for the version named. Apart from any worked example shown, the cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed these methods or checks.

[Every version of this method](https://www.drybench.com/methods/m/pk-compartment-simulate) · [Every method](https://www.drybench.com/methods/m) · [What the levels mean](https://www.drybench.com/methods/levels)

## Version 2.0.2

**Level: Checked against a reference; Bourne's Basic Pharmacokinetics ch. 4, 6, 8, 19; PKPDsim 1.4.1; superposition, 2-cpt infusion and oral our derivation. Reference kind: our own exact-arithmetic script and a hand-worked case; an outside program, PKPDsim, 1.4.1.** `pk-compartment-simulate@2.0.2`

Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.

**Verification statement:** Concentrations by the one-compartment bolus, infusion and first-order absorption forms (with the ka = kel case) and the two-compartment bolus form, as stated in Bourne's open textbook Basic Pharmacokinetics, chapters 4, 6, 8 and 19, read 17 November 2026 at their equation images, hashes in the record, rearranged where stated; the two-compartment infusion and oral forms, their ka = λ limit, the divided difference and superposition over doses are our derivation. Values are computed on the decimals given (precision as stated). Compared with a 40-digit solution of the compartment equations and with PKPDsim 1.4.1 run offline on its own models, and with a second implementation in Python by a separate agent of the same model family (74 cases, 27 at the edges). Linear time-invariant kinetics, no lag time.

The central concentration at stated times after bolus, zero-order infusion or first-order absorption doses, by each model's closed-form response summed over the doses.

- **How results are reported:** Each value is read as its shortest decimal times its unit's exact factor and converted once to a working double (times exactly to hours, then rounded once); the responses are computed in double precision, the two-compartment terms as pk-two-compartment-constants forms them. Each e^(−λ·s) is within about λ·s·3u relative of its value on the stated decimals (u = 2^−53; about 2.3e-13 at λ·s = 700); measured maximum 4.5e-16 relative against the 40-digit solution.
- **Uncertainty:** The caller's model and parameters, solved exactly; no uncertainty is propagated from them.
- **Reference, as its record states it:** a 40-digit matrix exponential, each value compared with PKPDsim 1.4.1
- **Computes through:** `pk-two-compartment-constants@2.0.2`
- **Level confirmed by this project's ruling of** 17 November 2026

[What this page can and cannot show](#what-this-page-can-and-cannot-show)

### What was checked

121 cases in 2 files, linked by this exact version.

Run through the tool at build against our own exact-arithmetic script and a hand-worked case; an outside program, PKPDsim, 1.4.1: 102 agree within the tolerance the file states, 19 refuse as the case expects, 0 differ, 0 were not run.

- **File 1, 74 cases**
  - **Where the expected values came from:** our own exact-arithmetic script and a hand-worked case
  - **Recorded on:** 2026-11-14
  - **Reference:** second implementation by a fresh agent (Python 3.13), 2026-11-14; licence BSD-3-Clause
  - **Tolerance as the file states it:** every number relative 1e-15; a concentration relative 3·2^−53·Λ where that is larger, Λ the largest λ·s (or ka·s) of the doses at or before the case's output times, the record's stated bound on each e^(−λs); below the smallest normal double only an exact 0; statuses, codes and units exact

- **File 2, 47 cases**
  - **Where the expected values came from:** an outside program, PKPDsim 1.4.1
  - **Recorded on:** 2026-11-14
  - **Reference:** PKPDsim, 1.4.1; licence MIT
  - **Tolerance as the file states it:** relative 1e-10 against a 40-digit solution of the compartment equations, absolute 1e-20 below 1e-10 in the elements' unit; every concentration confirmed by PKPDsim 1.4.1 within 1e-8 relative; times relative 1e-12 (absolute 1e-22 h below 1e-10 h), since a time in minutes is converted; statuses, codes and units exact

Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.

### What was not checked

Three compartments, lag times, time-varying or dose-dependent parameters (none offered). A concentration above 0 on the stated values (a bolus at or before the output time, or an infusion or oral dose strictly before it) that comes out as exactly 0 in double precision, its exponents λ·s above about 745, is refused as RESULT\_OUTSIDE\_DOUBLE\_RANGE, never served as 0. So is a normal concentration formed through a value below the normal range: an intermediate of the two-compartment terms as pk-two-compartment-constants flags it (k12·k21 subnormal, say), an exponent λ that is not normal, or a term one of whose factors or partial products (a coefficient, the amount, e^(−λs), the oral divided difference, the infusion's 1 − e^(−λs)) is above 0 on the stated values but came out 0 or subnormal, where that term's bound could move the value by more than 2^−54 of it. Such a term below that bound is kept as negligible. No reordering is attempted.

### Definition or model

A closed form: the result follows from the inputs by the equations alone.

### Equations

**Equation 1**

```equation
per unit amount, C(s) = Σ_i c_i·e^(−λ_i s): one compartment c = 1/V, λ = CL/V
two compartments c = (A, B)/dose and λ = (α, β) of pk-two-compartment-constants
```

| Symbol | Meaning and unit |
| --- | --- |
| c\_i | coefficient per unit amount dosed, 1/L |
| λ\_i | exponent, 1/h |
| s | time since the dose, h |

Source: Bourne DWA. Basic Pharmacokinetics, online textbook (boomer.org/c/p4), Chapter 4, One Compartment IV Bolus, p. Chapter 4, page 6 (Apparent Volume of Distribution), section as stated in Bourne: Equation 4.6.6, Cp = (Dose/V)·e^(−kel·t) (image Fig24.gif, SHA-256 8119096da4e9a81bf767d2fbc354efa131758232bba91e0e47da7a5da0a2a951), with kel = CL/V as in pk-one-compartment-parameters (Eq. 4.8.5); two compartments through pk-two-compartment-constants (Bourne, Chapter 19, page 2, Eqs. 19.2.2 to 19.2.4); writing each as a sum of coefficients per unit amount times exponentials is the record's, the online textbook as retrieved on 17 November 2026, each page last modified 28 July 2024 by its footer; the hash is of the page's HTML as retrieved, whose rotating promotional footer differs on a re-fetch; the equation images, hashed in the locator, do not; read in full on 2026-11-17 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 9956680513ee. Free to read (free to read at boomer.org; Copyright 2001-2026 David W. A. Bourne; the site states its material should be used for educational or self-study purposes only; no reuse licence (read and hashed, never vendored)), checked 2026-11-17. No erratum found (searched the pages as retrieved: the site has no errata or corrections channel), 2026-11-17.

**Equation 2**

```equation
C(s) = D·Σ c_i·e^(−λ_i s)
```

| Symbol | Meaning and unit |
| --- | --- |
| C | concentration at time since the dose (or in nM), mg/L |
| D | the dose (or in nmol), mg |

Source: Bourne DWA. Basic Pharmacokinetics, online textbook (boomer.org/c/p4), Chapter 4, One Compartment IV Bolus, p. Chapter 4, page 6 (Apparent Volume of Distribution), section as stated in Bourne: Equation 4.6.6, Cp = (Dose/V)·e^(−kel·t) (image Fig24.gif, SHA-256 8119096da4e9a81bf767d2fbc354efa131758232bba91e0e47da7a5da0a2a951); for two compartments Bourne, Chapter 19, page 2, Equation 19.2.3 (Fig3023.gif, SHA-256 b9008a830e1157fab461b90925a5bb2a12f334d4324c74921a923c591422c6a3), through pk-two-compartment-constants, the online textbook as retrieved on 17 November 2026, each page last modified 28 July 2024 by its footer; the hash is of the page's HTML as retrieved, whose rotating promotional footer differs on a re-fetch; the equation images, hashed in the locator, do not; read in full on 2026-11-17 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 9956680513ee. Free to read (free to read at boomer.org; Copyright 2001-2026 David W. A. Bourne; the site states its material should be used for educational or self-study purposes only; no reuse licence (read and hashed, never vendored)), checked 2026-11-17. No erratum found (searched the pages as retrieved: the site has no errata or corrections channel), 2026-11-17.

**Equation 3**

```equation
R = D/T
C(s) = R·Σ c_i·(1 − e^(−λ_i s))/λ_i for s ≤ T, and R·Σ c_i·(1 − e^(−λ_i T))/λ_i·e^(−λ_i (s − T)) after
```

| Symbol | Meaning and unit |
| --- | --- |
| R | infusion rate (or in nmol/h), mg/h |
| T | infusion duration, h |

Source: Bourne DWA. Basic Pharmacokinetics, online textbook (boomer.org/c/p4), Chapter 6, Intravenous Infusion, p. Chapter 6, page 6 (Post Infusion), section as stated in Bourne, one compartment: Equation 6.6.1, Cp = (k0/(kel·V))·\[1 − e^(−kel·t)\] during the infusion (image Fig1504.gif, SHA-256 1f6c514a635b7693ff358201fc66707c98d951585f350a14009771ff78a2d120), Equation 6.6.2, its value at the end D (fig0601.png, SHA-256 78e320eea1b2130c797ce702343bc7b7dfaabd37ee3e2c715ccfa0a63354c9da), and Equations 6.6.3 and 6.6.4, Cp = (k0/(kel·V))·\[1 − e^(−kel·D)\]·e^(−kel·(t − D)) after it (Fig0602.jpg, SHA-256 b5d6182b5ad0f765dac1353c31dcd3fdcc63d99b45a0c5f9eeb0d39539dd77c6; Fig0603.jpg, SHA-256 3f8a895abb73e54d3f50d0f4fe8bf1f95e2b515d2370366a37305f5b2551c5d2), Bourne's k0 the rate and D the duration (the record's R and T). For two compartments the record applies the same form to each exponential term c\_i·e^(−λ\_i s) of the bolus response (its derivation by convolution, accepted in this project's scientific review of 10 November 2026); the book prints no two-compartment infusion form, the online textbook as retrieved on 17 November 2026, each page last modified 28 July 2024 by its footer; the hash is of the page's HTML as retrieved, whose rotating promotional footer differs on a re-fetch; the equation images, hashed in the locator, do not; read in full on 2026-11-17 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning f8a4fb30ddc7. Free to read (free to read at boomer.org; Copyright 2001-2026 David W. A. Bourne; the site states its material should be used for educational or self-study purposes only; no reuse licence (read and hashed, never vendored)), checked 2026-11-17. No erratum found (searched the pages as retrieved: the site has no errata or corrections channel), 2026-11-17.

**Equation 4**

```equation
C(s) = F·D·ka·Σ c_i·(e^(−λ_i s) − e^(−ka·s))/(ka − λ_i), and at ka = λ_i the limit F·D·ka·c_i·s·e^(−λ_i s)
```

| Symbol | Meaning and unit |
| --- | --- |
| F | fraction absorbed |
| ka | absorption rate constant, 1/h |

Source: Bourne DWA. Basic Pharmacokinetics, online textbook (boomer.org/c/p4), Chapter 8, Pharmacokinetics of Oral Administration, p. Chapter 8, page 3 (Integrated equation), section as stated in Bourne, one compartment: Equation 8.3.1, Cp = (F·Dose·ka/(V·(ka − kel)))·\[e^(−kel·t) − e^(−ka·t)\] (image Fig1706.gif, SHA-256 437387298ff9d6d9ea543ac3babd04f6c48bee67f44eb1ef7281a2ddc1249a2a), and its kel = ka = k case, Equation 8.3.5, Cp = (F·Dose·k/V)·t·e^(−k·t) (Eq080305.png, SHA-256 19b742e815c5679b78e599d71b5a0727362112e8520a7ea88dbb76eddf66820d). For two compartments the record applies the same form to each exponential term c\_i·e^(−λ\_i s) (its derivation by convolution); the two-compartment limit at ka = α or β and the divided difference are the record's derivation; the book prints the two-compartment oral curve only as A·e^(−αt) + B·e^(−βt) + C·e^(−ka·t) with A + B + C = 0 (Chapter 19, page 7), without its coefficients, the online textbook as retrieved on 17 November 2026, each page last modified 28 July 2024 by its footer; the hash is of the page's HTML as retrieved, whose rotating promotional footer differs on a re-fetch; the equation images, hashed in the locator, do not; read in full on 2026-11-17 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 1071b2aee352. Free to read (free to read at boomer.org; Copyright 2001-2026 David W. A. Bourne; the site states its material should be used for educational or self-study purposes only; no reuse licence (read and hashed, never vendored)), checked 2026-11-17. No erratum found (searched the pages as retrieved: the site has no errata or corrections channel), 2026-11-17.

**Equation 5**

```equation
C(t) = Σ over doses d with t_d ≤ t of C_d(t − t_d), each response zero before its dose: the record's statement of linear time-invariant superposition. Only a bolus makes the concentration jump. Where an iv_bolus dose other than the first is given at an output time (the two times equal in hours after the kit's exact conversion), the value at t includes that dose, and concentrationBeforeDose gives the sum over doses with t_d < t. An infusion or oral dose contributes zero at its dose time and the concentration is continuous there, so concentrationBeforeDose never appears on those routes
nor at the first dose on any route, since no drug is assumed before it
```

| Symbol | Meaning and unit |
| --- | --- |
| C | concentration at the output time (or in nM), mg/L |
| t | output time, h |
| t\_d | dose time, h |

Ruling of this project: 10 November 2026, section "CSO memo, 10 November 2026: \`pk\_compartment\_simulate\`, gate (a)". Not yet published; its effect is stated on this page. A choice this project made, not a value from the literature.

### Conventions

What each mode computes:

- `model = one_compartment`: One central compartment with first-order elimination: parameters CL and V.
- `model = two_compartment`: A central and a peripheral compartment, elimination from the central one: parameters CL, V1, Q and V2.

### Constants

Constants: none used.

### Worked example

Worked example: one case of pk-compartment-simulate\@2.0.2, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.

**Inputs**

- model = one\_compartment
- route = iv\_bolus
- parameters.clearance = 2.5 L/h
- parameters.volume = 30 L
- doses\[0\].time = 0 h
- doses\[0\].amount = 100 mg
- times\[0\] = 0 h
- times\[1\] = 0.5 h
- times\[2\] = 1 h
- times\[3\] = 2 h
- times\[4\] = 4 h
- times\[5\] = 8 h
- times\[6\] = 12 h
- times\[7\] = 24 h
- times\[8\] = 48 h

**Steps**

1. lambda = 0.083333333 1/h, from parameters.clearance, parameters.volume; by equation 1.
2. c1 = 0.033333333 1/L, from parameters.volume; by equation 1.
3. c-0 = 3.3333333 mg/L, from doses\[0\].amount, c1, times\[0\]; by equation 2; gives concentrations\[0\].concentration.
4. c-half = 3.1972982 mg/L, from c-0, lambda, times\[1\]; by equation 2; gives concentrations\[1\].concentration.

The working, as the case writes it:

```equation
k = 2.5/30 = 0.0833333 1/h
C(0.5 h) = (100/30)·e^(−0.0416667) = 3.333333 × 0.9591894 = 3.197298 mg/L
C(0) = 100/30 = 3.333333 mg/L
```

**Answer**

- `concentrations[0].concentration` = **3.3333333 mg/L**
- `concentrations[1].concentration` = **3.1972982 mg/L**

Where these values came from: an outside program, PKPDsim 1.4.1; 40-digit matrix exponential of the compartment equations; the 40-digit Taylor integration agrees within 5.1e-41 relative; every value confirmed by PKPDsim 1.4.1's library model within 8.4e-14 relative at its nonzero outputs (the worst over the file is in about.crossCheck).

At build the tool returned this answer within the tolerance the file states: relative 1e-10 against a 40-digit solution of the compartment equations, absolute 1e-20 below 1e-10 in the elements' unit; every concentration confirmed by PKPDsim 1.4.1 within 1e-8 relative; times relative 1e-12 (absolute 1e-22 h below 1e-10 h), since a time in minutes is converted; statuses, codes and units exact.

Who worked this case: not recorded.

### What it refuses, and its input ranges

- `ARGUMENT_NOT_FOR_MODEL`: a parameter of the other model is given: refused, not ignored Next: Remove the parameters of the other model, or choose the model they belong to.
- `ARGUMENT_REQUIRED_FOR_MODEL`: a parameter of the chosen model is missing Next: State every parameter of the chosen model.
- `ARGUMENT_NOT_FOR_ROUTE`: an absorption rate constant or bioavailability with an intravenous route, or an infusion duration with another route Next: Remove the arguments of the other route, or choose the route they belong to.
- `ARGUMENT_REQUIRED_FOR_ROUTE`: first\_order\_absorption without ka or F, or iv\_infusion without its duration Next: State the arguments the route needs: ka and F for first-order absorption, the duration for an infusion.
- `TOO_MANY_DOSES`: more than 1000 doses (the compute band) Next: Shorten the regimen to the compute band's dose count; for a regular regimen at steady state each dosing interval repeats the last, so later intervals need not be simulated.
- `DOSE_TIMES_NOT_INCREASING`: dose times not strictly increasing Next: List the doses in strictly increasing time; two doses at one time are one dose of their sum.
- `DIMENSIONS_MIXED`: doses in both mass and amount of substance: no molar mass is assumed Next: State every dose in mass, or every dose in amount of substance, converting with the molar mass yourself.
- `INFUSIONS_OVERLAP`: an infusion starts before the previous one ends (starting exactly at its end is allowed) Next: Start each infusion at or after the end of the one before.
- `OUTPUT_TIMES_NOT_INCREASING`: output times repeated or not in increasing order Next: List the output times in strictly increasing order, each once.
- `TIME_BEFORE_FIRST_DOSE`: an output time before the first dose: the model assumes no drug before the first stated dose; a zero there would read as a statement about exposure the caller has not made Next: Start the output times at or after the first dose, or add the earlier dose that was given.

### Changes

No correction is logged for pk-compartment-simulate\@2.0.2.

## Tools that use it

- [`pk_compartment_simulate`](https://www.drybench.com/methods/tools/pk-compartment-simulate)

## Cite this version

Concentrations of a one- or two-compartment model for a stated regimen. Drybench; pk-compartment-simulate\@2.0.2; [https://www.drybench.com/methods/m/pk-compartment-simulate/2.0.2](https://www.drybench.com/methods/m/pk-compartment-simulate/2.0.2) (accessed \[date\]).
