@@ -1466,12 +1466,12 @@ end
14661466 sol_c = solve (prob_c, Rosenbrock23 ())
14671467 sol_d = solve (prob_d, Rosenbrock23 ())
14681468 sol_cd = solve (prob_cd, Rosenbrock23 ())
1469- @test sol_c[X][end ] ≈ 2.0 atol = 1e-3 rtol = 1e-3
1470- @test sol_c[Y][end ] ≈ 1.0 atol = 1e-3 rtol = 1e-3
1471- @test sol_d[X][end ] ≈ 1.0 atol = 1e-3 rtol = 1e-3
1472- @test sol_d[Y][end ] ≈ 2.0 atol = 1e-3 rtol = 1e-3
1473- @test sol_cd[Y][end ] ≈ 2.0 atol = 1e-3 rtol = 1e-3
1474- @test sol_cd[Y][end ] ≈ 2.0 atol = 1e-3 rtol = 1e-3
1469+ @test sol_c[X][end ]≈ 2.0 atol= 1e-3 rtol= 1e-3
1470+ @test sol_c[Y][end ]≈ 1.0 atol= 1e-3 rtol= 1e-3
1471+ @test sol_d[X][end ]≈ 1.0 atol= 1e-3 rtol= 1e-3
1472+ @test sol_d[Y][end ]≈ 2.0 atol= 1e-3 rtol= 1e-3
1473+ @test sol_cd[Y][end ]≈ 2.0 atol= 1e-3 rtol= 1e-3
1474+ @test sol_cd[Y][end ]≈ 2.0 atol= 1e-3 rtol= 1e-3
14751475 end
14761476
14771477 # Complicated and multiple events.
@@ -1485,18 +1485,22 @@ end
14851485 D (X2) ~ p2 + k2 - d2* X2,
14861486 D (X3) ~ p3 + k3 - d3* X3,
14871487 D (X4) ~ p4 + k4 - d4* X4,
1488- D (X5) ~ p4 + k4 - d4* X5,
1488+ D (X5) ~ p4 + k4 - d4* X5
14891489 ]
1490- cevents = [[t + d1 + k1 ~ 0.5 ] => [Pre (X1)* (p1 + 5 + Pre (X2)) + Pre (k1) ~ Pre (3 X2 + k2)]]
1490+ cevents = [[t + d1 + k1 ~
1491+ 0.5 ] => [Pre (X1)* (p1 + 5 + Pre (X2)) + Pre (k1) ~ Pre (3 X2 + k2)]]
14911492 devents = [
14921493 2.0 => [exp (p2 + Pre (p2)) ~ 5.0 ],
1493- [1.0 ] => [(4 + Pre (k2) + Pre (k4) + Pre (k3))^ 3 + exp (1 + Pre (k3)) ~ (3 + p3 + Pre (k2))^ 3 ],
1494- (t == 1.5 ) => [
1495- Pre (k2) + Pre (k3) ~ p4 * (2 + Pre (k1)) + 3 ,
1494+ [1.0 ] => [(4 + Pre (k2) + Pre (k4) + Pre (k3))^ 3 + exp (1 + Pre (k3)) ~
1495+ (3 + p3 + Pre (k2))^ 3 ],
1496+ (t ==
1497+ 1.5 ) => [
1498+ Pre (k2) + Pre (k3) ~ p4 * (2 + Pre (k1)) + 3 ,
14961499 Pre (p5) + 2 + 3 Pre (k4) + Pre (p5) ~ exp (p5)
14971500 ]
14981501 ]
1499- @mtkcompile sys = System (eqs, t, us, ps; continuous_events = cevents, discrete_events = devents)
1502+ @mtkcompile sys = System (
1503+ eqs, t, us, ps; continuous_events = cevents, discrete_events = devents)
15001504
15011505 # Simulates system so that all events trigger.
15021506 sim_cond = [
@@ -1542,27 +1546,27 @@ end
15421546 # Simulates the model. Checks that the correct values are achieved.
15431547 prob = ODEProblem (model, [], (0.0 , 100.0 ))
15441548 sol = solve (prob, Rosenbrock23 ())
1545- @test sol. ps[model. kup] == 2.0
1549+ @test sol. ps[model. kup] == 2.0
15461550 @test sol. ps[model. k[1 ]] == 3.0
15471551 @test sol. ps[model. k[2 ]] == 1.0
1548- @test sol[model. X[1 ]][end ] ≈ 2.0 atol = 1e-8 rtol = 1e-8
1549- @test sol[model. X[2 ]][end ] ≈ 6.0 atol = 1e-8 rtol = 1e-8
1552+ @test sol[model. X[1 ]][end ]≈ 2.0 atol= 1e-8 rtol= 1e-8
1553+ @test sol[model. X[2 ]][end ]≈ 6.0 atol= 1e-8 rtol= 1e-8
15501554 end
15511555
15521556 # Checks for a functional affect.
15531557 let
15541558 # Creates model.
15551559 @variables X (t) = 5.0
1556- @parameters p = 2.0 d (t) = 1.0
1560+ @parameters p= 2.0 d (t)= 1.0
15571561 eqs = [D (X) ~ p - d * X]
15581562 affect! (mod, obs, ctx, integ) = return (; d = 2.0 )
15591563 cevent = [t ~ 1.0 ] => (f = affect!, modified = (; d))
15601564 @mtkcompile sys = System (eqs, t; continuous_events = [cevent])
15611565
15621566 # Simualtes the model and checks that values is correct.
15631567 sol = solve (ODEProblem (sys, [], (0.0 , 100.0 )), Rosenbrock23 ())
1564- @test sol[X][end ] ≈ 1.0 atol = 1e-8 rtol = 1e-8
1568+ @test sol[X][end ]≈ 1.0 atol= 1e-8 rtol= 1e-8
15651569 @test sol. ps[p] == 2.0
15661570 @test sol. ps[d] == [1.0 , 2.0 ]
15671571 end
1568- end
1572+ end
0 commit comments