Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit 918dad4

Browse files
author
root
committed
Automatic build\nPublished by build of: SciML/SciMLTutorials.jl@1d6157c
1 parent 958aa4a commit 918dad4

5 files changed

Lines changed: 157 additions & 81 deletions

File tree

html/advanced/02-advanced_ODE_solving.html

Lines changed: 78 additions & 37 deletions
Large diffs are not rendered by default.

markdown/advanced/02-advanced_ODE_solving.md

Lines changed: 75 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ using BenchmarkTools
154154
```
155155

156156
```
157-
447.845 μs (2561 allocations: 186.89 KiB)
157+
592.133 μs (2561 allocations: 186.89 KiB)
158158
retcode: Success
159159
Interpolation: automatic order switching interpolation
160160
t: 115-element Vector{Float64}:
@@ -230,7 +230,7 @@ prob_jac = ODEProblem(f,[1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))
230230
```
231231

232232
```
233-
291.287 μs (2002 allocations: 126.28 KiB)
233+
367.386 μs (2002 allocations: 126.28 KiB)
234234
retcode: Success
235235
Interpolation: automatic order switching interpolation
236236
t: 115-element Vector{Float64}:
@@ -291,19 +291,52 @@ the Julia code for this.
291291
```julia
292292
using ModelingToolkit
293293
de = modelingtoolkitize(prob)
294-
ModelingToolkit.generate_jacobian(de...)[2] # Second is in-place
295-
```
296-
297-
```
298-
Error: MethodError: no method matching iterate(::ModelingToolkit.ODESystem)
299-
Closest candidates are:
300-
iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:664
301-
iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Int64) at rang
302-
e.jl:664
303-
iterate(!Matched::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} whe
304-
re {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s
305-
77"<:Dict} at dict.jl:693
306-
...
294+
ModelingToolkit.generate_jacobian(de)[2] # Second is in-place
295+
```
296+
297+
```
298+
:(function (var"##out#7430", var"##arg#7428", var"##arg#7429", t)
299+
#= /root/.cache/julia-buildkite-plugin/depots/a6029d3a-f78b-41ea-bc97
300+
-28aa57c6c6ea/packages/SymbolicUtils/9iQGH/src/code.jl:282 =#
301+
#= /root/.cache/julia-buildkite-plugin/depots/a6029d3a-f78b-41ea-bc97
302+
-28aa57c6c6ea/packages/SymbolicUtils/9iQGH/src/code.jl:283 =#
303+
let var"x₁(t)" = #= /root/.cache/julia-buildkite-plugin/depots/a6029d
304+
3a-f78b-41ea-bc97-28aa57c6c6ea/packages/SymbolicUtils/9iQGH/src/code.jl:169
305+
=# @inbounds(var"##arg#7428"[1]), var"x₂(t)" = #= /root/.cache/julia-build
306+
kite-plugin/depots/a6029d3a-f78b-41ea-bc97-28aa57c6c6ea/packages/SymbolicUt
307+
ils/9iQGH/src/code.jl:169 =# @inbounds(var"##arg#7428"[2]), var"x₃(t)" = #=
308+
/root/.cache/julia-buildkite-plugin/depots/a6029d3a-f78b-41ea-bc97-28aa57c
309+
6c6ea/packages/SymbolicUtils/9iQGH/src/code.jl:169 =# @inbounds(var"##arg#7
310+
428"[3]), α₁ = #= /root/.cache/julia-buildkite-plugin/depots/a6029d3a-f78b-
311+
41ea-bc97-28aa57c6c6ea/packages/SymbolicUtils/9iQGH/src/code.jl:169 =# @inb
312+
ounds(var"##arg#7429"[1]), α₂ = #= /root/.cache/julia-buildkite-plugin/depo
313+
ts/a6029d3a-f78b-41ea-bc97-28aa57c6c6ea/packages/SymbolicUtils/9iQGH/src/co
314+
de.jl:169 =# @inbounds(var"##arg#7429"[2]), α₃ = #= /root/.cache/julia-buil
315+
dkite-plugin/depots/a6029d3a-f78b-41ea-bc97-28aa57c6c6ea/packages/SymbolicU
316+
tils/9iQGH/src/code.jl:169 =# @inbounds(var"##arg#7429"[3])
317+
#= /root/.cache/julia-buildkite-plugin/depots/a6029d3a-f78b-41ea-
318+
bc97-28aa57c6c6ea/packages/Symbolics/h8kPL/src/build_function.jl:331 =#
319+
#= /root/.cache/julia-buildkite-plugin/depots/a6029d3a-f78b-41ea-
320+
bc97-28aa57c6c6ea/packages/SymbolicUtils/9iQGH/src/code.jl:329 =# @inbounds
321+
begin
322+
#= /root/.cache/julia-buildkite-plugin/depots/a6029d3a-f7
323+
8b-41ea-bc97-28aa57c6c6ea/packages/SymbolicUtils/9iQGH/src/code.jl:325 =#
324+
var"##out#7430"[1] = (*)(-1, α₁)
325+
var"##out#7430"[2] = α₁
326+
var"##out#7430"[3] = 0
327+
var"##out#7430"[4] = (*)(α₃, var"x₃(t)")
328+
var"##out#7430"[5] = (+)((*)(-2, α₂, var"x₂(t)"), (*)(-1,
329+
α₃, var"x₃(t)"))
330+
var"##out#7430"[6] = (*)(2, α₂, var"x₂(t)")
331+
var"##out#7430"[7] = (*)(α₃, var"x₂(t)")
332+
var"##out#7430"[8] = (*)(-1, α₃, var"x₂(t)")
333+
var"##out#7430"[9] = 0
334+
#= /root/.cache/julia-buildkite-plugin/depots/a6029d3a-f7
335+
8b-41ea-bc97-28aa57c6c6ea/packages/SymbolicUtils/9iQGH/src/code.jl:327 =#
336+
nothing
337+
end
338+
end
339+
end)
307340
```
308341

