Skip to content

Commit 86411c2

Browse files
authored
Merge branch 'SciML:master' into master
2 parents e0bb5d2 + 6bd3679 commit 86411c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1083
-768
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Yingbo Ma <[email protected]>", "Chris Rackauckas <[email protected]> and contributors"]
4-
version = "10.0.0"
4+
version = "10.0.1"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

docs/src/basics/Composition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ end
3232
3333
connected = compose(
3434
System([decay2.f ~ decay1.x
35-
D(decay1.f) ~ 0], t; name = :connected), decay1, decay2)
35+
D(decay1.f) ~ 0], t; name = :connected), decay1, decay2)
3636
3737
equations(connected)
3838

src/ModelingToolkit.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ export Differential, expand_derivatives, @derivatives
303303
export Equation, ConstrainedEquation
304304
export Term, Sym
305305
export SymScope, LocalScope, ParentScope, GlobalScope
306-
export independent_variable, equations, controls, observed, full_equations, jumps, cost,
306+
export independent_variable, equations, observed, full_equations, jumps, cost,
307307
brownians
308308
export initialization_equations, guesses, defaults, parameter_dependencies, hierarchy
309309
export mtkcompile, expand_connections, linearize, linearization_function,
310-
LinearizationProblem, structural_simplify
310+
LinearizationProblem, linearization_ap_transform, structural_simplify
311311
export solve
312312
export Pre
313313

@@ -316,7 +316,6 @@ export calculate_jacobian, generate_jacobian, generate_rhs, generate_custom_func
316316
export calculate_control_jacobian, generate_control_jacobian
317317
export calculate_tgrad, generate_tgrad
318318
export generate_cost, calculate_cost_gradient, generate_cost_gradient
319-
export calculate_factorized_W
320319
export calculate_cost_hessian, generate_cost_hessian
321320
export calculate_massmatrix, generate_diffusion_function
322321
export stochastic_integral_transform

