Skip to content

Commit f4b8f07

Browse files
Merge branch 'SciML:master' into dg/scp
2 parents 106d67e + 4e45105 commit f4b8f07

Some content is hidden

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

57 files changed

+1570
-762
lines changed

.github/workflows/Documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
version: 'lts'
2626
- run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
2727
- name: Install dependencies
28-
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ -e 'using Pkg; Pkg.develop([PackageSpec(path=pwd()), PackageSpec(path=joinpath(pwd(), "lib", "ModelingToolkitBase"))]); Pkg.instantiate()'
28+
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ -e 'using Pkg; Pkg.develop([PackageSpec(path=pwd()), PackageSpec(path=joinpath(pwd(), "lib", "ModelingToolkitBase")), PackageSpec(path=joinpath(pwd(), "lib", "SciCompDSL"))]); Pkg.instantiate()'
2929
- name: Build and deploy
3030
env:
3131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
3-
version = "11.7.1"
3+
version = "11.8.0"
44
authors = ["Yingbo Ma <[email protected]>", "Chris Rackauckas <[email protected]> and contributors"]
55

66
[deps]
@@ -81,7 +81,7 @@ Libdl = "1"
8181
LinearAlgebra = "1"
8282
LinearSolve = "3.56"
8383
Logging = "1"
84-
ModelingToolkitBase = "1.5.3"
84+
ModelingToolkitBase = "1.7.0"
8585
ModelingToolkitStandardLibrary = "2.20"
8686
ModelingToolkitTearing = "1.2.1"
8787
Moshi = "0.3.6"

docs/Project.toml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
2626
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
2727
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2828
PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
29+
SciCompDSL = "91a8cdf1-4ca6-467b-a780-87fda3fff15e"
2930
SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226"
3031
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
3132
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
@@ -36,31 +37,34 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
3637
[compat]
3738
Attractors = "1.24"
3839
BenchmarkTools = "1.3"
39-
BifurcationKit = "0.4, 0.5"
40-
CairoMakie = "0.13, 0.15"
40+
BifurcationKit = "0.5"
41+
CairoMakie = "0.15"
4142
CommonSolve = "0.2"
42-
DataInterpolations = "6.5, 8"
43+
ControlSystemsBase = "1.20"
44+
ControlSystemsMTK = "2.6"
45+
DataInterpolations = "8"
4346
DiffEqDevTools = "2"
4447
Distributions = "0.25"
4548
Documenter = "1"
46-
DynamicQuantities = "^0.11.2, 0.12, 1"
49+
DynamicQuantities = "1"
4750
FMI = "0.14"
4851
FMIZoo = "1"
49-
InfiniteOpt = "0.5"
52+
InfiniteOpt = "0.6"
5053
Ipopt = "1"
5154
JumpProcesses = "9"
5255
ModelingToolkit = "11"
53-
ModelingToolkitStandardLibrary = "2.19"
54-
NonlinearSolve = "3, 4"
55-
Optim = "1.7, 2"
56-
Optimization = "4, 5"
56+
ModelingToolkitStandardLibrary = "2.26"
57+
NonlinearSolve = "4"
58+
Optim = "1.9, 2"
59+
Optimization = "5"
5760
OptimizationOptimJL = "0.4"
5861
OrdinaryDiffEq = "6.31"
5962
Plots = "1.36"
6063
PreallocationTools = "0.4, 1"
64+
SciCompDSL = "1"
6165
SciMLStructures = "1.1"
6266
Setfield = "1"
6367
StochasticDiffEq = "6"
6468
SymbolicIndexingInterface = "0.3.1"
65-
SymbolicUtils = "3, 4"
66-
Symbolics = "6"
69+
SymbolicUtils = "4"
70+
Symbolics = "7"

