|
867 | 867 | @test sign.(cos.(3 * (required_crossings_c2 .+ 1e-6))) == sign.(last.(cr2))
|
868 | 868 | end
|
869 | 869 |
|
870 |
| -@testset "Discrete variable timeseries" begin |
871 |
| - @variables x(t) |
872 |
| - @parameters a(t) b(t) c(t) |
873 |
| - cb1 = [x ~ 1.0] => [a ~ -a] |
874 |
| - function save_affect!(integ, u, p, ctx) |
875 |
| - integ.ps[p.b] = 5.0 |
876 |
| - end |
877 |
| - cb2 = [x ~ 0.5] => (save_affect!, [], [b], [b], nothing) |
878 |
| - cb3 = 1.0 => [c ~ t] |
879 |
| - |
880 |
| - @mtkbuild sys = ODESystem(D(x) ~ cos(t), t, [x], [a, b, c]; |
881 |
| - continuous_events = [cb1, cb2], discrete_events = [cb3]) |
882 |
| - prob = ODEProblem(sys, [x => 1.0], (0.0, 2pi), [a => 1.0, b => 2.0, c => 0.0]) |
883 |
| - @test sort(canonicalize(Discrete(), prob.p)[1]) == [0.0, 1.0, 2.0] |
884 |
| - sol = solve(prob, Tsit5()) |
885 |
| - |
886 |
| - @test sol[a] == [-1.0] |
887 |
| - @test sol[b] == [5.0, 5.0] |
888 |
| - @test sol[c] == [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] |
889 |
| -end |
890 |
| - |
891 | 870 | @testset "Discrete event reinitialization (#3142)" begin
|
892 | 871 | @connector LiquidPort begin
|
893 | 872 | p(t)::Float64, [description = "Set pressure in bar",
|
|
0 commit comments