Skip to content

Commit b133fed

Browse files
committed
add param to disable noise term scaling for BAOAB
1 parent d30c9bc commit b133fed

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/algorithms.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,5 +866,6 @@ dv = f(v,u) dt - \gamma v dt + g(u) \sqrt{2\gamma} dW
866866
"""
867867
struct BAOAB{T} <: StochasticDiffEqAlgorithm
868868
gamma::T
869+
scale_noise::Bool
869870
end
870-
BAOAB(;gamma=1.0) = BAOAB(gamma)
871+
BAOAB(;gamma=1.0, scale_noise=true) = BAOAB(gamma, scale_noise)

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 - c1^2)
23+
c2 = sqrt(1 - alg.scale_noise*c1^2) # 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 - c1^2)
37+
c2 = sqrt(1 - alg.scale_noise*c1^2) # if scale_noise == false, c2 = 1
3838

3939
tmp = zero(u)
4040

0 commit comments

Comments
 (0)