Delay Differential Equations (DDE)
ODE solver extension for models with delayed state feedback.
Class
- class openpkpd.pk.ode.dde.DDESubroutine(n_compartments=10, rtol=1e-06, atol=1e-08, method='RK45')[source]
Bases:
PKSubroutineGeneric DDE solver for PK/PD models with constant or parameter-dependent delays.
The delay value (τ) is read from
pk_paramsas"TAU"or"DELAY". If neither is present, the solver degenerates to a plain ODE (τ = 0).The history function is injected into
pk_paramsunder the key"_AHISTORY"before each call todes_callable, allowing the user’s$DEScode to look up past compartment states.Parameters
- n_compartmentsint
Number of ODE compartments (default 10).
- rtol, atolfloat
Tolerances for the underlying
solve_ivp(RK45).- methodstr
scipy integration method (default
"RK45").
- solve(pk_params, dose_events, obs_times, pk_callable=None, des_callable=None)[source]
Integrate the DDE system for a single subject.
The
des_callableis called as:dadt = des_callable(t, a_list, pk_params_with_history, [], [])
where
pk_params_with_historyis pk_params augmented with the key"_AHISTORY".- Return type:
PKSolution- Parameters:
Parameters
- pk_params :
PK parameter dict (e.g.,
{"CL": 3.0, "V": 10.0, "TAU": 2.0}).- dose_events :
Dose events for this subject (bolus or infusion).
- obs_times :
Observation times (unsorted is OK).
- pk_callable :
Unused; included for interface compatibility.
- des_callable :
REQUIRED compiled
$DEScallable with signature(t, A_list, pk_params, theta, eta) -> dAdt_list.
Returns
PKSolution
Raises
- PKError
If
des_callableis None or ODE integration fails.
Overview
DDESubroutine extends ADVAN6 to support delayed compartment values in the
$DES right-hand side. The solver integrates piecewise using scipy’s
solve_ivp with history interpolation.
from openpkpd.pk.ode.dde import DDESubroutine
dde = DDESubroutine(n_compartments=2, delay_params=["TAU"])
The $DES block may reference ALAG(n) or explicit delay parameters.
See examples/16_dde_model.py for a full example.