Skip to content

Commit bc01882

Browse files
test: test get_updated_symbolic_problem copying guesses of algebraic variables
1 parent df5afa9 commit bc01882

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/initializationsystem.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ end
15131513
@inferred solve(prob)
15141514
end
15151515

1516-
@testset "Issue#3570, #3552: `Initial`s are copied to `u0` during `solve`/`init`" begin
1516+
@testset "Issue#3570, #3552: `Initial`s/guesses are copied to `u0` during `solve`/`init`" begin
15171517
@parameters g
15181518
@variables x(t) [state_priority = 10] y(t) λ(t)
15191519
eqs = [D(D(x)) ~ λ * x
@@ -1522,9 +1522,17 @@ end
15221522
@mtkbuild pend = ODESystem(eqs, t)
15231523

15241524
prob = ODEProblem(
1525-
pend, [x => (2 / 2)], (0.0, 1.5), [g => 1], guesses ==> 1, y => 2 / 2])
1525+
pend, [x => (2 / 2), D(x) => 0.0], (0.0, 1.5),
1526+
[g => 1], guesses ==> 1, y => 2 / 2])
15261527
sol = solve(prob)
15271528

1529+
@testset "Guesses of initialization problem copied to algebraic variables" begin
1530+
prob.f.initialization_data.initializeprob[λ] = 1.0
1531+
prob2 = DiffEqBase.get_updated_symbolic_problem(
1532+
pend, prob; u0 = prob.u0, p = prob.p)
1533+
@test prob2[λ] 1.0
1534+
end
1535+
15281536
@testset "`setsym_oop`" begin
15291537
setter = setsym_oop(prob, [Initial(x)])
15301538
(u0, p) = setter(prob, [0.8])

0 commit comments

Comments
 (0)