Skip to content

Commit c73b0a2

Browse files
test: test mutation of Initial parameters
1 parent b664e1c commit c73b0a2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/initializationsystem.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,3 +1312,22 @@ end
13121312
sol = solve(prob, Tsit5())
13131313
@test sol.ps[p] [2.0, 4.0]
13141314
end
1315+
1316+
@testset "Issue#3318: Mutating `Initial` parameters works" begin
1317+
@variables x(t) y(t)[1:2] [guess = ones(2)]
1318+
@parameters p[1:2, 1:2]
1319+
@mtkbuild sys = ODESystem(
1320+
[D(x) ~ x, D(y) ~ p * y], t; initialization_eqs = [x^2 + y[1]^2 + y[2]^2 ~ 4])
1321+
prob = ODEProblem(sys, [x => 1.0, y[1] => 1], (0.0, 1.0), [p => 2ones(2, 2)])
1322+
integ = init(prob, Tsit5())
1323+
@test integ[x] 1.0
1324+
@test integ[y] [1.0, sqrt(2.0)]
1325+
prob.ps[Initial(x)] = 0.5
1326+
integ = init(prob, Tsit5())
1327+
@test integ[x] 0.5
1328+
@test integ[y] [1.0, sqrt(2.75)]
1329+
prob.ps[Initial(y[1])] = 0.5
1330+
integ = init(prob, Tsit5())
1331+
@test integ[x] 0.5
1332+
@test integ[y][0.5, sqrt(3.5)] atol=1e-6
1333+
end

0 commit comments

Comments
 (0)