Skip to content

Commit 1a19972

Browse files
test: add common components under test/common/
1 parent f4d5d7f commit 1a19972

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

test/common/rc_model.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import ModelingToolkitStandardLibrary.Electrical as El
2+
import ModelingToolkitStandardLibrary.Blocks as Bl
3+
4+
@mtkmodel RCModel begin
5+
@parameters begin
6+
R = 1.0
7+
C = 1.0
8+
V = 1.0
9+
end
10+
@components begin
11+
resistor = El.Resistor(R = R)
12+
capacitor = El.Capacitor(C = C)
13+
shape = Bl.Constant(k = V)
14+
source = El.Voltage()
15+
ground = El.Ground()
16+
end
17+
@equations begin
18+
connect(shape.output, source.V)
19+
connect(source.p, resistor.p)
20+
connect(resistor.n, capacitor.p)
21+
connect(capacitor.n, source.n)
22+
connect(capacitor.n, ground.g)
23+
end
24+
end
25+
26+
@named rc_model = RCModel()

test/common/serial_inductor.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import ModelingToolkitStandardLibrary.Electrical as El
2+
import ModelingToolkitStandardLibrary.Blocks as Bl
3+
4+
@mtkmodel LLModel begin
5+
@components begin
6+
shape = Bl.Constant(k = 10.0)
7+
source = El.Voltage()
8+
resistor = El.Resistor(R = 1.0)
9+
inductor1 = El.Inductor(L = 1.0e-2)
10+
inductor2 = El.Inductor(L = 2.0e-2)
11+
ground = El.Ground()
12+
end
13+
@equations begin
14+
connect(shape.output, source.V)
15+
connect(source.p, resistor.p)
16+
connect(resistor.n, inductor1.p)
17+
connect(inductor1.n, inductor2.p)
18+
connect(source.n, inductor2.n)
19+
connect(inductor2.n, ground.g)
20+
end
21+
end
22+
23+
@named ll_model = LLModel()
24+
25+
@mtkmodel LL2Model begin
26+
@components begin
27+
shape = Bl.Constant(k = 10.0)
28+
source = El.Voltage()
29+
resistor1 = El.Resistor(R = 1.0)
30+
resistor2 = El.Resistor(R = 1.0)
31+
inductor1 = El.Inductor(L = 1.0e-2)
32+
inductor2 = El.Inductor(L = 2.0e-2)
33+
ground = El.Ground()
34+
end
35+
@equations begin
36+
connect(shape.output, source.V)
37+
connect(source.p, inductor1.p)
38+
connect(inductor1.n, resistor1.p)
39+
connect(inductor1.n, resistor2.p)
40+
connect(resistor1.n, resistor2.n)
41+
connect(resistor2.n, inductor2.p)
42+
connect(source.n, inductor2.n)
43+
connect(inductor2.n, ground.g)
44+
end
45+
end
46+
47+
@named ll2_model = LL2Model()

0 commit comments

Comments
 (0)