CompartmentalSystemBuilder#

class pharmpy.CompartmentalSystemBuilder(cs=None)[source]#

Bases: object

Builder for CompartmentalSystem

Methods Summary

add_compartment(compartment)

Add compartment to system

add_flow(source, destination, rate)

Add flow between two compartments

move_dose(source, destination)

Move a dose input from one compartment to another

remove_compartment(compartment)

Remove compartment from system

remove_flow(source, destination)

Remove flow between two compartments

set_dose(compartment, dose)

Set dose of compartment

set_lag_time(compartment, lag_time)

Set lag time of compartment

Methods Documentation

add_compartment(compartment)[source]#

Add compartment to system

The compartment will be added without any flows to other compartments. Use the add_flow method to add flows to and from the newly added compartment.

Parameters:

compartment (Compartment) – Compartment to add

Examples

>>> from pharmpy import CompartmentalSystemBuilder
>>> cb = CompartmentalSystemBuilder()
>>> central = cb.add_compartment("CENTRAL")
add_flow(source, destination, rate)[source]#

Add flow between two compartments

Parameters:
  • source (Compartment) – Source compartment

  • destination (Compartment) – Destination compartment

  • rate (Expression) – Symbolic rate of flow

Examples

>>> from pharmpy import CompartmentalSystemBuilder
>>> cb = CompartmentalSystemBuilder()
>>> depot = Compartment("DEPOT")
>>> cb.add_compartment(depot)
>>> central = Compartment("CENTRAL")
>>> cb.add_compartment("CENTRAL")
>>> cb.add_flow(depot, central, "KA")
move_dose(source, destination)[source]#

Move a dose input from one compartment to another

Parameters:
  • source (Compartment) – Source compartment

  • destination (Compartment) – Destination compartment

remove_compartment(compartment)[source]#

Remove compartment from system

Parameters:

compartment (Compartment) – Compartment object to remove from system

Examples

>>> from pharmpy import CompartmentalSystemBuilder
>>> cb = CompartmentalSystemBuilder()
>>> central = Compartment("CENTRAL")
>>> cb.add_compartment(central)
>>> cb.remove_compartment(central)
remove_flow(source, destination)[source]#

Remove flow between two compartments

Parameters:
  • source (Compartment) – Source compartment

  • destination (Compartment) – Destination compartment

Examples

>>> from pharmpy import CompartmentalSystemBuilder
>>> cb = CompartmentalSystemBuilder()
>>> depot = Compartment("DEPOT")
>>> cb.add_compartment(depot)
>>> central = Compartment("CENTRAL")
>>> cb.add_compartment(central)
>>> cb.add_flow(depot, central, "KA")
>>> cb.remove_flow(depot, central)
set_dose(compartment, dose)[source]#

Set dose of compartment

Parameters:
  • compartment (Compartment) – Compartment for which to change dose

  • dose (Dose) – New dose

Returns:

Compartment – The new updated compartment

set_lag_time(compartment, lag_time)[source]#

Set lag time of compartment

Parameters:
  • compartment (Compartment) – Compartment for which to change lag time

  • lag_time (expr) – New lag time

Returns:

Compartment – The new updated compartment