Main Content

Compartment object

Object containing compartment information


The SimBiology® compartment object represents a container for species in a model. Compartment size can vary or remain constant during a simulation. All models must have at least one compartment and all species in a model must be assigned to a compartment. Compartment names must be unique within a model.

Compartments allow you to define the size (Capacity) of physically isolated regions that may affect simulation, and associate pools of species within those regions. You can specify or change Capacity using rules, events, and variants, similar to species amounts or parameter values.

The model object stores compartments as a flat list. Each compartment stores information on its own organization; in other words a compartment has information on which compartment it lives within (Owner) and who it contains (Compartments).

The flat list of compartments in the model object lets you vary the way compartments are organized in your model without invalidating any expressions.

To add species that participate in reactions, add the reaction to the model using the addreaction method. When you define a reaction with a new species:

  • If no compartment objects exist in the model, the addreaction method creates a compartment object (called 'unnamed') in the model and adds the newly created species to that compartment.

  • If only one compartment object exists in the model, the method creates a species object in that compartment.

  • If there is more than one compartment object in the model, you must qualify the species name with the compartment name.

    For example, cell.glucose denotes that you want to put the species named glucose into a compartment named cell. Additionally, if the compartment named cell does not exist, the process of adding the reaction creates the compartment and names it cell.

Alternatively, create and add a species object to a compartment object, using the addspecies method at the command line.

When you use the SimBiology desktop to create a new model, it adds an empty compartment (unnamed), to which you can add species.

You can specify reactions that cross compartments using the syntax compartment1Name.species1Name –> compartment2Name.species2Name. If you add a reaction that contains species from different compartments, and the reaction rate dimensions are concentration/time, all reactants should be from the same compartment.

In addition, if the reaction is reversible then there are two cases:

  • If the kinetic law is MassAction, and the reaction rate reaction rate dimensions are concentration/time, then the products must be from the same compartment.

  • If the kinetic law is not MassAction, then both reactants and products must be in the same compartment.

See Property Summary for links to compartment property reference pages. Properties define the characteristics of an object. Use the get and set commands to list object properties and change their values at the command line. You can graphically change object properties in the graphical user interface.

Constructor Summary

addcompartmentCreate compartment object and add to model or compartment

Method Summary

Methods for compartment objects

addcompartmentCreate compartment object and add to model or compartment
addspeciesCreate species object and add to model or compartment
copyobjCopy SimBiology object and its children
deleteDelete SimBiology object
displayDisplay summary of SimBiology object
findUsagesFind out how a species, parameter, or compartment is used in a model
getGet SimBiology object properties
moveMove SimBiology compartment object to new owner
renameRename SimBiology model component and update expressions
reorder (model, compartment, kinetic law)Reorder component lists
setSet SimBiology object properties

Property Summary

Properties for compartment objects

CapacityCompartment capacity
CapacityUnitsCompartment capacity units
CompartmentsArray of compartments in model or compartment
Constant Specify variable or constant species amount, parameter value, or compartment capacity
ConstantCapacity Specify variable or constant compartment capacity
NameSpecify name of object
NotesHTML text describing SimBiology object
OwnerOwning compartment
ParentIndicate parent object
SpeciesArray of species in compartment object
TagSpecify label for SimBiology object
TypeDisplay SimBiology object type
Units Units for species amount, parameter value, compartment capacity, observable expression
UserDataSpecify data to associate with object
ValueValue of species, compartment, or parameter object

Version History

Introduced in R2008a