Skip to content

Commit 5fcf864

Browse files
committed
Merge branch 'master' into careful-event-affects
2 parents 3c6b37e + 1f669d9 commit 5fcf864

Some content is hidden

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

48 files changed

+1863
-338
lines changed

.github/workflows/Documentation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
JULIA_DEBUG: "Documenter"
3232
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ --code-coverage=user docs/make.jl
3333
- uses: julia-actions/julia-processcoverage@v1
34-
- uses: codecov/codecov-action@v4
34+
- uses: codecov/codecov-action@v5
3535
with:
36-
file: lcov.info
36+
files: lcov.info
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838
fail_ci_if_error: true

.github/workflows/Downstream.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ jobs:
6868
exit(0) # Exit immediately, as a success
6969
end
7070
- uses: julia-actions/julia-processcoverage@v1
71-
- uses: codecov/codecov-action@v4
71+
- uses: codecov/codecov-action@v5
7272
with:
73-
file: lcov.info
73+
files: lcov.info
7474
token: ${{ secrets.CODECOV_TOKEN }}
75-
fail_ci_if_error: true
75+
fail_ci_if_error: false

.github/workflows/Tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
group:
3333
- InterfaceI
3434
- InterfaceII
35+
- Initialization
3536
- SymbolicIndexingInterface
3637
- Extended
3738
- Extensions

Project.toml

Lines changed: 7 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.50.0"
4+
version = "9.54.0"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
@@ -64,6 +64,7 @@ BifurcationKit = "0f109fa4-8a5d-4b75-95aa-f515264e7665"
6464
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
6565
DeepDiffs = "ab62b9b5-e342-54a8-a765-a90f495de1a6"
6666
HomotopyContinuation = "f213a82b-91d6-5c5d-acf7-10f1c761b327"
67+
InfiniteOpt = "20393b10-9daf-11e9-18c9-8db751c92c57"
6768
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
6869

6970
[extensions]
@@ -72,6 +73,7 @@ MTKChainRulesCoreExt = "ChainRulesCore"
7273
MTKDeepDiffsExt = "DeepDiffs"
7374
MTKHomotopyContinuationExt = "HomotopyContinuation"
7475
MTKLabelledArraysExt = "LabelledArrays"
76+
MTKInfiniteOptExt = "InfiniteOpt"
7577

7678
[compat]
7779
AbstractTrees = "0.3, 0.4"
@@ -104,6 +106,7 @@ FunctionWrappers = "1.1"
104106
FunctionWrappersWrappers = "0.1"
105107
Graphs = "1.5.2"
106108
HomotopyContinuation = "2.11"
109+
InfiniteOpt = "0.5"
107110
InteractiveUtils = "1"
108111
JuliaFormatter = "1.0.47"
109112
JumpProcesses = "9.13.1"
@@ -123,17 +126,17 @@ REPL = "1"
123126
RecursiveArrayTools = "3.26"
124127
Reexport = "0.2, 1"
125128
RuntimeGeneratedFunctions = "0.5.9"
126-
SciMLBase = "2.57.1"
129+
SciMLBase = "2.64"
127130
SciMLStructures = "1.0"
128131
Serialization = "1"
129132
Setfield = "0.7, 0.8, 1"
130133
SimpleNonlinearSolve = "0.1.0, 1, 2"
131134
SparseArrays = "1"
132135
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
133136
StaticArrays = "0.10, 0.11, 0.12, 1.0"
134-
SymbolicIndexingInterface = "0.3.31"
137+
SymbolicIndexingInterface = "0.3.35"
135138
SymbolicUtils = "3.7"
136-
Symbolics = "6.15.4"
139+
Symbolics = "6.19"
137140
URIs = "1"
138141
UnPack = "0.1, 1.0"
139142
Unitful = "1.1"

docs/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ DynamicQuantities = "^0.11.2, 0.12, 1"
3333
ModelingToolkit = "8.33, 9"
3434
NonlinearSolve = "3, 4"
3535
Optim = "1.7"
36-
Optimization = "3.9"
37-
OptimizationOptimJL = "0.1"
36+
Optimization = "3.9, 4"
37+
OptimizationOptimJL = "0.1, 0.4"
3838
OrdinaryDiffEq = "6.31"
3939
Plots = "1.36"
4040
SciMLStructures = "1.1"

docs/src/basics/FAQ.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ parameter_index(sys, sym)
8282
Note that while the variable index will be an integer, the parameter index is a struct of
8383
type `ParameterIndex` whose internals should not be relied upon.
8484

85+
## Can I index with strings?
86+
87+
Strings are not considered symbolic variables, and thus cannot directly be used for symbolic
88+
indexing. However, ModelingToolkit does provide a method to parse the string representation of
89+
a variable, given the system in which that variable exists.
90+
91+
```@docs
92+
ModelingToolkit.parse_variable
93+
```
94+
8595
## Transforming value maps to arrays
8696

8797
ModelingToolkit.jl allows (and recommends) input maps like `[x => 2.0, y => 3.0]`

