Skip to content

Commit cbff89d

Browse files
refactor: change structural_simplify and mtkbuild to mtkcompile
1 parent 8f7e4e1 commit cbff89d

28 files changed

+161
-161
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ using ModelingToolkit: t_nounits as t
7171
end
7272
end
7373

74-
@mtkbuild sys = RC()
74+
@mtkcompile sys = RC()
7575
prob = ODEProblem(sys, Pair[], (0, 10.0))
7676
sol = solve(prob)
7777

docs/src/connectors/connections.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ eqs = [connect(capacitor.p, resistor.p)
104104
105105
@named model = ODESystem(eqs, t; systems)
106106
107-
sys = structural_simplify(model)
107+
sys = mtkcompile(model)
108108
109109
println.(equations(sys))
110110
nothing # hide
@@ -146,7 +146,7 @@ eqs = [connect(damping.flange_a, body.flange)
146146
147147
@named model = ODESystem(eqs, t; systems)
148148
149-
sys = structural_simplify(model)
149+
sys = mtkcompile(model)
150150
151151
println.(full_equations(sys))
152152
nothing # hide
@@ -182,7 +182,7 @@ eqs = [connect(damping.flange_a, body.flange)
182182
183183
@named model = ODESystem(eqs, t; systems)
184184
185-
sys = structural_simplify(model)
185+
sys = mtkcompile(model)
186186
187187
println.(full_equations(sys))
188188
nothing # hide
@@ -277,7 +277,7 @@ function simplify_and_solve(damping, spring, body, ground; initialization_eqs =
277277
278278
@named model = ODESystem(eqs, t; systems = [ground, body, spring, damping])
279279
280-
sys = structural_simplify(model)
280+
sys = mtkcompile(model)
281281
282282
println.(full_equations(sys))
283283

docs/src/connectors/sign_convention.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Here we can see that a positive input force results in an increasing velocity.
8888
connect(mass.flange, force.flange)
8989
end
9090
end
91-
@mtkbuild sys = Model()
91+
@mtkcompile sys = Model()
9292
full_equations(sys)
9393
```
9494

@@ -128,7 +128,7 @@ Here we can see that a positive input current results in an increasing voltage.
128128
connect(capacitor.n, current.p, ground.g)
129129
end
130130
end
131-
@mtkbuild sys = Model()
131+
@mtkcompile sys = Model()
132132
full_equations(sys)
133133
```
134134

@@ -146,7 +146,7 @@ Reversing the pins gives the same result
146146
connect(capacitor.p, current.n, ground.g)
147147
end
148148
end
149-
@mtkbuild sys = Model()
149+
@mtkcompile sys = Model()
150150
full_equations(sys)
151151
```
152152

@@ -184,6 +184,6 @@ A positive input mass flow leads to an increasing pressure (in this case we get
184184
connect(fluid, flow.port)
185185
end
186186
end
187-
@mtkbuild sys = Model()
187+
@mtkcompile sys = Model()
188188
full_equations(sys) |> first
189189
```

docs/src/tutorials/custom_component.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ nothing # hide
109109

110110
## Simulating the Model
111111

112-
`@mtkbuild` builds a structurally simplified `ChaoticAttractor` model.
112+
`@mtkcompile` builds a structurally simplified `ChaoticAttractor` model.
113113
Since the initial voltage of the capacitors was already specified via `v` and the initial current of inductor via `i`, no initial condition is given and an empty pair is supplied.
114114

115115
```@example components
116-
@mtkbuild sys = ChaoticAttractor()
116+
@mtkcompile sys = ChaoticAttractor()
117117
prob = ODEProblem(sys, Pair[], (0, 5e4))
118118
sol = solve(prob; saveat = 1.0)
119119

docs/src/tutorials/dc_motor_pi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Now the model can be simulated. Typical rotational mechanical systems are descri
7676
so that it can be represented as a system of `ODEs` (ordinary differential equations).
7777

7878
```@example dc_motor_pi
79-
sys = structural_simplify(model)
79+
sys = mtkcompile(model)
8080
prob = ODEProblem(sys, [sys.L1.i => 0.0], (0, 6.0))
8181
sol = solve(prob)
8282

docs/src/tutorials/input_component.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ end
6868
df = generate_data() # example data
6969
7070
@named system = MassSpringDamperSystem(df.data, df.time)
71-
sys = structural_simplify(system)
71+
sys = mtkcompile(system)
7272
prob = ODEProblem(sys, [], (0, df.time[end]))
7373
sol = solve(prob)
7474
plot(sol)
@@ -93,7 +93,7 @@ my_interpolation = LinearInterpolation(df.data, df.time)
9393
connect(src.output, model.input)
9494
end
9595
end;
96-
@mtkbuild sys = MassSpringDamperSystem2()
96+
@mtkcompile sys = MassSpringDamperSystem2()
9797
9898
prob = ODEProblem(sys, [], (0, df.time[end]))
9999
sol = solve(prob, Tsit5())
@@ -159,7 +159,7 @@ end
159159
df = generate_data() # example data
160160
161161
@named system = MassSpringDamperSystem(df.data, df.time)
162-
sys = structural_simplify(system)
162+
sys = mtkcompile(system)
163163
prob = ODEProblem(sys, [], (0, df.time[end]))
164164
sol = solve(prob)
165165
plot(sol)
@@ -217,7 +217,7 @@ function System(; name)
217217
end
218218
219219
@named system = System()
220-
sys = structural_simplify(system)
220+
sys = mtkcompile(system)
221221
prob = ODEProblem(sys, [], (0, time[end]))
222222
223223
rdata[] = data1
@@ -263,7 +263,7 @@ function System(; name)
263263
end
264264

265265
@named system = System()
266-
sys = structural_simplify(system, split = false)
266+
sys = mtkcompile(system, split = false)
267267
s = complete(system)
268268

269269
dt = 4e-4

docs/src/tutorials/rc_circuit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using ModelingToolkit: t_nounits as t
3333
end
3434
end
3535
36-
@mtkbuild sys = RC()
36+
@mtkcompile sys = RC()
3737
prob = ODEProblem(sys, Pair[], (0, 10.0))
3838
sol = solve(prob)
3939

docs/src/tutorials/thermal_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using ModelingToolkit: t_nounits as t
3030
end
3131
end
3232
33-
@mtkbuild sys = HeatConductionModel()
33+
@mtkcompile sys = HeatConductionModel()
3434
prob = ODEProblem(sys, Pair[], (0, 5.0))
3535
sol = solve(prob)
3636

test/Blocks/continuous.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ an integrator with a constant input is often used together with the system under
1515
@named c = Constant(; k = 1)
1616
@named int = Integrator(x = 1)
1717
@named iosys = ODESystem(connect(c.output, int.input), t, systems = [int, c])
18-
sys = structural_simplify(iosys)
18+
sys = mtkcompile(iosys)
1919
prob = ODEProblem(sys, Pair[], (0.0, 1.0))
2020
sol = solve(prob, Rodas4())
2121
@test sol.retcode == Success
@@ -34,7 +34,7 @@ end
3434
],
3535
t,
3636
systems = [int, source, der])
37-
sys = structural_simplify(iosys)
37+
sys = mtkcompile(iosys)
3838
prob = ODEProblem(sys, Pair[int.x => 0.0], (0.0, 10.0))
3939
sol = solve(prob, Rodas4())
4040
@test sol.retcode == Success
@@ -48,7 +48,7 @@ end
4848
@named c = Constant(; k = 1)
4949
@named pt1 = FirstOrder(; k = k, T = T)
5050
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
51-
sys = structural_simplify(iosys)
51+
sys = mtkcompile(iosys)
5252
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
5353
sol = solve(prob, Rodas4())
5454
@test sol.retcode == Success
@@ -57,7 +57,7 @@ end
5757
# Test highpass feature
5858
@named pt1 = FirstOrder(; k = k, T = T, lowpass = false)
5959
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
60-
sys = structural_simplify(iosys)
60+
sys = mtkcompile(iosys)
6161
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
6262
sol = solve(prob, Rodas4())
6363
@test sol.retcode == Success
@@ -81,7 +81,7 @@ end
8181
@named c = Constant(; k = 1)
8282
@named pt2 = SecondOrder(; k = k, w = w, d = d)
8383
@named iosys = ODESystem(connect(c.output, pt2.input), t, systems = [pt2, c])
84-
sys = structural_simplify(iosys)
84+
sys = mtkcompile(iosys)
8585
prob = ODEProblem(sys, [unknowns(sys) .=> 0.0...; pt2.xd => 0.0], (0.0, 100.0))
8686
sol = solve(prob, Rodas4())
8787
@test sol.retcode == Success
@@ -100,7 +100,7 @@ end
100100
],
101101
t,
102102
systems = [ss, c])
103-
sys = structural_simplify(model)
103+
sys = mtkcompile(model)
104104
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
105105
sol = solve(prob, Rodas4())
106106
@test sol.retcode == Success
@@ -120,7 +120,7 @@ end
120120
],
121121
t,
122122
systems = [ss, c])
123-
sys = structural_simplify(model)
123+
sys = mtkcompile(model)
124124
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
125125
sol = solve(prob, Rodas4())
126126
@test sol.retcode == Success
@@ -160,7 +160,7 @@ end
160160
],
161161
t,
162162
systems = [pi_controller, plant, ref, fb])
163-
sys = structural_simplify(model)
163+
sys = mtkcompile(model)
164164
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
165165
sol = solve(prob, Rodas4())
166166
@test sol.retcode == Success
@@ -183,7 +183,7 @@ end
183183
],
184184
t,
185185
systems = [pid_controller, plant, ref, fb])
186-
sys = structural_simplify(model)
186+
sys = mtkcompile(model)
187187
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
188188
sol = solve(prob, Rodas4())
189189
@test sol.retcode == Success
@@ -201,7 +201,7 @@ end
201201
],
202202
t,
203203
systems = [pid_controller, plant, ref, fb])
204-
sys = structural_simplify(model)
204+
sys = mtkcompile(model)
205205
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
206206
sol = solve(prob, Rodas4())
207207
@test sol.retcode == Success
@@ -220,7 +220,7 @@ end
220220
],
221221
t,
222222
systems = [pid_controller, plant, ref, fb])
223-
sys = structural_simplify(model)
223+
sys = mtkcompile(model)
224224
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
225225
sol = solve(prob, Rodas4())
226226
@test sol.retcode == Success
@@ -254,7 +254,7 @@ end
254254
],
255255
t,
256256
systems = [pi_controller, plant, ref, fb, sat])
257-
sys = structural_simplify(model)
257+
sys = mtkcompile(model)
258258
prob = ODEProblem(sys, Pair[], (0.0, 20.0))
259259
sol = solve(prob, Rodas4())
260260
end
@@ -271,7 +271,7 @@ end
271271
],
272272
t,
273273
systems = [pi_controller_lim, plant, ref, fb, sat])
274-
sys = structural_simplify(model)
274+
sys = mtkcompile(model)
275275
prob = ODEProblem(sys, Pair[], (0.0, 20.0))
276276
sol = solve(prob, Rodas4())
277277
end
@@ -303,7 +303,7 @@ end
303303
],
304304
t,
305305
systems = [pid_controller, plant, ref])
306-
sys = structural_simplify(model)
306+
sys = mtkcompile(model)
307307
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
308308
sol = solve(prob, Rodas4())
309309

