diff --git a/docs/src/tutorials/modelingtoolkit.md b/docs/src/tutorials/modelingtoolkit.md index af2b3957..4866bf58 100644 --- a/docs/src/tutorials/modelingtoolkit.md +++ b/docs/src/tutorials/modelingtoolkit.md @@ -8,6 +8,7 @@ by hand. Those exact features are also potentially useful for GPU computing, and tutorial showcases how to effectively use MTK with DiffEqGPU.jl. !!! warn + This tutorial currently only works for ODEs defined by ModelingToolkit. More work will be required to support DAEs in full. This is work that is ongoing and expected to be completed by the summer of 2025. @@ -29,16 +30,16 @@ eqs = [D(D(x)) ~ σ * (y - x), D(z) ~ x * y - β * z] @mtkbuild sys = ODESystem(eqs, t) -u0 = SA[D(x) => 2f0, - x => 1f0, - y => 0f0, - z => 0f0] +u0 = SA[D(x) => 2.0f0, + x => 1.0f0, + y => 0.0f0, + z => 0.0f0] -p = SA[σ => 28f0, - ρ => 10f0, - β => 8f0 / 3f0] +p = SA[σ => 28.0f0, + ρ => 10.0f0, + β => 8.0f0 / 3.0f0] -tspan = (0f0, 100f0) +tspan = (0.0f0, 100.0f0) prob = ODEProblem{false}(sys, u0, tspan, p) sol = solve(prob, Tsit5()) ``` @@ -64,7 +65,7 @@ sym_setter = setsym_oop(sys, [σ, ρ, β]) The return `sym_setter` is our optimized function, let's see it in action: ```@example mtk -u0, p = sym_setter(prob,@SVector(rand(Float32,3))) +u0, p = sym_setter(prob, @SVector(rand(Float32, 3))) ``` Notice it takes in the vector of values for `[σ, ρ, β]` and spits out the new `u0, p`. So @@ -73,7 +74,7 @@ we can build and solve an MTK generated ODE on the GPU using the following: ```@example mtk using DiffEqGPU, CUDA function prob_func2(prob, i, repeat) - u0, p = sym_setter(prob,@SVector(rand(Float32,3))) + u0, p = sym_setter(prob, @SVector(rand(Float32, 3))) remake(prob, u0 = u0, p = p) end diff --git a/src/DiffEqGPU.jl b/src/DiffEqGPU.jl index 66f64b8e..aebffe9c 100644 --- a/src/DiffEqGPU.jl +++ b/src/DiffEqGPU.jl @@ -68,8 +68,6 @@ include("ensemblegpukernel/tableaus/verner_tableaus.jl") include("ensemblegpukernel/tableaus/rodas_tableaus.jl") include("ensemblegpukernel/tableaus/kvaerno_tableaus.jl") - - include("utils.jl") include("algorithms.jl") include("solve.jl") diff --git a/src/ensemblegpuarray/problem_generation.jl b/src/ensemblegpuarray/problem_generation.jl index 24c5deaf..4e8ca23f 100644 --- a/src/ensemblegpuarray/problem_generation.jl +++ b/src/ensemblegpuarray/problem_generation.jl @@ -58,7 +58,6 @@ function generate_problem(prob::SciMLBase.AbstractODEProblem, _tgrad = nothing end - f_func = ODEFunction(_f, Wfact = _Wfact!, Wfact_t = _Wfact!_t, #colorvec=colorvec, diff --git a/src/solve.jl b/src/solve.jl index 23abbe66..0c55aa8a 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -273,7 +273,7 @@ function batch_solve_up_kernel(ensembleprob, probs, alg, ensemblealg, I, adaptiv _callback.continuous_callbacks)...) dev = ensemblealg.dev - probs = adapt(dev,adapt.((dev,), probs)) + probs = adapt(dev, adapt.((dev,), probs)) #Adaptive version only works with saveat if adaptive diff --git a/test/ensemblegpuarray_sde.jl b/test/ensemblegpuarray_sde.jl index 3cbafb7d..6638b5f9 100644 --- a/test/ensemblegpuarray_sde.jl +++ b/test/ensemblegpuarray_sde.jl @@ -50,9 +50,10 @@ NRate[2, 2] = 1 u0 = ComplexF32[1.0; 0.0; 0.0; 0.0] tspan = (0.0f0, 10.0f0) p = (10.0f0, 28.0f0, 8 / 3.0f0) -prob = SDEProblem(lorenz, multiplicative_noise, u0, tspan, p, noise_rate_prototype=NRate) +prob = SDEProblem(lorenz, multiplicative_noise, u0, tspan, p, noise_rate_prototype = NRate) -prob_func = (prob, i, repeat) -> remake(prob, p=p) -monteprob = EnsembleProblem(prob, prob_func=prob_func) +prob_func = (prob, i, repeat) -> remake(prob, p = p) +monteprob = EnsembleProblem(prob, prob_func = prob_func) -@test_throws "Incompatible problem detected. EnsembleGPUArray currently requires `prob.noise_rate_prototype === nothing`, i.e. only diagonal noise is currently supported. Track https://github.com/SciML/DiffEqGPU.jl/issues/331 for more information." sol = solve(monteprob, SRA1(), EnsembleCPUArray(), trajectories=10_000, saveat=1.0f0) +@test_throws "Incompatible problem detected. EnsembleGPUArray currently requires `prob.noise_rate_prototype === nothing`, i.e. only diagonal noise is currently supported. Track https://github.com/SciML/DiffEqGPU.jl/issues/331 for more information." sol=solve( + monteprob, SRA1(), EnsembleCPUArray(), trajectories = 10_000, saveat = 1.0f0)