Dynamical systems driven by ODEs
Sommaire 
Autonomous dynamical systems
Consider a timevarying system $A(t)=(A_1(t),A_2(t),\ldots A_J(t))$ defined by a system of Ordinary Differential Equations (ODE)

(1.1) 
where $\dot{A}(t)$ denotes the vector of derivatives of $A(t)$ with respect to $t$:

(1.2) 
Notations:
 let $A_0 = A(t_0)$ be the initial condition of the system defined at the initial time $t_0$,
 let $A^{\star}$ be the solution of the system at equilibrium: $F(A^{\star}) =0$
A basic model
We assume here that there is no input:
 \(\begin{align} A(t_0) & = &A_0 \\ \dot{A}(t) & = &F(A(t)) \, \ t \geq t_0 \end{align}\)


Consider a basic VK model with $A=(N,I,V)$ where $N$ is the number of non infected target cells, $C$ the number of infected target cells and $V$ the number of virus.
After infection and before treatment, the dynamics of the system is described by this ODE system:

(1.3) 
The equilibrium state of this system is $A^{\star} = (N^{\star} , I^{\star} , V^{\star})$, where

(1.4) 
Assume that the system has reached the equilibrium state $A^{\star}$ when the treatment starts at time $t_0=0$.
The treatment inhibits the infection of the target cells and blocks the production of virus. The dynamics of the new system is described with the new ODE system (1.5).
This system, and the initial conditions, can be exactly reproduced using the MLXTRAN macros (block EQUATION)

(1.5) 
$EQUATION T_0 = 0 N_0 = delta*c/(beta*p); I_0 = (sd*N)/delta V_0 = p*I/c DDT_N = s  beta*(1eta)*N*V  d*N DDT_I = beta*(1eta)*N*V  delta*I DDT_V = p*(1epsilon)*I  c*V 
 Remark1
 Here, $T_0 = 0$ means that the system is constant and is $A^{\star}$, defined in the script by $(N_0, I_0, V_0)$, for any $t<0$.
 Remark2
 If the initial condition is not given in the model, it is assumed to be 0.
Piecewise defined dynamical systems
More generally, we can consider inputless systems which are piecewise defined: there exists a sequence of times $t_0< t_1< ...<t_K$ and functions $F^{(1)}, F^{(2)},\ldots,F^{(K)}$ such that
 \(\begin{align} A(t_0) &= &A_0 \\ \dot{A}(t) &= &F_k(A(t)) \ , \ t_{k1} \leq t \leq t_{k} \end{align}\)



(1.6) (1.7) (1.8) 
VARIABLES ID, TIME, VL use=DV, EVENT list=(Start1, Start2, Stop) $EQUATION SWITCH CASE T < T_Start1 N = delta*c/(beta*p); I = (sd*N)/delta V = p*I/c CASE T_Start1 < T < T_Start2 DDT_N = s  beta*N*V  d*N DDT_I = beta*N*V  delta*I CASE T_Start2 < T < T_Stop DDT_N = s  beta*(1eta)*N*V  d*N DDT_I = beta*(1eta)*N*V  delta*I DDT_V = p*(1epsilon)*I  c*V CASE T > T_Stop DDT_N = s  beta*(1eta*exp(k1*(TT_Stop)))*N*V  d*N DDT_I = beta*(1eta*exp(k1*(TT_Stop)))*N*V  delta*I DDT_V = p*(1epsilon*exp(k2*(TT_Stop)))*I  c*V END
T_0 = T_Start1 <br> N_0 = delta*c/(beta*p) <br> I_0 = (sd*N)/delta <br> V_0 = p*I/c SWITCH CASE T_Start1 < T < T_Start2 be = beta pe = p*(1epsilon) CASE T_Start2 < T < T_Stop be = beta*(1eta) pe = p*(1epsilon) CASE T > T_Stop be = beta*(1eta*exp(k1*(TT_Stop))) pe = p*(1epsilon*exp(k2*(TT_Stop))) END DDT_N = s  be*N*V  d*N DDT_I = be*N*V  delta*I DDT_V = pe*I  c*V 
Dynamical systems with source terms
Consider now the system (1.1) with inputs:

