-
-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Description
Perhaps I am doing something wrong but combining VectorOfArray
with adaptive stepsize control in OrdinarryDiffEq
doesn't seem to work:
using OrdinaryDiffEq
using RecursiveArrayTools
u0 = VectorOfArray([ones(4, 4) for _ in 1:4])
# With this, error control works and the time steps are shorter:
# u0 = ones(4, 4, 4)
function dudt!(du, u, p, t)
@. du = -u
end
tspan = (0.0, 100.0)
prob = ODEProblem(dudt!, u0, tspan)
integrator = init(prob, Midpoint(), dtmax=10.0)
for i in 1:10
step!(integrator)
@info "" integrator.EEst integrator.dt (integrator.cache.fsalfirst[1] === integrator.cache.k[1])
end
println("Final time t = $(integrator.t)")
println("Solution u = $(integrator.sol.u[end][1, 1, 1])")
println("Exact u = $(exp(-integrator.t))")
This chooses the maximum allowed dt=10.0
and produces an inaccurate integration. To me its seems related to the use of recursivecopy!
in apply_step!
of OrdinaryDiffEq
. It copies references to the underlying arrays instead of contents.
After that the error estimates are zero.
Metadata
Metadata
Assignees
Labels
No labels