Compartments¶
With the SUND toolbox, it is possible to assign a compartment to a model object. In this way, it is possible to connect only some models, or to create multiple versions of the same model (with e.g. different parameter or state values). Below are snippets from the example available in Examples > Use cases > Using compartments.
sund.install_model("sub_model.txt")
SubModel = sund.import_model("sub_model") # Load the model class for the sub model
adipose_model = SubModel(compartment="adipose") # Assign the model to a compartment
When a model is assigned to a compartment, all states, parameters, inputs, outputs, and features are internally prepended with the compartment name. So in the example above, if we have the following features:
########## FEATURES
glucose = glu
uptake = uptake
So for example, print(adipose_model.feature_names)
would now return ['adipose:glucose', 'adipose:uptake']
.
Inputs from other compartments¶
Since this also applies to the inputs, some additional steps are needed to capture the output from other compartments. If the compartment is known, you can prepend the input name with that compartment name. For example if the input comes from a model in the compartment main
:
########## INPUTS
adipose_uptake = main:uptake @ 0
If the output comes from a model not assigned to a compartment, it is possible to append the input with only a colon:
########## INPUTS
adipose_uptake = :uptake @ 0