Skip to content

Commit fe43d9d

Browse files
committed
fix dt scaling when scale_noise==false
1 parent 9d8eb55 commit fe43d9d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/caches/dynamical_caches.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
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}
2121
k = zero(rate_prototype.x[1])
2222
c1 = exp(-alg.gamma*dt)
23-
c2 = sqrt(1 - alg.scale_noise*c1^2) # if scale_noise == false, c2 = 1
23+
c2 = alg.scale_noise ? sqrt((1 - c1^2)/abs(dt)) : 1 # if scale_noise == false, c2 = 1
2424
BAOABConstantCache(k, uEltypeNoUnits(1//2), uEltypeNoUnits(c1), uEltypeNoUnits(c2))
2525
end
2626

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

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

3939
tmp = zero(u)
4040

src/perform_step/dynamical.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ end
4242
u2 = u1 + half*dt*du2
4343

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

4848
# A
@@ -69,7 +69,7 @@ end
6969

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

7575
# A

0 commit comments

Comments
 (0)