@@ -324,7 +324,7 @@ end
324324
],
325325
t,
326326
systems = [pid_controller, plant, ref])
327-
sys = structural_simplify(model)
327+
sys = mtkcompile(model)
328328
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
329329
sol = solve(prob, Rodas4())
330330

@@ -345,7 +345,7 @@ end
345345
],
346346
t,
347347
systems = [pid_controller, plant, ref])
348-
sys = structural_simplify(model)
348+
sys = mtkcompile(model)
349349
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
350350
sol = solve(prob, Rodas4())
351351

@@ -367,7 +367,7 @@ end
367367
],
368368
t,
369369
systems = [pid_controller, plant, ref])
370-
sys = structural_simplify(model)
370+
sys = mtkcompile(model)
371371
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
372372
sol = solve(prob, Rodas4())
373373

@@ -389,7 +389,7 @@ end
389389
],
390390
t,
391391
systems = [pid_controller, plant, ref])
392-
sys = structural_simplify(model)
392+
sys = mtkcompile(model)
393393
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
394394
sol = solve(prob, Rodas4())
395395

@@ -412,7 +412,7 @@ end
412412
],
413413
t,
414414
systems = [pid_controller, plant, ref])
415-
sys = structural_simplify(model)
415+
sys = mtkcompile(model)
416416
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
417417
sol = solve(prob, Rodas4())
418418

