Tutorials › Quantitative Systems Pharmacology (QSP) › Analytical Reference Solutions for ODE Verification

Verification, Validation and Independent Validation · Tutorial 747 of 799

Analytical Reference Solutions for ODE Verification

Use closed-form ODE solutions as quantitative reference trajectories to test whether implemented QSP components reproduce their specified dynamics.

Advanced 10 min read

What You'll Learn

  • Derive the analytical trajectory for a constant-input first-order turnover model.
  • Use the pseudo-first-order reversible-binding solution and identify when its assumptions apply.
  • Calculate exact amount trajectories for a two-compartment linear model after an IV bolus.
  • Compare simulated and analytical values using absolute and scaled errors.
  • Diagnose mismatches caused by units, initial conditions, parameters, or output handling.

Why Analytical References Matter

A QSP component can produce smooth, plausible trajectories and still implement the wrong equation. Verification asks whether the executable code solves the mathematical model that was specified. When a component has an exact solution, that solution provides a reference independent of the numerical solver: evaluate both at the same times and with the same parameters, inputs, units, and initial conditions, then quantify their difference.

Analytical references are especially useful for small components embedded in larger models. A turnover state, a binding process under fixed ligand concentration, or a linear compartment subsystem can be tested in isolation before interactions make discrepancies harder to locate. Agreement does not establish that the equations adequately represent biology or that the model is suitable for a particular prediction; it establishes a narrower claim about implementation of the tested equations under the tested conditions.

Definition: An analytical reference solution is a closed-form expression for a model state as a function of time, derived from the specified differential equations and assumptions. For verification, the reference trajectory and the executable trajectory must use the same equations, parameters, initial conditions, inputs, and time units.

First-Order Turnover Under Constant Input

Consider a state \(R(t)\), such as the amount or concentration of a turnover-controlled quantity, governed by constant input and first-order loss:

$$ \frac{dR}{dt}=k_{\mathrm{in}}-k_{\mathrm{out}}R,\qquad R(0)=R_0. $$

Assume \(k_{\mathrm{in}}\) and \(k_{\mathrm{out}}\) are constant, \(k_{\mathrm{out}}>0\), and there are no time-varying inputs, events, or additional coupled states. If \(R\) is measured in units \(U\), then \(k_{\mathrm{in}}\) has units \(U/\text{time}\) and \(k_{\mathrm{out}}\) has units \(1/\text{time}\). The steady state is \(R_{\mathrm{ss}}=k_{\mathrm{in}}/k_{\mathrm{out}}\). Subtracting this steady state from the differential equation gives \(d(R-R_{\mathrm{ss}})/dt=-k_{\mathrm{out}}(R-R_{\mathrm{ss}})\), whose solution is exponential decay of the deviation from steady state:

$$ R(t)=R_{\mathrm{ss}}+(R_0-R_{\mathrm{ss}})e^{-k_{\mathrm{out}}t} =\frac{k_{\mathrm{in}}}{k_{\mathrm{out}}} +\left(R_0-\frac{k_{\mathrm{in}}}{k_{\mathrm{out}}}\right)e^{-k_{\mathrm{out}}t}. $$

Worked Example: Checking a Turnover State

Suppose a hypothetical model has \(k_{\mathrm{in}}=12\) units/h, \(k_{\mathrm{out}}=0.20\) h\(^{-1}\), and \(R_0=40\) units. Calculate the reference value at 5 h.

First, \(R_{\mathrm{ss}}=12/0.20=60\) units. Thus,

$$ R(5)=60+(40-60)e^{-(0.20)(5)} =60-20e^{-1} =60-20(0.367879) =52.6424\ \text{units}. $$

The reference prediction is \(52.64\) units at 5 h. A simulation result should be compared with this value using a prespecified numerical tolerance, not judged only by whether its plotted curve looks similar. The assumptions hold for this calculation because the example specifies constant rates and input, with no events or coupling.

Reversible Binding With Fixed Free Ligand

A useful binding reference is available when free ligand concentration \(L\) is held constant and receptor total concentration \(R_{\mathrm{tot}}\) is fixed. Let \(C(t)\) be the concentration of complex. For association rate constant \(k_{\mathrm{on}}\) and dissociation rate constant \(k_{\mathrm{off}}\), the model is

$$ \frac{dC}{dt}=k_{\mathrm{on}}L(R_{\mathrm{tot}}-C)-k_{\mathrm{off}}C. $$

Here \(k_{\mathrm{on}}\) has units concentration\(^{-1}\) time\(^{-1}\), and \(k_{\mathrm{off}}\) has units time\(^{-1}\). Because \(L\) is fixed, the equation is linear in \(C\). Define \(k_{\mathrm{obs}}=k_{\mathrm{on}}L+k_{\mathrm{off}}\). Setting the derivative to zero gives \(C_{\mathrm{ss}}=k_{\mathrm{on}}LR_{\mathrm{tot}}/k_{\mathrm{obs}}\). The difference \(C-C_{\mathrm{ss}}\) obeys \(d(C-C_{\mathrm{ss}})/dt=-k_{\mathrm{obs}}(C-C_{\mathrm{ss}})\), giving the exact trajectory below.

