Skip to content

Commit 716c8aa

Browse files
docs: rename ODESystem to System
1 parent 58b3766 commit 716c8aa

27 files changed

+80
-94
lines changed

docs/src/API/variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ When variables with descriptions are present in systems, they will be printed wh
3434
```@example metadata
3535
@variables u(t) [description = "A short description of u"]
3636
@parameters p [description = "A description of p"]
37-
@named sys = ODESystem([u ~ p], t)
37+
@named sys = System([u ~ p], t)
3838
show(stdout, "text/plain", sys) # hide
3939
```
4040

@@ -298,7 +298,7 @@ In the example below, we define a system with tunable parameters and extract bou
298298
@parameters k [tunable = true, bounds = (0, Inf)]
299299
eqs = [D(x) ~ (-x + k * u) / T # A first-order system with time constant T and gain k
300300
y ~ x]
301-
sys = ODESystem(eqs, t, name = :tunable_first_order)
301+
sys = System(eqs, t, name = :tunable_first_order)
302302
```
303303

304304
```@example metadata

docs/src/basics/AbstractSystem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ model manipulation and compilation.
1212
There are three immediate subtypes of `AbstractSystem`, classified by how many independent variables each type has:
1313

1414
- `AbstractTimeIndependentSystem`: has no independent variable (e.g.: `NonlinearSystem`)
15-
- `AbstractTimeDependentSystem`: has a single independent variable (e.g.: `ODESystem`)
15+
- `AbstractTimeDependentSystem`: has a single independent variable (e.g.: `System`)
1616
- `AbstractMultivariateSystem`: may have multiple independent variables (e.g.: `PDESystem`)
1717

1818
## Constructors and Naming

