ODEProblem(sys, op, tspan) builds an ordinary differential equation
problem from a complete system: op gives initial values of unknowns and
values of parameters (as formulas x ~ 1, pairs, or a named list),
overriding their defaults. Compiled differential algebraic systems become
mass matrix problems. ODEFunction(sys) builds the right-hand side,
Jacobian and mass matrix without the values.
Usage
ODEFunction(sys, jac = FALSE, tgrad = FALSE, ...)
ODEProblem(
sys,
op = list(),
tspan = NULL,
...,
jac = FALSE,
tgrad = FALSE,
u0 = NULL,
p = NULL,
mass_matrix = NULL,
check_initialization = TRUE
)Arguments
- sys
A complete
System, or an R functionf(u, p, t).- jac
Generate the symbolic Jacobian.
- tgrad
Generate the time gradient.
- ...
Further values: a legacy parameter map, or solver options stored with the problem (
callback,tstops, ...). ForODEFunction(f, ...)of an R function:jac_fn,tgrad_fn,mass_matrix,analytic(function(u0, p, t), forcalculate_solution_errors()),paramjac,jvpandvjp.- op
Operating point: values of unknowns and parameters.
- tspan
Time span
c(t0, t1).- u0, p
Initial values and parameters for raw problems.
- mass_matrix
Mass matrix for raw problems.
- check_initialization
Check algebraic constraints at t0 and solve for algebraic unknowns that have no value.
Details
ODEProblem(f, u0, tspan, p) with an R function f(u, p, t) builds a
problem without a system.
Examples
t <- t_nounits; D <- D_nounits
variables("x(t)"); parameters("tau")
sys <- mtkcompile(System(list(D(x) ~ (1 - x) / tau), t, name = "sys"))
prob <- ODEProblem(sys, list(x ~ 0, tau ~ 3), c(0, 10))
sol <- solve(prob)
sol[x][length(sol$t)]
#> [1] 0.9643242