Skip to content

Commit 38dddbe

Browse files
committed
Test changing indpendent variable of ODEs with array variable
1 parent be112aa commit 38dddbe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/basic_transformations.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,20 @@ end
287287
@test all(isapprox.(sol[ss.t], sol[ss.y]; atol = 1e-10))
288288
@test all(sol[ss.x][2:end] .< sol[ss.x][1])
289289
end
290+
291+
@testset "Change independent variable with array variables" begin
292+
@variables x(t) y(t) z(t)[1:2]
293+
eqs = [
294+
D(x) ~ 2,
295+
z ~ ModelingToolkit.scalarize.([sin(y), cos(y)]),
296+
D(y) ~ z[1]^2 + z[2]^2
297+
]
298+
@named sys = ODESystem(eqs, t)
299+
sys = complete(sys)
300+
new_sys = change_independent_variable(sys, sys.x; add_old_diff = true)
301+
ss_new_sys = structural_simplify(new_sys; allow_symbolic = true)
302+
u0 = [new_sys.y => 0.5, new_sys.t => 0.0]
303+
prob = ODEProblem(ss_new_sys, u0, (0.0, 0.5), [])
304+
sol = solve(prob, Tsit5(); reltol = 1e-5)
305+
@test sol[new_sys.y][end] 0.75
306+
end

0 commit comments

Comments
 (0)