@@ -22,6 +22,10 @@ callback = ContinuousCallback(condition, affect!)
22
22
sol = solve (prob, Tsit5 (), callback = callback)
23
23
@test length (sol) < 20
24
24
25
+ # Force integrator to step on event
26
+ sol = solve (prob, Tsit5 (), callback = callback, tstops = [- 2.95 ])
27
+ @test sol (- 2.95 , continuity = :right ) ≈ sol (- 2.95 , continuity = :left ) + 2
28
+
25
29
condition = function (out, u, t, integrator) # Event when event_f(u,t,k) == 0
26
30
out[1 ] = - t - 2.95
27
31
end
@@ -36,6 +40,10 @@ callback = VectorContinuousCallback(condition, affect!, 1)
36
40
37
41
sol = solve (prob, Tsit5 (), callback = callback)
38
42
43
+ # Force integrator to step on event
44
+ sol = solve (prob, Tsit5 (), callback = callback, tstops = [- 2.95 ])
45
+ @test sol (- 2.95 , continuity = :right ) ≈ sol (- 2.95 , continuity = :left ) + 2
46
+
39
47
f = function (du, u, p, t)
40
48
du[1 ] = - u[1 ] + sin (t)
41
49
end
@@ -54,6 +62,10 @@ callback = ContinuousCallback(condition, affect!)
54
62
55
63
sol = solve (prob, Tsit5 (), callback = callback, abstol = 1e-8 , reltol = 1e-6 )
56
64
65
+ # Force integrator to step on event
66
+ sol = solve (prob, Tsit5 (), callback = callback, abstol = 1e-8 , reltol = 1e-6 , tstops = [2.95 ])
67
+ @test sol (2.95 , continuity = :right )[1 ] ≈ sol (2.95 , continuity = :left )[1 ] + 2
68
+
57
69
condition = function (out, u, t, integrator) # Event when event_f(u,t,k) == 0
58
70
out[1 ] = t - 2.95
59
71
end
@@ -68,6 +80,10 @@ callback = VectorContinuousCallback(condition, affect!, 1)
68
80
69
81
sol = solve (prob, Tsit5 (), callback = callback, abstol = 1e-8 , reltol = 1e-6 )
70
82
83
+ # Force integrator to step on event
84
+ sol = solve (prob, Tsit5 (), callback = callback, abstol = 1e-8 , reltol = 1e-6 , tstops = [2.95 ])
85
+ @test sol (2.95 , continuity = :right )[1 ] ≈ sol (2.95 , continuity = :left )[1 ] + 2
86
+
71
87
f = function (du, u, p, t)
72
88
du[1 ] = u[2 ]
73
89
du[2 ] = - 9.81
0 commit comments