Skip to contents

Load a model into a symengine environment

Usage

rxS(
  x,
  doConst = TRUE,
  promoteLinSens = FALSE,
  envir = parent.frame(),
  pkTime = FALSE,
  timeSwitch = FALSE
)

Arguments

x

rxode2 object

doConst

Load constants into the environment as well; a character vector loads every constant except the named ones.

promoteLinSens

Promote solved linear compartment systems to sensitivity-based solutions.

envir

default is NULL; Environment to put symengine variables in.

pkTime

When TRUE, time in statements that do not depend on a state is loaded as rx_time_pk, defined by rx_time_pk~t in ..lhs0, so it stays separate from the time in d/dt() after those statements are inlined; rxSolve(..., nonmem = TRUE) then reads it as the record time. Only for callers that write ..lhs0 into the model they build.

timeSwitch

When TRUE, a comparison of time with an expression of the parameters (t >= exp(ltsw)) is loaded as a comparison with an internal variable rx_tsw_<k>_ holding that expression, so a sensitivity model can declare it mtime() and add the exact jump at the switch (see .rxTimeSwitchLines()). "check" only records such comparisons. Only for callers that write those declarations into the model they build.

Value

rxode2/symengine environment

See also

Other Symbolic tools: rxSymEngineCacheReset(), rxToSE()

Author

Matthew Fidler

Examples

# \donttest{
pk <- function() {
  model({
    d/dt(depot) <- -ka * depot
    d/dt(central) <- ka * depot - cl / v * central
  })
}
s <- rxS(pk)
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
# the d/dt() lines as loaded
s$..ddt
#> [1] "d/dt(depot)=-ka*depot"               "d/dt(central)=ka*depot-cl*central/v"
# each derivative is a symengine expression; differentiate it in the env
with(s, D(rx__d_dt_central__, ka))
#> (Symbol)	depot
# }