Skip to content

Commit 3dd7778

Browse files
authored
Merge branch 'master' into iv_property
2 parents d505921 + 874985c commit 3dd7778

24 files changed

+186
-51
lines changed

Project.toml

Lines changed: 4 additions & 4 deletions
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 = "9.32.0"
4+
version = "9.33.1"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
@@ -96,7 +96,7 @@ Libdl = "1"
9696
LinearAlgebra = "1"
9797
MLStyle = "0.4.17"
9898
NaNMath = "0.3, 1"
99-
NonlinearSolve = "3.12"
99+
NonlinearSolve = "3.14"
100100
OrderedCollections = "1"
101101
OrdinaryDiffEq = "6.82.0"
102102
PrecompileTools = "1"
@@ -112,8 +112,8 @@ SparseArrays = "1"
112112
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
113113
StaticArrays = "0.10, 0.11, 0.12, 1.0"
114114
SymbolicIndexingInterface = "0.3.28"
115-
SymbolicUtils = "2.1"
116-
Symbolics = "5.32"
115+
SymbolicUtils = "3.2"
116+
Symbolics = "6"
117117
URIs = "1"
118118
UnPack = "0.1, 1.0"
119119
Unitful = "1.1"

docs/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ Plots = "1.36"
3737
SciMLStructures = "1.1"
3838
StochasticDiffEq = "6"
3939
SymbolicIndexingInterface = "0.3.1"
40-
SymbolicUtils = "2, 3"
41-
Symbolics = "5"
40+
SymbolicUtils = "3"
41+
Symbolics = "6"
4242
Unitful = "1.12"

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Documenter, ModelingToolkit
2+
using ModelingToolkit: SciMLBase
23

34
# Make sure that plots don't throw a bunch of warnings / errors!
45
ENV["GKSwstype"] = "100"

docs/src/internals.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ The procedure for variable elimination inside [`structural_simplify`](@ref) is
2727

2828
## Preparing a system for simulation
2929

30-
Before a simulation or optimization can be performed, the symbolic equations stored in an [`AbstractSystem`](@ref) must be converted into executable code. This step typically occurs after the simplification explained above, and is performed when an instance of a [`SciMLBase.SciMLProblem`](@ref), such as a [`ODEProblem`](@ref), is constructed.
30+
Before a simulation or optimization can be performed, the symbolic equations stored in an [`AbstractSystem`](@ref) must be converted into executable code. This step typically occurs after the simplification explained above, and is performed when an instance of a [`SciMLBase.AbstractSciMLProblem`](@ref), such as a [`ODEProblem`](@ref), is constructed.
3131
The call chain typically looks like this, with the function names in the case of an `ODESystem` indicated in parentheses
3232

3333
1. Problem constructor ([`ODEProblem`](@ref))
3434
2. Build an `DEFunction` ([`process_DEProblem`](@ref) -> [`ODEFunction`](@ref)
3535
3. Write actual executable code ([`generate_function`](@ref) or [`generate_custom_function`](@ref))
3636

3737
Apart from [`generate_function`](@ref), which generates the dynamics function, `ODEFunction` also builds functions for observed equations (`build_explicit_observed_function`) and Jacobians (`generate_jacobian`) etc. These are all stored in the `ODEFunction`.
38+
39+
## Creating an `MTKParameters` object
40+
41+
It may be useful to create a parameter object without creating the problem. For this
42+
purpose, the `MTKParameters` constructor is exposed as public API.
43+
44+
```@docs
45+
MTKParameters
46+
```

ext/MTKBifurcationKitExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ function BifurcationKit.BifurcationProblem(osys::ODESystem, args...; kwargs...)
144144
if !ModelingToolkit.iscomplete(osys)
145145
error("A completed `ODESystem` is required. Call `complete` or `structural_simplify` on the system before creating a `BifurcationProblem`")
146146
end
147-
nsys = NonlinearSystem([0 ~ eq.rhs for eq in equations(osys)],
147+
nsys = NonlinearSystem([0 ~ eq.rhs for eq in full_equations(osys)],
148148
unknowns(osys),
149149
parameters(osys);
150+
observed = observed(osys),
150151
name = nameof(osys))
151152
return BifurcationKit.BifurcationProblem(complete(nsys), args...; kwargs...)
152153
end

src/ModelingToolkit.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,6 @@ export debug_system
275275
export Sample, Hold, Shift, ShiftIndex, sampletime, SampleTime
276276
export Clock, SolverStepClock, TimeDomain
277277

278+
export MTKParameters
279+
278280
end # module

src/debugging.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ function debug_sub(ex)
3232
f = operation(ex)
3333
args = map(debug_sub, arguments(ex))
3434
f in LOGGED_FUN ? logged_fun(f, args...) :
35-
maketerm(typeof(ex), f, args, symtype(t), metadata(ex))
35+
maketerm(typeof(ex), f, args, metadata(ex))
3636
end

src/structural_transformation/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,6 @@ function simplify_shifts(var)
449449
return simplify_shifts(ModelingToolkit.Shift(t1 === nothing ? t2 : t1, s1 + s2)(vv2))
450450
else
451451
return maketerm(typeof(var), operation(var), simplify_shifts.(arguments(var)),
452-
Symbolics.symtype(var), unwrap(var).metadata)
452+
unwrap(var).metadata)
453453
end
454454
end

src/systems/abstractsystem.jl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ function _apply_to_variables(f::F, ex) where {F}
10981098
iscall(ex) || return ex
10991099
maketerm(typeof(ex), _apply_to_variables(f, operation(ex)),
11001100
map(Base.Fix1(_apply_to_variables, f), arguments(ex)),
1101-
symtype(ex), metadata(ex))
1101+
metadata(ex))
11021102
end
11031103

