Skip to content

Commit e2f3f72

Browse files
committed
WIP
1 parent 033b67e commit e2f3f72

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
struct BiGraph{T}
2+
data::Vector{Vector{T}}
3+
end
4+
5+
function sys2bigraph(sys)
6+
ss = states(sys)
7+
data = Operation[]
8+
for eq in sys.eqs
9+
es = []
10+
lhs = eq.lhs
11+
lhs.op isa Differential && push!(eq, lhs)
12+
push!(data, es)
13+
end
14+
end

test/index_reduction.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using ModelingToolkit
2+
using ModelingToolkit: sys2bigraph
3+
using DiffEqBase
4+
using Test
5+
6+
# Define some variables
7+
@parameters t L g
8+
@variables x(t) y(t) w(t) z(t) T(t)
9+
@derivatives D'~t
10+
11+
eqs2 = [D(D(x)) ~ T*x,
12+
D(D(y)) ~ T*y - g,
13+
0 ~ x^2 + y^2 - L^2]
14+
pendulum2 = ODESystem(eqs, t, [x, y, T], [L, g], name=:pendulum)
15+
ModelingToolkit.ode_order_lowering(pendulum2)
16+
17+
# Simple pendulum in cartesian coordinates
18+
eqs = [D(x) ~ w,
19+
D(y) ~ z,
20+
D(w) ~ T*x,
21+
D(z) ~ T*y - g,
22+
0 ~ x^2 + y^2 - L^2]
23+
pendulum = ODESystem(eqs, t, [x, y, w, z, T], [L, g], name=:pendulum)
24+
25+
sys2bigraph(pendulum)

0 commit comments

Comments
 (0)