Skip to content

Commit df6c944

Browse files
refactor: do not use @mtkmodel
1 parent a4c1b5b commit df6c944

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/ModelingToolkitBase/test/common/rc_model.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@ import ModelingToolkitStandardLibrary.Electrical as El
22
import ModelingToolkitStandardLibrary.Blocks as Bl
33
using SciCompDSL
44

5-
@mtkmodel RCModel begin
6-
@parameters begin
5+
@component function RCModel(; name)
6+
pars = @parameters begin
77
R = 1.0
88
C = 1.0
99
V = 1.0
1010
end
11-
@components begin
11+
systems = @named begin
1212
resistor = El.Resistor(R = R)
1313
capacitor = El.Capacitor(C = C)
1414
shape = Bl.Constant(k = V)
1515
source = El.Voltage()
1616
ground = El.Ground()
1717
end
18-
@equations begin
18+
eqs = [
1919
connect(shape.output, source.V)
2020
connect(source.p, resistor.p)
2121
connect(resistor.n, capacitor.p)
2222
connect(capacitor.n, source.n)
2323
connect(capacitor.n, ground.g)
24-
end
24+
]
25+
System(eqs, t, [], pars; systems, name)
2526
end
2627

2728
@named rc_model = RCModel()

lib/ModelingToolkitBase/test/odesystem.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,13 +1028,14 @@ end
10281028

10291029
# the same, but with @mtkmodel
10301030
@independent_variables x
1031-
@mtkmodel MyModel begin
1032-
@variables begin
1031+
@component function MyModel(; name)
1032+
vars = @variables begin
10331033
y(x)
10341034
end
1035-
@equations begin
1035+
eqs = [
10361036
y ~ 0
1037-
end
1037+
]
1038+
return System(eqs, t, vars, []; name)
10381039
end
10391040
@test_nowarn @mtkcompile sys = MyModel()
10401041

0 commit comments

Comments
 (0)