Skip to content

Commit a3bee38

Browse files
committed
Test derivative guesses
1 parent ea01bae commit a3bee38

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/initializationsystem.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ end
510510
end
511511

512512
# https://github.com/SciML/ModelingToolkit.jl/issues/3029
513-
@testset "Derivatives in Initialization Equations" begin
513+
@testset "Derivatives in initialization equations" begin
514514
@variables x(t)
515515
sys = ODESystem(
516516
[D(D(x)) ~ 0], t; initialization_eqs = [x ~ 0, D(x) ~ 1], name = :sys) |>
@@ -523,6 +523,20 @@ end
523523
@test_nowarn ODEProblem(sys, [D(x) => 1.0], (0.0, 1.0), [])
524524
end
525525

526+
# https://github.com/SciML/ModelingToolkit.jl/issues/3049
527+
@testset "Derivatives in initialization guesses" begin
528+
for sign in [-1.0, +1.0]
529+
@variables x(t)
530+
sys = ODESystem(
531+
[D(D(x)) ~ 0], t;
532+
initialization_eqs = [D(x)^2 ~ 1, x ~ 0], guesses = [D(x) => sign], name = :sys
533+
) |> structural_simplify
534+
prob = ODEProblem(sys, [], (0.0, 1.0), [])
535+
sol = solve(prob, Tsit5())
536+
@test sol(1.0, idxs=sys.x) sign # system with D(x(0)) = ±1 should solve to x(1) = ±1
537+
end
538+
end
539+
526540
# https://github.com/SciML/ModelingToolkit.jl/issues/2619
527541
@parameters k1 k2 ω
528542
@variables X(t) Y(t)

0 commit comments

Comments
 (0)