Skip to content

Commit 60cdf22

Browse files
forgot a file
1 parent 0501bf5 commit 60cdf22

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/downstream/symbol_indexing.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using ModelingToolkit, OrdinaryDiffEq, RecursiveArrayTools, SymbolicIndexingInterface, Test
22
using Optimization, OptimizationOptimJL
3-
# compat for MTKv8 and v9
4-
unknowns = isdefined(ModelingToolkit, :states) ? ModelingToolkit.states :
5-
ModelingToolkit.unknowns
3+
using ModelingToolkit: t_nounits as t, D_nounits as D
64

7-
@parameters t σ ρ β
5+
@parameters σ ρ β
86
@variables x(t) y(t) z(t)
97
D = Differential(t)
108

@@ -19,8 +17,7 @@ eqs = [D(x) ~ σ * (y - x),
1917
@variables a(t) α(t)
2018
connections = [0 ~ lorenz1.x + lorenz2.y + a * γ,
2119
α ~ 2lorenz1.x + a * γ]
22-
@named sys = ODESystem(connections, t, [a, α], [γ], systems = [lorenz1, lorenz2])
23-
sys_simplified = structural_simplify(sys)
20+
@mtkbuild sys = ODESystem(connections, t, [a, α], [γ], systems = [lorenz1, lorenz2])
2421

2522
u0 = [lorenz1.x => 1.0,
2623
lorenz1.y => 0.0,
@@ -39,7 +36,7 @@ p = [lorenz1.σ => 10.0,
3936
γ => 2.0]
4037

4138
tspan = (0.0, 100.0)
42-
prob = ODEProblem(sys_simplified, u0, tspan, p)
39+
prob = ODEProblem(sys, u0, tspan, p)
4340
integ = init(prob, Rodas4())
4441
sol = solve(prob, Rodas4())
4542

@@ -135,7 +132,7 @@ sol1 = sol(0.0:1.0:10.0)
135132

136133
sol2 = sol(0.1)
137134
@test sol2 isa Vector
138-
@test length(sol2) == length(unknowns(sys_simplified))
135+
@test length(sol2) == length(unknowns(sys))
139136
@test first(sol2) isa Real
140137

141138
sol3 = sol(0.0:1.0:10.0, idxs = [lorenz1.x, lorenz2.x])
@@ -191,9 +188,9 @@ sol10 = sol(0.1, idxs = 2)
191188
@test sol10 isa Real
192189

193190
@test is_timeseries(sol) == Timeseries()
194-
getx = getu(sys_simplified, lorenz1.x)
195-
get_arr = getu(sys_simplified, [lorenz1.x, lorenz2.x])
196-
get_tuple = getu(sys_simplified, (lorenz1.x, lorenz2.x))
191+
getx = getu(sys, lorenz1.x)
192+
get_arr = getu(sys, [lorenz1.x, lorenz2.x])
193+
get_tuple = getu(sys, (lorenz1.x, lorenz2.x))
197194
get_obs = getu(sol, lorenz1.x + lorenz2.x) # can't use sys for observed
198195
get_obs_arr = getu(sol, [lorenz1.x + lorenz2.x, lorenz1.y + lorenz2.y])
199196
l1x_idx = variable_index(sol, lorenz1.x)

0 commit comments

Comments
 (0)