Skip to content

Commit

Permalink
fix dt scaling when scale_noise==false
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightup1 committed Dec 8, 2023
1 parent 9d8eb55 commit fe43d9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/caches/dynamical_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
function alg_cache(alg::BAOAB,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prototype,jump_rate_prototype,::Type{uEltypeNoUnits},::Type{uBottomEltypeNoUnits},::Type{tTypeNoUnits},uprev,f,t,dt,::Type{Val{false}}) where {uEltypeNoUnits,uBottomEltypeNoUnits,tTypeNoUnits}
k = zero(rate_prototype.x[1])
c1 = exp(-alg.gamma*dt)
c2 = sqrt(1 - alg.scale_noise*c1^2) # if scale_noise == false, c2 = 1
c2 = alg.scale_noise ? sqrt((1 - c1^2)/abs(dt)) : 1 # if scale_noise == false, c2 = 1
BAOABConstantCache(k, uEltypeNoUnits(1//2), uEltypeNoUnits(c1), uEltypeNoUnits(c2))
end

Expand All @@ -34,7 +34,7 @@ function alg_cache(alg::BAOAB,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prototy

half = uEltypeNoUnits(1//2)
c1 = exp(-alg.gamma*dt)
c2 = sqrt(1 - alg.scale_noise*c1^2) # if scale_noise == false, c2 = 1
c2 = alg.scale_noise ? sqrt((1 - c1^2)/abs(dt)) : 1 # if scale_noise == false, c2 = 1

tmp = zero(u)

Expand Down
4 changes: 2 additions & 2 deletions src/perform_step/dynamical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ end
u2 = u1 + half*dt*du2

# O
noise = integrator.g(u2,p,t+dt*half).*W.dW / sqdt
noise = integrator.g(u2,p,t+dt*half).*W.dW
du3 = c1*du2 + c2*noise

# A
Expand All @@ -69,7 +69,7 @@ end

# O
integrator.g(gtmp,utmp,p,t+dt*half)
@.. noise = gtmp*W.dW / sqdt
@.. noise = gtmp*W.dW
@.. dutmp = c1*dutmp + c2*noise

# A
Expand Down

0 comments on commit fe43d9d

Please sign in to comment.