Skip to content

Commit 2ecda0b

Browse files
authored
Merge pull request #2179 from SciML/myb/formatting
New formatting
2 parents 5561943 + de43c69 commit 2ecda0b

File tree

99 files changed

+2221
-2153
lines changed

Some content is hidden

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

99 files changed

+2221
-2153
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ MacroTools = "0.5"
7979
NaNMath = "0.3, 1"
8080
RecursiveArrayTools = "2.3"
8181
Reexport = "0.2, 1"
82-
RuntimeGeneratedFunctions = "0.5.10"
82+
RuntimeGeneratedFunctions = "=0.5.9"
8383
SciMLBase = "1.76.1"
8484
Setfield = "0.7, 0.8, 1"
8585
SimpleNonlinearSolve = "0.1.0"

docs/make.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,34 @@ cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
1010
include("pages.jl")
1111

1212
mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
13-
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
14-
"packages" => [
15-
"base",
16-
"ams",
17-
"autoload",
18-
"mathtools",
19-
"require",
20-
])))
13+
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
14+
"packages" => [
15+
"base",
16+
"ams",
17+
"autoload",
18+
"mathtools",
19+
"require",
20+
])))
2121

2222
makedocs(sitename = "ModelingToolkit.jl",
23-
authors = "Chris Rackauckas",
24-
modules = [ModelingToolkit],
25-
clean = true, doctest = false, linkcheck = true,
26-
linkcheck_ignore = ["https://epubs.siam.org/doi/10.1137/0903023"],
27-
strict = [
28-
:doctest,
29-
:linkcheck,
30-
:parse_error,
31-
:example_block,
32-
# Other available options are
33-
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
34-
],
35-
format = Documenter.HTML(; analytics = "UA-90474609-3",
36-
assets = ["assets/favicon.ico"],
37-
mathengine,
38-
canonical = "https://docs.sciml.ai/ModelingToolkit/stable/",
39-
prettyurls = (get(ENV, "CI", nothing) == "true")),
40-
pages = pages)
23+
authors = "Chris Rackauckas",
24+
modules = [ModelingToolkit],
25+
clean = true, doctest = false, linkcheck = true,
26+
linkcheck_ignore = ["https://epubs.siam.org/doi/10.1137/0903023"],
27+
strict = [
28+
:doctest,
29+
:linkcheck,
30+
:parse_error,
31+
:example_block,
32+
# Other available options are
33+
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
34+
],
35+
format = Documenter.HTML(; analytics = "UA-90474609-3",
36+
assets = ["assets/favicon.ico"],
37+
mathengine,
38+
canonical = "https://docs.sciml.ai/ModelingToolkit/stable/",
39+
prettyurls = (get(ENV, "CI", nothing) == "true")),
40+
pages = pages)
4141

4242
deploydocs(repo = "github.com/SciML/ModelingToolkit.jl.git";
43-
push_preview = true)
43+
push_preview = true)