docs/make.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ makedocs(
4141
# this link tends to fail linkcheck stochastically and often takes much longer to succeed
4242
# even in the browser it takes ages
4343
"http://www.scholarpedia.org/article/Differential-algebraic_equations",
44+
"https://link.springer.com/book/10.1007/978-3-030-91032-7",
45+
4446
],
4547
format = Documenter.HTML(;
4648
assets = ["assets/favicon.ico"],

docs/src/API/System.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ nameof
7272
ModelingToolkit.has_description
7373
ModelingToolkit.get_description
7474
ModelingToolkit.description
75-
ModelingToolkit.has_defaults
76-
ModelingToolkit.get_defaults
77-
defaults
75+
bindings
76+
initial_conditions
7877
ModelingToolkit.has_guesses
7978
ModelingToolkit.get_guesses
8079
guesses

docs/src/API/variables.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@ additional types of metadata.
2020

2121
## Variable defaults
2222

23-
Variables can be assigned default values to avoid having to specify defaults to the
24-
[`System`](@ref) constructor.
23+
Variables can be assigned default values during construction. For example:
24+
25+
```julia
26+
@variables x(t) = 1 y(t) = x
27+
```
28+
29+
Here `x` has a default of `1`, and `y` has a default of `x`. While both of these cases are
30+
stored under the same metadata key, ModelingToolkit treats them differently. Constant
31+
(non-symbolic) defaults (such as that of `x`) are translated to initial conditions
32+
([`initial_conditions`](@ref)). Symbolic defaults (such as that of `y`) are translated to
33+
bindings ([`bindings`](@ref)). For more information on the difference between bindings and
34+
initial conditions, please refer to the documentation on [initialization](@ref initialization)
35+
of systems, and specifically the section on [bindings and initial conditions](@ref bindings_and_ics).
2536

2637
```@docs
2738
ModelingToolkit.hasdefault

docs/src/basics/Composition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ sir = compose(
212212
t,
213213
[S, I, R],
214214
[β, γ],
215-
defaults = [seqn.β => β
215+
bindings = [seqn.β => β
216216
ieqn.β => β
217217
ieqn.γ => γ
218218
reqn.γ => γ], name = :sir),

docs/src/basics/Debugging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
1111
1212
@variables u1(t) u2(t) u3(t)
1313
eqs = [D(u1) ~ -√(u1), D(u2) ~ -√(u2), D(u3) ~ -√(u3)]
14-
defaults = [u1 => 1.0, u2 => 2.0, u3 => 3.0]
15-
@named sys = System(eqs, t; defaults)
14+
initial_conditions = [u1 => 1.0, u2 => 2.0, u3 => 3.0]
15+
@named sys = System(eqs, t; initial_conditions)
1616
sys = mtkcompile(sys)
1717
```
1818

@@ -38,7 +38,7 @@ We could have figured that out ourselves, but it is not always so obvious for mo
3838
Suppose we also want to validate that `u1 + u2 >= 2.0`. We can do this via the assertions functionality.
3939

4040
```@example debug
41-
@mtkcompile sys = System(eqs, t; defaults, assertions = [(u1 + u2 >= 2.0) => "Oh no!"])
41+
@mtkcompile sys = System(eqs, t; initial_conditions, assertions = [(u1 + u2 >= 2.0) => "Oh no!"])
4242
```
4343

4444
The assertions must be an iterable of pairs, where the first element is the symbolic condition and

docs/src/basics/Events.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ Suppose we have a population of `N(t)` cells that can grow and die, and at time
289289
`t1` we want to inject `M` more cells into the population. We can model this by
290290

291291
```@example events
292-
@parameters M tinject α(t)
292+
@parameters M tinject
293+
@discretes α(t)
293294
@variables N(t)
294295
Dₜ = Differential(t)
295296
eqs = [Dₜ(N) ~ α - N]
@@ -411,7 +412,7 @@ example:
411412

412413
```@example events
413414
@variables x(t)
414-
@parameters c(t)
415+
@discretes c(t)
415416
416417
ev = ModelingToolkit.SymbolicDiscreteCallback(
417418
1.0 => [c ~ Pre(c) + 1], discrete_parameters = c, iv = t)
@@ -430,21 +431,9 @@ sol([1.0, 2.0], idxs = [c, c * cos(x)])
430431
```
431432

432433
Note that only time-dependent parameters that are explicitly passed as `discrete_parameters`
433-
will be saved. If we repeat the above example with `c` not a `discrete_parameter`:
434-
435-
```@example events
436-
@variables x(t)
437-
@parameters c(t)
438-
439-
@mtkcompile sys = System(
440-
D(x) ~ c * cos(x), t, [x], [c]; discrete_events = [1.0 => [c ~ Pre(c) + 1]])
441-
442-
prob = ODEProblem(sys, [x => 0.0, c => 1.0], (0.0, 2pi))
443-
sol = solve(prob, Tsit5())
444-
sol.ps[c] # sol[c] will error, since `c` is not a timeseries value
445-
```
446-
447-
It can be seen that the timeseries for `c` is not saved.
434+
will be saved. The `discrete_parameters` argument is also required for the callback to compile
435+
successfully - omitting it will result in an error because the equation modifying the discrete
436+
would have no unknowns/observables.
448437

449438
## [(Experimental) Imperative affects](@id imp_affects)
450439

@@ -464,7 +453,9 @@ Bang-bang control of a heater connected to a leaky plant requires hysteresis in
464453

465454
```@example events
466455
@variables temp(t)
467-
params = @parameters furnace_on_threshold=0.5 furnace_off_threshold=0.7 furnace_power=1.0 leakage=0.1 furnace_on(t)::Bool=false
456+
@parameters furnace_on_threshold=0.5 furnace_off_threshold=0.7 furnace_power=1.0 leakage=0.1
457+
@discretes furnace_on(t)::Bool = false
458+
params = [furnace_on_threshold, furnace_off_threshold, furnace_power, leakage, furnace_on]
468459
eqs = [
469460
D(temp) ~ furnace_on * furnace_power - temp^2 * leakage
470461
]

docs/src/basics/Linearization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ eqs = [D(x) ~ v
7878
D(v) ~ -k * x - k3 * x^3 - c * v + 10u.u
7979
y.u ~ x]
8080
81-
@named duffing = System(eqs, t, systems = [y, u], defaults = [u.u => 0])
81+
@named duffing = System(eqs, t, systems = [y, u], initial_conditions = [u.u => 0])
8282
8383
# pass a constant value for `x`, since it is the variable we will change in operating points
8484
linfun, simplified_sys = linearization_function(duffing, [u.u], [y.u]; op = Dict(x => NaN));

0 commit comments

Comments
 (0)