SciML / StochasticDiffEq.jl

Solvers for stochastic differential equations which connect with the scientific machine learning (SciML) ecosystem
Other
245 stars 66 forks source link

Error with constant cache for BAOAB #517

Closed jebej closed 1 year ago

jebej commented 1 year ago

The following errors out because the cache logic tries to copyto! to a Float64(I suppose it expected an array). I'm not too sure how the whole machinery works, so I don't know how to fix this.

using StochasticDiffEq
jj!(ϕ′,ϕ,τ,β,I) = (I - ϕ′ - sin(ϕ))/β
jj!(ϕ′,ϕ,p::Tuple,τ) = jj!(ϕ′,ϕ,τ,p[1],p[2])
identity_sde(v, u, p, t) = v # needed to form second order SDE
g(u,p,t) = 1

ϕ_init = 0.0
ϕ′_init = 0.0
tspan = (0.0,50.0)
β = 1.25
I = 2.0
prob = DynamicalSDEProblem{false}(jj!,identity_sde,g,ϕ′_init,ϕ_init,tspan,(β,I))

solve(prob,BAOAB(),dt=1/10)
jebej commented 1 year ago

Pinging @jamesgardner1421 who implemented this.

ChrisRackauckas commented 1 year ago

https://github.com/SciML/StochasticDiffEq.jl/pull/518 looks like a fine fix.

jamesgardner1421 commented 1 year ago

Just opened a PR that should fix this for you. Originally I only ever tested it with arrays but it will also work with scalars once the PR is merged.

jebej commented 1 year ago

Thanks! I also wanted to ask about the form of the SDE, but I'll open a new issue.