Skip to content

Commit 33af160

Browse files
refactor: rename ODESystem to System
1 parent cbff89d commit 33af160

File tree

18 files changed

+149
-149
lines changed

18 files changed

+149
-149
lines changed

docs/src/API/linear_analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ using ModelingToolkitStandardLibrary.Blocks, ModelingToolkit
6161
t = ModelingToolkit.get_iv(P)
6262
eqs = [connect(P.output, :plant_output, C.input) # Connect with an automatically created analysis point called :plant_output
6363
connect(C.output, :plant_input, P.input)]
64-
sys = ODESystem(eqs, t, systems = [P, C], name = :feedback_system)
64+
sys = System(eqs, t, systems = [P, C], name = :feedback_system)
6565
6666
matrices_S = get_sensitivity(sys, :plant_input)[1] # Compute the matrices of a state-space representation of the (input)sensitivity function.
6767
matrices_T = get_comp_sensitivity(sys, :plant_input)[1]

docs/src/connectors/connections.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ end
102102
eqs = [connect(capacitor.p, resistor.p)
103103
connect(resistor.n, ground.g, capacitor.n)]
104104
105-
@named model = ODESystem(eqs, t; systems)
105+
@named model = System(eqs, t; systems)
106106
107107
sys = mtkcompile(model)
108108
@@ -144,7 +144,7 @@ end
144144
eqs = [connect(damping.flange_a, body.flange)
145145
connect(ground.flange, damping.flange_b)]
146146
147-
@named model = ODESystem(eqs, t; systems)
147+
@named model = System(eqs, t; systems)
148148
149149
sys = mtkcompile(model)
150150
@@ -180,7 +180,7 @@ end
180180
eqs = [connect(damping.flange_a, body.flange)
181181
connect(ground.flange, damping.flange_b)]
182182
183-
@named model = ODESystem(eqs, t; systems)
183+
@named model = System(eqs, t; systems)
184184
185185
sys = mtkcompile(model)
186186
@@ -275,7 +275,7 @@ function simplify_and_solve(damping, spring, body, ground; initialization_eqs =
275275
eqs = [connect(spring.flange_a, body.flange, damping.flange_a)
276276
connect(spring.flange_b, damping.flange_b, ground.flange)]
277277
278-
@named model = ODESystem(eqs, t; systems = [ground, body, spring, damping])
278+
@named model = System(eqs, t; systems = [ground, body, spring, damping])
279279
280280
sys = mtkcompile(model)
281281

docs/src/tutorials/input_component.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function MassSpringDamper(; name)
4343
D(x) ~ dx
4444
D(dx) ~ ddx]
4545
46-
ODESystem(eqs, t; name, systems = [input])
46+
System(eqs, t; name, systems = [input])
4747
end
4848
4949
function MassSpringDamperSystem(data, time; name)
@@ -54,7 +54,7 @@ function MassSpringDamperSystem(data, time; name)
5454
eqs = [connect(clk.output, src.input)
5555
connect(src.output, model.input)]
5656
57-
ODESystem(eqs, t, [], []; name, systems = [src, clk, model])
57+
System(eqs, t, [], []; name, systems = [src, clk, model])
5858
end
5959
6060
function generate_data()
@@ -134,7 +134,7 @@ function MassSpringDamper(; name)
134134
D(x) ~ dx
135135
D(dx) ~ ddx]
136136
137-
ODESystem(eqs, t, vars, pars; name, systems = [input])
137+
System(eqs, t, vars, pars; name, systems = [input])
138138
end
139139
140140
function MassSpringDamperSystem(data, time; name)
@@ -145,7 +145,7 @@ function MassSpringDamperSystem(data, time; name)
145145
eqs = [connect(model.input, src.output)
146146
connect(clk.output, src.input)]
147147
148-
ODESystem(eqs, t; name, systems = [src, clk, model])
148+
System(eqs, t; name, systems = [src, clk, model])
149149
end
150150
151151
function generate_data()
@@ -213,7 +213,7 @@ function System(; name)
213213
D(x) ~ dx
214214
D(dx) ~ ddx]
215215
216-
ODESystem(eqs, t, vars, pars; name)
216+
System(eqs, t, vars, pars; name)
217217
end
218218
219219
@named system = System()
@@ -240,7 +240,7 @@ Additional code could be added to resolve this issue, for example by using a `Re
240240

241241
## `SampledData` Component
242242

243-
To resolve the issues presented above, the `ModelingToolkitStandardLibrary.Blocks.SampledData` component can be used which allows for a resusable `ODESystem` and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallelize the call to `solve()`.
243+
To resolve the issues presented above, the `ModelingToolkitStandardLibrary.Blocks.SampledData` component can be used which allows for a resusable `System` and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallelize the call to `solve()`.
244244

245245
```julia
246246
using ModelingToolkit
@@ -259,7 +259,7 @@ function System(; name)
259259
D(x) ~ dx
260260
D(dx) ~ ddx]
261261

262-
ODESystem(eqs, t, vars, pars; systems = [src], name)
262+
System(eqs, t, vars, pars; systems = [src], name)
263263
end
264264

