@@ -19,7 +19,7 @@ to ensure that the problem that is built uses static structures. For example thi
1919that the ` u0 ` and ` p ` specifications should use static arrays. This looks as follows:
2020
2121``` @example mtk
22- using OrdinaryDiffEqTsit5 , ModelingToolkit, StaticArrays
22+ using OrdinaryDiffEq , ModelingToolkit, StaticArrays
2323using ModelingToolkit: t_nounits as t, D_nounits as D
2424
2525@parameters σ ρ β
@@ -30,14 +30,14 @@ eqs = [D(D(x)) ~ σ * (y - x),
3030 D(z) ~ x * y - β * z]
3131
3232@mtkbuild sys = ODESystem(eqs, t)
33- u0 = SA [D(x) => 2.0f0,
34- x => 1.0f0,
35- y => 0.0f0,
36- z => 0.0f0]
33+ u0 = @SVector [D(x) => 2.0f0,
34+ x => 1.0f0,
35+ y => 0.0f0,
36+ z => 0.0f0]
3737
38- p = SA [σ => 28.0f0,
39- ρ => 10.0f0,
40- β => 8.0f0 / 3.0f0]
38+ p = @SVector [σ => 28.0f0,
39+ ρ => 10.0f0,
40+ β => 8.0f0 / 3.0f0]
4141
4242tspan = (0.0f0, 100.0f0)
4343prob = ODEProblem{false}(sys, u0, tspan, p)
@@ -60,12 +60,13 @@ form by changing those 3 values by using the `setsym_oop` as follows:
6060``` @example mtk
6161using SymbolicIndexingInterface
6262sym_setter = setsym_oop(sys, [σ, ρ, β])
63+ nothing # hide
6364```
6465
6566The return ` sym_setter ` is our optimized function, let's see it in action:
6667
6768``` @example mtk
68- u0, p = sym_setter(prob, @ SVector(rand(Float32, 3)))
69+ u0, p = sym_setter(prob, SVector{3} (rand(Float32, 3)))
6970```
7071
7172Notice it takes in the vector of values for ` [σ, ρ, β] ` and spits out the new ` u0, p ` . So
@@ -74,7 +75,7 @@ we can build and solve an MTK generated ODE on the GPU using the following:
7475``` @example mtk
7576using DiffEqGPU, CUDA
7677function prob_func2(prob, i, repeat)
77- u0, p = sym_setter(prob, @ SVector(rand(Float32, 3)))
78+ u0, p = sym_setter(prob, SVector{3} (rand(Float32, 3)))
7879 remake(prob, u0 = u0, p = p)
7980end
8081
0 commit comments