Skip to content

Commit f9b0fa9

Browse files
committed
Add split parameters tests
Needs SciML/ModelingToolkitStandardLibrary.jl#211
1 parent 87fc28f commit f9b0fa9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using SafeTestsets, Test
2323
@safetestset "JumpSystem Test" include("jumpsystem.jl")
2424
@safetestset "Constraints Test" include("constraints.jl")
2525
@safetestset "Reduction Test" include("reduction.jl")
26+
@safetestset "Split Parameters Test" include("split_parameters.jl")
2627
@safetestset "ODAEProblem Test" include("odaeproblem.jl")
2728
@safetestset "Components Test" include("components.jl")
2829
@safetestset "Model Parsing Test" include("model_parsing.jl")

test/split_parameters.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using ModelingToolkit, Test
2+
using ModelingToolkitStandardLibrary.Blocks
3+
using OrdinaryDiffEq
4+
5+
dt = 4e-4
6+
t_end = 10.0
7+
time = 0:dt:t_end
8+
x = @. time^2 + 1.0
9+
10+
@parameters t
11+
D = Differential(t)
12+
13+
vars = @variables y(t)=1 dy(t)=0 ddy(t)=0
14+
@named src = SampledData(; data = Float64[], dt)
15+
@named int = Integrator()
16+
17+
eqs = [y ~ src.output.u
18+
D(y) ~ dy
19+
D(dy) ~ ddy
20+
connect(src.output, int.input)]
21+
22+
@named sys = ODESystem(eqs, t, vars, []; systems = [int, src])
23+
s = complete(sys)
24+
sys = structural_simplify(sys)
25+
26+
prob = ODEProblem(sys, [], (0.0, t_end), [s.src.data => x]; split_parameters = true)
27+
@test prob.p isa Tuple{Vector{Float64}, Vector{Int}, Vector{Vector{Float64}}}
28+
@time sol = solve(prob, ImplicitEuler());
29+
prob2 = ODEProblem(sys, [], (0.0, t_end), [s.src.data => x]; to_float = false)
30+
@test prob2.p isa Vector{Union{Float64, Int64, Vector{Float64}}}
31+
@time sol2 = solve(prob2, ImplicitEuler());

0 commit comments

Comments
 (0)