docs/src/basics/Composition.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
2121
function decay(; name)
2222
@parameters a
2323
@variables x(t) f(t)
24-
ODESystem([
24+
System([
2525
D(x) ~ -a * x + f
2626
], t;
2727
name = name)
@@ -31,7 +31,7 @@ end
3131
@named decay2 = decay()
3232
3333
connected = compose(
34-
ODESystem([decay2.f ~ decay1.x
34+
System([decay2.f ~ decay1.x
3535
D(decay1.f) ~ 0], t; name = :connected), decay1, decay2)
3636
3737
equations(connected)
@@ -69,7 +69,7 @@ subsystems. A model is the composition of itself and its subsystems.
6969
For example, if we have:
7070

7171
```julia
72-
@named sys = compose(ODESystem(eqs, indepvar, unknowns, ps), subsys)
72+
@named sys = compose(System(eqs, indepvar, unknowns, ps), subsys)
7373
```
7474

7575
the `equations` of `sys` is the concatenation of `get_eqs(sys)` and
@@ -122,7 +122,7 @@ With symbolic parameters, it is possible to set the default value of a parameter
122122

123123
```julia
124124
# ...
125-
sys = ODESystem(
125+
sys = System(
126126
# ...
127127
# directly in the defaults argument
128128
defaults = Pair{Num, Any}[x => u,
@@ -144,20 +144,20 @@ d = GlobalScope(d)
144144

145145
p = [a, b, c, d]
146146

147-
level0 = ODESystem(Equation[], t, [], p; name = :level0)
148-
level1 = ODESystem(Equation[], t, [], []; name = :level1) level0
147+
level0 = System(Equation[], t, [], p; name = :level0)
148+
level1 = System(Equation[], t, [], []; name = :level1) level0
149149
parameters(level1)
150150
#level0₊a
151151
#b
152152
#c
153153
#d
154-
level2 = ODESystem(Equation[], t, [], []; name = :level2) level1
154+
level2 = System(Equation[], t, [], []; name = :level2) level1
155155
parameters(level2)
156156
#level1₊level0₊a
157157
#level1₊b
158158
#c
159159
#d
160-
level3 = ODESystem(Equation[], t, [], []; name = :level3) level2
160+
level3 = System(Equation[], t, [], []; name = :level3) level2
161161
parameters(level3)
162162
#level2₊level1₊level0₊a
163163
#level2₊level1₊b
@@ -194,12 +194,12 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
194194
N = S + I + R
195195
@parameters β, γ
196196
197-
@named seqn = ODESystem([D(S) ~ -β * S * I / N], t)
198-
@named ieqn = ODESystem([D(I) ~ β * S * I / N - γ * I], t)
199-
@named reqn = ODESystem([D(R) ~ γ * I], t)
197+
@named seqn = System([D(S) ~ -β * S * I / N], t)
198+
@named ieqn = System([D(I) ~ β * S * I / N - γ * I], t)
199+
@named reqn = System([D(R) ~ γ * I], t)
200200
201201
sir = compose(
202-
ODESystem(
202+
System(
203203
[
204204
S ~ ieqn.S,
205205
I ~ seqn.I,
@@ -266,6 +266,6 @@ equations are discontinuous in either the unknown or one of its derivatives. Thi
266266
causes the solver to take very small steps around the discontinuity, and
267267
sometimes leads to early stopping due to `dt <= dt_min`. The correct way to
268268
handle such dynamics is to tell the solver about the discontinuity by a
269-
root-finding equation, which can be modeling using [`ODESystem`](@ref)'s event
269+
root-finding equation, which can be modeling using [`System`](@ref)'s event
270270
support. Please see the tutorial on [Callbacks and Events](@ref events) for
271271
details and examples.

docs/src/basics/Debugging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
1212
@variables u1(t) u2(t) u3(t)
1313
eqs = [D(u1) ~ -√(u1), D(u2) ~ -√(u2), D(u3) ~ -√(u3)]
1414
defaults = [u1 => 1.0, u2 => 2.0, u3 => 3.0]
15-
@named sys = ODESystem(eqs, t; defaults)
15+
@named sys = System(eqs, t; defaults)
1616
sys = mtkcompile(sys)
1717
```
1818

@@ -38,7 +38,7 @@ We could have figured that out ourselves, but it is not always so obvious for mo
3838
Suppose we also want to validate that `u1 + u2 >= 2.0`. We can do this via the assertions functionality.
3939

4040
```@example debug
41-
@mtkcompile sys = ODESystem(eqs, t; defaults, assertions = [(u1 + u2 >= 2.0) => "Oh no!"])
41+
@mtkcompile sys = System(eqs, t; defaults, assertions = [(u1 + u2 >= 2.0) => "Oh no!"])
4242
```
4343

4444
The assertions must be an iterable of pairs, where the first element is the symbolic condition and

docs/src/basics/Events.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ or into more specialized callback types from the
99
[DiffEqCallbacks.jl](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_library/)
1010
library.
1111

12-
[`ODESystem`](@ref)s and [`SDESystem`](@ref)s accept keyword arguments
12+
[`System`](@ref)s and [`SDESystem`](@ref)s accept keyword arguments
1313
`continuous_events` and `discrete_events` to symbolically encode continuous or
1414
discrete callbacks. [`JumpSystem`](@ref)s currently support only
1515
`discrete_events`. Continuous events are applied when a given condition becomes
@@ -59,7 +59,7 @@ For example, consider the following system.
5959
```julia
6060
@variables x(t) y(t)
6161
@parameters p(t)
62-
@mtkcompile sys = ODESystem([x * y ~ p, D(x) ~ 0], t)
62+
@mtkcompile sys = System([x * y ~ p, D(x) ~ 0], t)
6363
event = [t == 1] => [x ~ Pre(x) + 1]
6464
```
6565

@@ -132,7 +132,7 @@ function UnitMassWithFriction(k; name)
132132
@variables x(t)=0 v(t)=0
133133
eqs = [D(x) ~ v
134134
D(v) ~ sin(t) - k * sign(v)]
135-
ODESystem(eqs, t; continuous_events = [v ~ 0], name) # when v = 0 there is a discontinuity
135+
System(eqs, t; continuous_events = [v ~ 0], name) # when v = 0 there is a discontinuity
136136
end
137137
@mtkcompile m = UnitMassWithFriction(0.7)
138138
prob = ODEProblem(m, Pair[], (0, 10pi))
@@ -154,7 +154,7 @@ like this
154154
root_eqs = [x ~ 0] # the event happens at the ground x(t) = 0
155155
affect = [v ~ -Pre(v)] # the effect is that the velocity changes sign
156156
157-
@mtkcompile ball = ODESystem(
157+
@mtkcompile ball = System(
158158
[D(x) ~ v
159159
D(v) ~ -9.8], t; continuous_events = root_eqs => affect) # equation => affect
160160
@@ -175,7 +175,7 @@ Multiple events? No problem! This example models a bouncing ball in 2D that is e
175175
continuous_events = [[x ~ 0] => [vx ~ -Pre(vx)]
176176
[y ~ -1.5, y ~ 1.5] => [vy ~ -Pre(vy)]]
177177
178-
@mtkcompile ball = ODESystem(
178+
@mtkcompile ball = System(
179179
[
180180
D(x) ~ vx,
181181
D(y) ~ vy,
@@ -255,7 +255,7 @@ end
255255
256256
reflect = [x ~ 0] => (bb_affect!, [v], [], [], nothing)
257257
258-
@mtkcompile bb_sys = ODESystem(bb_eqs, t, sts, par,
258+
@mtkcompile bb_sys = System(bb_eqs, t, sts, par,
259259
continuous_events = reflect)
260260
261261
u0 = [v => 0.0, x => 1.0]
@@ -300,7 +300,7 @@ injection = (t == tinject) => [N ~ Pre(N) + M]
300300
u0 = [N => 0.0]
301301
tspan = (0.0, 20.0)
302302
p = [α => 100.0, tinject => 10.0, M => 50]
303-
@mtkcompile osys = ODESystem(eqs, t, [N], [α, M, tinject]; discrete_events = injection)
303+
@mtkcompile osys = System(eqs, t, [N], [α, M, tinject]; discrete_events = injection)
304304
oprob = ODEProblem(osys, u0, tspan, p)
305305
sol = solve(oprob, Tsit5(); tstops = 10.0)
306306
plot(sol)
@@ -319,7 +319,7 @@ to
319319
```@example events
320320
injection = ((t == tinject) & (N < 50)) => [N ~ Pre(N) + M]
321321
322-
@mtkcompile osys = ODESystem(eqs, t, [N], [M, tinject, α]; discrete_events = injection)
322+
@mtkcompile osys = System(eqs, t, [N], [M, tinject, α]; discrete_events = injection)
323323
oprob = ODEProblem(osys, u0, tspan, p)
324324
sol = solve(oprob, Tsit5(); tstops = 10.0)
325325
plot(sol)
@@ -346,7 +346,7 @@ killing = ModelingToolkit.SymbolicDiscreteCallback(
346346
347347
tspan = (0.0, 30.0)
348348
p = [α => 100.0, tinject => 10.0, M => 50, tkill => 20.0]
349-
@mtkcompile osys = ODESystem(eqs, t, [N], [α, M, tinject, tkill];
349+
@mtkcompile osys = System(eqs, t, [N], [α, M, tinject, tkill];
350350
discrete_events = [injection, killing])
351351
oprob = ODEProblem(osys, u0, tspan, p)
352352
sol = solve(oprob, Tsit5(); tstops = [10.0, 20.0])
@@ -375,7 +375,7 @@ killing = ModelingToolkit.SymbolicDiscreteCallback(
375375
[20.0] => [α ~ 0.0], discrete_parameters = α, iv = t)
376376
377377
p = [α => 100.0, M => 50]
378-
@mtkcompile osys = ODESystem(eqs, t, [N], [α, M];
378+
@mtkcompile osys = System(eqs, t, [N], [α, M];
379379
discrete_events = [injection, killing])
380380
oprob = ODEProblem(osys, u0, tspan, p)
381381
sol = solve(oprob, Tsit5())
@@ -415,7 +415,7 @@ example:
415415
416416
ev = ModelingToolkit.SymbolicDiscreteCallback(
417417
1.0 => [c ~ Pre(c) + 1], discrete_parameters = c, iv = t)
418-
@mtkcompile sys = ODESystem(
418+
@mtkcompile sys = System(
419419
D(x) ~ c * cos(x), t, [x], [c]; discrete_events = [ev])
420420
421421
prob = ODEProblem(sys, [x => 0.0], (0.0, 2pi), [c => 1.0])
@@ -436,7 +436,7 @@ will be saved. If we repeat the above example with `c` not a `discrete_parameter
436436
@variables x(t)
437437
@parameters c(t)
438438
439-
@mtkcompile sys = ODESystem(
439+
@mtkcompile sys = System(
440440
D(x) ~ c * cos(x), t, [x], [c]; discrete_events = [1.0 => [c ~ Pre(c) + 1]])
441441
442442
prob = ODEProblem(sys, [x => 0.0], (0.0, 2pi), [c => 1.0])
@@ -537,7 +537,7 @@ will write `furnace_on = false` back to the system, and when `temp = furnace_on_
537537
to the system.
538538

539539
```@example events
540-
@named sys = ODESystem(
540+
@named sys = System(
541541
eqs, t, [temp], params; continuous_events = [furnace_disable, furnace_enable])
542542
ss = mtkcompile(sys)
543543
prob = ODEProblem(ss, [temp => 0.0, furnace_on => true], (0.0, 10.0))
@@ -650,7 +650,7 @@ affect activation point, with -1 mapped to 0.
650650
We can now simulate the encoder.
651651

652652
```@example events
653-
@named sys = ODESystem(
653+
@named sys = System(
654654
eqs, t, [theta, omega], params; continuous_events = [qAevt, qBevt])
655655
ss = mtkcompile(sys)
656656
prob = ODEProblem(ss, [theta => 0.0], (0.0, pi))

docs/src/basics/FAQ.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ eqs = [x1 + x2 + 1 ~ 0
205205
x1 + x2 + x3 + 2 ~ 0
206206
x1 + D(x3) + x4 + 3 ~ 0
207207
2 * D(D(x1)) + D(D(x2)) + D(D(x3)) + D(x4) + 4 ~ 0]
208-
@named sys = ODESystem(eqs, t)
208+
@named sys = System(eqs, t)
209209
sys = mtkcompile(sys)
210210
prob = ODEProblem(sys, [], (0, 1))
211211
```
@@ -237,7 +237,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
237237

238238
sts = @variables x1(t) = 0.0
239239
eqs = [D(x1) ~ 1.1 * x1]
240-
@mtkcompile sys = ODESystem(eqs, t)
240+
@mtkcompile sys = System(eqs, t)
241241
prob = ODEProblem{false}(sys, [], (0, 1); u0_constructor = x -> SVector(x...))
242242
```
243243

@@ -252,7 +252,7 @@ using ModelingToolkit
252252
@independent_variables x
253253
D = Differential(x)
254254
@variables y(x)
255-
@named sys = ODESystem([D(y) ~ x], x)
255+
@named sys = System([D(y) ~ x], x)
256256
```
257257

258258
## Ordering of tunable parameters
@@ -279,7 +279,7 @@ using ModelingToolkit
279279
280280
@parameters p q[1:3] r[1:2, 1:2]
281281
282-
@named sys = ODESystem(Equation[], ModelingToolkit.t_nounits, [], [p, q, r])
282+
@named sys = System(Equation[], ModelingToolkit.t_nounits, [], [p, q, r])
283283
sys = complete(sys)
284284
```
285285

docs/src/basics/InputOutput.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import ModelingToolkit: t_nounits as t, D_nounits as D
4444
eqs = [D(x) ~ -k * (x + u)
4545
y ~ x]
4646
47-
@named sys = ODESystem(eqs, t)
47+
@named sys = System(eqs, t)
4848
f, x_sym, ps = ModelingToolkit.generate_control_function(sys, [u], simplify = true);
4949
nothing # hide
5050
```

docs/src/basics/Linearization.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ eqs = [u ~ kp * (r - y) # P controller
2929
D(x) ~ -x + u # First-order plant
3030
y ~ x] # Output equation
3131
32-
@named sys = ODESystem(eqs, t) # Do not call @mtkcompile when linearizing
32+
@named sys = System(eqs, t) # Do not call @mtkcompile when linearizing
3333
matrices, simplified_sys = linearize(sys, [r], [y]) # Linearize from r to y
3434
matrices
3535
```
3636

37-
The named tuple `matrices` contains the matrices of the linear statespace representation, while `simplified_sys` is an `ODESystem` that, among other things, indicates the unknown variable order in the linear system through
37+
The named tuple `matrices` contains the matrices of the linear statespace representation, while `simplified_sys` is an `System` that, among other things, indicates the unknown variable order in the linear system through
3838

3939
```@example LINEARIZE
4040
using ModelingToolkit: inputs, outputs
@@ -78,7 +78,7 @@ eqs = [D(x) ~ v
7878
D(v) ~ -k * x - k3 * x^3 - c * v + 10u.u
7979
y.u ~ x]
8080
81-
@named duffing = ODESystem(eqs, t, systems = [y, u], defaults = [u.u => 0])
81+
@named duffing = System(eqs, t, systems = [y, u], defaults = [u.u => 0])
8282
8383
# pass a constant value for `x`, since it is the variable we will change in operating points
8484
linfun, simplified_sys = linearization_function(duffing, [u.u], [y.u]; op = Dict(x => NaN));

docs/src/basics/MTKLanguage.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ equations.
1616
### [Defining components with `@mtkmodel`](@id mtkmodel)
1717

1818
`@mtkmodel` is a convenience macro to define components. It returns
19-
`ModelingToolkit.Model`, which includes a system constructor (`ODESystem` by
19+
`ModelingToolkit.Model`, which includes a system constructor (`System` by
2020
default), a `structure` dictionary with metadata, and flag `isconnector` which is
2121
set to `false`.
2222

@@ -263,7 +263,7 @@ end
263263

264264
### Setting the type of system:
265265

266-
By default `@mtkmodel` returns an ODESystem. Different types of system can be
266+
By default `@mtkmodel` returns an System. Different types of system can be
267267
defined with the following syntax:
268268

269269
```
@@ -273,20 +273,6 @@ end
273273
274274
```
275275

276-
Example:
277-
278-
```@example mtkmodel-example
279-
@mtkmodel Float2Bool::DiscreteSystem begin
280-
@variables begin
281-
u(t)::Float64
282-
y(t)::Bool
283-
end
284-
@equations begin
285-
y ~ u != 0
286-
end
287-
end
288-
```
289-
290276
## Connectors
291277

292278
Connectors are special models that can be used to connect different components together.
@@ -301,7 +287,7 @@ MTK provides 3 distinct connectors:
301287
### [Defining connectors with `@connector`](@id connector)
302288

303289
`@connector` returns `ModelingToolkit.Model`. It includes a constructor that returns
304-
a connector system (`ODESystem` by default), a `structure` dictionary with metadata, and flag `isconnector`
290+
a connector system (`System` by default), a `structure` dictionary with metadata, and flag `isconnector`
305291
which is set to `true`.
306292

307293
A simple connector can be defined with syntax similar to following example:

docs/src/basics/Precompilation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module PrecompilationMWE
2121
using ModelingToolkit
2222

2323
@variables x(ModelingToolkit.t_nounits)
24-
@named sys = ODESystem([ModelingToolkit.D_nounits(x) ~ -x + 1], ModelingToolkit.t_nounits)
24+
@named sys = System([ModelingToolkit.D_nounits(x) ~ -x + 1], ModelingToolkit.t_nounits)
2525
prob = ODEProblem(mtkcompile(sys), [x => 30.0], (0, 100), [],
2626
eval_expression = true, eval_module = @__MODULE__)
2727

docs/src/basics/Validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ end
110110
sts = @variables a(t)=0 [unit = u"cm"]
111111
ps = @parameters s=-1 [unit = u"cm"] c=c [unit = u"cm"]
112112
eqs = [D(a) ~ dummycomplex(c, s);]
113-
sys = ODESystem(
113+
sys = System(
114114
eqs, t, [sts...;], [ps...;], name = :sys, checks = ~ModelingToolkit.CheckUnits)
115115
sys_simple = mtkcompile(sys)
116116
```

0 commit comments

Comments
 (0)