From d6f963c232039065ca532a777076093c947204b0 Mon Sep 17 00:00:00 2001 From: Sikorski Date: Fri, 20 Sep 2024 15:39:11 +0200 Subject: [PATCH] fix langevin_girsanov() typos --- src/simulators/openmm.jl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/simulators/openmm.jl b/src/simulators/openmm.jl index 2c7b1ee..1b89824 100644 --- a/src/simulators/openmm.jl +++ b/src/simulators/openmm.jl @@ -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 @@ -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 \ No newline at end of file