Skip to content

Commit ad53f85

Browse files
committed
Clean up and export flatten
1 parent 169d91b commit ad53f85

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/systems/reduction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export alias_elimination
1+
export alias_elimination, flatten
22

33
function flatten(sys::ODESystem)
44
if isempty(sys.systems)

test/reduction.jl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ let
109109
x ~ y
110110
];
111111
sys = ODESystem(eqs, t, [x], []);
112-
asys = alias_elimination(ModelingToolkit.flatten(sys))
112+
asys = alias_elimination(flatten(sys))
113113

114114
test_equal.(asys.eqs, [D(x) ~ 2x])
115115
test_equal.(asys.observed, [y ~ x])
@@ -119,27 +119,18 @@ end
119119
let
120120
@parameters t
121121
@derivatives D'~t
122-
123-
## Define a system
124-
125122
@variables x(t), u(t), y(t)
126123
@parameters a, b, c, d
127124
ol = ODESystem([D(x) ~ a * x + b * u, y ~ c * x], t, name=:ol)
128-
129-
## Define another system that is purely observing
130-
131125
@variables u_c(t), y_c(t)
132126
@parameters k_P
133127
pc = ODESystem(Equation[], t, pins=[y_c], observed = [u_c ~ k_P * y_c], name=:pc)
134-
135-
## Connect them
136-
137128
connections = [
138129
ol.u ~ pc.u_c,
139130
y_c ~ ol.y
140131
]
132+
connected = ODESystem(connections, t, systems=[ol, pc])
141133

142-
connected = MTK.ODESystem(connections, t, systems=[ol, pc])
143-
144-
@test_nowarn MTK.flatten(connected)
134+
@test equations(connected) isa Vector{Equation}
135+
@test_nowarn flatten(connected)
145136
end

0 commit comments

Comments
 (0)