docs/pages.jl

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@ pages = [
22
"Home" => "index.md",
33
"tutorials/ode_modeling.md",
44
"Tutorials" => Any["tutorials/acausal_components.md",
5-
"tutorials/nonlinear.md",
6-
"tutorials/optimization.md",
7-
"tutorials/modelingtoolkitize.md",
8-
"tutorials/stochastic_diffeq.md",
9-
"tutorials/parameter_identifiability.md"],
5+
"tutorials/nonlinear.md",
6+
"tutorials/optimization.md",
7+
"tutorials/modelingtoolkitize.md",
8+
"tutorials/stochastic_diffeq.md",
9+
"tutorials/parameter_identifiability.md"],
1010
"Examples" => Any["Basic Examples" => Any["examples/higher_order.md",
11-
"examples/spring_mass.md",
12-
"examples/modelingtoolkitize_index_reduction.md",
13-
"examples/parsing.md"],
14-
"Advanced Examples" => Any["examples/tearing_parallelism.md",
15-
"examples/sparse_jacobians.md",
16-
"examples/perturbation.md"]],
11+
"examples/spring_mass.md",
12+
"examples/modelingtoolkitize_index_reduction.md",
13+
"examples/parsing.md"],
14+
"Advanced Examples" => Any["examples/tearing_parallelism.md",
15+
"examples/sparse_jacobians.md",
16+
"examples/perturbation.md"]],
1717
"Basics" => Any["basics/AbstractSystem.md",
18-
"basics/ContextualVariables.md",
19-
"basics/Variable_metadata.md",
20-
"basics/Composition.md",
21-
"basics/Events.md",
22-
"basics/Linearization.md",
23-
"basics/Validation.md",
24-
"basics/DependencyGraphs.md",
25-
"basics/FAQ.md"],
18+
"basics/ContextualVariables.md",
19+
"basics/Variable_metadata.md",
20+
"basics/Composition.md",
21+
"basics/Events.md",
22+
"basics/Linearization.md",
23+
"basics/Validation.md",
24+
"basics/DependencyGraphs.md",
25+
"basics/FAQ.md"],
2626
"System Types" => Any["systems/ODESystem.md",
27-
"systems/SDESystem.md",
28-
"systems/JumpSystem.md",
29-
"systems/NonlinearSystem.md",
30-
"systems/OptimizationSystem.md",
31-
"systems/DiscreteSystem.md",
32-
"systems/PDESystem.md"],
27+
"systems/SDESystem.md",
28+
"systems/JumpSystem.md",
29+
"systems/NonlinearSystem.md",
30+
"systems/OptimizationSystem.md",
31+
"systems/DiscreteSystem.md",
32+
"systems/PDESystem.md"],
3333
"comparison.md",
3434
"internals.md",
3535
]

docs/src/basics/Composition.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ function decay(; name)
2222
@variables x(t) f(t)
2323
D = Differential(t)
2424
ODESystem([
25-
D(x) ~ -a * x + f,
26-
];
27-
name = name)
25+
D(x) ~ -a * x + f,
26+
];
27+
name = name)
2828
end
2929
3030
@named decay1 = decay()
@@ -33,7 +33,7 @@ end
3333
@parameters t
3434
D = Differential(t)
3535
connected = compose(ODESystem([decay2.f ~ decay1.x
36-
D(decay1.f) ~ 0], t; name = :connected), decay1, decay2)
36+
D(decay1.f) ~ 0], t; name = :connected), decay1, decay2)
3737
3838
equations(connected)
3939
@@ -52,10 +52,10 @@ Now we can solve the system:
5252

5353
```@example composition
5454
x0 = [decay1.x => 1.0
55-
decay1.f => 0.0
56-
decay2.x => 1.0]
55+
decay1.f => 0.0
56+
decay2.x => 1.0]
5757
p = [decay1.a => 0.1
58-
decay2.a => 0.2]
58+
decay2.a => 0.2]
5959
6060
using DifferentialEquations
6161
prob = ODEProblem(simplified_sys, x0, (0.0, 100.0), p)
@@ -96,7 +96,7 @@ in their namespaced form. For example:
9696

9797
```julia
9898
u0 = [x => 2.0
99-
subsys.x => 2.0]
99+
subsys.x => 2.0]
100100
```
101101

102102
Note that any default values within the given subcomponent will be
@@ -124,11 +124,11 @@ With symbolic parameters, it is possible to set the default value of a parameter
124124
```julia
125125
# ...
126126
sys = ODESystem(
127-
# ...
128-
# directly in the defaults argument
129-
defaults = Pair{Num, Any}[x => u,
130-
y => σ,
131-
z => u - 0.1])
127+
# ...
128+
# directly in the defaults argument
129+
defaults = Pair{Num, Any}[x => u,
130+
y => σ,
131+
z => u - 0.1])
132132
# by assigning to the parameter
133133
sys.y = u * 1.1
134134
```
@@ -138,11 +138,11 @@ In a hierarchical system, variables of the subsystem get namespaced by the name
138138
```julia
139139
@parameters t a b c d e f
140140
p = [a #a is a local variable
141-
ParentScope(b) # b is a variable that belongs to one level up in the hierarchy
142-
ParentScope(ParentScope(c))# ParentScope can be nested
143-
DelayParentScope(d) # skips one level before applying ParentScope
144-
DelayParentScope(e, 2) # second argument allows skipping N levels
145-
GlobalScope(f)]
141+
ParentScope(b) # b is a variable that belongs to one level up in the hierarchy
142+
ParentScope(ParentScope(c))# ParentScope can be nested
143+
DelayParentScope(d) # skips one level before applying ParentScope
144+
DelayParentScope(e, 2) # second argument allows skipping N levels
145+
GlobalScope(f)]
146146