@@ -429,7 +429,7 @@ end
429429
@named c = Constant(; k = 1)
430430
@named pt1 = TransferFunction(b = [1.2], a = [3.14, 1])
431431
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
432-
sys = structural_simplify(iosys)
432+
sys = mtkcompile(iosys)
433433
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
434434
sol = solve(prob, Rodas4())
435435
@test sol.retcode == Success
@@ -439,7 +439,7 @@ end
439439
@named c = Constant(; k = 1)
440440
@named pt1 = TransferFunction(b = [1.2], a = [3.14, 0])
441441
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
442-
sys = structural_simplify(iosys)
442+
sys = mtkcompile(iosys)
443443
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
444444
sol = solve(prob, Rodas4())
445445
@test sol.retcode == Success
@@ -463,7 +463,7 @@ end
463463
k, w, d = 1.0, 1.0, 0.5
464464
@named pt1 = TransferFunction(b = [w^2], a = [1, 2d * w, w^2])
465465
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
466-
sys = structural_simplify(iosys)
466+
sys = mtkcompile(iosys)
467467
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
468468
sol = solve(prob, Rodas4())
469469
@test sol.retcode == Success
@@ -473,7 +473,7 @@ end
473473
@named c = Constant(; k = 1)
474474
@named pt1 = TransferFunction(b = [1, 0], a = [1, 1])
475475
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
476-
sys = structural_simplify(iosys)
476+
sys = mtkcompile(iosys)
477477
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
478478
sol = solve(prob, Rodas4())
479479
@test sol.retcode == Success
@@ -483,7 +483,7 @@ end
483483
# Test with no state
484484
@named pt1 = TransferFunction(b = [2.7], a = [pi])
485485
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
486-
sys = structural_simplify(iosys)
486+
sys = mtkcompile(iosys)
487487
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
488488
sol = solve(prob, Rodas4())
489489
@test sol.retcode == Success

0 commit comments

Comments
 (0)