Skip to content

Commit

Permalink
fix langevin_girsanov() typos
Browse files Browse the repository at this point in the history
  • Loading branch information
axsk committed Sep 20, 2024
1 parent 9dc01e1 commit d6f963c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/simulators/openmm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -458,24 +458,26 @@ function langevin_girsanov(sim, q, steps, u)
M = repeat(masses(sim), inner=3)

# Maxwell-Boltzmann distribution
p = randn(length(M)) .* sqrt(M .* kB .* T)
p = randn(length(M)) .* sqrt.(M .* kB .* T)

t2 = dt / 2
a = @. t2 / M # eq 18
d = @. exp(-ξ * dt) # eq 17
f = @. sqrt(kB * T * M * (1 - exp(-2 * γ * dt))) # eq 17
f = @. sqrt(kB * T * M * (1 - exp(-2 * ξ * dt))) # eq 17

b = similar(p)
η = similar(p)
Δη = similar(p)
F = similar(p)
g = 0


for i in 1:steps
randn!(η)
@. q += a * p # A

# girsanov part
F = u(q) # perturbation force ∇U_bias = -F
F .= u(q) # perturbation force ∇U_bias = -F
@. Δη = (d + 1) / f + dt / 2 * F
g += η' * Δη + Δη' * Δη / 2
F .+= force(sim, q) # total force: -∇V - ∇U_bias
Expand All @@ -490,5 +492,9 @@ function langevin_girsanov(sim, q, steps, u)
return q, exp(-g)
end

function batcheddot(x, y)
sum(a .* y, dims=1)
end


end #module

0 comments on commit d6f963c

Please sign in to comment.