From Compartments to a State Vector
A PBPK model describes how drug moves among physiological compartments over time. To integrate such a model numerically, the compartment quantities must be represented in a fixed order as a single state vector, and the model must return the rate of change of every state in that same order. A correct set of physiological equations can still produce incorrect predictions if one derivative is assigned to the wrong state or uses inconsistent units.
This tutorial uses amounts as the states and a small, deliberately simplified three-compartment model to make the indexing explicit. Its transfer coefficients are illustrative first-order rate constants; they are not calculations of blood-flow-limited exchange. The purpose is to define a reliable state-vector and derivative-function contract.
For a model with \(m\) compartments, choose an explicit indexing convention, such as \(y_1=A_{\mathrm{central}}, y_2=A_{\mathrm{liver}}, y_3=A_{\mathrm{kidney}}\). Here \(A_i\) denotes drug amount in compartment \(i\). If amount is measured in milligrams and time in hours, each derivative has units of milligrams per hour. A transfer rate constant has units of inverse hours.
Specify the State, Parameters, and Initial Conditions
Before writing the derivative function, make a mapping from each array index to one named quantity. State the units as well as the compartment names. The same mapping must be used when defining initial conditions, calculating derivatives, and extracting model outputs.
| Index | State | Meaning | Unit |
|---|---|---|---|
| 1 | \(A_1\) | Drug amount in the central compartment | mg |
| 2 | \(A_2\) | Drug amount in the liver compartment | mg |
| 3 | \(A_3\) | Drug amount in the kidney compartment | mg |
An initial condition supplies the state at the start time \(t_0\): \(y(t_0)=y_0\). It is not a derivative or a dose rate. For a dose-free interval that starts just after a bolus placed in the central compartment, one possible initial condition is \(y_0=(100,0,0)^\mathsf{T}\) mg. A different dosing history, or a different starting time, may require different initial amounts.
In the simple model below, transfer from the central compartment to each tissue is first order in the central amount, and return transfer is first order in the tissue amount. Elimination occurs from the liver and kidney states. Assume fixed rate constants, fixed compartment volumes, no input during the interval, and nonnegative initial amounts. These assumptions define this example; more detailed PBPK models may require additional states and processes.
Worked Example: Assigning State Indices and Initial Amounts
Hypothetical setup. A reduced model tracks central, liver, and kidney amounts in that order. Immediately after a 100 mg central bolus, there is no drug in either tissue compartment.
The state vector and initial condition are
The initial amount is 100 mg in the central compartment, 0 mg in the liver, and 0 mg in the kidney. The vector has three components, so the derivative function must return three rates, in central–liver–kidney order. Naming this mapping before implementation prevents a vector such as \((100,0,0)\) from being interpreted differently in separate parts of the model.
Write the Derivative Function
Let \(k_{12}\) denote transfer from central to liver, \(k_{21}\) return from liver to central, \(k_{13}\) transfer from central to kidney, and \(k_{31}\) return from kidney to central. Let \(k_{20}\) and \(k_{30}\) denote elimination from liver and kidney, respectively. Each rate constant has units \(\mathrm{h}^{-1}\). Under first-order kinetics, for example, the central-to-liver transfer rate is \(k_{12}A_1\), in \(\mathrm{mg/h}\).
Each state’s derivative is the sum of rates entering that compartment minus the rates leaving it. Therefore, for a dose-free interval,
The derivative function returns these three expressions in the exact state order. The central derivative is not just a sum of losses: it also includes return from both tissues. The liver and kidney derivatives include their incoming central transfers, their return transfers, and their elimination losses. All terms in each equation have units \(\mathrm{mg/h}\).
Worked Example: Evaluating All Three Derivatives
Hypothetical values. Use the initial state \(y(t_0)=(100,0,0)^\mathsf{T}\) mg and the rate constants \(k_{12}=0.20\), \(k_{21}=0.10\), \(k_{13}=0.10\), \(k_{31}=0.05\), \(k_{20}=0.05\), and \(k_{30}=0.02\ \mathrm{h}^{-1}\). Assume the model has no input during this interval.
For the central state, substitute the initial amounts and rate constants:
For the liver and kidney states, the calculations are
Thus the derivative function returns \((-30,20,10)^\mathsf{T}\ \mathrm{mg/h}\) at \(t_0\), in central–liver–kidney order. These are instantaneous rates at the starting state, not the amounts after one hour. The negative central rate and positive tissue rates indicate initial movement out of the central compartment into the two tissues.
Check the Equations Before Integrating
A useful verification is to add the three amount derivatives. Internal transfers should cancel because each transfer leaving one modeled compartment enters another. In this example, the total drug amount is \(A_{\mathrm{tot}}=A_1+A_2+A_3\). Adding the equations gives
For example, the term \(-k_{12}A_1\) in the central equation cancels with \(+k_{12}A_1\) in the liver equation. The remaining terms are elimination losses. This equality is a direct check on the written equations: with no input, total amount cannot increase in this model, and it decreases only through the specified elimination pathways. At the initial state in the worked example, both eliminating amounts are zero, so the sum of the derivatives is \(-30+20+10=0\ \mathrm{mg/h}\), as expected.
This check depends on the stated model boundaries: all internal transfer destinations are included, and there is no unmodeled input or output. If a process moves drug outside the modeled system, it should appear as an external loss; if drug enters, it should appear as an input. Conservation checks must reflect what the states actually represent.
Write down which named compartment each state-vector position represents, and use the same order throughout.
Give one initial amount for each state in that order, with explicit units and a defined start time.
For every compartment, add incoming rates and subtract outgoing rates, checking that each term has the same units.
Check its length and ordering, evaluate it at a simple state, and test expected mass balance or other model-specific identities.
Amounts, Concentrations, and Model Outputs
An amount state is often convenient for writing transfer balances. Concentrations can be derived from amounts when the compartment volumes are known. With constant volume \(V_i\), concentration in compartment \(i\) is \(C_i=A_i/V_i\). If \(A_i\) is in mg and \(V_i\) is in L, \(C_i\) is in mg/L. The state vector can remain in amounts even when reported outputs are concentrations.
Worked Example: Calculating Concentrations From the State
Hypothetical values. At a particular time, suppose the state is \((40,30,20)^\mathsf{T}\) mg, and the fixed central, liver, and kidney volumes are \(5.0\), \(1.5\), and \(0.30\) L, respectively.
Using \(C_i=A_i/V_i\), the concentrations are
These concentrations are derived quantities, not additional states in this representation. With constant \(V_i\), their derivatives satisfy \(dC_i/dt=(1/V_i)dA_i/dt\). If volume changes with time, this simple conversion of derivatives no longer applies; differentiating \(C_i=A_i/V_i\) also introduces a term for the changing volume.
Implementation Choices and Failure Modes
The main alternative is to store concentrations, rather than amounts, as the states. Either representation can be valid, but the derivative equations must match it. For amount states, transfer rates can be expressed directly in amount per time. For concentration states, transfer terms generally require volume factors so that gains and losses are expressed in concentration per time. Mixing an amount-based equation with concentration states, or vice versa, produces dimensional errors even if the numerical values look plausible.
A derivative function should implement the model equations for the current time and state, using a stable parameter-to-rate mapping and returning one derivative per state. It should not silently reorder states, use a different unit for a parameter than the equations assume, or treat an initial dose amount as a continuous input rate. This tutorial’s equations assume a dose-free interval after the initial condition; other input patterns require their own explicit terms and timing.
Common warning signs include a derivative vector of the wrong length, an unexpected sign at a simple test state, a total amount that grows despite having no input, or a concentration that results from dividing by the wrong compartment volume. A mass-balance check may not detect every error: swapping two tissue indices can preserve the total amount while assigning predictions to the wrong organs. Verify both arithmetic and the state-to-compartment mapping.
- Index mismatch: The mistaken reasoning is that all components are interchangeable because they share units. They are not; each position has a defined physiological meaning. Check the index map for the initial state, derivative, volumes, and outputs.
- Inconsistent units: A rate constant in \(\mathrm{h}^{-1}\) multiplied by an amount in mg gives \(\mathrm{mg/h}\). Combining that term with a rate in \(\mathrm{mg/min}\) without conversion is invalid.
- Confusing amount and concentration: An amount of 30 mg is not a concentration of 30 mg/L. Divide by the appropriate volume only when calculating concentration.
- Missing a transfer destination: If a modeled transfer leaves one state but does not enter another modeled state, the total-amount check may reveal an unintended loss. Decide whether that loss is a real external process or an omitted state.
A state-vector representation is an implementation structure, not a guarantee that the physiological model is complete or correct. This reduced example omits many processes and does not establish physiological parameter values. The representation is useful because it makes the relationship between model equations, numerical inputs, and reported compartment quantities explicit.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- If the state order is central, liver, kidney, what must be true about the derivative returned by the model?
- For \(A_1=50\) mg and \(k_{12}=0.20\ \mathrm{h}^{-1}\), what is the central-to-liver transfer rate, including units?
- In the three-compartment model, why do internal transfer terms cancel when the three amount derivatives are added?
- If \(A_{\mathrm{liver}}=24\) mg and \(V_{\mathrm{liver}}=1.2\) L, what is the liver concentration?
- Why can a total-amount check fail to detect an incorrect swap of the liver and kidney indices?
Solutions. 1. The returned vector must have three entries ordered as the central, liver, and kidney derivatives, matching the state vector. 2. The rate is \(k_{12}A_1=(0.20\ \mathrm{h}^{-1})(50\ \mathrm{mg})=10\ \mathrm{mg/h}\). 3. Every modeled internal transfer appears once as an outgoing loss and once as an incoming gain, so those equal terms cancel in the sum. 4. \(C_{\mathrm{liver}}=24\ \mathrm{mg}/1.2\ \mathrm{L}=20\ \mathrm{mg/L}\). 5. Swapping the indices can leave the sum of all amounts unchanged while assigning state values and derivatives to the wrong named organs; the mapping must be checked separately.