BVProblem(sys, op, tspan, guesses = ) builds a boundary value problem
from a compiled system with constraints such as EvalAt(0)(x) ~ 1 and
EvalAt(1)(x) ~ 2. Unknowns given values in op are fixed at the initial
time; guesses (and the system's guesses) start the iteration.
Details
BVProblem(f, bc, u0, tspan, p) builds one from an R function f(u, p, t) and a residual bc(sol, p, t), where sol(s) returns the state at
time s.
Solve with solve(bvp, MIRK4(), dt = 0.01) (collocation with mesh
refinement from an initial step dt; also MIRK5(), MIRK6()),
Shooting(Tsit5()) or MultipleShooting(10, Tsit5()). The result is a
BVPSolution, an ODE solution with dense output.
Examples
t <- t_nounits; D <- D_nounits
variables("y(t)")
sys <- mtkcompile(System(list(D(D(y)) ~ -y), t, name = "bvp",
constraints = list(EvalAt(0)(y) ~ 0, EvalAt(pi / 2)(y) ~ 1)))
bvp <- BVProblem(sys, list(), c(0, pi / 2), guesses = list(y ~ 0, D(y) ~ 1))
sol <- solve(bvp, MIRK4(), dt = 0.05)
sol(pi / 4)[1]
#> y(t)
#> 0.7071068