Multi-language suite for high-performance solvers of differential equations and scientific machine learning (SciML) components. Ordinary differential equations (ODEs), stochastic differential equations (SDEs), delay differential equations (DDEs), differential-algebraic equations (DAEs), and more in Julia.
As reported here. Changing the size of the ODE system during integration with a callback throws an error when using some functions (eg resize! works but deleteat! does not) if one uses the default automatic stiffness detection algorithm. The issue is fixed when specifying the solver.
using DifferentialEquations
const α = -0.3
function f(du,u,p,t)
for i in 1:length(u)
du[i] = α*u[i]
end
end
function condition(u,t,integrator) # Event when event_f(u,t) == 0
minimum(u)-0.01
end
function affect!(integrator)
u = integrator.u
#resize!(integrator,length(u)-1) # This works
deleteat!(integrator, length(u)) # This errors
nothing
end
callback = ContinuousCallback(condition,affect!)
u0 = [5, 3, 1]
tspan = (0.0,20.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob,callback=callback) # specifying the algorithm fixes the problem
As reported here. Changing the size of the ODE system during integration with a callback throws an error when using some functions (eg resize! works but deleteat! does not) if one uses the default automatic stiffness detection algorithm. The issue is fixed when specifying the solver.