Modules
- class protocol.Protocol(name: str, end_time: float, points: int, intervals: Optional[dict] = None, spikes: Optional[dict] = None)
A Pharmokinetic (PK) protocol
INPUTS:
- name: str
Name of the protocol. Will be used for plotting
- end: float
End time of the protocol (assumed that start time is 0)
- points: int
Number of time discretization points
- intervals: list of dicts
List of dictionaries of constant dosage
The intervals must be dictionaries stored in a list as follows: intervals = [{‘start’: 0, ‘end’: 0.1, ‘dose’: 1},
{‘start’: 0.5, ‘end’: 0.6, ‘dose’: 1}, {‘start’: 0.9, ‘end’: 1, ‘dose’: 2}, … etc]
‘start’ and ‘end’ are start and end times of dosage in hrs. ‘dose’ is the rate of dosage in ng/h
- spikes: list of dicts
List of delta functions that represent dose injections
The dosage injections must be stored as follows: spikes = [{‘time’: 0.2, ‘dose’: 1},
{‘time’: 0.8, ‘dose’: 2}, … etc]
‘time’ is the time at which the instantaneous dose is applied
- show_graph()
Plots a figure of the protocol
- class model.Model(dict: dict)
A Pharmokinetic (PK) model
INPUTS: dictionary describing the model
- name: str
This will be used for plotting the solutions
- CL: float
[mL/h], the clearance/elimination rate from the central compartment
- Vc: float
[mL], the volume of the central compartment
- ka: float, optional
[1/h], the “absorption” rate for the s.c dosing. If a ka is not given in the dictionary, its default value will be 0
- Qpi: float, optional
[mL/h], the transition rate between central compartment and peripheral compartments i, where i can be any positive integer By default there are no peripheral compartmentss
- Vpi: float, optional
[mL], the volume of the peripheral compartments i, where i can be any positive integer. Qpi and Vpi must be present at the same time. If only one of them is offered, the code will throw an error By default there are no peripheral compartmentss
The dictionary should have the following template: {
‘name’: name your model <str>, (for visualization purposes)
‘CL’: CL <float> [mL/h],
‘Vc’: Vc <float>, [mL]
‘ka’: ka <float>, [1/h] (if subcutaneous)
‘Qp1’: Qp1 <float>, [mL/h] (if one peripheral used)
‘Vp1’: Vp1 <float>, [mL] (if one peripheral used)
‘Qp2’: Qp1 <float>, [mL/h] (if two peripheral used)
‘Vp2’: Vp1 <float>, [mL] (if two peripheral used)
‘Qp3’: Qp1 <float>, [mL/h] (if three peripheral used)
‘Vp3’: Vp1 <float>, [mL] (if three peripheral used) … etc
}
The peripheral compartmentss must be added starting from 1 and increasing in increments of 1 up to the maximum number peripheral compartmentss used
At a minimum, the model must have a main compartiemnt with CL and Vc given, and a name
- class solution.Solution(model, protocol)
A Pharmokinetic (PK) solution model
INPUTS
- model: object
see Model class
- protocol: object
see Protocol class
This class creates one or more solution objects that contain the time interval, and the drug quantities in the central compartiment, the peripheral compartiments and the subcutaneous compartiment (if present). The solution can be visualized by calling the “visualization” method.
The general system of equations governing the Pk model can be written as:
dq/dt = A*q + D
where q is a vector that holds all the unknowns in the following format: q = [qc q0 qp1 qp2 qp3 …] A is a matrix that encapsulates the coupling between unknowns, and D is a vector of the form: D = [dose(t) 0 0 0 …]
OUTPUT:
- Solution: object
Holds the time, and solution vectors Time can be accessed with solution.t Solutions can be accessed with solution.y