11041104
abstract type SymScope end
@@ -1110,7 +1110,7 @@ function LocalScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}})
11101110
args = arguments(sym)
11111111
a1 = setmetadata(args[1], SymScope, LocalScope())
11121112
maketerm(typeof(sym), operation(sym), [a1, args[2:end]...],
1113-
symtype(sym), metadata(sym))
1113+
metadata(sym))
11141114
else
11151115
setmetadata(sym, SymScope, LocalScope())
11161116
end
@@ -1127,7 +1127,7 @@ function ParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}})
11271127
a1 = setmetadata(args[1], SymScope,
11281128
ParentScope(getmetadata(value(args[1]), SymScope, LocalScope())))
11291129
maketerm(typeof(sym), operation(sym), [a1, args[2:end]...],
1130-
symtype(sym), metadata(sym))
1130+
metadata(sym))
11311131
else
11321132
setmetadata(sym, SymScope,
11331133
ParentScope(getmetadata(value(sym), SymScope, LocalScope())))
@@ -1146,7 +1146,7 @@ function DelayParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}}, N)
11461146
a1 = setmetadata(args[1], SymScope,
11471147
DelayParentScope(getmetadata(value(args[1]), SymScope, LocalScope()), N))
11481148
maketerm(typeof(sym), operation(sym), [a1, args[2:end]...],
1149-
symtype(sym), metadata(sym))
1149+
metadata(sym))
11501150
else
11511151
setmetadata(sym, SymScope,
11521152
DelayParentScope(getmetadata(value(sym), SymScope, LocalScope()), N))
@@ -1162,7 +1162,7 @@ function GlobalScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}})
11621162
args = arguments(sym)
11631163
a1 = setmetadata(args[1], SymScope, GlobalScope())
11641164
maketerm(typeof(sym), operation(sym), [a1, args[2:end]...],
1165-
symtype(sym), metadata(sym))
1165+
metadata(sym))
11661166
else
11671167
setmetadata(sym, SymScope, GlobalScope())
11681168
end
@@ -1180,13 +1180,13 @@ function renamespace(sys, x)
11801180
if iscall(x) && operation(x) isa Operator
11811181
return maketerm(typeof(x), operation(x),
11821182
Any[renamespace(sys, only(arguments(x)))],
1183-
symtype(x), metadata(x))::T
1183+
metadata(x))::T
11841184
end
11851185
if iscall(x) && operation(x) === getindex
11861186
args = arguments(x)
11871187
return maketerm(
11881188
typeof(x), operation(x), vcat(renamespace(sys, args[1]), args[2:end]),
1189-
symtype(x), metadata(x))::T
1189+
metadata(x))::T
11901190
end
11911191
let scope = getmetadata(x, SymScope, LocalScope())
11921192
if scope isa LocalScope
@@ -1271,13 +1271,12 @@ function namespace_expr(
12711271
# metadata from the rescoped variable
12721272
rescoped = renamespace(n, O)
12731273
maketerm(typeof(rescoped), operation(rescoped), renamed,
1274-
symtype(rescoped),
12751274
metadata(rescoped))
12761275
elseif Symbolics.isarraysymbolic(O)
12771276
# promote_symtype doesn't work for array symbolics
1278-
maketerm(typeof(O), operation(O), renamed, symtype(O), metadata(O))
1277+
maketerm(typeof(O), operation(O), renamed, metadata(O))
12791278
else
1280-
maketerm(typeof(O), operation(O), renamed, symtype(O), metadata(O))
1279+
maketerm(typeof(O), operation(O), renamed, metadata(O))
12811280
end
12821281
elseif isvariable(O)
12831282
renamespace(n, O)
@@ -2275,14 +2274,13 @@ function linearization_function(sys::AbstractSystem, inputs,
22752274
end
22762275
x0 = merge(defaults_and_guesses(sys), op)
22772276
if has_index_cache(sys) && get_index_cache(sys) !== nothing
2278-
sys_ps = MTKParameters(sys, p, x0; eval_expression, eval_module)
2277+
sys_ps = MTKParameters(sys, p, x0)
22792278
else
22802279
sys_ps = varmap_to_vars(p, parameters(sys); defaults = x0)
22812280
end
22822281
p[get_iv(sys)] = NaN
22832282
if has_index_cache(initsys) && get_index_cache(initsys) !== nothing
2284-
oldps = MTKParameters(initsys, p, merge(guesses(sys), defaults(sys), op);
2285-
eval_expression, eval_module)
2283+
oldps = MTKParameters(initsys, p, merge(guesses(sys), defaults(sys), op))
22862284
initsys_ps = parameters(initsys)
22872285
p_getter = build_explicit_observed_function(
22882286
sys, initsys_ps; eval_expression, eval_module)

src/systems/clock_inference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function substitute_sample_time(ex, dt)
6363
end
6464
new_args[i] = ex_arg
6565
end
66-
maketerm(typeof(ex), op, new_args, symtype(ex), metadata(ex))
66+
maketerm(typeof(ex), op, new_args, metadata(ex))
6767
end
6868
end
6969

0 commit comments

Comments
 (0)