A compartment is a block that acts as an integrator of quantities of materials in a model. The quantity held within this block is calculated with a differential equation, where the input and output rates are defined by the transfer blocks.
Note that the compartment block is only available with the ODE toolbox.
Creating a compartment
From the Projects window
Expand the Project to which you wish to add the compartment by clicking the + symbol next to it. Right-click on ‘Blocks’, or a sub-system
in ‘Blocks’, and select Compartment
from the pop-up menu.
From the matrix window
From the Blocks window
Editing a compartment
|Note||Most block properties can be edited directly in the blocks window.
The block editor is shown by right-clicking the block in a window and selecting Edit. In the Blocks window, you can also show the block editor by selecting the block and clicking the button, or by double-clicking the right-most “validation” column of the block.
The block editor has three tabs:
This page lets you edit basic properties such as name, sub-system and base unit. See editing properties for more information.
This page lets you specify initial conditions and other index specific properties. See Editing values for more information.
Dimension - You can specify the dimension of the block by using the Type drop down list. Depending on the dimension the index drop down lists are activated.
- For blocks that are non-scalar, the first columns will specify indices from the index lists
. This allows you to specify different expressions for different indices. The top row is named “default” and can be used when the same value should be set for all indices.
- Allows you to enter an expression for the initial inventory of the corresponding material. Note that a value, a parameter or an Expression
in the initial condition is evaluated when the simulation is started and time = t0. The Expression editing tool
is available to help the user to enter and edit data.
dy/dt - Lets you add extra term to the differential equation of the compartment. This feature is useful, for instance, for a simple integration of values where it is not logical to modify the state of the compartment through transfers.
– If set, the inventory of the compartment cannot be negative. Default = “disabled”
. This feature, though very useful, can affect the model in a way that the non-existing inventory is later added to following compartments. To avoid issues with this, make sure transfer blocks around it take into account for this truncation. Use mass balance block
to test the system.
Abs. error tol.– Sets the absolute error tolerance for the given material. If empty, the “global” value set in simulation settings is used. Default =
- By using the Table control button
you can display more columns that will help you document your model.