Skip to content

Commit

Permalink
refactor interpolation step
Browse files Browse the repository at this point in the history
  • Loading branch information
oameye committed Feb 23, 2024
1 parent 63a186b commit e4bfeb8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/largedeviations/geometric_min_action_method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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`.
Expand Down

0 comments on commit e4bfeb8

Please sign in to comment.