Analytical Solutions and Differential Equations
The dynamical problem types specify the dynamical models that are the nonlinear transformation of the NLME model. There are two major types of dynamical models: analytical models and DEProblem
s. An analytical model is a small differential equation with an analytical solution. This analytical solution is used by the solvers to greatly enhance the performance. On the other hand, DEProblem
is a specification of a differential equation for numerical solution by DifferentialEquations
. This is used for specifying dynamical equations which do not have an analytical solution, such as many nonlinear ordinary differential equations (ODEs), or the myriad of differential equation types supported by DifferentialEquations
, such as delay differential equations (DDEs) and stochastic differential equations (SDEs).
Analytical Solutions
Analytical problems are a predefined ODE with an analytical solution. While limited in flexibility, the analytical solutions can be much faster for simulation and estimation. In the @model
DSL, an analytical solution is declared by name. For example:
@dynamics Central1
declares the use of Central1
dynamics. Analytical solutions have preset names which are used in the internal model. These parameters must be given values in the @pre
block.
Central1
Pumas.Central1
— TypeCentral1()
An analytical model for a one compartment model with dosing into Central
. Equivalent to
Central' = -CL/Vc*Central
where clearance, CL
, and volume, Vc
, are required to be defined in the @pre
block.
Depots1Central1
Pumas.Depots1Central1
— TypeDepots1Central1()
An analytical model for a one compartment model with a central compartment, Central
, and a depot, Depot
. Equivalent to
Depot' = -Ka*Depot
Central' = Ka*Depot - CL/Vc*Central
where absoption rate, Ka
, clearance, CL
, and volume, Vc
, are required to be defined in the @pre
block.
Depots2Central1
Pumas.Depots2Central1
— TypeDepots2Central1()
An analytical model for a one compartment model with a central compartment, Central
, and two depots, Depot1
and Depot2
. Equivalent to
Depot1' = -Ka1*Depot1
Depot2' = -Ka2*Depot2
Central' = Ka1*Depot1 + Ka2*Depot2 - CL/Vc*Central
where absorption rates, Ka1
and Ka2
, clearance, CL
, and volume, Vc
, are required to be defined in the @pre
block.
When using this model during simulation or estimation, it is preferred to have 2 dosing rows for each subject in the dataset, where the first dose goes into cmt =1
(or cmt = Depot1
) and the second dose goes into cmt=2
(or cmt=Depot2
). Central compartment gets cmt=3
or (cmt = Central
). e.g.
ev = DosageRegimen([100,100],cmt=[1,2]) s1 = Subject(id=1, events=ev)
Central1Periph1
Pumas.Central1Periph1
— TypeCentral1Periph1()
An analytical model for a two-compartment model with a central compartment, Central
and a peripheral compartment, Peripheral
. Equivalent to
Central' = -(CL+Q)/Vc*Central + Q/Vp*Peripheral
Peripheral' = Q/Vc*Central - Q/Vp*Peripheral
where clearance, CL
, and volumes, Vc
and Vp
, and distribution clearance, Q
, are required to be defined in the @pre
block.
Depots1Central1Periph1
Pumas.Depots1Central1Periph1
— TypeDepots1Central1Periph1()
An analytical model for a two-compartment model with a central compartment, Central
, a peripheral compartment, Peripheral
, and a depot Depot
. Equivalent to
Depot' = -Ka*Depot
Central' = Ka*Depot - (CL+Q)/Vc*Central + Q/Vp*Peripheral
Peripheral' = Q/Vc*Central - Q/Vp*Peripheral
where absorption rate, Ka
, clearance, CL
, and volumes, Vc
and Vp
, and distribution clearance, Q
, are required to be defined in the @pre
block.
Central1Meta1
Pumas.Central1Meta1
— TypeCentral1Meta1()
An analytical model for a model with a central compartment, Central
, and a metabolite, Metabolite
. Equivalent to Central' = -(CL+CLfm)/VcCentral Metabolite' = CLfm/VcCentral - CLm/Vm*Metabolite where clearances (CL
and CLm
) and volumes (Vc
and Vm
) and formation clearance of metabolite CLfm
are required to be defined in the @pre
block.
Central1Periph1Meta1
Pumas.Central1Periph1Meta1
— TypeCentral1Periph1Meta1()
An analytical model for a two compartment model with a central compartment, Central
, with a peripheral compartment, Peripheral
, and a metabolite compartment, Metabolite
. Equivalent to
Central' = -(CL+Q+CLfm)/Vc*Central + Q/Vp*CPeripheral
CPeripheral' = Q/Vc*Central - Q/Vp*CPeripheral
Metabolite' = -CLm/Vm*Metabolite + CLfm/Vc*Central
where clearances (CL
and CLm
) and volumes (Vc
, Vp
and Vm
), distribution clearance (Q
), and formation clearance of metabolite CLfm
are required to be defined in the @pre
block.
Central1Periph1Meta1Periph1
Pumas.Central1Periph1Meta1Periph1
— TypeCentral1Periph1Meta1Periph1()
An analytical model for a two compartment model with a central compartment, Central
, with a peripheral compartment, Peripheral
, and a metabolite compartment, Metabolite
, with a peripheral compartment, MPeripheral
. Equivalent to
Central' = -(CL+Q+CLfm)/Vc*Central + Q/Vp*CPeripheral
CPeripheral' = Q/Vc*Central - Q/Vp*CPeripheral
Metabolite' = -(CLm+Qm)/Vm*Metabolite + Qm/Vmp*MPeripheral + CLfm/Vc*Central
MPeripheral' = Qm/Vm*Metabolite - Qm/Vmp*MPeripheral
where clearances (CL
and CLm
) and volumes (Vc
, Vp
, Vm
and Vmp
), distribution clearances (Q
and Qm
) and formation clearance of metabolite CLfm
are required to be defined in the @pre
block.
Differential Equations DEProblem
DEProblem
s are types from DifferentialEquations
which are used to specify differential equations to be solved numerically via the solvers of the package. In the @model
interface, the DEProblem
is set to be an ODEProblem
defining an ODE. The models are defined by writing each of the differential equations in the system, e.g.
@dynamics begin
Central' = -(CL / Vc) * Central
end
for a simple one compartment model and
@dynamics begin
Depot' = -Ka * Depot
Central' = Ka * Depot - (CL / Vc) * Central
end
for a one compartment model with first order absorption.
Default solvers
Dynamical models that do not have an analytical solution have to be integrated numerically. There are a myriad of solvers with different properties and performance under different conditions. For simobs
the default value is
AutoTsit5(
Rosenbrock23(
autodiff = Val{true}(),
linsolve = LinearSolve.GenericLUFactorization(),
chunk_size = Val{1}(),
),
)
while for fitting it is
AutoVern7(
Rodas5P(
autodiff = Val{true}(),
linsolve = LinearSolve.GenericLUFactorization(),
chunk_size = Val{1}(),
),
)
The AutoX(Y)
signature where X
and Y
are names of integrators means that X
will be used unless stiffness is detected and then Y
will be used. In both simobs
and fit
(or any other function where it may be relevant to set diffeq_options
) it is possible to change these defaults using the diffeq_options
keyword argument with an alg
element. For example, it is possible to fit using Vern7
only using the syntax
results = fit(model, population, param, FOCE(); diffeq_options = (; alg = Vern7()))
This should only be done if the user is certain that stiffness could not be detected even at extreme parameter values, but it would in principle remove a little bit of overhead if the model is indeed not stiff.