$$ C(t)=C_{\mathrm{ss}}+(C_0-C_{\mathrm{ss}})e^{-k_{\mathrm{obs}}t}, \qquad C_{\mathrm{ss}}=\frac{k_{\mathrm{on}}LR_{\mathrm{tot}}}{k_{\mathrm{on}}L+k_{\mathrm{off}}}. $$

This is a pseudo-first-order reference, not a general solution for a closed system in which free ligand is depleted as complex forms. Using it for a closed, mass-balanced binding system would compare the implementation with the wrong equations.

Worked Example: Comparing a Binding Trajectory

For a hypothetical binding component, let \(L=10\) nM be maintained constant, \(R_{\mathrm{tot}}=100\) nM, \(C_0=0\) nM, \(k_{\mathrm{on}}=0.020\) nM\(^{-1}\)h\(^{-1}\), and \(k_{\mathrm{off}}=0.30\) h\(^{-1}\). Find \(C(2)\).

The effective rate is \(k_{\mathrm{obs}}=(0.020)(10)+0.30=0.50\) h\(^{-1}\). The steady state is \(C_{\mathrm{ss}}=(0.020)(10)(100)/0.50=40\) nM. Therefore,

$$ C(2)=40+(0-40)e^{-(0.50)(2)} =40(1-e^{-1}) =40(1-0.367879) =25.2848\ \text{nM}. $$

The analytical reference is \(25.28\) nM after 2 h. This calculation assumes the specified free ligand concentration remains at 10 nM throughout and that total receptor is fixed. If the code instead tracks ligand depletion, the discrepancy would reflect different model assumptions rather than necessarily a solver defect.

Two-Compartment Linear Model

Linear compartment systems can also have exact reference trajectories. Consider a hypothetical IV bolus into the central compartment, with central amount \(A_1\) and peripheral amount \(A_2\):

$$ \frac{dA_1}{dt}=-(k_{10}+k_{12})A_1+k_{21}A_2, \qquad \frac{dA_2}{dt}=k_{12}A_1-k_{21}A_2. $$

The rate constants \(k_{10}, k_{12}, k_{21}\) have units time\(^{-1}\). The initial conditions for a central bolus of dose \(D\) are \(A_1(0)=D\) and \(A_2(0)=0\). With constant rate constants, this is a linear system with constant coefficients. Its modes are exponentials associated with the eigenvalues of its coefficient matrix. For \(k_{10}=0.40\), \(k_{12}=0.30\), and \(k_{21}=0.20\) h\(^{-1}\), the characteristic equation is

$$ \lambda^2+(k_{10}+k_{12}+k_{21})\lambda+k_{10}k_{21} =\lambda^2+0.90\lambda+0.080=0. $$

Its roots are \(-0.10\) and \(-0.80\) h\(^{-1}\). Substitution into the differential equations, together with the initial conditions, gives the following exact amount trajectories for any bolus dose \(D\):

$$ A_1(t)=\frac{D}{7}e^{-0.10t}+\frac{6D}{7}e^{-0.80t}, \qquad A_2(t)=\frac{3D}{7}\left(e^{-0.10t}-e^{-0.80t}\right). $$

The expressions satisfy the initial conditions: \(A_1(0)=D\) and \(A_2(0)=0\). They also satisfy the equations on differentiation. For example, differentiating \(A_1\) gives \(-0.10(D/7)e^{-0.10t}-0.80(6D/7)e^{-0.80t}\); inserting the displayed \(A_1,A_2\) into \(-(0.70)A_1+0.20A_2\) gives the same expression. The second equation is verified by differentiating \(A_2\) and substituting the same trajectories. This provides a direct check of the derived reference.

Worked Example: Testing Central and Peripheral Amounts

Use the preceding hypothetical rates and a central bolus \(D=100\) mg. Calculate both amounts at 2 h.

At 2 h, \(e^{-0.10(2)}=e^{-0.2}=0.818731\) and \(e^{-0.80(2)}=e^{-1.6}=0.201897\). Then

$$ A_1(2)=\frac{100}{7}(0.818731)+\frac{600}{7}(0.201897) =11.6962+17.3054 =29.0016\ \text{mg}, $$
$$ A_2(2)=\frac{300}{7}(0.818731-0.201897) =42.8571(0.616834) =26.4358\ \text{mg}. $$

