Skip to content

Commit 5e14400

Browse files
authored
Merge branch 'master' into myb/strong_alias
2 parents 5aeb26c + 8ae69d2 commit 5e14400

29 files changed

+482
-196
lines changed

.github/workflows/Documentation.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ jobs:
2121
env:
2222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
2323
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
24-
run: julia --project=docs/ docs/make.jl
24+
run: julia --project=docs/ --code-coverage=user docs/make.jl
25+
- uses: julia-actions/julia-processcoverage@v1
26+
- uses: codecov/codecov-action@v1
27+
with:
28+
file: lcov.info

.github/workflows/FormatCheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Format check
3333
run: |
3434
julia -e '
35-
out = Cmd(`git diff --name-only`) |> read |> String
35+
out = Cmd(`git diff`) |> read |> String
3636
if out == ""
3737
exit(0)
3838
else

.github/workflows/Invalidations.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Invalidations
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
# Skip intermediate builds: always.
8+
# Cancel intermediate builds: always.
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
evaluate:
14+
# Only run on PRs to the default branch.
15+
# In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch
16+
if: github.base_ref == github.event.repository.default_branch
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: julia-actions/setup-julia@v1
20+
with:
21+
version: '1'
22+
- uses: actions/checkout@v3
23+
- uses: julia-actions/julia-buildpkg@v1
24+
- uses: julia-actions/julia-invalidations@v1
25+
id: invs_pr
26+
27+
- uses: actions/checkout@v3
28+
with:
29+
ref: ${{ github.event.repository.default_branch }}
30+
- uses: julia-actions/julia-buildpkg@v1
31+
- uses: julia-actions/julia-invalidations@v1
32+
id: invs_default
33+
34+
- name: Report invalidation counts
35+
run: |
36+
echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
37+
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY
38+
- name: Check if the PR does increase number of invalidations
39+
if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total
40+
run: exit 1

Project.toml

Lines changed: 3 additions & 3 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 = "8.20.0"
4+
version = "8.21.0"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
@@ -50,7 +50,7 @@ ArrayInterfaceCore = "0.1.1"
5050
Combinatorics = "1"
5151
ConstructionBase = "1"
5252
DataStructures = "0.17, 0.18"
53-
DiffEqBase = "6.83.0"
53+
DiffEqBase = "6.103.0"
5454
DiffEqCallbacks = "2.16"
5555
DiffRules = "0.1, 1.0"
5656
Distributions = "0.23, 0.24, 0.25"
@@ -70,7 +70,7 @@ NonlinearSolve = "0.3.8"
7070
RecursiveArrayTools = "2.3"
7171
Reexport = "0.2, 1"
7272
RuntimeGeneratedFunctions = "0.4.3, 0.5"
73-
SciMLBase = "1.49"
73+
SciMLBase = "1.54"
7474
Setfield = "0.7, 0.8, 1"
7575
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
7676
StaticArrays = "0.10, 0.11, 0.12, 1.0"

README.md

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# ModelingToolkit.jl
22