147147
level0 = ODESystem(Equation[], t, [], p; name = :level0)
148148
level1 = ODESystem(Equation[], t, [], []; name = :level1) level0
@@ -208,18 +208,18 @@ N = S + I + R
208208
@named reqn = ODESystem([D(R) ~ γ * I])
209209
210210
sir = compose(ODESystem([
211-
S ~ ieqn.S,
212-
I ~ seqn.I,
213-
R ~ ieqn.R,
214-
ieqn.S ~ seqn.S,
215-
seqn.I ~ ieqn.I,
216-
seqn.R ~ reqn.R,
217-
ieqn.R ~ reqn.R,
218-
reqn.I ~ ieqn.I], t, [S, I, R], [β, γ],
219-
defaults = [seqn.β => β
220-
ieqn.β => β
221-
ieqn.γ => γ
222-
reqn.γ => γ], name = :sir), seqn, ieqn, reqn)
211+
S ~ ieqn.S,
212+
I ~ seqn.I,
213+
R ~ ieqn.R,
214+
ieqn.S ~ seqn.S,
215+
seqn.I ~ ieqn.I,
216+
seqn.R ~ reqn.R,
217+
ieqn.R ~ reqn.R,
218+
reqn.I ~ ieqn.I], t, [S, I, R], [β, γ],
219+
defaults = [seqn.β => β
220+
ieqn.β => β
221+
ieqn.γ => γ
222+
reqn.γ => γ], name = :sir), seqn, ieqn, reqn)
223223
```
224224

225225
Note that the states are forwarded by an equality relationship, while
@@ -241,7 +241,7 @@ u0 = [seqn.S => 990.0,
241241
reqn.R => 0.0]
242242
243243
p = [β => 0.5
244-
γ => 0.25]
244+
γ => 0.25]
245245
246246
tspan = (0.0, 40.0)
247247
prob = ODEProblem(sireqn_simple, u0, tspan, p, jac = true)

docs/src/basics/Events.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function UnitMassWithFriction(k; name)
6969
@variables t x(t)=0 v(t)=0
7070
D = Differential(t)
7171
eqs = [D(x) ~ v
72-
D(v) ~ sin(t) - k * sign(v)]
72+
D(v) ~ sin(t) - k * sign(v)]
7373
ODESystem(eqs, t; continuous_events = [v ~ 0], name) # when v = 0 there is a discontinuity
7474
end
7575
@named m = UnitMassWithFriction(0.7)
@@ -94,7 +94,7 @@ root_eqs = [x ~ 0] # the event happens at the ground x(t) = 0
9494
affect = [v ~ -v] # the effect is that the velocity changes sign
9595
9696
@named ball = ODESystem([D(x) ~ v
97-
D(v) ~ -9.8], t; continuous_events = root_eqs => affect) # equation => affect
97+
D(v) ~ -9.8], t; continuous_events = root_eqs => affect) # equation => affect
9898
9999
ball = structural_simplify(ball)
100100
@@ -114,14 +114,14 @@ Multiple events? No problem! This example models a bouncing ball in 2D that is e
114114
D = Differential(t)
115115
116116
continuous_events = [[x ~ 0] => [vx ~ -vx]
117-
[y ~ -1.5, y ~ 1.5] => [vy ~ -vy]]
117+
[y ~ -1.5, y ~ 1.5] => [vy ~ -vy]]
118118
119119
@named ball = ODESystem([
120-
D(x) ~ vx,
121-
D(y) ~ vy,
122-
D(vx) ~ -9.8 - 0.1vx, # gravity + some small air resistance
123-
D(vy) ~ -0.1vy,
124-
], t; continuous_events)
120+
D(x) ~ vx,
121+
D(y) ~ vy,
122+
D(vx) ~ -9.8 - 0.1vx, # gravity + some small air resistance
123+
D(vy) ~ -0.1vy,
124+
], t; continuous_events)
125125
126126
ball = structural_simplify(ball)
127127
@@ -189,7 +189,7 @@ affect interface:
189189
sts = @variables x(t), v(t)
190190
par = @parameters g = 9.8
191191
bb_eqs = [D(x) ~ v
192-
D(v) ~ -g]
192+
D(v) ~ -g]
193193
194194
function bb_affect!(integ, u, p, ctx)
195195
integ.u[u.v] = -integ.u[u.v]
@@ -198,7 +198,7 @@ end
198198
reflect = [x ~ 0] => (bb_affect!, [v], [], nothing)
199199
200200
@named bb_model = ODESystem(bb_eqs, t, sts, par,
201-
continuous_events = reflect)
201+
continuous_events = reflect)
202202
203203
bb_sys = structural_simplify(bb_model)
204204
u0 = [v => 0.0, x => 1.0]
@@ -288,7 +288,7 @@ killing = (t == tkill) => [α ~ 0.0]
288288
tspan = (0.0, 30.0)
289289
p = [α => 100.0, tinject => 10.0, M => 50, tkill => 20.0]
290290
@named osys = ODESystem(eqs, t, [N], [α, M, tinject, tkill];
291-
discrete_events = [injection, killing])
291+
discrete_events = [injection, killing])
292292
oprob = ODEProblem(osys, u0, tspan, p)
293293
sol = solve(oprob, Tsit5(); tstops = [10.0, 20.0])
294294
plot(sol)
@@ -316,7 +316,7 @@ killing = [20.0] => [α ~ 0.0]
316316
317317
p = [α => 100.0, M => 50]
318318
@named osys = ODESystem(eqs, t, [N], [α, M];
319-
discrete_events = [injection, killing])
319+
discrete_events = [injection, killing])
320320
oprob = ODEProblem(osys, u0, tspan, p)
321321
sol = solve(oprob, Tsit5())
322322
plot(sol)

docs/src/basics/Linearization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ using ModelingToolkit
2626
D = Differential(t)
2727
2828
eqs = [u ~ kp * (r - y) # P controller
29-
D(x) ~ -x + u # First-order plant
30-
y ~ x] # Output equation
29+
D(x) ~ -x + u # First-order plant
30+
y ~ x] # Output equation
3131
3232
@named sys = ODESystem(eqs, t)
3333
matrices, simplified_sys = linearize(sys, [r], [y]) # Linearize from r to y

docs/src/basics/Validation.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ using ModelingToolkit, Unitful
1212
1313
@variables(t, [unit = u"s"], x(t), [unit = u"m"], g(t), w(t), [unit = "Hz"])
1414
15-
@variables(begin t, [unit = u"s"],
16-
x(t), [unit = u"m"],
17-
g(t),
18-
w(t), [unit = "Hz"] end)
15+
@variables(begin
16+
t, [unit = u"s"],
17+
x(t), [unit = u"m"],
18+
g(t),
19+
w(t), [unit = "Hz"]
20+
end)
1921
2022
# Simultaneously set default value (use plain numbers, not quantities)
2123
@variables x=10 [unit = u"m"]

docs/src/basics/Variable_metadata.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Dₜ = Differential(t)
113113
@parameters T [tunable = true, bounds = (0, Inf)]
114114
@parameters k [tunable = true, bounds = (0, Inf)]
115115
eqs = [Dₜ(x) ~ (-x + k * u) / T # A first-order system with time constant T and gain k
116-
y ~ x]
116+
y ~ x]
117117
sys = ODESystem(eqs, t, name = :tunable_first_order)
118118
```
119119

docs/src/examples/parsing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ symbolic forms from that? For example, say we had the following system we wanted
77

88
```@example parsing
99
ex = [:(y ~ x)
10-
:(y ~ -2x + 3 / z)
11-
:(z ~ 2)]
10+
:(y ~ -2x + 3 / z)
11+
:(z ~ 2)]
1212
```
1313

1414
We can use the function `parse_expr_to_symbolic` from Symbolics.jl to generate the symbolic

docs/src/examples/sparse_jacobians.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function brusselator_2d_loop(du, u, p, t)
2424
i, j = Tuple(I)
2525
x, y = xyd_brusselator[I[1]], xyd_brusselator[I[2]]
2626
ip1, im1, jp1, jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
27-
limit(j - 1, N)
27+
limit(j - 1, N)
2828
du[i, j, 1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
2929
4u[i, j, 1]) +
3030
B + u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] +

0 commit comments

Comments
 (0)