You can also append "compartments" to the model. Because of the ODE solving internals, you cannot add fake compartments to the model until after all the differential equations are defined.

For example this is legal:

ode.1c.ka <- function(){
  model({
    C2 = center/V
    d / dt(depot) = -KA * depot
    d/dt(center) = KA * depot - CL*C2
    cmt(eff)
  })
}

ode.1c.ka <- ode.1c.ka()
print(ode.1c.ka)

You can see this more clearly with the underlying classic rxode2 model:

ode.1c.ka$simulationModel

But compartments defined before all the differential equations is not supported; So the model below:

ode.1c.ka <- rxode2({
    cmt(eff)
    C2 = center/V;
    d / dt(depot) = -KA * depot
    d/dt(center) = KA * depot - CL*C2
})

will give an error:

Error in rxModelVars_(obj) : 
  Evaluation error: Compartment 'eff' needs differential equations defined.


Try the rxode2 package in your browser

Any scripts or data that you put into this service are public.

rxode2 documentation built on Oct. 30, 2024, 9:06 a.m.