Documentation

8.18 Worked analytic-versus-ODE verification

The Chapter 8 experiment represents the same one-compartment oral model as ADVAN2 TRANS2 and ADVAN13 $DES.

For dose \(D=100\), \(CL=5\), \(V=50\), \(KA=1.2\), and \(k=CL/V=0.1\), the closed-form concentration is

\[ C(t)=\frac{D}{V}\frac{KA}{KA-k}\left(e^{-kt}-e^{-KA t}\right). \]

The analytic control stream is ctlanalytic.ctl; the ODE stream is ctlode.ctl. Both use the same csvengine.csv, parameters, scale and error model. The ODE sets TOL=10 ATOL=12.

Reproduce

python tools/ch08_examples.py `
  --nlmx ../nlmx/target/release/nlmx.exe `
  --output documents/ch08/results-recheck

Use a new output folder. The harness refuses non-empty destinations and refuses to replace changed fixtures.

Results

Eight observation times from 0.25 to 24 hours were compared. The retained csvanalytic_vs_ode.csv gives every value and error.

Comparison Maximum absolute discrepancy
ADVAN2 versus closed form \(4.44\times10^{-16}\)
ADVAN13 versus closed form \(1.19\times10^{-11}\)
ADVAN2 versus ADVAN13 \(1.19\times10^{-11}\)
ODE error against analytic reference

These are measured results for the 4.3.0 executable hash recorded in jsonexample_summary.json, not universal error bounds. The 4.4.0 source tree is documented separately.

Negative fixture

The same harness submits a $PK block containing verbatim Fortran. It exits 5 and reports that verbatim code is unsupported. Positive and negative fixtures together test agreement and refusal boundaries.

Extending the experiment

Add two/three compartments, coincident rates, fixed/modelled infusions, lags, ETA-dependent events, steady state, resets, stiff ODEs and nonlinear error models. Compare values and derivatives over a tolerance grid and against an independently implemented reference.

Common mistakes

  • Presenting one linear fixture as full NONMEM equivalence.
  • Hiding the executable/source version difference.
  • Comparing rounded report values rather than CSV precision.

Checklist

  • Freeze executable hash and fixture bytes.
  • Predefine absolute and relative tolerances.
  • Retain row-level discrepancies and expected failures.

Further reading

See ODE tolerance control, accuracy boundaries and Chapter 42's planned validation matrix.