Skip to content

Commit 74abd47

Browse files
committed
Add Modelica's example in test
1 parent 417530b commit 74abd47

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/components.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,50 @@ end
138138
@unpack foo = goo
139139
@test ModelingToolkit.defaults(goo)[foo.a] == 3
140140
@test ModelingToolkit.defaults(goo)[foo.b] == 300
141+
142+
#=
143+
model Circuit
144+
Ground ground;
145+
Load load;
146+
Resistor resistor;
147+
equation
148+
connect(load.p , ground.p);
149+
connect(resistor.p, ground.p);
150+
end Circuit;
151+
model Load
152+
extends TwoPin;
153+
Resistor resistor;
154+
equation
155+
connect(p, resistor.p);
156+
connect(resistor.n, n);
157+
end Load;
158+
=#
159+
160+
function Load(;name)
161+
R = 1
162+
@named p = Pin()
163+
@named n = Pin()
164+
@named resistor = Resistor(R=R)
165+
eqs = [
166+
connect(p, resistor.p);
167+
connect(resistor.n, n);
168+
]
169+
@named sys = ODESystem(eqs, t)
170+
compose(sys, [p, n, resistor]; name=name)
171+
end
172+
173+
function Circuit(;name)
174+
R = 1
175+
@named ground = Ground()
176+
@named load = Load()
177+
@named resistor = Resistor(R=R)
178+
eqs = [
179+
connect(load.p , ground.g);
180+
connect(resistor.p, ground.g);
181+
]
182+
@named sys = ODESystem(eqs, t)
183+
compose(sys, [ground, resistor, load]; name=name)
184+
end
185+
186+
@named foo = Circuit()
187+
@test_broken structural_simplify(foo) isa AbstractSystem

0 commit comments

Comments
 (0)