Skip to content

Commit 9fd20fd

Browse files
committed
Change most @parameters t to use @independent_variables t
1 parent 2e71485 commit 9fd20fd

23 files changed

+61
-44
lines changed

docs/src/basics/Validation.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Units may be assigned with the following syntax.
88

99
```@example validation
1010
using ModelingToolkit, DynamicQuantities
11-
@parameters t [unit = u"s"]
11+
@independent_variables t [unit = u"s"]
1212
@variables x(t) [unit = u"m"] g(t) w(t) [unit = u"Hz"]
1313
1414
@parameters(t, [unit = u"s"])
@@ -50,7 +50,8 @@ Example usage below. Note that `ModelingToolkit` does not force unit conversions
5050

5151
```@example validation
5252
using ModelingToolkit, DynamicQuantities
53-
@parameters t [unit = u"ms"] τ [unit = u"ms"]
53+
@independent_variables t [unit = u"ms"]
54+
@parameters τ [unit = u"ms"]
5455
@variables E(t) [unit = u"kJ"] P(t) [unit = u"MW"]
5556
D = Differential(t)
5657
eqs = [D(E) ~ P - E / τ,
@@ -74,7 +75,8 @@ An example of an inconsistent system: at present, `ModelingToolkit` requires tha
7475

7576
```@example validation
7677
using ModelingToolkit, DynamicQuantities
77-
@parameters t [unit = u"ms"] τ [unit = u"ms"]
78+
@independent_variables t [unit = u"ms"]
79+
@parameters τ [unit = u"ms"]
7880
@variables E(t) [unit = u"J"] P(t) [unit = u"MW"]
7981
D = Differential(t)
8082
eqs = [D(E) ~ P - E / τ,
@@ -119,7 +121,7 @@ In order for a function to work correctly during both validation & execution, th
119121

120122
```julia
121123
using ModelingToolkit, DynamicQuantities
122-
@parameters t [unit = u"ms"]
124+
@independent_variables t [unit = u"ms"]
123125
@variables E(t) [unit = u"J"] P(t) [unit = u"MW"]
124126
D = Differential(t)
125127
eqs = [D(E) ~ P - E / 1u"ms"]
@@ -134,7 +136,8 @@ Instead, they should be parameterized:
134136

135137
```@example validation3
136138
using ModelingToolkit, DynamicQuantities
137-
@parameters t [unit = u"ms"] τ [unit = u"ms"]
139+
@independent_variables t [unit = u"ms"]
140+
@parameters τ [unit = u"ms"]
138141
@variables E(t) [unit = u"kJ"] P(t) [unit = u"MW"]
139142
D = Differential(t)
140143
eqs = [D(E) ~ P - E / τ]

src/systems/diffeqs/basic_transformations.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Example:
1616
```julia
1717
using ModelingToolkit, OrdinaryDiffEq, Test
1818
19-
@parameters t α β γ δ
19+
@independent_variables t
20+
@parameters α β γ δ
2021
@variables x(t) y(t)
2122
D = Differential(t)
2223

src/systems/diffeqs/modelingtoolkitize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Generate `SDESystem`, dependent variables, and parameters from an `SDEProblem`.
242242
function modelingtoolkitize(prob::DiffEqBase.SDEProblem; kwargs...)
243243
prob.f isa DiffEqBase.AbstractParameterizedFunction &&
244244
return (prob.f.sys, prob.f.sys.unknowns, prob.f.sys.ps)
245-
@parameters t
245+
@independent_variables t
246246
p = prob.p
247247
has_p = !(p isa Union{DiffEqBase.NullParameters, Nothing})
248248

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ collect_differential_variables(sys) = collect_operator_variables(sys, Differenti
418418
Return a `Set` with all applied operators in `x`, example:
419419
420420
```
421-
@parameters t
421+
@independent_variables t
422422
@variables u(t) y(t)
423423
D = Differential(t)
424424
eq = D(y) ~ u

test/abstractsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using ModelingToolkit
22
using Test
33
MT = ModelingToolkit
44

5-
@parameters t
5+
@independent_variables t
66
@variables x
77
struct MyNLS <: MT.AbstractSystem
88
name::Any

test/basic_transformations.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ModelingToolkit, OrdinaryDiffEq, Test
22

3-
@parameters t α β γ δ
3+
@independent_variables t
4+
@parameters α β γ δ
45
@variables x(t) y(t)
56
D = Differential(t)
67

test/components.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ sol = solve(prob, Tsit5())
304304
Hey there, Pin1!
305305
"""
306306
@connector function Pin1(; name)
307-
@parameters t
307+
@independent_variables t
308308
sts = @variables v(t)=1.0 i(t)=1.0
309309
ODESystem(Equation[], t, sts, []; name = name)
310310
end
@@ -314,7 +314,7 @@ sol = solve(prob, Tsit5())
314314
Hey there, Pin2!
315315
"""
316316
@component function Pin2(; name)
317-
@parameters t
317+
@independent_variables t
318318
sts = @variables v(t)=1.0 i(t)=1.0
319319
ODESystem(Equation[], t, sts, []; name = name)
320320
end

test/constants.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ UMT = ModelingToolkit.UnitfulUnitCheck
66
@constants a = 1
77
@test_throws MT.ArgumentError @constants b
88

9-
@parameters t
9+
@independent_variables t
1010
@variables x(t) w(t)
1111
D = Differential(t)
1212
eqs = [D(x) ~ a]
@@ -29,7 +29,7 @@ simp = structural_simplify(sys)
2929
@constants β=1 [unit = u"m/s"]
3030
UMT.get_unit(β)
3131
@test MT.isconstant(β)
32-
@parameters t [unit = u"s"]
32+
@independent_variables t [unit = u"s"]
3333
@variables x(t) [unit = u"m"]
3434
D = Differential(t)
3535
eqs = [D(x) ~ β]

test/direct.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ for i in 1:3
4141
@test eval(ModelingToolkit.toexpr.(eqs)[i]) == eval(simpexpr[i])
4242
end
4343

44-
@parameters t σ ρ β
44+
@parameters σ ρ β
4545
@variables x y z
4646
= ModelingToolkit.jacobian(eqs, [x, y, z])
4747
for i in 1:3
@@ -59,7 +59,7 @@ reference_jac = sparse(ModelingToolkit.jacobian(du, [x, y, z]))
5959
findnz(reference_jac)[[1, 2]]
6060

6161
let
62-
@parameters t
62+
@independent_variables t
6363
@variables x(t) y(t) z(t)
6464
@test ModelingToolkit.exprs_occur_in([x, y, z], x^2 * y) == [true, true, false]
6565
end
@@ -197,7 +197,7 @@ test_worldage()
197197

198198
let
199199
@register_symbolic foo(x)
200-
@parameters t
200+
@independent_variables t
201201
D = Differential(t)
202202

203203
@test isequal(expand_derivatives(D(foo(t))), D(foo(t)))

test/downstream/linearization_dd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using ControlSystemsMTK
1212
using ControlSystemsMTK.ControlSystemsBase: sminreal, minreal, poles
1313
connect = ModelingToolkit.connect
1414

15-
@parameters t
15+
@independent_variables t
1616
D = Differential(t)
1717

1818
@named link1 = Link(; m = 0.2, l = 10, I = 1, g = -9.807)

0 commit comments

Comments
 (0)