Compartment macro


The macro compartment defines a PK model compartment. Compartments can be the target of an administration, can be subject to a clearance process or can be linked with other compartments for exchange processes. The compartment amount, concentration and volume are variables.


Arguments for the macro compartment are:

  • cmt: Unique identifier of the compartment. Its default value is 1.
  • amount: Name of variable defined as the amount within the compartment. Its dynamics are defined by dose absorptions, eliminations, and the transfer rates with other compartments. These dynamics can extend an ODE system that defines a component with this name.
  • volume: Name of predefined variable to use as the volume of the compartment. It enables to define concentration. Its default value is 1.
  • concentration: Name of the variable defined as the concentration within the compartment.


; To define a compartment with ID 1, of volume V, an amount called Ac, and a concentration called Cc
compartment(cmt=1, amount=Ac, volume=V, concentration=Cc)

If no administration is involved for a compartment, and if the amount and all its dynamics are defined as an ODE component with its derivative, then the compartment macro definition is not needed.

Example with Mlxplore
In the following example, a compartment is defined in the PK: bloc and the dynamics of the amount is defined with the iv and elimination macro. The model is implemented in the file compartment.mlxplore.mlxtran available as Mlxplore demo. A snapshot of the code is shown below:

input = {V, k}

compartment(cmt=1, amount=Ac, concentration=Cc, volume=V)
iv(cmt=1, type=1)
elimination(cmt=1, k)

The considered administration is a dose of 1 at time 5. We defined the one compartment, and the associated concentration, amount, id, are defined in it. Therefore, it is very simple to define the associated dynamics. We added an absorption process as a bolus and defined a linear elimination. The results can be seen in the following figure.


The main interest of this example is that all the parameters of the compartments are well defined and therefore their manipulation is easy.

Rules and Best Practices

  • We encourage the user to use all the fields in the macro to guarantee non confusion between concentration, amount, …
    CAUTION: if the volume is not given, it will be assumed to be equal to 1. The volume is in particular needed to calculate k from the clearance when Cl is used as input of the elimination macro.
  • The compartment definition has to be done in the first place before additional macros.
  • Format restriction (non compliance will raise an exception)
    • The value after cmt= is necessarily an integer.
    • The value after amount=, volume= and concentration= are necessarily strings.