@@ -138,6 +138,7 @@ fsys = flatten(sys)
138
138
@test isequal (ModelingToolkit. continuous_events (sys2)[2 ]. eqs[], sys. x ~ 1 )
139
139
140
140
sys = complete (sys)
141
+ sys_nosplit = complete (sys; split = false )
141
142
sys2 = complete (sys2)
142
143
# Functions should be generated for root-finding equations
143
144
prob = ODEProblem (sys, Pair[], (0.0 , 2.0 ))
@@ -155,15 +156,22 @@ cond.rf_ip(out, [2], p0, t0)
155
156
@test out[] ≈ 1 # signature is u,p,t
156
157
157
158
prob = ODEProblem (sys, Pair[], (0.0 , 2.0 ))
159
+ prob_nosplit = ODEProblem (sys_nosplit, Pair[], (0.0 , 2.0 ))
158
160
sol = solve (prob, Tsit5 ())
161
+ sol_nosplit = solve (prob_nosplit, Tsit5 ())
159
162
@test minimum (t -> abs (t - 1 ), sol. t) < 1e-10 # test that the solver stepped at the root
163
+ @test minimum (t -> abs (t - 1 ), sol_nosplit. t) < 1e-10 # test that the solver stepped at the root
160
164
161
165
# Test that a user provided callback is respected
162
166
test_callback = DiscreteCallback (x -> x, x -> x)
163
167
prob = ODEProblem (sys, Pair[], (0.0 , 2.0 ), callback = test_callback)
168
+ prob_nosplit = ODEProblem (sys_nosplit, Pair[], (0.0 , 2.0 ), callback = test_callback)
164
169
cbs = get_callback (prob)
170
+ cbs_nosplit = get_callback (prob_nosplit)
165
171
@test cbs isa CallbackSet
166
172
@test cbs. discrete_callbacks[1 ] == test_callback
173
+ @test cbs_nosplit isa CallbackSet
174
+ @test cbs_nosplit. discrete_callbacks[1 ] == test_callback
167
175
168
176
prob = ODEProblem (sys2, Pair[], (0.0 , 3.0 ))
169
177
cb = get_callback (prob)
@@ -234,9 +242,11 @@ continuous_events = [[x ~ 0] => [vx ~ -vx]
234
242
D (vy) ~ - 0.01 vy], t; continuous_events)
235
243
236
244
ball = structural_simplify (ball)
245
+ ball_nosplit = structural_simplify (ball; split = false )
237
246
238
247
tspan = (0.0 , 5.0 )
239
248
prob = ODEProblem (ball, Pair[], tspan)
249
+ prob_nosplit = ODEProblem (ball_nosplit, Pair[], tspan)
240
250
241
251
cb = get_callback (prob)
242
252
@test cb isa ModelingToolkit. DiffEqCallbacks. VectorContinuousCallback
@@ -250,9 +260,13 @@ cond.rf_ip(out, [0, 0, 0, 0], p0, t0)
250
260
@test out ≈ [0 , 1.5 , - 1.5 ]
251
261
252
262
sol = solve (prob, Tsit5 ())
263
+ sol_nosplit = solve (prob_nosplit, Tsit5 ())
253
264
@test 0 <= minimum (sol[x]) <= 1e-10 # the ball never went through the floor but got very close
254
265
@test minimum (sol[y]) ≈ - 1.5 # check wall conditions
255
266
@test maximum (sol[y]) ≈ 1.5 # check wall conditions
267
+ @test 0 <= minimum (sol_nosplit[x]) <= 1e-10 # the ball never went through the floor but got very close
268
+ @test minimum (sol_nosplit[y]) ≈ - 1.5 # check wall conditions
269
+ @test maximum (sol_nosplit[y]) ≈ 1.5 # check wall conditions
256
270
257
271
# tv = sort([LinRange(0, 5, 200); sol.t])
258
272
# plot(sol(tv)[y], sol(tv)[x], line_z=tv)
@@ -270,13 +284,18 @@ continuous_events = [
270
284
D (vx) ~ - 1
271
285
D (vy) ~ 0 ], t; continuous_events)
272
286
287
+ ball_nosplit = structural_simplify (ball)
273
288
ball = structural_simplify (ball)
274
289
275
290
tspan = (0.0 , 5.0 )
276
291
prob = ODEProblem (ball, Pair[], tspan)
292
+ prob_nosplit = ODEProblem (ball_nosplit, Pair[], tspan)
277
293
sol = solve (prob, Tsit5 ())
294
+ sol_nosplit = solve (prob_nosplit, Tsit5 ())
278
295
@test 0 <= minimum (sol[x]) <= 1e-10 # the ball never went through the floor but got very close
279
296
@test - minimum (sol[y]) ≈ maximum (sol[y]) ≈ sqrt (2 ) # the ball will never go further than √2 in either direction (gravity was changed to 1 to get this particular number)
297
+ @test 0 <= minimum (sol_nosplit[x]) <= 1e-10 # the ball never went through the floor but got very close
298
+ @test - minimum (sol_nosplit[y]) ≈ maximum (sol_nosplit[y]) ≈ sqrt (2 ) # the ball will never go further than √2 in either direction (gravity was changed to 1 to get this particular number)
280
299
281
300
# tv = sort([LinRange(0, 5, 200); sol.t])
282
301
# plot(sol(tv)[y], sol(tv)[x], line_z=tv)
0 commit comments