Skip to content

Commit 73a0c3e

Browse files
committed
Test changing indpendent variable of ODEs with array variable
1 parent cb4e6b5 commit 73a0c3e

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
@@ -259,3 +259,20 @@ end
259259
nested_input_sys = complete(nested_input_sys; flatten = false)
260260
@test change_independent_variable(nested_input_sys, nested_input_sys.x) isa ODESystem
261261
end
262+
263+
@testset "Change independent variable with array variables" begin
264+
@variables x(t) y(t) z(t)[1:2]
265+
eqs = [
266+
D(x) ~ 2
267+
z ~ ModelingToolkit.scalarize.([sin(y), cos(y)])
268+
D(y) ~ z[1]^2 + z[2]^2
269+
]
270+
@named sys = ODESystem(eqs, t)
271+
sys = complete(sys)
272+
new_sys = change_independent_variable(sys, sys.x; add_old_diff = true)
273+
ss_new_sys = structural_simplify(new_sys; allow_symbolic = true)
274+
u0 = [new_sys.y => 0.5, new_sys.t => 0.0]
275+
prob = ODEProblem(ss_new_sys, u0, (0.0, 0.5), [])
276+
sol = solve(prob, Tsit5(); reltol = 1e-5)
277+
@test sol[new_sys.y][end] 0.75
278+
end

0 commit comments

Comments
 (0)