Skip to content

Pharmacokinetics

Pharmacokinetics shared by the biology packages: the input of drugs in schedules of infusions.

DosingInteraction(label, *, target, state='x', dose=1.0, period=None, width=1.0, start=0.0, count=None)

Bases: RateInteraction

Input of a drug into a state of a target at the rate dose, constantly or in a schedule of infusions.

Without a period the drug enters at the constant rate dose. With a period it enters at the rate dose for width time units every period from start, count times or without end. The dose is a function of the namespace, which reads the parameters of the target, or a number.

Parameters:

Name Type Description Default
label str

The label of the interaction, unique among the parts of its system.

required
target Annotated[str, RoleSpec()]

The path of the element or group whose drug state the dose raises.

required
state str

The name of the state of the target that holds the drug.

'x'
dose Callable[[SimpleNamespace], object] | float

A function of the namespace that returns the rate of the input during an infusion, or a number.

1.0
period float | None

The time between the starts of infusions, or None for a constant input.

None
width float

The duration of every infusion.

1.0
start float

The time of the first infusion.

0.0
count int | None

The number of infusions, or None for a schedule that never ends.

None

Raises:

Type Description
ValidationError

The state is not a name, the dose is neither a function nor a number, or the schedule is not positive.

Examples:

>>> from skcomplex.core.elements import CompartmentElement
>>> from skcomplex.core.system import System
>>> from skcomplex.engine.runtime import Simulation
>>> from skcomplex.models.biology.common.pharmacokinetics import DosingInteraction
>>> dosing = DosingInteraction('dosing', target='patient', state='n', dose=2.0, period=10.0, count=3)
>>> system = System(elements=[CompartmentElement('patient', n=0.0)], interactions=[dosing])
>>> trajectory = Simulation(system, dt=0.5).check().prepare().run(until=40.0).trajectory_
>>> round(float(trajectory.values('patient.n')[-1]), 3)
6.0
Source code in src/skcomplex/models/biology/common/pharmacokinetics/_dosing.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def __init__(
    self,
    label: str,
    *,
    target: Annotated[str, RoleSpec()],
    state: str = 'x',
    dose: Callable[[SimpleNamespace], object] | float = 1.0,
    period: float | None = None,
    width: float = 1.0,
    start: float = 0.0,
    count: int | None = None,
) -> None:
    super().__init__(label, target=target, state=state)
    self.dose = dose
    self.period = period
    self.width = width
    self.start = start
    self.count = count