-
-
Notifications
You must be signed in to change notification settings - Fork 79
Closed
Description
Take the following bouncing ball model
using DifferentialEquations, Sundials
function f(du,u,p,t)
du[1] = u[2]
du[2] = -9.81
end
function condition(u,t,integrator)
z = -u[1]
return z
end
function affect(integrator)
integrator.u[2] = -0.8*integrator.u[2]
#auto_dt_reset!(integrator)
#set_proposed_dt!(integrator, integrator.dt)
end
cb = ContinuousCallback(condition,affect)
u0 = [1.0,0.0]
tspan = (0.0,2.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob,CVODE_BDF(),saveat=0.1,callback=cb)
println("... show time")
for t in sol.t
@show t
end
If CVODE_BDF is used, then sol.t is:
t = 0.0
t = 0.1
t = 0.2
t = 0.3
t = 0.4
t = 0.5
t = 0.6
t = 0.7
t = 0.8
t = 0.9
t = 1.0
t = 1.1
t = 1.2
t = 1.3
t = 1.4
t = 1.5
t = 1.6
t = 1.7
t = 1.8
t = 1.9
t = 2.0
so no event points are stored in "sol". If integrator Tsit5() is used, the correct output is produced:
t = 0.0
t = 0.1
t = 0.2
t = 0.3
t = 0.4
t = 0.4515236409857255
t = 0.4515236409857255
t = 0.5
t = 0.6
t = 0.7
t = 0.8
t = 0.9
t = 1.0
t = 1.1
t = 1.1739614665628781
t = 1.1739614665628781
t = 1.2
t = 1.3
t = 1.4
t = 1.5
t = 1.6
t = 1.7
t = 1.7519117270245959
t = 1.7519117270245959
t = 1.8
t = 1.9
t = 2.0
Metadata
Metadata
Assignees
Labels
No labels