Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/PALC/correction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ function palc_correction!(
if cb_trig && !rf_succ # Triggered callback but rootfind was unsuccessful
cb_trig = false
hit_bnd = NaN
if abs(cache.ds)==dsmin # check if ds=dsmin to avoid getting stuck repeating the failed rootfind
done = true
success = false
set_min_stepsize_retcode!(cache) # failed termination if this occurs
end
scale_and_clamp_ds!(cache, 0.5, dsmin, dsmax)
elseif isnan(hit_bnd)
# Push solution and set done
Expand Down Expand Up @@ -120,7 +125,7 @@ function palc_correction!(
if abs(cache.ds) == dsmin
done = true
success = false
cache.ret = :MinimumStepSize # update ret with 'done' condition. This won't be overwritten since success=false (see continuation.jl)
set_min_stepsize_retcode!(cache) # update ret with 'done' condition. This won't be overwritten since success=false (see continuation.jl)
else
# Reduce step-size and reattempt
scale_and_clamp_ds!(cache, 0.5, dsmin, dsmax)
Expand Down Expand Up @@ -248,6 +253,11 @@ function palc_correction!(
if cb_trig && !rf_succ # Triggered callback but rootfind was unsuccessful
cb_trig = false
hit_bnd = NaN
if abs(cache.ds)==dsmin # check if ds=dsmin to avoid getting stuck repeating the failed rootfind
done = true
success = false
set_min_stepsize_retcode!(cache) # failed termination if this occurs
end
scale_and_clamp_ds!(cache, 0.5, dsmin, dsmax)
elseif isnan(hit_bnd)
# Push solution and set done
Expand Down Expand Up @@ -278,7 +288,7 @@ function palc_correction!(
if abs(cache.ds) == dsmin
done = true
success = false
cache.ret = :MinimumStepSize # update ret with 'done' condition. This won't be overwritten since success=false (see continuation.jl)
set_min_stepsize_retcode!(cache) # update ret with 'done' condition. This won't be overwritten since success=false (see continuation.jl)
else
# Reduce step-size and reattempt
scale_and_clamp_ds!(cache, 0.5, dsmin, dsmax)
Expand Down Expand Up @@ -575,4 +585,9 @@ function set_successful_retcode!(cache, hit_bnd, cb_trig, jj)
elseif !cb_trig
cache.ret = :HitBound
end
end

function set_min_stepsize_retcode!(cache)
cache.ret = :MinimumStepSize
return nothing
end
Loading