-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically convert incompatible vector problems to svector
Required for diffeqr and diffeqpy. Note that the `f` functions are okay when generated by MTK, since it generates a dispatch for SA -> SA, so therefore all that's needed is the u0 and p conversion for this to work downstream.
- Loading branch information
1 parent
518d95b
commit 8c95e15
Showing
5 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using DiffEqGPU, OrdinaryDiffEq, StaticArrays, LinearAlgebra | ||
include("../utils.jl") | ||
|
||
function lorenz(u, p, t) | ||
σ = p[1] | ||
ρ = p[2] | ||
β = p[3] | ||
du1 = σ * (u[2] - u[1]) | ||
du2 = u[1] * (ρ - u[3]) - u[2] | ||
du3 = u[1] * u[2] - β * u[3] | ||
return SVector{3}(du1, du2, du3) | ||
end | ||
|
||
u0 = [1.0f0; 0.0f0; 0.0f0] | ||
tspan = (0.0f0, 10.0f0) | ||
p = [10.0f0, 28.0f0, 8 / 3.0f0] | ||
prob = ODEProblem{false}(lorenz, u0, tspan, p) | ||
prob_func = (prob, i, repeat) -> remake(prob, p = (@SVector rand(Float32, 3)) .* p) | ||
monteprob = EnsembleProblem(prob, prob_func = prob_func, safetycopy = false) | ||
sol = solve(monteprob, GPUTsit5(), EnsembleGPUKernel(backend), | ||
trajectories = 10_000, | ||
saveat = 1.0f0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters