Skip to content

Commit 0cbf493

Browse files
committed
Merge branch 'master' into myb/dd
2 parents 79ee3a6 + 024e66c commit 0cbf493

Some content is hidden

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

66 files changed

+4316
-1112
lines changed

.github/workflows/Tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28+
version:
29+
- "1"
30+
- "lts"
31+
- "pre"
2832
group:
2933
- InterfaceI
3034
- InterfaceII
@@ -35,5 +39,6 @@ jobs:
3539
- RegressionI
3640
uses: "SciML/.github/.github/workflows/tests.yml@v1"
3741
with:
42+
julia-version: "${{ matrix.version }}"
3843
group: "${{ matrix.group }}"
3944
secrets: "inherit"

Project.toml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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.41.0"
4+
version = "9.48.0"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
88
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
99
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
1010
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
11+
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
1112
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
1213
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
1314
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
@@ -36,6 +37,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3637
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
3738
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
3839
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
40+
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
3941
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
4042
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
4143
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
@@ -60,27 +62,30 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
6062
BifurcationKit = "0f109fa4-8a5d-4b75-95aa-f515264e7665"
6163
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
6264
DeepDiffs = "ab62b9b5-e342-54a8-a765-a90f495de1a6"
65+
HomotopyContinuation = "f213a82b-91d6-5c5d-acf7-10f1c761b327"
6366
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
6467

6568
[extensions]
6669
MTKBifurcationKitExt = "BifurcationKit"
6770
MTKChainRulesCoreExt = "ChainRulesCore"
6871
MTKDeepDiffsExt = "DeepDiffs"
72+
MTKHomotopyContinuationExt = "HomotopyContinuation"
6973
MTKLabelledArraysExt = "LabelledArrays"
7074

7175
[compat]
7276
AbstractTrees = "0.3, 0.4"
7377
ArrayInterface = "6, 7"
74-
BifurcationKit = "0.3"
78+
BifurcationKit = "0.4"
7579
BlockArrays = "1.1"
7680
ChainRulesCore = "1"
7781
Combinatorics = "1"
82+
CommonSolve = "0.2.4"
7883
Compat = "3.42, 4"
7984
ConstructionBase = "1"
8085
DataInterpolations = "6.4"
8186
DataStructures = "0.17, 0.18"
8287
DeepDiffs = "1"
83-
DiffEqBase = "6.103.0"
88+
DiffEqBase = "6.157"
8489
DiffEqCallbacks = "2.16, 3, 4"
8590
DiffEqNoiseProcess = "5"
8691
DiffRules = "0.1, 1.0"
@@ -96,6 +101,7 @@ ForwardDiff = "0.10.3"
96101
FunctionWrappers = "1.1"
97102
FunctionWrappersWrappers = "0.1"
98103
Graphs = "1.5.2"
104+
HomotopyContinuation = "2.11"
99105
InteractiveUtils = "1"
100106
JuliaFormatter = "1.0.47"
101107
JumpProcesses = "9.13.1"
@@ -106,23 +112,26 @@ LinearAlgebra = "1"
106112
MLStyle = "0.4.17"
107113
NaNMath = "0.3, 1"
108114
NonlinearSolve = "3.14"
115+
OffsetArrays = "1"
109116
OrderedCollections = "1"
110117
OrdinaryDiffEq = "6.82.0"
118+
OrdinaryDiffEqCore = "1.7.0"
111119
PrecompileTools = "1"
120+
REPL = "1"
112121
RecursiveArrayTools = "3.26"
113122
Reexport = "0.2, 1"
114123
RuntimeGeneratedFunctions = "0.5.9"
115-
SciMLBase = "2.52.1"
124+
SciMLBase = "2.57.1"
116125
SciMLStructures = "1.0"
117126
Serialization = "1"
118127
Setfield = "0.7, 0.8, 1"
119128
SimpleNonlinearSolve = "0.1.0, 1"
120129
SparseArrays = "1"
121130
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
122131
StaticArrays = "0.10, 0.11, 0.12, 1.0"
123-
SymbolicIndexingInterface = "0.3.29"
132+
SymbolicIndexingInterface = "0.3.31"
124133
SymbolicUtils = "3.7"
125-
Symbolics = "6.12"
134+
Symbolics = "6.15.2"
126135
URIs = "1"
127136
UnPack = "0.1, 1.0"
128137
Unitful = "1.1"
@@ -145,7 +154,9 @@ Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
145154
OptimizationMOI = "fd9f6733-72f4-499f-8506-86b2bdd0dea1"
146155
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
147156
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
157+
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
148158
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
159+
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
149160
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
150161
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
151162
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
@@ -158,4 +169,4 @@ Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
158169
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
159170

