Skip to content

Pharmacokinetics

Pharmacokinetics shared by the biology packages.

It covers 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: Interaction

Input of a drug into a state of a target at the rate dose.

The drug enters 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 components of its system.

required
target Role

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.systems.biology.common.kinetics import CompartmentElement
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.biology.common.pharmacokinetics import DosingInteraction
>>> dosing = DosingInteraction('dosing', target='patient', state='x', dose=2.0, period=10.0, count=3)
>>> system = System(elements=[CompartmentElement('patient', x=0.0)], interactions=[dosing])
>>> trajectory = system.prepare().simulate(until=40.0, dt=0.5)
>>> round(float(trajectory.get_values('patient.x')[-1]), 3)
6.0
Source code in src/skcomplex/systems/biology/common/pharmacokinetics/_dosing.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
def __init__(
    self,
    label: str,
    *,
    target: Role,
    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)
    self.target = target
    self.state = state
    self.dose = dose
    self.period = period
    self.width = width
    self.start = start
    self.count = count