3-
[![Github Action CI](https://github.com/SciML/ModelingToolkit.jl/workflows/CI/badge.svg)](https://github.com/SciML/ModelingToolkit.jl/actions)
4-
[![Coverage Status](https://coveralls.io/repos/github/SciML/ModelingToolkit.jl/badge.svg?branch=master)](https://coveralls.io/github/SciML/ModelingToolkit.jl?branch=master)
3+
4+
[![Join the chat at https://julialang.zulipchat.com #sciml-bridged](https://img.shields.io/static/v1?label=Zulip&message=chat&color=9558b2&labelColor=389826)](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
55
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](http://mtk.sciml.ai/stable/)
6-
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](http://mtk.sciml.ai/dev/)
6+
[![Global Docs](https://img.shields.io/badge/docs-SciML-blue.svg)](https://docs.sciml.ai/dev/modules/ModelingToolkit/)
7+
8+
[![codecov](https://codecov.io/gh/SciML/ModelingToolkit.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/SciML/ModelingToolkit.jl)
9+
[![Coverage Status](https://coveralls.io/repos/github/SciML/ModelingToolkit.jl/badge.svg?branch=master)](https://coveralls.io/github/SciML/ModelingToolkit.jl?branch=master)
10+
[![Build Status](https://github.com/SciML/ModelingToolkit.jl/workflows/CI/badge.svg)](https://github.com/SciML/ModelingToolkit.jl/actions?query=workflow%3ACI)
11+
712
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
13+
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
814

915
ModelingToolkit.jl is a modeling framework for high-performance symbolic-numeric computation
1016
in scientific computing and scientific machine learning.
@@ -32,32 +38,33 @@ lower it to a first order system, symbolically generate the Jacobian function
3238
for the numerical integrator, and solve it.
3339

3440
```julia
35-
using ModelingToolkit, OrdinaryDiffEq
41+
using DifferentialEquations, ModelingToolkit
3642

3743
@parameters t σ ρ β
3844
@variables x(t) y(t) z(t)
3945
D = Differential(t)
4046

41-
eqs = [D(D(x)) ~ σ*(y-x),
42-
D(y) ~ x*-z)-y,
43-
D(z) ~ x*y - β*z]
47+
eqs = [D(D(x)) ~ σ * (y - x),
48+
D(y) ~ x *- z) - y,
49+
D(z) ~ x * y - β * z]
4450

4551
@named sys = ODESystem(eqs)
46-
sys = ode_order_lowering(sys)
52+
sys = structural_simplify(sys)
4753

4854
u0 = [D(x) => 2.0,
49-
x => 1.0,
50-
y => 0.0,
51-
z => 0.0]
52-
53-
p ==> 28.0,
54-
ρ => 10.0,
55-
β => 8/3]
56-
57-
tspan = (0.0,100.0)
58-
prob = ODEProblem(sys,u0,tspan,p,jac=true)
59-
sol = solve(prob,Tsit5())
60-
using Plots; plot(sol,vars=(x,y))
55+
x => 1.0,
56+
y => 0.0,
57+
z => 0.0]
58+
59+
p ==> 28.0,
60+
ρ => 10.0,
61+
β => 8 / 3]
62+
63+
tspan = (0.0, 100.0)
64+
prob = ODEProblem(sys, u0, tspan, p, jac = true)
65+
sol = solve(prob)
66+
using Plots
67+
plot(sol, idxs = (x, y))
6168
```
6269

6370
![Lorenz2](https://user-images.githubusercontent.com/1814174/79118645-744eb580-7d5c-11ea-9c37-13c4efd585ca.png)
@@ -69,48 +76,50 @@ interacting Lorenz equations and simulate the resulting Differential-Algebraic
6976
Equation (DAE):
7077

7178
```julia
72-
using ModelingToolkit, OrdinaryDiffEq
79+
using DifferentialEquations, ModelingToolkit
7380

7481
@parameters t σ ρ β
7582
@variables x(t) y(t) z(t)
7683
D = Differential(t)
7784

78-
eqs = [D(x) ~ σ*(y-x),
79-
D(y) ~ x*-z)-y,
80-
D(z) ~ x*y - β*z]
85+
eqs = [D(x) ~ σ * (y - x),
86+
D(y) ~ x *- z) - y,
87+
D(z) ~ x * y - β * z]
8188

8289
@named lorenz1 = ODESystem(eqs)
8390
@named lorenz2 = ODESystem(eqs)
8491

8592
@variables a(t)
8693
@parameters γ
87-
connections = [0 ~ lorenz1.x + lorenz2.y + a*γ]
88-
@named connected = ODESystem(connections,t,[a],[γ],systems=[lorenz1,lorenz2])
94+
connections = [0 ~ lorenz1.x + lorenz2.y + a * γ]
95+
@named connected = ODESystem(connections, t, [a], [γ], systems = [lorenz1, lorenz2])
96+
sys = structural_simplify(connected)
8997

9098
u0 = [lorenz1.x => 1.0,
91-
lorenz1.y => 0.0,
92-
lorenz1.z => 0.0,
93-
lorenz2.x => 0.0,
94-
lorenz2.y => 1.0,
95-
lorenz2.z => 0.0,
96-
a => 2.0]
97-
98-
p = [lorenz1.σ => 10.0,
99-
lorenz1.ρ => 28.0,
100-
lorenz1.β => 8/3,
101-
lorenz2.σ => 10.0,
102-
lorenz2.ρ => 28.0,
103-
lorenz2.β => 8/3,
104-
γ => 2.0]
105-
106-
tspan = (0.0,100.0)
107-
prob = ODEProblem(connected,u0,tspan,p)
108-
sol = solve(prob,Rodas4())
109-
110-
using Plots; plot(sol,vars=(a,lorenz1.x,lorenz2.z))
99+
lorenz1.y => 0.0,
100+
lorenz1.z => 0.0,
101+
lorenz2.x => 0.0,
102+
lorenz2.y => 1.0,
103+
lorenz2.z => 0.0,
104+
a => 2.0]
105+
106+
p = [lorenz1.σ => 10.0,
107+
lorenz1.ρ => 28.0,
108+
lorenz1.β => 8 / 3,
109+
lorenz2.σ => 10.0,
110+
lorenz2.ρ => 28.0,
111+
lorenz2.β => 8 / 3,
112+
γ => 2.0]
113+
114+
tspan = (0.0, 100.0)
115+
prob = ODEProblem(sys, u0, tspan, p)
116+
sol = solve(prob)
117+
118+
using Plots
119+
plot(sol, idxs = (a, lorenz1.x, lorenz2.z))
111120
```
112121

113-
![](https://user-images.githubusercontent.com/1814174/110242538-87461780-7f24-11eb-983c-4b2c93cfc909.png)
122+
![](https://user-images.githubusercontent.com/17304743/187790221-528046c3-dbdb-4853-b977-799596c147f3.png)
114123

115124
# Citation
116125
If you use ModelingToolkit.jl in your research, please cite [this paper](https://arxiv.org/abs/2103.05244):

docs/make.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ using Documenter, ModelingToolkit
22

33
include("pages.jl")
44

5+
mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
6+
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
7+
"packages" => [
8+
"base",
9+
"ams",
10+
"autoload",
11+
"mathtools",
12+
"require",
13+
])))
14+
515
makedocs(sitename = "ModelingToolkit.jl",
616
authors = "Chris Rackauckas",
717
modules = [ModelingToolkit],
@@ -16,6 +26,7 @@ makedocs(sitename = "ModelingToolkit.jl",
1626
],
1727
format = Documenter.HTML(; analytics = "UA-90474609-3",
1828
assets = ["assets/favicon.ico"],
29+
mathengine,
1930
canonical = "https://mtk.sciml.ai/stable/",
2031
prettyurls = (get(ENV, "CI", nothing) == "true")),
2132
pages = pages)

docs/src/basics/AbstractSystem.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Optionally, a system could have:
6060
- `get_defaults(sys)`: A `Dict` that maps variables into their default values.
6161
- `independent_variables(sys)`: The independent variables of a system.
6262
- `get_noiseeqs(sys)`: Noise equations of the current-level system.
63+
- `get_metadata(sys)`: Any metadata about the system or its origin to be used by downstream packages.
6364

6465
Note that if you know a system is an `AbstractTimeDependentSystem` you could use `get_iv` to get the
6566
unique independent variable directly, rather than using `independent_variables(sys)[1]`, which is clunky and may cause problems if `sys` is an `AbstractMultivariateSystem` because there may be more than one independent variable. `AbstractTimeIndependentSystem`s do not have a method `get_iv`, and `independent_variables(sys)` will return a size-zero result for such. For an `AbstractMultivariateSystem`, `get_ivs` is equivalent.

docs/src/basics/Validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ w(t), [unit = "Hz"]
2020
end)
2121

2222
# Simultaneously set default value (use plain numbers, not quantities)
23-
@variable x=10 [unit = u"m"]
23+
@variables x=10 [unit = u"m"]
2424

2525
# Symbolic array: unit applies to all elements
26-
@variable x[1:3] [unit = u"m"]
26+
@variables x[1:3] [unit = u"m"]
2727
```
2828

2929
Do not use `quantities` such as `1u"s"`, `1/u"s"` or `u"1/s"` as these will result in errors; instead use `u"s"`, `u"s^-1"`, or `u"s"^-1`.

docs/src/mtkitize_tutorials/sparse_jacobians.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ prob = ODEProblem(brusselator_2d_loop,u0,(0.,11.5),p)
5050
Now let's use `modelingtoolkitize` to generate the symbolic version:
5151

5252
```@example sparsejac
53-
sys = modelingtoolkitize(prob)
53+
sys = modelingtoolkitize(prob);
54+
nothing # hide
5455
```
5556

5657
Now we regenerate the problem using `jac=true` for the analytical Jacobian

src/ModelingToolkit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export JumpSystem
167167
export ODEProblem, SDEProblem
168168
export NonlinearFunction, NonlinearFunctionExpr
169169
export NonlinearProblem, BlockNonlinearProblem, NonlinearProblemExpr
170-
export OptimizationProblem, OptimizationProblemExpr
170+
export OptimizationProblem, OptimizationProblemExpr, constraints
171171
export AutoModelingToolkit
172172
export SteadyStateProblem, SteadyStateProblemExpr
173173
export JumpProblem, DiscreteProblem

0 commit comments

Comments
 (0)