160171
[targets]
161-
test = ["AmplNLWriter", "BenchmarkTools", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq", "Pkg", "JET"]
172+
test = ["AmplNLWriter", "BenchmarkTools", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqCore", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq", "Pkg", "JET"]

docs/Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[deps]
22
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
33
BifurcationKit = "0f109fa4-8a5d-4b75-95aa-f515264e7665"
4+
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
45
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
56
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
67
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
@@ -22,7 +23,8 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
2223

2324
[compat]
2425
BenchmarkTools = "1.3"
25-
BifurcationKit = "0.3"
26+
BifurcationKit = "0.4"
27+
DataInterpolations = "6.5"
2628
DifferentialEquations = "7.6"
2729
Distributions = "0.25"
2830
Documenter = "1"

docs/pages.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ pages = [
1212
"tutorials/parameter_identifiability.md",
1313
"tutorials/bifurcation_diagram_computation.md",
1414
"tutorials/SampledData.md",
15-
"tutorials/domain_connections.md"],
15+
"tutorials/domain_connections.md",
16+
"tutorials/callable_params.md"],
1617
"Examples" => Any[
1718
"Basic Examples" => Any["examples/higher_order.md",
1819
"examples/spring_mass.md",
1920
"examples/modelingtoolkitize_index_reduction.md",
20-
"examples/parsing.md",
2121
"examples/remake.md"],
2222
"Advanced Examples" => Any["examples/tearing_parallelism.md",
2323
"examples/sparse_jacobians.md",

docs/src/basics/AbstractSystem.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Optionally, a system could have:
6363
- `get_defaults(sys)`: A `Dict` that maps variables into their default values
6464
for the current-level system.
6565
- `get_noiseeqs(sys)`: Noise equations of the current-level system.
66+
- `get_description(sys)`: A string that describes what a system represents.
6667
- `get_metadata(sys)`: Any metadata about the system or its origin to be used by downstream packages.
6768

6869
Note that if you know a system is an `AbstractTimeDependentSystem` you could use `get_iv` to get the

docs/src/basics/MTKLanguage.md

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,17 @@ end
6363
@structural_parameters begin
6464
f = sin
6565
N = 2
66+
M = 3
6667
end
6768
begin
6869
v_var = 1.0
6970
end
7071
@variables begin
7172
v(t) = v_var
72-
v_array(t)[1:2, 1:3]
73+
v_array(t)[1:N, 1:M]
7374
v_for_defaults(t)
7475
end
75-
@extend ModelB(; p1)
76+
@extend ModelB(p1 = 1)
7677
@components begin
7778
model_a = ModelA(; k_array)
7879
model_array_a = [ModelA(; k = i) for i in 1:N]
@@ -148,14 +149,18 @@ julia> ModelingToolkit.getdefault(model_c1.v)
148149

149150
#### `@extend` begin block
150151

151-
- Partial systems can be extended in a higher system as `@extend PartialSystem(; kwargs)`.
152-
- Keyword arguments pf partial system in the `@extend` definition are added as the keyword arguments of the base system.
153-
- Note that in above example, `p1` is promoted as an argument of `ModelC`. Users can set the value of `p1`. However, as `p2` isn't listed in the model definition, its initial guess can't be specified while creating an instance of `ModelC`.
152+
Partial systems can be extended in a higher system in two ways:
154153

155-
```julia
156-
julia> @mtkbuild model_c2 = ModelC(; p1 = 2.0)
154+
- `@extend PartialSystem(var1 = value1)`
155+
156+
+ This is the recommended way of extending a base system.
157+
+ The default values for the arguments of the base system can be declared in the `@extend` statement.
158+
+ Note that all keyword arguments of the base system are added as the keyword arguments of the main system.
157159

158-
```
160+
- `@extend var_to_unpack1, var_to_unpack2 = partial_sys = PartialSystem(var1 = value1)`
161+
162+
+ In this method: explicitly list the variables that should be unpacked, provide a name for the partial system and declare the base system.
163+
+ Note that only the arguments listed out in the declaration of the base system (here: `var1`) are added as the keyword arguments of the higher system.
159164

160165
#### `@components` begin block
161166

@@ -301,7 +306,7 @@ end
301306

302307
For more examples of usage, checkout [ModelingToolkitStandardLibrary.jl](https://github.com/SciML/ModelingToolkitStandardLibrary.jl/)
303308

304-
## More on `Model.structure`
309+
## [More on `Model.structure`](@id model_structure)
305310

306311
`structure` stores metadata that describes composition of a model. It includes:
307312

@@ -324,17 +329,57 @@ For example, the structure of `ModelC` is:
324329
julia> ModelC.structure
325330
Dict{Symbol, Any} with 10 entries:
326331
:components => Any[Union{Expr, Symbol}[:model_a, :ModelA], Union{Expr, Symbol}[:model_array_a, :ModelA, :(1:N)], Union{Expr, Symbol}[:model_array_b, :ModelA, :(1:N)]]
327-
:variables => Dict{Symbol, Dict{Symbol, Any}}(:v=>Dict(:default=>:v_var, :type=>Real), :v_array=>Dict(:type=>Real, :size=>(2, 3)), :v_for_defaults=>Dict(:type=>Real))
332+
:variables => Dict{Symbol, Dict{Symbol, Any}}(:v=>Dict(:default=>:v_var, :type=>Real), :v_array=>Dict(:value=>nothing, :type=>Real, :size=>(:N, :M)), :v_for_defaults=>Dict(:type=>Real))
328333
:icon => URI("https://github.com/SciML/SciMLDocs/blob/main/docs/src/assets/logo.png")
329-
:kwargs => Dict{Symbol, Dict}(:f=>Dict(:value=>:sin), :N=>Dict(:value=>2), :v=>Dict{Symbol, Any}(:value=>:v_var, :type=>Real), :v_array=>Dict{Symbol, Union{Nothing, UnionAll}}(:value=>nothing, :type=>AbstractArray{Real}), :v_for_defaults=>Dict{Symbol, Union{Nothing, DataType}}(:value=>nothing, :type=>Real), :p1=>Dict(:value=>nothing))
330-
:structural_parameters => Dict{Symbol, Dict}(:f=>Dict(:value=>:sin), :N=>Dict(:value=>2))
331-
:independent_variable => t
334+
:kwargs => Dict{Symbol, Dict}(:f=>Dict(:value=>:sin), :p2=>Dict(:value=>NoValue()), :N=>Dict(:value=>2), :M=>Dict(:value=>3), :v=>Dict{Symbol, Any}(:value=>:v_var, :type=>Real), :v_array=>Dict{Symbol, Any}(:value=>nothing, :type=>Real, :size=>(:N, :M)), :v_for_defaults=>Dict{Symbol, Union{Nothing, DataType}}(:value=>nothing, :type=>Real), :p1=>Dict(:value=>1))
335+
:structural_parameters => Dict{Symbol, Dict}(:f=>Dict(:value=>:sin), :N=>Dict(:value=>2), :M=>Dict(:value=>3))
336+
:independent_variable => :t
332337
:constants => Dict{Symbol, Dict}(:c=>Dict{Symbol, Any}(:value=>1, :type=>Int64, :description=>"Example constant."))
333338
:extend => Any[[:p2, :p1], Symbol("#mtkmodel__anonymous__ModelB"), :ModelB]
334339
:defaults => Dict{Symbol, Any}(:v_for_defaults=>2.0)
335340
:equations => Any["model_a.k ~ f(v)"]
336341
```
337342

343+
### Different ways to define symbolics arrays:
344+
345+
`@mtkmodel` supports symbolics arrays in both `@parameters` and `@variables`.
346+
Using a structural parameters, symbolic arrays of arbitrary lengths can be defined.
347+
Refer the following example for different ways to define symbolic arrays.
348+
349+
```@example mtkmodel-example
350+
@mtkmodel ModelWithArrays begin
351+
@structural_parameters begin
352+
N = 2
353+
M = 3
354+
end
355+
@parameters begin
356+
p1[1:4]
357+
p2[1:N]
358+
p3[1:N, 1:M] = 10,
359+
[description = "A multi-dimensional array of arbitrary length with description"]
360+
(p4[1:N, 1:M] = 10),
361+
[description = "An alternate syntax for p3 to match the syntax of vanilla parameters macro"]
362+
end
363+
@variables begin
364+
v1(t)[1:2] = 10, [description = "An array of variable `v1`"]
365+
v2(t)[1:3] = [1, 2, 3]
366+
end
367+
end
368+
```
369+
370+
The size of symbolic array can be accessed via `:size` key, along with other metadata (refer [More on `Model.structure`](@ref model_structure))
371+
of the symbolic variable.
372+
373+
```julia
374+
julia> ModelWithArrays.structure
375+
Dict{Symbol, Any} with 5 entries:
376+
:variables => Dict{Symbol, Dict{Symbol, Any}}(:v2 => Dict(:value => :([1, 2, 3]), :type => Real, :size => (3,)), :v1 => Dict(:value => :v1, :type => Real, :description => "An array of variable `v1`", :size => (2,)))
377+
:kwargs => Dict{Symbol, Dict}(:p2 => Dict{Symbol, Any}(:value => nothing, :type => Real, :size => (:N,)), :v1 => Dict{Symbol, Any}(:value => :v1, :type => Real, :description => "An array of variable `v1`", :size => (2,)), :N => Dict(:value => 2), :M => Dict(:value => 3), :p4 => Dict{Symbol, Any}(:value => 10, :type => Real, :description => "An alternate syntax for p3 to match the syntax of vanilla parameters macro", :size => (:N, :M)), :v2 => Dict{Symbol, Any}(:value => :([1, 2, 3]), :type => Real, :size => (3,)), :p1 => Dict{Symbol, Any}(:value => nothing, :type => Real, :size => (4,)), :p3 => Dict{Symbol, Any}(:value => :p3, :type => Real, :description => "A multi-dimensional array of arbitrary length with description", :size => (:N, :M)))
378+
:structural_parameters => Dict{Symbol, Dict}(:N => Dict(:value => 2), :M => Dict(:value => 3))
379+
:independent_variable => :t
380+
:parameters => Dict{Symbol, Dict{Symbol, Any}}(:p2 => Dict(:value => nothing, :type => Real, :size => (:N,)), :p4 => Dict(:value => 10, :type => Real, :description => "An alternate syntax for p3 to match the syntax of vanilla parameters macro", :size => (:N, :M)), :p1 => Dict(:value => nothing, :type => Real, :size => (4,)), :p3 => Dict(:value => :p3, :type => Real, :description => "A multi-dimensional array of arbitrary length with description", :size => (:N, :M)))), false)
381+
```
382+
338383
### Using conditional statements
339384

340385
#### Conditional elements of the system

docs/src/examples/parsing.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)