Skip to content

Commit e3d21b6

Browse files
authored
Merge pull request #1050 from SciML/update_dae_tests
Fix DAE tests
2 parents af5b8c2 + 53019dd commit e3d21b6

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

test/compositional_modelling/component_based_model_creation.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ let
4646
sys₂.μ => (log(2) / 600), sys₃.α₀ => 5e-4, sys₃.α => 0.5, sys₃.K => 40.0,
4747
sys₃.n => 2, sys₃.δ => (log(2) / 120), sys₃.β => (20 * log(2) / 120),
4848
sys₃.μ => (log(2) / 600)]
49-
u₀ = [sys₁.m => 0.0, sys₁.P => 20.0, sys.R => 0.0, sys.m => 0.0, sys₂.P => 0.0,
50-
sys.R => 0.0, sys.m => 0.0, sys₃.P => 0.0, sys₃.R => 0.0]
49+
u₀ = [sys₁.m => 0.0, sys₁.P => 20.0, sys₂.m => 0.0, sys₂.P => 0.0,
50+
sys₃.m => 0.0, sys₃.P => 0.0]
5151
tspan = (0.0, 100000.0)
5252
oprob = ODEProblem(oderepressilator, u₀, tspan, pvals)
5353
sol = solve(oprob, Tsit5())
@@ -94,13 +94,15 @@ let
9494
@test all(isapprox.(sol(tvs, idxs = sys₁.P), sol2(tvs, idxs = 4), atol = 1e-4))
9595

9696
# Test conversion to nonlinear system.
97+
u₀_nl = [sys₁.m => 0.0, sys₁.P => 20.0, sys₁.R => 0.0, sys₂.m => 0.0, sys₂.P => 0.0,
98+
sys₂.R => 0.0, sys₃.m => 0.0, sys₃.P => 0.0, sys₃.R => 0.0]
9799
@named nsys = NonlinearSystem(connections, [], [])
98100
@named ssrepressilator = ReactionSystem(t; systems = [nsys, sys₁, sys₂, sys₃])
99101
ssrepressilator = complete(ssrepressilator)
100102
@named nlrepressilator = convert(NonlinearSystem, ssrepressilator, include_zero_odes = false)
101103
sys2 = structural_simplify(nlrepressilator)
102104
@test length(equations(sys2)) <= 6
103-
nlprob = NonlinearProblem(sys2, u₀, pvals)
105+
nlprob = NonlinearProblem(sys2, u₀_nl, pvals)
104106
sol = solve(nlprob, NLSolveJL(), abstol = 1e-9)
105107
@test sol[sys₁.P] sol[sys₂.P] sol[sys₃.P]
106108
@test sol[sys₁.m] sol[sys₂.m] atol=1e-7
@@ -113,7 +115,7 @@ let
113115
@named nlrepressilator = convert(NonlinearSystem, fsys, include_zero_odes = false)
114116
sys2 = structural_simplify(nlrepressilator)
115117
@test length(equations(sys2)) <= 6
116-
nlprob = NonlinearProblem(sys2, u₀, pvals)
118+
nlprob = NonlinearProblem(sys2, u₀_nl, pvals)
117119
sol = solve(nlprob, NLSolveJL(), abstol = 1e-9)
118120
@test sol[sys₁.P] sol[sys₂.P] sol[sys₃.P]
119121
@test sol[sys₁.m] sol[sys₂.m] atol=1e-7
@@ -131,7 +133,7 @@ let
131133
@named nlrepressilator = convert(NonlinearSystem, repressilator2, include_zero_odes = false)
132134
sys2 = structural_simplify(nlrepressilator)
133135
@test length(equations(sys2)) <= 6
134-
nlprob = NonlinearProblem(sys2, u₀, pvals)
136+
nlprob = NonlinearProblem(sys2, u₀_nl, pvals)
135137
sol = solve(nlprob, NLSolveJL(), abstol = 1e-9)
136138
@test sol[sys₁.P] sol[sys₂.P] sol[sys₃.P]
137139
@test sol[sys₁.m] sol[sys₂.m] atol=1e-7
@@ -252,7 +254,7 @@ let
252254
@named nlrepressilator = convert(NonlinearSystem, repressilator2, include_zero_odes = false)
253255
sys2 = structural_simplify(nlrepressilator)
254256
@test length(equations(sys2)) <= 6
255-
nlprob = NonlinearProblem(sys2, u₀, pvals)
257+
nlprob = NonlinearProblem(sys2, u₀_nl, pvals)
256258
sol = solve(nlprob, NLSolveJL(), abstol = 1e-9)
257259
@test sol[sys₁.P] sol[sys₂.P] sol[sys₃.P]
258260
@test sol[sys₁.m] sol[sys₂.m] atol=1e-7

test/dsl/dsl_options.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ let
784784
@test isequal(equations(rn)[4], 3Y + X ~ S + X*d)
785785

786786
# Checks that simulations has the correct output
787-
u0 = Dict([S => 1 + rand(rng), X => 1 + rand(rng), Y => 1 + rand(rng)])
787+
u0 = Dict([S => 1 + rand(rng)])
788788
ps = Dict([p => 1 + rand(rng), d => 1 + rand(rng), k => 1 + rand(rng)])
789789
oprob = ODEProblem(rn, u0, (0.0, 10000.0), ps; structural_simplify=true)
790790
sol = solve(oprob, Tsit5(); abstol=1e-9, reltol=1e-9)
@@ -895,7 +895,7 @@ let
895895
@test equations(rn)[3] isa Equation
896896

897897
# Checks that simulations has the correct output
898-
u0 = Dict([S => 1 + rand(rng), X => 1 + rand(rng), Y => 1 + rand(rng)])
898+
u0 = Dict([S => 1 + rand(rng), Y => 1 + rand(rng)])
899899
ps = Dict([p => 1 + rand(rng), d => 1 + rand(rng), k => 1 + rand(rng)])
900900
oprob = ODEProblem(rn, u0, (0.0, 10000.0), ps; structural_simplify=true)
901901
sol = solve(oprob, Tsit5(); abstol=1e-9, reltol=1e-9)
@@ -1025,4 +1025,3 @@ let
10251025
@parameters v n
10261026
@test isequal(Catalyst.expand_registered_functions(equations(rn4)[1]), D(A) ~ v*(A^n))
10271027
end
1028-

test/miscellaneous_tests/reactionsystem_serialisation.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ let
513513
d, X --> 0, [misc = x -> 2x]
514514
end
515515
@test_throws Exception save_reactionsystem("test_serialisation.jl", rs)
516+
rm("test_serialisation.jl")
516517
end
517518

518519
# Test connection field.

0 commit comments

Comments
 (0)