@@ -298,6 +298,42 @@ eqs = [yd ~ Sample(dt)(y)
298
298
ss = mtkcompile (cl)
299
299
ss_nosplit = mtkcompile (cl; split = false )
300
300
301
+ prob = ODEProblem (ss, [x => 0.0 , kp => 1.0 ], (0.0 , 1.0 ))
302
+ prob_nosplit = ODEProblem (ss_nosplit, [x => 0.0 , kp => 1.0 ], (0.0 , 1.0 ))
303
+ sol = solve (prob, Tsit5 (), kwargshandle = KeywordArgSilent)
304
+ sol_nosplit = solve (prob_nosplit, Tsit5 (), kwargshandle = KeywordArgSilent)
305
+
306
+ function foo! (dx, x, p, t)
307
+ kp, ud1, ud2 = p
308
+ dx[1 ] = - x[1 ] + ud1 + ud2
309
+ end
310
+
311
+ function affect1! (integrator)
312
+ kp = integrator. p[1 ]
313
+ y = integrator. u[1 ]
314
+ r = 1.0
315
+ ud1 = kp * (r - y)
316
+ integrator. p[2 ] = ud1
317
+ nothing
318
+ end
319
+ function affect2! (integrator)
320
+ kp = integrator. p[1 ]
321
+ y = integrator. u[1 ]
322
+ r = 1.0
323
+ ud2 = kp * (r - y)
324
+ integrator. p[3 ] = ud2
325
+ nothing
326
+ end
327
+ cb1 = PeriodicCallback (affect1!, dt; final_affect = true , initial_affect = true )
328
+ cb2 = PeriodicCallback (affect2!, dt2; final_affect = true , initial_affect = true )
329
+ cb = CallbackSet (cb1, cb2)
330
+ # kp ud1 ud2
331
+ prob = ODEProblem (foo!, [0.0 ], (0.0 , 1.0 ), [1.0 , 1.0 , 1.0 ], callback = cb)
332
+ sol2 = solve (prob, Tsit5 ())
333
+
334
+ @test sol. u≈ sol2. u atol= 1e-6
335
+ @test sol_nosplit. u≈ sol2. u atol= 1e-6
336
+
301
337
# #
302
338
@info " Testing hybrid system with components"
303
339
using ModelingToolkitStandardLibrary. Blocks
0 commit comments