(2.1) 
where:

(2.2) 
The input $u(t)=(u_1(t),u_2(t),\ldots,u_J(t))$ of the system can be defined either in the datafile (doses in a PK model for instance) or in the model.
Piecewise constant inputs
We assume an additive model for the inputs: for any $1\leq \ell \leq L$
 \( \dot{A_{\ell}}(t) = F_\ell(A(t)) + u_\ell(t) \)
Then, there exists a sequence of times $(\tau_{\ell,j})$, durations $(d_{\ell,j})$ and amounts $(a_{\ell,j})$ such that

(2.3) 
Consider an IV infusion with two compartments, i.e. a very basic situation with only one type of administration. Such infusion can be described by the following system of equations:


If there is no need of any additional column DPT (depot compartment) in the datafile to distinguish different target depots for different types of administration, the model reduces to:
$VARIABLES ID, TIME, AMT, TINF, DV $EQUATION DDT_Ac = k*Ac  k12*Ac + k21*Ap DDT_Ap = k12*Ac  k21*Ap
If no additional information about the input is given in the model, the default is to assume that the input goes to the first component of the ODE system.
Assume now that the target compartment is not the first component of the system. Then, it is mandatory to associate in the model a component with the target compartment. As an example, consider the same datafile as before, but assume that the ODE system has been permuted, then the model should define the second component of the system as the target component:
$EQUATION INPUT(CMT=2) DDT_Ap = k12*Ac  k21*Ap <br> DDT_Ac = k*Ac  k12*Ac + k21*Ap
Spike inputs
We consider an inputless dynamical system: for any $1\leq \ell \leq L$,
 \( \dot{A_\ell}(t) = F_\ell(A(t)) \)
Spike inputs means that there exists a sequence of times $(\tau_{\ell,j})$ and amounts $(a_{\ell,j})$ such that
 \( A_\ell(\tau_{\ell,j}) = A_\ell(\tau_{\ell,j}^{}) + a_{\ell,j} \)
In other words, the amount $a_{\ell,j}$ is added to the component $A_\ell$ at time $\tau_{\ell,j}$.
Consider an IV bolus.

In this case, the input is given by the column AMT in the dataset.

Inputs defined in the model
Only some very basic inputs can be directly derived from the information in the datafile. More complex inputs should be defined in the model, or using some external forcing function
Example: Consider now a 2 compartments model


Then, several solutions exist for coding the input. A first solution consists in coding directly the input function in the ODE system:


DDT_Ac = k*Ac  k12*Ac + k21*Ap + a*exp(b*T) 
DDT_Ap = k12*Ac  k21*Ap 
This is clearly the simplest solution, but the input function is not defined as such.
Then, it would be impossible to encode the input in the MML.
The input function can be defined by an external forcing function (called ExpInput in the following example)


INPUT(CMT=1,RATE=ExpInput(a,b)) 
DDT_Ac = k*Ac  k12*Ac + k21*Ap 
DDT_Ap = k12*Ac  k21*Ap 
or directly in the model


INPUT(CMT=1,RATE=inline('a*exp(b*T)')) 
DDT_Ac = k*Ac  k12*Ac + k21*Ap 
DDT_Ap = k12*Ac  k21*Ap 
Multiple inputs
Different inputs in different components of the ODE system can easily be combined.


Important Remark: The datafile only contains information about the administration of the drugs, not about the PK model. The link between the depot compartments and the components of the ODES is defined in the model:


INPUT(DPT='GUT1', CMT=1) 
INPUT(DPT='GUT2', CMT=2) 
INPUT(DPT='SP', CMT=4) 
INPUT(DPT='SC', CMT=3) 
DDT_Ad1 = ka1*Ad1 
DDT_Ad2 = ka2*Ad2 
DDT_Ac = ka1*Ad1 + ka2*Ad2  k*Ac 
DDT_As = ks*As 
... ... 
Remark: Bioavailability or lagtimes can easily be taken into account in the model:


INPUT(DPT='GUT1', CMT=1 , Tlag= TLAG1 , P=F1) 
INPUT(DPT='GUT2', CMT=2 , P=F2) 
.... 