Skip to content

Commit 01d37d8

Browse files
refactor: remove references to ODESystem in source code
1 parent d70f650 commit 01d37d8

15 files changed

+61
-61
lines changed

src/ModelingToolkit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const D = Differential(t)
214214
PrecompileTools.@compile_workload begin
215215
using ModelingToolkit
216216
@variables x(ModelingToolkit.t_nounits)
217-
@named sys = ODESystem([ModelingToolkit.D_nounits(x) ~ -x], ModelingToolkit.t_nounits)
217+
@named sys = System([ModelingToolkit.D_nounits(x) ~ -x], ModelingToolkit.t_nounits)
218218
prob = ODEProblem(structural_simplify(sys), [x => 30.0], (0, 100), [], jac = true)
219219
@mtkmodel __testmod__ begin
220220
@constants begin

src/inputoutput.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ has_var(ex, x) = x ∈ Set(get_variables(ex))
161161

162162
"""
163163
(f_oop, f_ip), x_sym, p_sym, io_sys = generate_control_function(
164-
sys::AbstractODESystem,
164+
sys::System,
165165
inputs = unbound_inputs(sys),
166166
disturbance_inputs = nothing;
167167
implicit_dae = false,
@@ -193,7 +193,7 @@ t = 0
193193
f[1](x, inputs, p, t)
194194
```
195195
"""
196-
function generate_control_function(sys::AbstractODESystem, inputs = unbound_inputs(sys),
196+
function generate_control_function(sys::AbstractSystem, inputs = unbound_inputs(sys),
197197
disturbance_inputs = disturbances(sys);
198198
disturbance_argument = false,
199199
implicit_dae = false,
@@ -344,7 +344,7 @@ The structure represents a model of a disturbance, along with the input variable
344344
# Fields:
345345
346346
- `input`: The variable affected by the disturbance.
347-
- `model::M`: A model of the disturbance. This is typically an `ODESystem`, but type that implements [`ModelingToolkit.get_disturbance_system`](@ref)`(dist::DisturbanceModel) -> ::ODESystem` is supported.
347+
- `model::M`: A model of the disturbance. This is typically a `System`, but type that implements [`ModelingToolkit.get_disturbance_system`](@ref)`(dist::DisturbanceModel) -> ::System` is supported.
348348
"""
349349
struct DisturbanceModel{M}
350350
input::Any
@@ -354,7 +354,7 @@ end
354354
DisturbanceModel(input, model; name) = DisturbanceModel(input, model, name)
355355

356356
# Point of overloading for libraries, e.g., to be able to support disturbance models from ControlSystemsBase
357-
function get_disturbance_system(dist::DisturbanceModel{<:ODESystem})
357+
function get_disturbance_system(dist::DisturbanceModel{System})
358358
dist.model
359359
end
360360

@@ -395,7 +395,7 @@ c = 10 # Damping coefficient
395395
eqs = [connect(torque.flange, inertia1.flange_a)
396396
connect(inertia1.flange_b, spring.flange_a, damper.flange_a)
397397
connect(inertia2.flange_a, spring.flange_b, damper.flange_b)]
398-
model = ODESystem(eqs, t; systems = [torque, inertia1, inertia2, spring, damper],
398+
model = System(eqs, t; systems = [torque, inertia1, inertia2, spring, damper],
399399
name = :model)
400400
model = complete(model)
401401
model_outputs = [model.inertia1.w, model.inertia2.w, model.inertia1.phi, model.inertia2.phi]
@@ -427,7 +427,7 @@ function add_input_disturbance(sys, dist::DisturbanceModel, inputs = nothing; kw
427427

428428
eqs = [dsys.input.u[1] ~ d
429429
dist.input ~ u + dsys.output.u[1]]
430-
augmented_sys = ODESystem(eqs, t, systems = [dsys], name = gensym(:outer))
430+
augmented_sys = System(eqs, t, systems = [dsys], name = gensym(:outer))
431431
augmented_sys = extend(augmented_sys, sys)
432432

433433
(f_oop, f_ip), dvs, p, io_sys = generate_control_function(augmented_sys, all_inputs,

src/linearization.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The `simplified_sys` has undergone [`structural_simplify`](@ref) and had any occ
1919
2020
# Arguments:
2121
22-
- `sys`: An [`ODESystem`](@ref). This function will automatically apply simplification passes on `sys` and return the resulting `simplified_sys`.
22+
- `sys`: A [`System`](@ref) of ODEs. This function will automatically apply simplification passes on `sys` and return the resulting `simplified_sys`.
2323
- `inputs`: A vector of variables that indicate the inputs of the linearized input-output model.
2424
- `outputs`: A vector of variables that indicate the outputs of the linearized input-output model.
2525
- `simplify`: Apply simplification in tearing.
@@ -640,15 +640,15 @@ function plant(; name)
640640
@variables u(t)=0 y(t)=0
641641
eqs = [D(x) ~ -x + u
642642
y ~ x]
643-
ODESystem(eqs, t; name = name)
643+
System(eqs, t; name = name)
644644
end
645645
646646
function ref_filt(; name)
647647
@variables x(t)=0 y(t)=0
648648
@variables u(t)=0 [input = true]
649649
eqs = [D(x) ~ -2 * x + u
650650
y ~ x]
651-
ODESystem(eqs, t, name = name)
651+
System(eqs, t, name = name)
652652
end
653653
654654
function controller(kp; name)
@@ -657,7 +657,7 @@ function controller(kp; name)
657657
eqs = [
658658
u ~ kp * (r - y),
659659
]
660-
ODESystem(eqs, t; name = name)
660+
System(eqs, t; name = name)
661661
end
662662
663663
@named f = ref_filt()
@@ -668,7 +668,7 @@ connections = [f.y ~ c.r # filtered reference to controller reference
668668
c.u ~ p.u # controller output to plant input
669669
p.y ~ c.y]
670670
671-
@named cl = ODESystem(connections, t, systems = [f, c, p])
671+
@named cl = System(connections, t, systems = [f, c, p])
672672
673673
lsys0, ssys = linearize(cl, [f.u], [p.x])
674674
desired_order = [f.x, p.x]

src/structural_transformation/StructuralTransformations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using SymbolicUtils.Rewriters
1111
using SymbolicUtils: maketerm, iscall
1212

1313
using ModelingToolkit
14-
using ModelingToolkit: ODESystem, AbstractSystem, var_from_nested_derivative, Differential,
14+
using ModelingToolkit: System, AbstractSystem, var_from_nested_derivative, Differential,
1515
unknowns, equations, vars, Symbolic, diff2term_with_unit,
1616
shift2term_with_unit, value,
1717
operation, arguments, Sym, Term, simplify, symbolic_linear_solve,

src/structural_transformation/pantelides.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function pantelides!(
195195
eq′ = eq_to_diff[eq′]
196196
end # for _ in 1:maxiters
197197
pathfound ||
198-
error("maxiters=$maxiters reached! File a bug report if your system has a reasonable index (<100), and you are using the default `maxiters`. Try to increase the maxiters by `pantelides(sys::ODESystem; maxiters=1_000_000)` if your system has an incredibly high index and it is truly extremely large.")
198+
error("maxiters=$maxiters reached! File a bug report if your system has a reasonable index (<100), and you are using the default `maxiters`. Try to increase the maxiters by `pantelides(sys::System; maxiters=1_000_000)` if your system has an incredibly high index and it is truly extremely large.")
199199
end # for k in 1:neqs′
200200

201201
finalize && for var in 1:ndsts(graph)
@@ -206,13 +206,13 @@ function pantelides!(
206206
end
207207

208208
"""
209-
dae_index_lowering(sys::ODESystem; kwargs...) -> ODESystem
209+
dae_index_lowering(sys::System; kwargs...) -> System
210210
211211
Perform the Pantelides algorithm to transform a higher index DAE to an index 1
212212
DAE. `kwargs` are forwarded to [`pantelides!`](@ref). End users are encouraged to call [`structural_simplify`](@ref)
213213
instead, which calls this function internally.
214214
"""
215-
function dae_index_lowering(sys::ODESystem; kwargs...)
215+
function dae_index_lowering(sys::System; kwargs...)
216216
state = TearingState(sys)
217217
var_eq_matching = pantelides!(state; finalize = false, kwargs...)
218218
return invalidate_cache!(pantelides_reassemble(state, var_eq_matching))

src/structural_transformation/symbolics_tearing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function var_derivative_graph!(s::SystemStructure, v::Int)
4040
return var_diff
4141
end
4242

43-
function var_derivative!(ts::TearingState{ODESystem}, v::Int)
43+
function var_derivative!(ts::TearingState, v::Int)
4444
s = ts.structure
4545
var_diff = var_derivative_graph!(s, v)
4646
sys = ts.sys
@@ -58,7 +58,7 @@ function eq_derivative_graph!(s::SystemStructure, eq::Int)
5858
return eq_diff
5959
end
6060

61-
function eq_derivative!(ts::TearingState{ODESystem}, ieq::Int; kwargs...)
61+
function eq_derivative!(ts::TearingState, ieq::Int; kwargs...)
6262
s = ts.structure
6363

6464
eq_diff = eq_derivative_graph!(s, ieq)

src/systems/abstractsystem.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ function defaults(sys::AbstractSystem)
16501650
# `mapfoldr` is really important!!! We should prefer the base model for
16511651
# defaults, because people write:
16521652
#
1653-
# `compose(ODESystem(...; defaults=defs), ...)`
1653+
# `compose(System(...; defaults=defs), ...)`
16541654
#
16551655
# Thus, right associativity is required and crucial for correctness.
16561656
isempty(systems) ? defs : mapfoldr(namespace_defaults, merge, systems; init = defs)
@@ -2864,7 +2864,7 @@ using ModelingToolkit: t, D
28642864
28652865
@parameters p = 1.0, [description = "My parameter", tunable = false] q = 2.0, [description = "Other parameter"]
28662866
@variables x(t) = 3.0 [unit = u"m"]
2867-
@named sys = ODESystem(Equation[], t, [x], [p, q])
2867+
@named sys = System(Equation[], t, [x], [p, q])
28682868
ModelingToolkit.dump_parameters(sys)
28692869
```
28702870
@@ -2905,7 +2905,7 @@ using ModelingToolkit: t, D
29052905
29062906
@parameters p = 1.0, [description = "My parameter", tunable = false] q = 2.0, [description = "Other parameter"]
29072907
@variables x(t) = 3.0 [unit = u"m"]
2908-
@named sys = ODESystem(Equation[], t, [x], [p, q])
2908+
@named sys = System(Equation[], t, [x], [p, q])
29092909
ModelingToolkit.dump_unknowns(sys)
29102910
```
29112911
@@ -3083,7 +3083,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
30833083
@variables X(t)
30843084
eq1 = D(X) ~ p - d*X
30853085
eq2 = 0 ~ p - d*X
3086-
@named osys = ODESystem([eq1, eq2], t)
3086+
@named osys = System([eq1, eq2], t)
30873087
30883088
alg_equations(osys) # returns `[0 ~ p - d*X(t)]`.
30893089
"""
@@ -3102,7 +3102,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
31023102
@variables X(t)
31033103
eq1 = D(X) ~ p - d*X
31043104
eq2 = 0 ~ p - d*X
3105-
@named osys = ODESystem([eq1, eq2], t)
3105+
@named osys = System([eq1, eq2], t)
31063106
31073107
diff_equations(osys) # returns `[Differential(t)(X(t)) ~ p - d*X(t)]`.
31083108
"""
@@ -3122,8 +3122,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
31223122
@variables X(t)
31233123
eq1 = D(X) ~ p - d*X
31243124
eq2 = 0 ~ p - d*X
3125-
@named osys1 = ODESystem([eq1], t)
3126-
@named osys2 = ODESystem([eq2], t)
3125+
@named osys1 = System([eq1], t)
3126+
@named osys2 = System([eq2], t)
31273127
31283128
has_alg_equations(osys1) # returns `false`.
31293129
has_alg_equations(osys2) # returns `true`.
@@ -3144,8 +3144,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
31443144
@variables X(t)
31453145
eq1 = D(X) ~ p - d*X
31463146
eq2 = 0 ~ p - d*X
3147-
@named osys1 = ODESystem([eq1], t)
3148-
@named osys2 = ODESystem([eq2], t)
3147+
@named osys1 = System([eq1], t)
3148+
@named osys2 = System([eq2], t)
31493149
31503150
has_diff_equations(osys1) # returns `true`.
31513151
has_diff_equations(osys2) # returns `false`.
@@ -3167,9 +3167,9 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
31673167
@variables X(t)
31683168
eq1 = D(X) ~ p - d*X
31693169
eq2 = 0 ~ p - d*X
3170-
@named osys1 = ODESystem([eq1], t)
3171-
@named osys2 = ODESystem([eq2], t)
3172-
osys12 = compose(osys1, [osys2])
3170+
@named osys1 = ([eq1], t)
3171+
@named osys2 = ([eq2], t)
3172+
osys12 = compose(sys1, [osys2])
31733173
osys21 = compose(osys2, [osys1])
31743174
31753175
get_alg_eqs(osys12) # returns `Equation[]`.
@@ -3192,8 +3192,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
31923192
@variables X(t)
31933193
eq1 = D(X) ~ p - d*X
31943194
eq2 = 0 ~ p - d*X
3195-
@named osys1 = ODESystem([eq1], t)
3196-
@named osys2 = ODESystem([eq2], t)
3195+
@named osys1 = tem([eq1], t)
3196+
@named osys2 = tem([eq2], t)
31973197
osys12 = compose(osys1, [osys2])
31983198
osys21 = compose(osys2, [osys1])
31993199
@@ -3217,8 +3217,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
32173217
@variables X(t)
32183218
eq1 = D(X) ~ p - d*X
32193219
eq2 = 0 ~ p - d*X
3220-
@named osys1 = ODESystem([eq1], t)
3221-
@named osys2 = ODESystem([eq2], t)
3220+
@named osys1 = System([eq1], t)
3221+
@named osys2 = System([eq2], t)
32223222
osys12 = compose(osys1, [osys2])
32233223
osys21 = compose(osys2, [osys1])
32243224
@@ -3243,8 +3243,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
32433243
@variables X(t)
32443244
eq1 = D(X) ~ p - d*X
32453245
eq2 = 0 ~ p - d*X
3246-
@named osys1 = ODESystem([eq1], t)
3247-
@named osys2 = ODESystem([eq2], t)
3246+
@named osys1 = tem([eq1], t)
3247+
@named osys2 = tem([eq2], t)
32483248
osys12 = compose(osys1, [osys2])
32493249
osys21 = compose(osys2, [osys1])
32503250

src/systems/analysis_points.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ t = ModelingToolkit.get_iv(P)
3131
3232
eqs = [connect(P.output, C.input)
3333
connect(C.output, :plant_input, P.input)]
34-
sys = ODESystem(eqs, t, systems = [P, C], name = :feedback_system)
34+
sys = System(eqs, t, systems = [P, C], name = :feedback_system)
3535
3636
matrices_S, _ = get_sensitivity(sys, :plant_input) # Compute the matrices of a state-space representation of the (input) sensitivity function.
3737
matrices_T, _ = get_comp_sensitivity(sys, :plant_input)
@@ -1007,12 +1007,12 @@ See also [`get_sensitivity`](@ref), [`get_comp_sensitivity`](@ref), [`open_loop`
10071007
#
10081008

10091009
"""
1010-
generate_control_function(sys::ModelingToolkit.AbstractODESystem, input_ap_name::Union{Symbol, Vector{Symbol}, AnalysisPoint, Vector{AnalysisPoint}}, dist_ap_name::Union{Symbol, Vector{Symbol}, AnalysisPoint, Vector{AnalysisPoint}}; system_modifier = identity, kwargs)
1010+
generate_control_function(sys::ModelingToolkit.AbstractSystem, input_ap_name::Union{Symbol, Vector{Symbol}, AnalysisPoint, Vector{AnalysisPoint}}, dist_ap_name::Union{Symbol, Vector{Symbol}, AnalysisPoint, Vector{AnalysisPoint}}; system_modifier = identity, kwargs)
10111011
10121012
When called with analysis points as input arguments, we assume that all analysis points corresponds to connections that should be opened (broken). The use case for this is to get rid of input signal blocks, such as `Step` or `Sine`, since these are useful for simulation but are not needed when using the plant model in a controller or state estimator.
10131013
"""
10141014
function generate_control_function(
1015-
sys::ModelingToolkit.AbstractODESystem, input_ap_name::Union{
1015+
sys::ModelingToolkit.AbstractSystem, input_ap_name::Union{
10161016
Symbol, Vector{Symbol}, AnalysisPoint, Vector{AnalysisPoint}},
10171017
dist_ap_name::Union{
10181018
Nothing, Symbol, Vector{Symbol}, AnalysisPoint, Vector{AnalysisPoint}} = nothing;

src/systems/diffeqs/basic_transformations.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using ModelingToolkit, OrdinaryDiffEq
2121
@variables x(t) y(t)
2222
D = Differential(t)
2323
eqs = [D(x) ~ α*x - β*x*y, D(y) ~ -δ*y + γ*x*y]
24-
@named sys = ODESystem(eqs, t)
24+
@named sys = System(eqs, t)
2525
2626
sys2 = liouville_transform(sys)
2727
sys2 = complete(sys2)
@@ -40,22 +40,22 @@ Optimal Transport Approach
4040
Abhishek Halder, Kooktae Lee, and Raktim Bhattacharya
4141
https://abhishekhalder.bitbucket.io/F16ACC2013Final.pdf
4242
"""
43-
function liouville_transform(sys::AbstractODESystem; kwargs...)
43+
function liouville_transform(sys::System; kwargs...)
4444
t = get_iv(sys)
4545
@variables trJ
46-
D = ModelingToolkit.Differential(t)
46+
D = Differential(t)
4747
neweq = D(trJ) ~ trJ * -tr(calculate_jacobian(sys))
4848
neweqs = [equations(sys); neweq]
4949
vars = [unknowns(sys); trJ]
50-
ODESystem(
50+
System(
5151
neweqs, t, vars, parameters(sys);
5252
checks = false, name = nameof(sys), kwargs...
5353
)
5454
end
5555

5656
"""
5757
change_independent_variable(
58-
sys::AbstractODESystem, iv, eqs = [];
58+
sys::System, iv, eqs = [];
5959
add_old_diff = false, simplify = true, fold = false
6060
)
6161
@@ -95,7 +95,7 @@ By changing the independent variable, it can be reformulated for vertical positi
9595
```julia
9696
julia> @variables x(t) y(t);
9797
98-
julia> @named M = ODESystem([D(D(y)) ~ -9.81, D(D(x)) ~ 0.0], t);
98+
julia> @named M = System([D(D(y)) ~ -9.81, D(D(x)) ~ 0.0], t);
9999
100100
julia> M = change_independent_variable(M, x);
101101
@@ -109,7 +109,7 @@ julia> unknowns(M)
109109
```
110110
"""
111111
function change_independent_variable(
112-
sys::AbstractODESystem, iv, eqs = [];
112+
sys::System, iv, eqs = [];
113113
add_old_diff = false, simplify = true, fold = false
114114
)
115115
iv2_of_iv1 = unwrap(iv) # e.g. u(t)
@@ -166,7 +166,7 @@ function change_independent_variable(
166166
end
167167

168168
# Use the utility function to transform everything in the system!
169-
function transform(sys::AbstractODESystem)
169+
function transform(sys::System)
170170
eqs = map(transform, get_eqs(sys))
171171
unknowns = map(transform, get_unknowns(sys))
172172
unknowns = filter(var -> !isequal(var, iv2), unknowns) # remove e.g. u

src/systems/diffeqs/first_order_transform.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"""
22
$(TYPEDSIGNATURES)
33
4-
Takes a Nth order ODESystem and returns a new ODESystem written in first order
4+
Takes a Nth order System and returns a new System written in first order
55
form by defining new variables which represent the N-1 derivatives.
66
"""
7-
function ode_order_lowering(sys::ODESystem)
7+
function ode_order_lowering(sys::System)
88
iv = get_iv(sys)
99
eqs_lowered, new_vars = ode_order_lowering(equations(sys), iv, unknowns(sys))
1010
@set! sys.eqs = eqs_lowered
1111
@set! sys.unknowns = new_vars
1212
return sys
1313
end
1414

15-
function dae_order_lowering(sys::ODESystem)
15+
function dae_order_lowering(sys::System)
1616
iv = get_iv(sys)
1717
eqs_lowered, new_vars = dae_order_lowering(equations(sys), iv, unknowns(sys))
1818
@set! sys.eqs = eqs_lowered

0 commit comments

Comments
 (0)