265265
@named system = System()

test/Blocks/continuous.jl

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ an integrator with a constant input is often used together with the system under
1414
@testset "Constant" begin
1515
@named c = Constant(; k = 1)
1616
@named int = Integrator(x = 1)
17-
@named iosys = ODESystem(connect(c.output, int.input), t, systems = [int, c])
17+
@named iosys = System(connect(c.output, int.input), t, systems = [int, c])
1818
sys = mtkcompile(iosys)
1919
prob = ODEProblem(sys, Pair[], (0.0, 1.0))
2020
sol = solve(prob, Rodas4())
@@ -27,7 +27,7 @@ end
2727
@named source = Sine(; frequency = 1)
2828
@named int = Integrator(; k = 1)
2929
@named der = Derivative(; k = 1, T = 0.001)
30-
@named iosys = ODESystem(
30+
@named iosys = System(
3131
[
3232
connect(source.output, der.input),
3333
connect(der.output, int.input)
@@ -47,7 +47,7 @@ end
4747
k, T = 1.2, 0.1
4848
@named c = Constant(; k = 1)
4949
@named pt1 = FirstOrder(; k = k, T = T)
50-
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
50+
@named iosys = System(connect(c.output, pt1.input), t, systems = [pt1, c])
5151
sys = mtkcompile(iosys)
5252
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
5353
sol = solve(prob, Rodas4())
@@ -56,7 +56,7 @@ end
5656

5757
# Test highpass feature
5858
@named pt1 = FirstOrder(; k = k, T = T, lowpass = false)
59-
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
59+
@named iosys = System(connect(c.output, pt1.input), t, systems = [pt1, c])
6060
sys = mtkcompile(iosys)
6161
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
6262
sol = solve(prob, Rodas4())
@@ -80,7 +80,7 @@ end
8080
k, w, d = 1.0, 1.0, 0.5
8181
@named c = Constant(; k = 1)
8282
@named pt2 = SecondOrder(; k = k, w = w, d = d)
83-
@named iosys = ODESystem(connect(c.output, pt2.input), t, systems = [pt2, c])
83+
@named iosys = System(connect(c.output, pt2.input), t, systems = [pt2, c])
8484
sys = mtkcompile(iosys)
8585
prob = ODEProblem(sys, [unknowns(sys) .=> 0.0...; pt2.xd => 0.0], (0.0, 100.0))
8686
sol = solve(prob, Rodas4())
@@ -95,7 +95,7 @@ end
9595
D = [0;;]
9696
@named ss = StateSpace(; A, B, C, D, x = zeros(2))
9797
@named c = Constant(; k = 1)
98-
@named model = ODESystem([
98+
@named model = System([
9999
connect(c.output, ss.input)
100100
],
101101
t,
@@ -115,7 +115,7 @@ end
115115
u0 = [1] # This causes no effective input to the system since c.k = 1
116116
y0 = [2]
117117
@named ss = StateSpace(; A, B, C, D, x = zeros(2), u0, y0)
118-
@named model = ODESystem([
118+
@named model = System([
119119
connect(c.output, ss.input)
120120
],
121121
t,
@@ -142,7 +142,7 @@ Second order demo plant
142142
eqs = [D(x1) ~ x2
143143
D(x2) ~ -x1 - 0.5 * x2 + input.u
144144
output.u ~ 0.9 * x1 + x2]
145-
compose(ODESystem(eqs, t, sts, []; name), [input, output])
145+
compose(System(eqs, t, sts, []; name), [input, output])
146146
end
147147

148148
@testset "PI" begin
@@ -151,7 +151,7 @@ end
151151
@named pi_controller = PI(k = 1, T = 1)
152152
@named plant = Plant()
153153
@named fb = Feedback()
154-
@named model = ODESystem(
154+
@named model = System(
155155
[
156156
connect(ref.output, fb.input1),
157157
connect(plant.output, fb.input2),
@@ -174,7 +174,7 @@ end
174174
@named pid_controller = PID(k = 3, Ti = 0.5, Td = 1 / 100)
175175
@named plant = Plant()
176176
@named fb = Feedback()
177-
@named model = ODESystem(
177+
@named model = System(
178178
[
179179
connect(ref.output, fb.input1),
180180
connect(plant.output, fb.input2),
@@ -192,7 +192,7 @@ end
192192

193193
@testset "PI" begin
194194
@named pid_controller = PID(k = 3, Ti = 0.5, Td = false)
195-
@named model = ODESystem(
195+
@named model = System(
196196
[
197197
connect(ref.output, fb.input1),
198198
connect(plant.output, fb.input2),
@@ -211,7 +211,7 @@ end
211211

212212
@testset "PD" begin
213213
@named pid_controller = PID(k = 10, Ti = false, Td = 1)
214-
@named model = ODESystem(
214+
@named model = System(
215215
[
216216
connect(ref.output, fb.input1),
217217
connect(plant.output, fb.input2),
@@ -244,7 +244,7 @@ end
244244

245245
# without anti-windup measure
246246
sol = let
247-
@named model = ODESystem(
247+
@named model = System(
248248
[
249249
connect(ref.output, fb.input1),
250250
connect(plant.output, fb.input2),
@@ -261,7 +261,7 @@ end
261261

262262
# with anti-windup measure
263263
sol_lim = let
264-
@named model = ODESystem(
264+
@named model = System(
265265
[
266266
connect(ref.output, fb.input1),
267267
connect(plant.output, fb.input2),
@@ -295,7 +295,7 @@ end
295295
k = 3, Ti = 0.5, Td = 1 / 100, u_max = 1.5, u_min = -1.5,
296296
Ni = 0.1 / 0.5)
297297
@named plant = Plant()
298-
@named model = ODESystem(
298+
@named model = System(
299299
[
300300
connect(ref.output, pid_controller.reference),
301301
connect(plant.output, pid_controller.measurement),
@@ -316,7 +316,7 @@ end
316316
@testset "PI" begin
317317
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = false, u_max = 1.5,
318318
u_min = -1.5, Ni = 0.1 / 0.5)
319-
@named model = ODESystem(
319+
@named model = System(
320320
[
321321
connect(ref.output, pid_controller.reference),
322322
connect(plant.output, pid_controller.measurement),
@@ -337,7 +337,7 @@ end
337337
@testset "PD" begin
338338
@named pid_controller = LimPID(k = 10, Ti = false, Td = 1, u_max = 1.5,
339339
u_min = -1.5)
340-
@named model = ODESystem(
340+
@named model = System(
341341
[
342342
connect(ref.output, pid_controller.reference),
343343
connect(plant.output, pid_controller.measurement),
@@ -359,7 +359,7 @@ end
359359
@testset "wp" begin
360360
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = 1 / 100, u_max = 1.5,
361361
u_min = -1.5, Ni = 0.1 / 0.5, wp = 0, wd = 1)
362-
@named model = ODESystem(
362+
@named model = System(
363363
[
364364
connect(ref.output, pid_controller.reference),
365365
connect(plant.output, pid_controller.measurement),
@@ -381,7 +381,7 @@ end
381381
@testset "wd" begin
382382
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = 1 / 100, u_max = 1.5,
383383
u_min = -1.5, Ni = 0.1 / 0.5, wp = 1, wd = 0)
384-
@named model = ODESystem(
384+
@named model = System(
385385
[
386386
connect(ref.output, pid_controller.reference),
387387
connect(plant.output, pid_controller.measurement),
@@ -404,7 +404,7 @@ end
404404
@testset "PI without AWM" begin
405405
@named pid_controller = LimPID(k = 3, Ti = 0.5, Td = false, u_max = 1.5,
406406
u_min = -1.5, Ni = Inf)
407-
@named model = ODESystem(
407+
@named model = System(
408408
[
409409
connect(ref.output, pid_controller.reference),
410410
connect(plant.output, pid_controller.measurement),
@@ -428,7 +428,7 @@ end
428428

429429
@named c = Constant(; k = 1)
430430
@named pt1 = TransferFunction(b = [1.2], a = [3.14, 1])
431-
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
431+
@named iosys = System(connect(c.output, pt1.input), t, systems = [pt1, c])
432432
sys = mtkcompile(iosys)
433433
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
434434
sol = solve(prob, Rodas4())
@@ -438,7 +438,7 @@ end
438438
# Test logic for a_end by constructing an integrator
439439
@named c = Constant(; k = 1)
440440
@named pt1 = TransferFunction(b = [1.2], a = [3.14, 0])
441-
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
441+
@named iosys = System(connect(c.output, pt1.input), t, systems = [pt1, c])
442442
sys = mtkcompile(iosys)
443443
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
444444
sol = solve(prob, Rodas4())
@@ -462,7 +462,7 @@ end
462462

463463
k, w, d = 1.0, 1.0, 0.5
464464
@named pt1 = TransferFunction(b = [w^2], a = [1, 2d * w, w^2])
465-
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
465+
@named iosys = System(connect(c.output, pt1.input), t, systems = [pt1, c])
466466
sys = mtkcompile(iosys)
467467
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
468468
sol = solve(prob, Rodas4())
@@ -472,7 +472,7 @@ end
472472
# test zeros (high-pass version of first test)
473473
@named c = Constant(; k = 1)
474474
@named pt1 = TransferFunction(b = [1, 0], a = [1, 1])
475-
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
475+
@named iosys = System(connect(c.output, pt1.input), t, systems = [pt1, c])
476476
sys = mtkcompile(iosys)
477477
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
478478
sol = solve(prob, Rodas4())
@@ -482,7 +482,7 @@ end
482482

483483
# Test with no state
484484
@named pt1 = TransferFunction(b = [2.7], a = [pi])
485-
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
485+
@named iosys = System(connect(c.output, pt1.input), t, systems = [pt1, c])
486486
sys = mtkcompile(iosys)
487487
prob = ODEProblem(sys, Pair[], (0.0, 100.0))
488488
sol = solve(prob, Rodas4())

0 commit comments

Comments
 (0)