-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
DimensionError with unitful dt
for stochastic integrator
#529
Comments
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
.StochasticDiffEq.jl/src/integrators/type.jl
Line 33 in 0cd915e
This line thus fails with a
DimensionError
ifdt
is eg inns
during__init
, since the calculated unit forsqdt
will besqrt(ns)
:StochasticDiffEq.jl/src/solve.jl
Line 596 in 0cd915e
The text was updated successfully, but these errors were encountered: