From e4bfeb8be70783b363c197bfbaece3d5948c42d2 Mon Sep 17 00:00:00 2001 From: oameye Date: Fri, 23 Feb 2024 10:28:17 +0100 Subject: [PATCH] refactor interpolation step --- .../geometric_min_action_method.jl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/largedeviations/geometric_min_action_method.jl b/src/largedeviations/geometric_min_action_method.jl index 9a12f31a..501ece14 100644 --- a/src/largedeviations/geometric_min_action_method.jl +++ b/src/largedeviations/geometric_min_action_method.jl @@ -76,13 +76,7 @@ function geometric_min_action_method(sys::StochSystem, init::Matrix, arclength = end # re-interpolate - s = zeros(N) - for j in 2:N - s[j] = s[j - 1] + anorm(update_path[:, j] - update_path[:, j - 1], sys.Σ) #! anorm or norm? - end - s_length = s / s[end] * arclength - interp = ParametricSpline(s_length, update_path, k = 3) - path = reduce(hcat, [interp(x) for x in range(0, arclength, length = N)]) + path = interpolate_path(update_path, sys, N, arclength) push!(paths, path) push!(action, S(path)) @@ -96,6 +90,17 @@ function geometric_min_action_method(sys::StochSystem, init::Matrix, arclength = paths, action end +function interpolate_path(path, sys, N, arclength) + s = zeros(N) + for j in 2:N + s[j] = s[j - 1] + anorm(path[:, j] - path[:, j - 1], sys.Σ) #! anorm or norm? + end + s_length = s / s[end] * arclength + interp = ParametricSpline(s_length, path, k = 3) + return reduce(hcat, [interp(x) for x in range(0, arclength, length = N)]) +end + + """ heymann_vandeneijnden_step(sys::StochSystem, path, N, L; kwargs...) Solves eq. (6) of Ref.[^1] for an initial `path` with `N` points and arclength `L`.