docs/src/basics/Variable_metadata.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,44 @@ hasbounds(u)
8686
getbounds(u)
8787
```
8888

89+
Bounds can also be specified for array variables. A scalar array bound is applied to each
90+
element of the array. A bound may also be specified as an array, in which case the size of
91+
the array must match the size of the symbolic variable.
92+
93+
```@example metadata
94+
@variables x[1:2, 1:2] [bounds = (-1, 1)]
95+
hasbounds(x)
96+
```
97+
98+
```@example metadata
99+
getbounds(x)
100+
```
101+
102+
```@example metadata
103+
getbounds(x[1, 1])
104+
```
105+
106+
```@example metadata
107+
getbounds(x[1:2, 1])
108+
```
109+
110+
```@example metadata
111+
@variables x[1:2] [bounds = (-Inf, [1.0, Inf])]
112+
hasbounds(x)
113+
```
114+
115+
```@example metadata
116+
getbounds(x)
117+
```
118+
119+
```@example metadata
120+
getbounds(x[2])
121+
```
122+
123+
```@example metadata
124+
hasbounds(x[2])
125+
```
126+
89127
## Guess
90128

91129
Specify an initial guess for custom initial conditions of an `ODESystem`.

docs/src/examples/higher_order.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
ModelingToolkit has a system for transformations of mathematical
44
systems. These transformations allow for symbolically changing
55
the representation of the model to problems that are easier to
6-
numerically solve. One simple to demonstrate transformation is the
6+
numerically solve. One simple to demonstrate transformation, is
77
`structural_simplify`, which does a lot of tricks, one being the
88
transformation that turns an Nth order ODE into N
99
coupled 1st order ODEs.
@@ -15,16 +15,28 @@ We utilize the derivative operator twice here to define the second order:
1515
using ModelingToolkit, OrdinaryDiffEq
1616
using ModelingToolkit: t_nounits as t, D_nounits as D
1717
18-
@parameters σ ρ β
19-
@variables x(t) y(t) z(t)
20-
21-
eqs = [D(D(x)) ~ σ * (y - x),
22-
D(y) ~ x * (ρ - z) - y,
23-
D(z) ~ x * y - β * z]
24-
25-
@named sys = ODESystem(eqs, t)
18+
@mtkmodel SECOND_ORDER begin
19+
@parameters begin
20+
σ = 28.0
21+
ρ = 10.0
22+
β = 8 / 3
23+
end
24+
@variables begin
25+
x(t) = 1.0
26+
y(t) = 0.0
27+
z(t) = 0.0
28+
end
29+
@equations begin
30+
D(D(x)) ~ σ * (y - x)
31+
D(y) ~ x * (ρ - z) - y
32+
D(z) ~ x * y - β * z
33+
end
34+
end
35+
@mtkbuild sys = SECOND_ORDER()
2636
```
2737

38+
The second order ODE has been automatically transformed to two first order ODEs.
39+
2840
Note that we could've used an alternative syntax for 2nd order, i.e.
2941
`D = Differential(t)^2` and then `D(x)` would be the second derivative,
3042
and this syntax extends to `N`-th order. Also, we can use `*` or `` to compose
@@ -33,28 +45,17 @@ and this syntax extends to `N`-th order. Also, we can use `*` or `∘` to compos
3345
Now let's transform this into the `ODESystem` of first order components.
3446
We do this by calling `structural_simplify`:
3547

36-
```@example orderlowering
37-
sys = structural_simplify(sys)
38-
```
39-
4048
Now we can directly numerically solve the lowered system. Note that,
4149
following the original problem, the solution requires knowing the
42-
initial condition for `x'`, and thus we include that in our input
43-
specification:
50+
initial condition for both `x` and `D(x)`.
51+
The former already got assigned a default value in the `@mtkmodel`,
52+
but we still have to provide a value for the latter.
4453

4554
```@example orderlowering
46-
u0 = [D(x) => 2.0,
47-
x => 1.0,
48-
y => 0.0,
49-
z => 0.0]
50-
51-
p = [σ => 28.0,
52-
ρ => 10.0,
53-
β => 8 / 3]
54-
55+
u0 = [D(sys.x) => 2.0]
5556
tspan = (0.0, 100.0)
56-
prob = ODEProblem(sys, u0, tspan, p, jac = true)
57+
prob = ODEProblem(sys, u0, tspan, [], jac = true)
5758
sol = solve(prob, Tsit5())
58-
using Plots;
59-
plot(sol, idxs = (x, y));
59+
using Plots
60+
plot(sol, idxs = (sys.x, sys.y))
6061
```

docs/src/examples/perturbation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ eqs_pert = taylor_coeff(eq_pert, ϵ, 0:2)
3939
!!! note
4040

4141
The 0-th order equation can be solved analytically, but ModelingToolkit does currently not feature automatic analytical solution of ODEs, so we proceed with solving it numerically.
42-
These are the ODEs we want to solve. Now construct an `ODESystem`, which automatically inserts dummy derivatives for the velocities:
42+
43+
These are the ODEs we want to solve. Now construct an `ODESystem`, which automatically inserts dummy derivatives for the velocities:
4344

4445
```@example perturbation
4546
@mtkbuild sys = ODESystem(eqs_pert, t)

docs/src/tutorials/initialization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ the `initialization_eqs` keyword argument, for example:
113113

114114
```@example init
115115
prob = ODEProblem(pend, [x => 1], (0.0, 1.5), [g => 1], guesses = [λ => 0, y => 1],
116-
initialization_eqs = [y ~ 1])
116+
initialization_eqs = [y ~ 0])
117117
sol = solve(prob, Rodas5P())
118118
plot(sol, idxs = (x, y))
119119
```

0 commit comments

Comments
 (0)