Skip to content

Commit 5e279ce

Browse files
committed
Added test from issue (and a simplified version of it)
1 parent 6e636b2 commit 5e279ce

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/odesystem.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,3 +1194,23 @@ end
11941194
@test_nowarn obsfn(buffer, [1.0], ps..., 3.0)
11951195
@test buffer [2.0, 3.0, 4.0]
11961196
end
1197+
1198+
# https://github.com/SciML/ModelingToolkit.jl/issues/2859
1199+
@testset "Initialization with defaults from observed equations (edge case)" begin
1200+
@variables x(t) y(t) z(t)
1201+
eqs = [D(x) ~ 0, y ~ x, D(z) ~ 0]
1202+
defaults = [x => 1, z => y]
1203+
@named sys = ODESystem(eqs, t; defaults)
1204+
ssys = structural_simplify(sys)
1205+
prob = ODEProblem(ssys, [], (0.0, 1.0), [])
1206+
@test prob[x] == prob[y] == prob[z] == 1.0
1207+
1208+
@parameters y0
1209+
@variables x(t) y(t) z(t)
1210+
eqs = [D(x) ~ 0, y ~ y0 / x, D(z) ~ y]
1211+
defaults = [y0 => 1, x => 1, z => y]
1212+
@named sys = ODESystem(eqs, t; defaults)
1213+
ssys = structural_simplify(sys)
1214+
prob = ODEProblem(ssys, [], (0.0, 1.0), [])
1215+
@test prob[x] == prob[y] == prob[z] == 1.0
1216+
end

0 commit comments

Comments
 (0)