set_peripheral_compartments#

pharmpy.modeling.set_peripheral_compartments(model, n, name=None)[source]#

Sets the number of peripheral compartments for central compartment to a specified number.

If name is set, the peripheral compartment will be added to the compartment with the specified name instead.

Parameters:
  • model (Model) – Pharmpy model

  • n (int) – Number of transit compartments

  • name (str) – Name of compartment to add peripheral to.

Returns:

Model – Pharmpy model object

Examples

>>> from pharmpy.modeling import *
>>> model = load_example_model("pheno")
>>> model = set_peripheral_compartments(model, 2)
>>> model.statements.ode_system
Bolus(AMT, admid=1) → CENTRAL
┌───────────┐
│PERIPHERAL1│
└───────────┘
  ↑      │
Q2/V1  Q2/V2
  │      ↓
┌───────────┐
│  CENTRAL  │──CL/V1→
└───────────┘
   ↑      │
 Q3/V3  Q3/V1
   │      ↓
┌───────────┐
│PERIPHERAL2│
└───────────┘