Skip to content

EnsembleGPUArray() incompatibility with SecondOrderODEProblem() #271

@shahabahreini

Description

@shahabahreini

Hi, I attempted to solve a second-order differential equation using a Julia library. However, I encountered an issue with the EnsembleGPUArray function, as the generated ensemble is not working as expected. Below, you can find the code that I used:

using DifferentialEquations, DataFrames, CSV, DelimitedFiles, RecursiveArrayTools, DiffEqGPU, CUDA

function lorenz_ddu(ddu, du, u, p, t)
    ddu[1] = p[1]*(du[2]-u[1])
    ddu[2] = u[1]*(p[2]-u[3]) - u[2]
    ddu[3] = u[1]*u[2] - p[3]*u[3]
end

function ensembleOutputExtracter(simulationResult, numTrajectories)
    for j = 1:min(numTrajectories, length(simulationResult))
        solnew = vcat(j, simulationResult[j].t', simulationResult[:, :, j])
        open("shahab.txt", "a+") do file
            writedlm(file, solnew', ',')
        end
    end
end

CUDA.set_runtime_version!("local")

u0 = [1.0, 1.0, 1.0]
du0 = [1.1, 1.2, 1.3]
tspan = (0.0, 100.0)
p = [10.0, 28.0, 8/3]
prob = SecondOrderODEProblem(lorenz_ddu, du0, u0, tspan, p)
prob_func = (prob, i, repeat) -> remake(prob, u0=rand(3).*u0, p=rand(3).*p)
monteprob = EnsembleProblem(prob, prob_func=prob_func, safetycopy=false)
sol = solve(monteprob, Tsit5(), EnsembleGPUArray(CUDA.CUDABackend(), 0.0), save_everystep=false, trajectories=10, saveat=1.0f0)
ensembleOutputExtracter(sol, 10)

Am I missing something?
Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions