Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sundials.jl does not work with ArrayPartition from RecursiveArrayTools.jl #331

Open
mauro3 opened this issue Nov 20, 2021 · 1 comment
Open

Comments

@mauro3
Copy link
Contributor

mauro3 commented Nov 20, 2021

This errors:

using OrdinaryDiffEq, RecursiveArrayTools

function problem!(du, u, p, t)
    h, ϕ = u.x
    dh, dϕ = du.x
    dh .= 0.5 * h
    dϕ .= 0.1 * ϕ
end

h0 = rand(3, 4)
ϕ0 = rand(3, 4)
u0 = ArrayPartition(h0, ϕ0)

tspan = (0.0, 1e3)
prob = ODEProblem(problem!, u0, tspan)
sol = solve(prob, Tsit5()) # works
sol = solve(prob, CVODE_BDF())

with

ERROR: MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type ArrayPartition{Float64, Tuple{Matrix{Float64}, Matrix{Float64}}}
Closest candidates are:
...

Feel free to close if this is not going to be supported.

@ChrisRackauckas
Copy link
Member

Someone could do a kind of "reinterpret to a vector" kind of thing to get it to work in Sundials. Basically have a uvec created for internal to the binary and keep that separate from the one in the f and just u .= uvec if it's not a type that is compatible with the binary. It would have a bit of overhead like that but it's possible. I don't think it's a priority though, especially with the waning use cases where Sundials is actually faster, so I'll keep it open but don't plan to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants