diff --git a/src/derivatives.jl b/src/derivatives.jl index b5c7e409..3439aa27 100644 --- a/src/derivatives.jl +++ b/src/derivatives.jl @@ -71,11 +71,6 @@ function _derivative(A::SmoothedConstantInterpolation{<:AbstractVector}, t::Numb idx = get_idx(A, t, iguess) d_lower, d_upper, c_lower, c_upper = get_parameters(A, idx) - # Fix extrapolation behavior as constant for now - if t <= first(A.t) || t >= last(A.t) - return zero(c_upper / oneunit(t)) - end - if (t - A.t[idx]) < d_lower -2c_lower * ((t - A.t[idx]) / d_lower - 1) / d_lower elseif (A.t[idx + 1] - t) < d_upper diff --git a/src/parameter_caches.jl b/src/parameter_caches.jl index c5e1daf1..ca1f6c00 100644 --- a/src/parameter_caches.jl +++ b/src/parameter_caches.jl @@ -54,13 +54,11 @@ function smoothed_constant_interpolation_parameters( if isone(idx) || (idx == length(t)) # If extrapolation is periodic, make the transition differentiable if extrapolation_left == extrapolation_right == ExtrapolationType.Periodic - if isone(idx) - min(t[end] - t[end - 1], t[2] - t[1], 2d_max) / 2, (u[1] - u[end - 1]) / 2 - else - min(t[end] - t[end - 1], t[2] - t[1], 2d_max) / 2, (u[1] - u[end - 1]) / 2 - end + min(t[end] - t[end - 1], t[2] - t[1], 2d_max) / 2, (u[1] - u[end - 1]) / 2 else - zero(one(eltype(t)) / 2), zero(one(eltype(u)) / 2) + d = isone(idx) ? min(t[2] - t[1], 2d_max) / 2 : + min(t[end] - t[end - 1], 2d_max) / 2 + d, zero(one(eltype(u)) / 2) end else min(t[idx] - t[idx - 1], t[idx + 1] - t[idx], 2d_max) / 2, (u[idx] - u[idx - 1]) / 2