Skip to content

Commit

Permalink
force stepfail once before erroring
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Aug 20, 2017
1 parent 39691c5 commit 8518980
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/integrators/integrator_utils.jl
Expand Up @@ -3,7 +3,7 @@

# Accept or reject the step
if integrator.iter > 0
if (integrator.opts.adaptive && integrator.accept_step) || !integrator.opts.adaptive
if ((integrator.opts.adaptive && integrator.accept_step) || !integrator.opts.adaptive) && !integrator.force_stepfail
integrator.success_iter += 1
apply_step!(integrator)
elseif integrator.opts.adaptive && !integrator.accept_step
Expand Down Expand Up @@ -129,9 +129,13 @@ end
@inline function loopfooter!(integrator::SDEIntegrator)
ttmp = integrator.t + integrator.dt
if integrator.force_stepfail
integrator.last_stepfail = true
integrator.accept_step = false
if integrator.opts.adaptive
integrator.dtnew = integrator.dt/integrator.opts.failfactor
elseif integrator.last_stepfail
error("Newton steps could not converge and algorithm is not adaptive. Use a lower dt.")
end
integrator.last_stepfail = true
integrator.accept_step = false
elseif integrator.opts.adaptive
@fastmath integrator.q11 = integrator.EEst^integrator.opts.beta1
@fastmath integrator.q = integrator.q11/(integrator.qold^integrator.opts.beta2)
Expand Down Expand Up @@ -159,6 +163,7 @@ end
else
integrator.t = ttmp
end
integrator.last_stepfail = false
integrator.accept_step = true
integrator.dtpropose = integrator.dt
handle_callbacks!(integrator)
Expand Down

0 comments on commit 8518980

Please sign in to comment.