Skip to content

Commit

Permalink
add param to disable noise term scaling for BAOAB
Browse files Browse the repository at this point in the history
  • Loading branch information
jebej committed Jan 9, 2023
1 parent d30c9bc commit b133fed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -866,5 +866,6 @@ dv = f(v,u) dt - \gamma v dt + g(u) \sqrt{2\gamma} dW
"""
struct BAOAB{T} <: StochasticDiffEqAlgorithm
gamma::T
scale_noise::Bool
end
BAOAB(;gamma=1.0) = BAOAB(gamma)
BAOAB(;gamma=1.0, scale_noise=true) = BAOAB(gamma, scale_noise)
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 - c1^2)
c2 = sqrt(1 - alg.scale_noise*c1^2) # 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 - c1^2)
c2 = sqrt(1 - alg.scale_noise*c1^2) # if scale_noise == false, c2 = 1

tmp = zero(u)

Expand Down

0 comments on commit b133fed

Please sign in to comment.