Skip to content

Commit 2426464

Browse files
Merge pull request #3894 from AayushSabharwal/as/fix-callback-op
fix: fix callback with non-`Real` parameter and non-empty unknowns
2 parents 18cbb8d + 2b55628 commit 2426464

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/systems/callbacks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ end
855855
function default_operating_point(affsys::AffectSystem)
856856
sys = system(affsys)
857857

858-
op = Dict(unknowns(sys) .=> 0.0)
858+
op = AnyDict(unknowns(sys) .=> 0.0)
859859
for p in parameters(sys)
860860
T = symtype(p)
861861
if T <: Number

test/symbolic_events.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,3 +1421,22 @@ end
14211421
@named sys = System([D(y) ~ 2x + 1, x^2 ~ 2y^3], t; discrete_events = [dev])
14221422
sys = @test_nowarn mtkcompile(sys)
14231423
end
1424+
1425+
@testset "Non-`Real` symtype parameters in callback with unknown" begin
1426+
@mtkmodel MWE begin
1427+
@variables begin
1428+
x(t) = 1.0
1429+
end
1430+
@parameters begin
1431+
p(t)::Int = 1
1432+
end
1433+
@equations begin
1434+
D(x) ~ p * x
1435+
end
1436+
@discrete_events begin
1437+
1.0 => [x ~ p * Pre(x) * sin(x)]
1438+
end
1439+
end
1440+
@mtkcompile sys = MWE()
1441+
@test_nowarn ODEProblem(sys, [], (0.0, 1.0))
1442+
end

0 commit comments

Comments
 (0)