The reference values are \(29.00\) mg centrally and \(26.44\) mg peripherally. The model includes elimination from the central compartment through \(k_{10}\), so the sum of the two amounts is not expected to remain equal to the initial dose. The comparison is valid only if the executable model uses the same amount states, bolus condition, rates, and time units.

How to Make the Comparison

A verification comparison should be reproducible and localize errors rather than merely report that two curves differ. Choose time points that include the initial time, several interior times, and later times at which the dynamics have changed appreciably. Evaluate the exact expression at precisely the output times from the executable model. For each state and time, calculate an error such as

$$ e(t_i)=y_{\mathrm{sim}}(t_i)-y_{\mathrm{ref}}(t_i), \qquad e_{\mathrm{scaled}}(t_i)= \frac{|e(t_i)|}{\mathrm{atol}+\mathrm{rtol}|y_{\mathrm{ref}}(t_i)|}. $$

Here \(y_{\mathrm{sim}}\) and \(y_{\mathrm{ref}}\) denote simulated and reference values in the same units; \(\mathrm{atol}\) is an absolute tolerance in those units and \(\mathrm{rtol}\) is a dimensionless relative tolerance. A scaled error no greater than one satisfies this chosen pointwise tolerance. Near a zero reference value, the absolute tolerance prevents an unstable relative-error ratio. Tolerances should reflect the required numerical accuracy and the precision of the implementation, not be selected after seeing the result.

1
Isolate the component.
Disable unrelated mechanisms and specify the exact states, equations, initial conditions, units, and parameter values being tested.
2
Compute reference values.
Evaluate the analytical expressions at the same time points as the implementation output, using adequate numerical precision.
3
Quantify and inspect differences.
Calculate absolute and scaled errors for every tested state, then inspect how their signs and magnitudes vary over time.
4
Investigate before concluding.
Check equations, units, initial conditions, input handling, state mapping, and output-time alignment before attributing a mismatch to the solver.

Diagnostics, Alternatives, and Limitations

The pattern of error often points to the source. A nonzero error at time zero suggests an initial-condition, state-mapping, or output-alignment problem. A discrepancy that grows steadily can indicate a wrong rate constant, a unit conversion error, or an implementation defect. A correct early trajectory but wrong long-time value may indicate a steady-state or input error. A mismatch in only one state of a coupled system may indicate an indexing or output-mapping mistake. Conversely, small differences consistent with the chosen tolerance may arise from floating-point arithmetic and the numerical solver's approximation.

The analytical reference is the strongest direct comparison when the same mathematical assumptions yield a closed-form solution. A separately implemented high-accuracy numerical solution can serve as a useful cross-check when the equation is more complicated, but it is not an exact reference and could share a coding error with the implementation under test. Visual overlays are useful for seeing broad trajectory shape, but can conceal small, systematic discrepancies. Analytical checks also complement, rather than replace, code review and broader testing: they cover only the equations and conditions represented by the selected test cases.

A frequent mistake is to compare a simulation with a familiar formula without checking whether the assumptions match. For example, applying the fixed-free-ligand binding solution to a closed ligand–receptor system, or comparing a concentration output with a reference amount, creates a discrepancy even if each calculation is internally correct. The correction is to write down the exact implemented equations and state definitions first, verify units and conditions, and only then derive or select the reference. Another pitfall is to regard a close match at one time as proof of correctness; the comparison should cover multiple states and times, including the initial condition and the relevant time course.

These examples are deliberately simple. Their role is not to establish biological validity, assess qualification evidence, or test all behaviors of a complete QSP model. They provide transparent, quantitative checks of selected ODE components under specified conditions. More complex components may not admit a convenient closed form, and even a correct component-level match does not guarantee that interactions, event handling, or the full executable model are correct.

Key takeaway: An analytical reference is a precise verification target only when its equations and assumptions match the implemented component. Compare states at aligned times, quantify errors in context and units, and investigate discrepancies rather than relying on plots alone.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. For \(dR/dt=8-0.10R\), with \(R(0)=20\), what is the steady state and the exact value at 10 time units?
  2. Why does the fixed-free-ligand binding formula not generally apply when free ligand is depleted by binding?
  3. In the two-compartment example, what initial values must be used for a 50 mg central bolus?
  4. A simulation matches a reference at one late time but differs at time zero. Name two checks to make before deciding that the solver is accurate.

Solutions. (1) The steady state is \(8/0.10=80\) units. The solution is \(R(10)=80+(20-80)e^{-1}=80-60(0.367879)=57.9273\) units. (2) The formula assumes \(L\) is constant, which makes the equation linear in \(C\); ligand depletion makes \(L\) change with time and changes the governing equations. (3) Set \(A_1(0)=50\) mg and \(A_2(0)=0\) mg. (4) Check that the initial condition and state/output mapping are correct, and that the simulation and reference use aligned time points and the same units. A late-time match alone does not establish agreement across the trajectory.

Clinical Biostats