src/deprecations.jl

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,165 @@ macro mtkbuild(exprs...)
88
@mtkcompile $(exprs...)
99
end |> esc
1010
end
11+
12+
for T in [:ODESystem, :NonlinearSystem, :DiscreteSystem, :ImplicitDiscreteSystem]
13+
@eval @deprecate $T(args...; kwargs...) System(args...; kwargs...)
14+
end
15+
16+
for T in [:ODEProblem, :DDEProblem, :SDEProblem, :SDDEProblem, :DAEProblem,
17+
:BVProblem, :DiscreteProblem, :ImplicitDiscreteProblem]
18+
for (pType, pCanonical) in [
19+
(AbstractDict, :p),
20+
(AbstractArray{<:Pair}, :(Dict(p))),
21+
(AbstractArray, :(isempty(p) ? Dict() : Dict(parameters(sys) .=> p)))
22+
],
23+
(uType, uCanonical) in [
24+
(Nothing, :(Dict())),
25+
(AbstractDict, :u0),
26+
(AbstractArray{<:Pair}, :(Dict(u0))),
27+
(AbstractArray, :(isempty(u0) ? Dict() : Dict(unknowns(sys) .=> u0)))
28+
]
29+
30+
@eval function SciMLBase.$T(sys::System, u0::$uType, tspan, p::$pType; kw...)
31+
ctor = string($T)
32+
uCan = string($(QuoteNode(uCanonical)))
33+
pCan = string($(QuoteNode(pCanonical)))
34+
@warn """
35+
`$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use
36+
`$ctor(sys, merge($uCan, $pCan), tspan)` instead.
37+
"""
38+
SciMLBase.$T(sys, merge($uCanonical, $pCanonical), tspan; kw...)
39+
end
40+
@eval function SciMLBase.$T{iip}(
41+
sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip}
42+
ctor = string($T{iip})
43+
uCan = string($(QuoteNode(uCanonical)))
44+
pCan = string($(QuoteNode(pCanonical)))
45+
@warn """
46+
`$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use
47+
`$ctor(sys, merge($uCan, $pCan), tspan)` instead.
48+
"""
49+
return SciMLBase.$T{iip}(sys, merge($uCanonical, $pCanonical), tspan; kw...)
50+
end
51+
@eval function SciMLBase.$T{iip, spec}(
52+
sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip, spec}
53+
ctor = string($T{iip, spec})
54+
uCan = string($(QuoteNode(uCanonical)))
55+
pCan = string($(QuoteNode(pCanonical)))
56+
@warn """
57+
`$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use
58+
`$ctor(sys, merge($uCan, $pCan), tspan)` instead.
59+
"""
60+
return $T{iip, spec}(sys, merge($uCanonical, $pCanonical), tspan; kw...)
61+
end
62+
end
63+
64+
for pType in [SciMLBase.NullParameters, Nothing], uType in [Any, Nothing]
65+
@eval function SciMLBase.$T(sys::System, u0::$uType, tspan, p::$pType; kw...)
66+
ctor = string($T)
67+
pT = string($(QuoteNode(pType)))
68+
@warn """
69+
`$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use
70+
`$ctor(sys, u0, tspan)` instead.
71+
"""
72+
$T(sys, u0, tspan; kw...)
73+
end
74+
@eval function SciMLBase.$T{iip}(
75+
sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip}
76+
ctor = string($T{iip})
77+
pT = string($(QuoteNode(pType)))
78+
@warn """
79+
`$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use
80+
`$ctor(sys, u0, tspan)` instead.
81+
"""
82+
return $T{iip}(sys, u0, tspan; kw...)
83+
end
84+
@eval function SciMLBase.$T{iip, spec}(
85+
sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip, spec}
86+
ctor = string($T{iip, spec})
87+
pT = string($(QuoteNode(pType)))
88+
@warn """
89+
`$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use
90+
`$ctor(sys, u0, tspan)` instead.
91+
"""
92+
return $T{iip, spec}(sys, u0, tspan; kw...)
93+
end
94+
end
95+
end
96+
97+
for T in [:NonlinearProblem, :NonlinearLeastSquaresProblem,
98+
:SCCNonlinearProblem, :OptimizationProblem, :SteadyStateProblem]
99+
for (pType, pCanonical) in [
100+
(AbstractDict, :p),
101+
(AbstractArray{<:Pair}, :(Dict(p))),
102+
(AbstractArray, :(isempty(p) ? Dict() : Dict(parameters(sys) .=> p)))
103+
],
104+
(uType, uCanonical) in [
105+
(Nothing, :(Dict())),
106+
(AbstractDict, :u0),
107+
(AbstractArray{<:Pair}, :(Dict(u0))),
108+
(AbstractArray, :(isempty(u0) ? Dict() : Dict(unknowns(sys) .=> u0)))
109+
]
110+
111+
@eval function SciMLBase.$T(sys::System, u0::$uType, p::$pType; kw...)
112+
ctor = string($T)
113+
uCan = string($(QuoteNode(uCanonical)))
114+
pCan = string($(QuoteNode(pCanonical)))
115+
@warn """
116+
`$ctor(sys, u0, p; kw...)` is deprecated. Use `$ctor(sys, merge($uCan, $pCan))`
117+
instead.
118+
"""
119+
$T(sys, merge($uCanonical, $pCanonical); kw...)
120+
end
121+
@eval function SciMLBase.$T{iip}(
122+
sys::System, u0::$uType, p::$pType; kw...) where {iip}
123+
ctor = string($T{iip})
124+
uCan = string($(QuoteNode(uCanonical)))
125+
pCan = string($(QuoteNode(pCanonical)))
126+
@warn """
127+
`$ctor(sys, u0, p; kw...)` is deprecated. Use `$ctor(sys, merge($uCan, $pCan))`
128+
instead.
129+
"""
130+
return $T{iip}(sys, merge($uCanonical, $pCanonical); kw...)
131+
end
132+
@eval function SciMLBase.$T{iip, spec}(
133+
sys::System, u0::$uType, p::$pType; kw...) where {iip, spec}
134+
ctor = string($T{iip, spec})
135+
uCan = string($(QuoteNode(uCanonical)))
136+
pCan = string($(QuoteNode(pCanonical)))
137+
@warn """
138+
`$ctor(sys, u0, p; kw...)` is deprecated. Use `$ctor(sys, merge($uCan, $pCan))`
139+
instead.
140+
"""
141+
return $T{iip, spec}(sys, merge($uCanonical, $pCanonical); kw...)
142+
end
143+
end
144+
for pType in [SciMLBase.NullParameters, Nothing], uType in [Any, Nothing]
145+
@eval function SciMLBase.$T(sys::System, u0::$uType, p::$pType; kw...)
146+
ctor = string($T)
147+
pT = string($(QuoteNode(pType)))
148+
@warn """
149+
`$ctor(sys, u0, p::$pT; kw...)` is deprecated. Use `$ctor(sys, u0)` instead
150+
"""
151+
$T(sys, u0; kw...)
152+
end
153+
@eval function SciMLBase.$T{iip}(
154+
sys::System, u0::$uType, p::$pType; kw...) where {iip}
155+
ctor = string($T{iip})
156+
pT = string($(QuoteNode(pType)))
157+
@warn """
158+
`$ctor(sys, u0, p::$pT; kw...)` is deprecated. Use `$ctor(sys, u0)` instead
159+
"""
160+
return $T{iip}(sys, u0; kw...)
161+
end
162+
@eval function SciMLBase.$T{iip, spec}(
163+
sys::System, u0::$uType, p::$pType; kw...) where {iip, spec}
164+
ctor = string($T{iip, spec})
165+
pT = string($(QuoteNode(pType)))
166+
@warn """
167+
`$ctor(sys, u0, p::$pT; kw...)` is deprecated. Use `$ctor(sys, u0)` instead
168+
"""
169+
return $T{iip, spec}(sys, u0; kw...)
170+
end
171+
end
172+
end

