ExplicitODESystem#

class pharmpy.model.ExplicitODESystem(odes, ics)[source]#

Bases: ODESystem

System of ODEs described explicitly

Parameters:
  • odes (list) – Symbolic differential equations

  • ics (dict) – Symbolic initial conditions

Examples

>>> from pharmpy.model import ExplicitODESystem
>>> import sympy
>>> A_DEPOT = sympy.Function('A_DEPOT')
>>> A_CENTRAL = sympy.Function('A_CENTRAL')
>>> t = sympy.Symbol('t')
>>> AMT, KA, K = sympy.symbols('AMT KA K')
>>> eq1 = sympy.Eq(sympy.Derivative(A_DEPOT(t), t), -KA * A_DEPOT(t))
>>> eq2 = sympy.Eq(sympy.Derivative(A_CENTRAL(t)), -K*A_CENTRAL(t) + KA*A_DEPOT(t))
>>> ics = {A_DEPOT(0): AMT, A_CENTRAL(0): 0}
>>> odes = ExplicitODESystem([eq1, eq2], ics)
>>> odes
⎧d
⎪──(A_DEPOT(t)) = -KA⋅A_DEPOT(t)
⎪dt
⎨d
⎪──(A_CENTRAL(t)) = -K⋅A_CENTRAL(t) + KA⋅A_DEPOT(t)
⎪dt
⎪A_DEPOT(0) = AMT
⎩A_CENTRAL(0) = 0

Attributes Summary

amounts

Column vector of all amount functions

compartment_names

Names of all compartments

free_symbols

Get set of all free symbols in the ODE system

ics

Initial conditions

odes

List of ordinary differential equations

rhs_symbols

Get set of all free symbols in the right hand side expressions

Methods Summary

subs(substitutions)

Substitute expressions or symbols in ODE system

to_compartmental_system()

Get the explicit system as a compartmental ODE system

to_explicit_system([skip_output])

Attributes Documentation

amounts#

Column vector of all amount functions

Examples

>>> from pharmpy.modeling import load_example_model
>>> import sympy
>>> model = load_example_model("pheno")
>>> odes = model.statements.ode_system.to_explicit_system()
>>> sympy.pprint(odes.amounts)
⎡A_CENTRAL⎤
⎢         ⎥
⎣A_OUTPUT ⎦
compartment_names#

Names of all compartments

Examples

>>> from pharmpy.modeling import load_example_model
>>> model = load_example_model("pheno")
>>> odes = model.statements.ode_system.to_explicit_system()
>>> odes.compartment_names
['CENTRAL', 'OUTPUT']
free_symbols#

Get set of all free symbols in the ODE system

Returns:

set – Set of symbols

Examples

>>> from pharmpy.modeling import load_example_model
>>> model = load_example_model("pheno")
>>> odes = model.statements.ode_system.to_explicit_system()
>>> odes.free_symbols  
{AMT, CL, V, t}
ics#

Initial conditions

odes#

List of ordinary differential equations

rhs_symbols#

Get set of all free symbols in the right hand side expressions

Returns:

set – Set of symbols

Examples

>>> from pharmpy.modeling import load_example_model
>>> model = load_example_model("pheno")
>>> odes = model.statements.ode_system.to_explicit_system()
>>> odes.rhs_symbols   
{AMT, CL, V, t}

Methods Documentation

subs(substitutions)[source]#

Substitute expressions or symbols in ODE system

Examples

>>> from pharmpy.modeling import load_example_model
>>> model = load_example_model("pheno")
>>> odes = model.statements.ode_system.to_explicit_system()
>>> odes.subs({'AMT': 'DOSE'})
⎧d                  -CL⋅A_CENTRAL(t)
⎪──(A_CENTRAL(t)) = ─────────────────
⎪dt                         V
⎨d                 CL⋅A_CENTRAL(t)
⎪──(A_OUTPUT(t)) = ───────────────
⎪dt                       V
⎪A_CENTRAL(0) = DOSE
⎩A_OUTPUT(0) = 0
to_compartmental_system()[source]#

Get the explicit system as a compartmental ODE system

Returns:

CompartmentalSystem – The same ODE system in compartmental representation

Example

>>> from pharmpy.modeling import load_example_model
>>> model = load_example_model("pheno")
>>> statements = model.statements.to_explicit_system()
>>> statements.to_compartmental_system()    
to_explicit_system(skip_output=False)[source]#