Open jebej opened 1 year ago
The random values should have a sqrt(dt) factor for this to work.
I'm sorry, I can't see where the random values affect this issue. Is it not simply a question of changing the type parameter?
FWIW this is the example:
using Unitful, OrdinaryDiffEq, StochasticDiffEq
using Unitful: uconvert, GHz, J, ns
ℎ = Unitful.h # Plank constant
jj2!(ϕ′,ϕ,(M,η,Ej,i),t) = (Ej*i - Ej*sin(ϕ))/M # BAOAB version
identity_f(v,u,p,t) = v # needed to form second order dynamical ODE
g(u,p,t) = 1.0
setup_noisy_jj(M,η,Ej,i,ϕ_init=0.0,ϕ′_init=0.0/ns,tspan=(0ns,1ns)) =
DynamicalSDEProblem{false}(jj2!,identity_f,g,ϕ′_init,ϕ_init,tspan,(M,η,Ej,i))
# underdamped
M = 4.2E-28*J*ns^2
η = 1.1E-26*J*ns
Ej = ℎ * 50GHz
i = 0.0 # unitless
prob = setup_noisy_jj(M,η,Ej,i,0.5)
res = solve(prob,BAOAB(η/M, false),dt=0.001ns)
without the randomness having the appropriate sqrt(t) units, you will later just get a type error that sqrt(t) + t units are combined. We can definitely expand that type signature but I don't think it's enough to get around that.
Currently the type for the
sqdt
parameter ofSDEIntegrator
istType
, which is the same as the type fordt
. https://github.com/SciML/StochasticDiffEq.jl/blob/0cd915e95485a62e31368c90201f79d0606eebcf/src/integrators/type.jl#L33This line thus fails with a
DimensionError
ifdt
is eg inns
during__init
, since the calculated unit forsqdt
will besqrt(ns)
: https://github.com/SciML/StochasticDiffEq.jl/blob/0cd915e95485a62e31368c90201f79d0606eebcf/src/solve.jl#L596