Skip to content

Commit 90ddc86

Browse files
committed
Fix connect equations generation for array valued connectors
1 parent e767cfb commit 90ddc86

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/systems/connectors.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,13 @@ end
350350
function generate_connection_equations_and_stream_connections(csets::AbstractVector{<:ConnectionSet})
351351
eqs = Equation[]
352352
stream_connections = ConnectionSet[]
353+
353354
for cset in csets
354-
vtype = get_connection_type(cset.set[1].v)
355+
v = cset.set[1].v
356+
if hasmetadata(v, Symbolics.GetindexParent)
357+
v = getparent(v)
358+
end
359+
vtype = get_connection_type(v)
355360
if vtype === Stream
356361
push!(stream_connections, cset)
357362
continue

test/stream_connectors.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ end
228228

229229
@named simple = ODESystem([connect(vp1, vp2, vp3)], t)
230230
sys = expand_connections(compose(simple, [vp1, vp2, vp3]))
231-
@test equations(sys) == [
232-
vp1.v[1] ~ vp2.v[1]
233-
vp1.v[2] ~ vp2.v[2]
234-
vp1.v[1] ~ vp3.v[1]
235-
vp1.v[2] ~ vp3.v[2]
236-
0 ~ -vp1.i[1] - vp2.i[1] - vp3.i[1]
237-
0 ~ -vp1.i[2] - vp2.i[2] - vp3.i[2]
238-
]
231+
@test sort(equations(sys), by=string) == sort([
232+
vp1.v[1] ~ vp2.v[1]
233+
vp1.v[2] ~ vp2.v[2]
234+
vp1.v[1] ~ vp3.v[1]
235+
vp1.v[2] ~ vp3.v[2]
236+
0 ~ -vp1.i[1] - vp2.i[1] - vp3.i[1]
237+
0 ~ -vp1.i[2] - vp2.i[2] - vp3.i[2]
238+
], by=string)

0 commit comments

Comments
 (0)