src/discretedomain.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function (xn::Num)(k::ShiftIndex)
231231
@unpack clock, steps = k
232232
x = value(xn)
233233
# Verify that the independent variables of k and x match and that the expression doesn't have multiple variables
234-
vars = Symbolics.get_variables(x)
234+
vars = ModelingToolkit.vars(x)
235235
if length(vars) != 1
236236
error("Cannot shift a multivariate expression $x. Either create a new unknown and shift this, or shift the individual variables in the expression.")
237237
end

src/linearization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ function linearize_symbolic(sys::AbstractSystem, inputs,
505505
ps = parameters(sys; initial_parameters = true)
506506
p = reorder_parameters(sys, ps)
507507

508-
fun_expr = generate_function(sys, sts, ps; expression = Val{true})[1]
508+
fun_expr = generate_rhs(sys; expression = Val{true})[1]
509509
fun = eval_or_rgf(fun_expr; eval_expression, eval_module)
510510
dx = fun(sts, p, t)
511511

src/problems/bvproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
check_compatibility && check_compatible_system(BVProblem, sys)
99
isnothing(callback) || error("BVP solvers do not support callbacks.")
1010

11+
dvs = unknowns(sys)
12+
op = to_varmap(op, dvs)
1113
# Systems without algebraic equations should use both fixed values + guesses
1214
# for initialization.
1315
_op = has_alg_eqs(sys) ? op : merge(Dict(op), Dict(guesses))
@@ -17,7 +19,6 @@
1719
t = tspan !== nothing ? tspan[1] : tspan, check_compatibility = false, cse,
1820
checkbounds, time_dependent_init = false, expression, kwargs...)
1921

20-
dvs = unknowns(sys)
2122
stidxmap = Dict([v => i for (i, v) in enumerate(dvs)])
2223
u0_idxs = has_alg_eqs(sys) ? collect(1:length(dvs)) :
2324
[stidxmap[k] for (k, v) in op if haskey(stidxmap, k)]

src/problems/discreteproblem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end
4747
add_toterms!(u0map; replace = true)
4848
f, u0, p = process_SciMLProblem(DiscreteFunction{iip, spec}, sys, op;
4949
t = tspan !== nothing ? tspan[1] : tspan, check_compatibility, expression,
50-
kwargs...)
50+
build_initializeprob = false, kwargs...)
5151

5252
if expression == Val{true}
5353
u0 = :(f($u0, p, tspan[1]))

src/problems/nonlinearproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ end
6767
check_length, check_compatibility, expression, kwargs...)
6868

6969
kwargs = process_kwargs(sys; kwargs...)
70-
args = (; f, u0, p, ptype = StandardNonlinearProblem())
70+
ptype = getmetadata(sys, ProblemTypeCtx, StandardNonlinearProblem())
71+
args = (; f, u0, p, ptype)
7172

7273
return maybe_codegen_scimlproblem(expression, NonlinearProblem{iip}, args; kwargs...)
7374
end

src/problems/odeproblem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ end
7777
kwargs = process_kwargs(
7878
sys; expression, callback, eval_expression, eval_module, kwargs...)
7979

80-
args = (; f, u0, tspan, p, ptype = StandardODEProblem())
80+
ptype = getmetadata(sys, ProblemTypeCtx, StandardODEProblem())
81+
args = (; f, u0, tspan, p, ptype)
8182
maybe_codegen_scimlproblem(expression, ODEProblem{iip}, args; kwargs...)
8283
end
8384

0 commit comments

Comments
 (0)