Skip to content

Commit f5f1e6a

Browse files
test: test present of steady-state Initial parameters
1 parent 4626b56 commit f5f1e6a

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

test/initializationsystem.jl

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -406,30 +406,35 @@ sol = solve(prob, Tsit5())
406406
@test sol.u[1] == [1.0]
407407

408408
# Steady state initialization
409+
@testset "Steady state initialization" begin
410+
@parameters σ ρ β
411+
@variables x(t) y(t) z(t)
409412

410-
@parameters σ ρ β
411-
@variables x(t) y(t) z(t)
413+
eqs = [D(D(x)) ~ σ * (y - x),
414+
D(y) ~ x *- z) - y,
415+
D(z) ~ x * y - β * z]
412416

413-
eqs = [D(D(x)) ~ σ * (y - x),
414-
D(y) ~ x *- z) - y,
415-
D(z) ~ x * y - β * z]
417+
@named sys = ODESystem(eqs, t)
418+
sys = structural_simplify(sys)
416419

417-
@named sys = ODESystem(eqs, t)
418-
sys = structural_simplify(sys)
420+
u0 = [D(x) => 2.0,
421+
x => 1.0,
422+
D(y) => 0.0,
423+
z => 0.0]
419424

420-
u0 = [D(x) => 2.0,
421-
x => 1.0,
422-
D(y) => 0.0,
423-
z => 0.0]
425+
p ==> 28.0,
426+
ρ => 10.0,
427+
β => 8 / 3]
424428

425-
p ==> 28.0,
426-
ρ => 10.0,
427-
β => 8 / 3]
429+
tspan = (0.0, 0.2)
430+
prob_mtk = ODEProblem(sys, u0, tspan, p)
431+
sol = solve(prob_mtk, Tsit5())
432+
@test sol[x *- z) - y][1] == 0.0
428433

429-
tspan = (0.0, 0.2)
430-
prob_mtk = ODEProblem(sys, u0, tspan, p)
431-
sol = solve(prob_mtk, Tsit5())
432-
@test sol[x *- z) - y][1] == 0.0
434+
prob_mtk.ps[Initial(D(y))] = 1.0
435+
sol = solve(prob_mtk, Tsit5())
436+
@test sol[x *- z) - y][1] == 1.0
437+
end
433438

434439
@variables x(t) y(t) z(t)
435440
@parameters α=1.5 β=1.0 γ=3.0 δ=1.0

0 commit comments

Comments
 (0)