309342

@@ -337,21 +370,18 @@ which outputs:
337370
Now let's use that to give the analytical solution Jacobian:
338371
339372
```julia
340-
jac = eval(ModelingToolkit.generate_jacobian(de...)[2])
373+
jac = eval(ModelingToolkit.generate_jacobian(de)[2])
341374
f = ODEFunction(rober, jac=jac)
342375
prob_jac = ODEProblem(f,[1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))
343376
```
344377
345378
```
346-
Error: MethodError: no method matching iterate(::ModelingToolkit.ODESystem)
347-
Closest candidates are:
348-
iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:664
349-
iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Int64) at rang
350-
e.jl:664
351-
iterate(!Matched::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} whe
352-
re {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s
353-
77"<:Dict} at dict.jl:693
354-
...
379+
ODEProblem with uType Vector{Float64} and tType Float64. In-place: true
380+
timespan: (0.0, 100000.0)
381+
u0: 3-element Vector{Float64}:
382+
1.0
383+
0.0
384+
0.0
355385
```
356386
357387
@@ -395,7 +425,12 @@ prob_jac = ODEProblem(f,[1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))
395425
```
396426
397427
```
398-
Error: UndefVarError: jac not defined
428+
ODEProblem with uType Vector{Float64} and tType Float64. In-place: true
429+
timespan: (0.0, 100000.0)
430+
u0: 3-element Vector{Float64}:
431+
1.0
432+
0.0
433+
0.0
399434
```
400435
401436
@@ -499,7 +534,7 @@ f = ODEFunction(brusselator_2d_loop;jac_prototype=jac_sparsity)
499534
```
500535
501536
```
502-
(::SciMLBase.ODEFunction{true, typeof(Main.##WeaveSandBox#7200.brusselator_
537+
(::SciMLBase.ODEFunction{true, typeof(Main.##WeaveSandBox#7022.brusselator_
503538
2d_loop), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, No
504539
thing, Nothing, SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.
505540
SparseMatrixCSC{Float64, Int64}, Nothing, Nothing, Nothing, Nothing, Nothin
@@ -594,8 +629,8 @@ Now let's see how the version with sparsity compares to the version without:
594629
```
595630
596631
```
597-
4.190 s (3332 allocations: 65.33 MiB)
598-
870.451 ms (40171 allocations: 276.18 MiB)
632+
4.443 s (3332 allocations: 65.33 MiB)
633+
867.988 ms (40169 allocations: 276.18 MiB)
599634
retcode: Success
600635
Interpolation: 1st order linear
601636
t: 2-element Vector{Float64}:
@@ -667,7 +702,7 @@ prob_ode_brusselator_2d_sparse = ODEProblem(f,
667702
```
668703
669704
```
670-
868.578 ms (7390 allocations: 272.21 MiB)
705+
866.651 ms (7386 allocations: 272.21 MiB)
671706
retcode: Success
672707
Interpolation: 1st order linear
673708
t: 2-element Vector{Float64}:
@@ -718,8 +753,8 @@ GMRES linear solver.
718753
```
719754
720755
```
721-
55.095 s (1440760 allocations: 148.08 MiB)
722-
3.540 s (487052 allocations: 19.49 MiB)
756+
54.826 s (1440760 allocations: 148.08 MiB)
757+
3.373 s (487052 allocations: 19.49 MiB)
723758
retcode: Success
724759
Interpolation: 1st order linear
725760
t: 2-element Vector{Float64}:
@@ -769,11 +804,11 @@ Jv = JacVecOperator(brusselator_2d_loop,u0,p,0.0)
769804
```
770805
771806
```
772-
DiffEqOperators.JacVecOperator{Float64, typeof(Main.##WeaveSandBox#7200.bru
807+
DiffEqOperators.JacVecOperator{Float64, typeof(Main.##WeaveSandBox#7022.bru
773808
sselator_2d_loop), Array{ForwardDiff.Dual{DiffEqOperators.JacVecTag, Float6
774809
4, 1}, 3}, Array{ForwardDiff.Dual{DiffEqOperators.JacVecTag, Float64, 1}, 3
775810
}, Array{Float64, 3}, NTuple{4, Float64}, Float64, Bool}(Main.##WeaveSandBo
776-
x#7200.brusselator_2d_loop, ForwardDiff.Dual{DiffEqOperators.JacVecTag, Flo
811+
x#7022.brusselator_2d_loop, ForwardDiff.Dual{DiffEqOperators.JacVecTag, Flo
777812
at64, 1}[Dual{DiffEqOperators.JacVecTag}(0.0,0.0) Dual{DiffEqOperators.JacV
778813
ecTag}(0.12134432813715876,0.12134432813715876) Dual{DiffEqOperators.JacV
779814
ecTag}(0.1213443281371586,0.1213443281371586) Dual{DiffEqOperators.JacVecTa
@@ -852,7 +887,7 @@ prob_ode_brusselator_2d_jacfree = ODEProblem(f,u0,(0.,11.5),p)
852887
```
853888
854889
```
855-
2.135 s (942433 allocations: 1.05 GiB)
890+
2.052 s (942433 allocations: 1.05 GiB)
856891
retcode: Success
857892
Interpolation: 1st order linear
858893
t: 2-element Vector{Float64}:
@@ -898,7 +933,7 @@ pc = aspreconditioner(ruge_stuben(jac_sparsity))
898933
```
899934
900935
```
901-
52.841 ms (2126 allocations: 4.62 MiB)
936+
57.068 ms (2126 allocations: 4.62 MiB)
902937
retcode: Success
903938
Interpolation: 1st order linear
904939
t: 2-element Vector{Float64}:
@@ -976,8 +1011,8 @@ using Sundials
9761011
```
9771012
9781013
```
979-
14.894 s (51406 allocations: 3.40 MiB)
980-
296.532 ms (54356 allocations: 3.24 MiB)
1014+
18.035 s (51406 allocations: 3.40 MiB)
1015+
296.814 ms (54356 allocations: 3.24 MiB)
9811016
retcode: Success
9821017
Interpolation: 1st order linear
9831018
t: 2-element Vector{Float64}:
@@ -1099,7 +1134,7 @@ Environment:
10991134
Package Information:
11001135
11011136
```
1102-
Status `/var/lib/buildkite-agent/builds/4-amdci4-julia-csail-mit-edu/julialang/scimltutorials-dot-jl/tutorials/advanced/Project.toml`
1137+
Status `/var/lib/buildkite-agent/builds/2-amdci4-julia-csail-mit-edu/julialang/scimltutorials-dot-jl/tutorials/advanced/Project.toml`
11031138
[2169fc97] AlgebraicMultigrid v0.4.0
11041139
[6e4b80f9] BenchmarkTools v1.0.0
11051140
[052768ef] CUDA v2.6.3
@@ -1125,7 +1160,7 @@ Package Information:
11251160
And the full manifest:
11261161
11271162
```
1128-
Status `/var/lib/buildkite-agent/builds/4-amdci4-julia-csail-mit-edu/julialang/scimltutorials-dot-jl/tutorials/advanced/Manifest.toml`
1163+
Status `/var/lib/buildkite-agent/builds/2-amdci4-julia-csail-mit-edu/julialang/scimltutorials-dot-jl/tutorials/advanced/Manifest.toml`
11291164
[c3fe647b] AbstractAlgebra v0.16.0
11301165
[621f4979] AbstractFFTs v1.0.1
11311166
[1520ce14] AbstractTrees v0.3.4

notebook/advanced/02-advanced_ODE_solving.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"outputs": [],
8585
"cell_type": "code",
8686
"source": [
87-
"using ModelingToolkit\nde = modelingtoolkitize(prob)\nModelingToolkit.generate_jacobian(de...)[2] # Second is in-place"
87+
"using ModelingToolkit\nde = modelingtoolkitize(prob)\nModelingToolkit.generate_jacobian(de)[2] # Second is in-place"
8888
],
8989
"metadata": {},
9090
"execution_count": null
@@ -116,7 +116,7 @@
116116
"outputs": [],
117117
"cell_type": "code",
118118
"source": [
119-
"jac = eval(ModelingToolkit.generate_jacobian(de...)[2])\nf = ODEFunction(rober, jac=jac)\nprob_jac = ODEProblem(f,[1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))"
119+
"jac = eval(ModelingToolkit.generate_jacobian(de)[2])\nf = ODEFunction(rober, jac=jac)\nprob_jac = ODEProblem(f,[1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))"
120120
],
121121
"metadata": {},
122122
"execution_count": null
1.62 KB
Binary file not shown.

script/advanced/02-advanced_ODE_solving.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ prob_jac = ODEProblem(f,[1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))
4848

4949
using ModelingToolkit
5050
de = modelingtoolkitize(prob)
51-
ModelingToolkit.generate_jacobian(de...)[2] # Second is in-place
51+
ModelingToolkit.generate_jacobian(de)[2] # Second is in-place
5252

5353

5454
:((##MTIIPVar#376, u, p, t)->begin
@@ -70,7 +70,7 @@ ModelingToolkit.generate_jacobian(de...)[2] # Second is in-place
7070
end)
7171

7272

73-
jac = eval(ModelingToolkit.generate_jacobian(de...)[2])
73+
jac = eval(ModelingToolkit.generate_jacobian(de)[2])
7474
f = ODEFunction(rober, jac=jac)
7575
prob_jac = ODEProblem(f,[1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))
7676

0 commit comments

Comments
 (0)