Skip to content

Commit

Permalink
Add JACOBIAN_REUSE_THRESHOLD, and default it to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Mar 8, 2019
1 parent ea13bf3 commit 580ea42
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/derivative_utils.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const JACOBIAN_REUSE_THRESHOLD = Ref(3)

function calc_tderivative!(integrator, cache, dtd1, repeat_step)
@inbounds begin
@unpack t,dt,uprev,u,f,p = integrator
Expand Down Expand Up @@ -265,7 +267,7 @@ function calc_W!(integrator, cache::OrdinaryDiffEqMutableCache, dtgamma, repeat_
elseif DiffEqBase.has_jac(f) && f.jac_prototype !== nothing
# skip calculation of J if step is repeated
if repeat_step || (alg_can_repeat_jac(alg) &&
(!integrator.last_stepfail && nl_iters == 1 &&
(!integrator.last_stepfail && nl_iters <= JACOBIAN_REUSE_THRESHOLD[] &&
ηold < alg.new_jac_conv_bound))
new_jac = false
else
Expand All @@ -285,7 +287,7 @@ function calc_W!(integrator, cache::OrdinaryDiffEqMutableCache, dtgamma, repeat_
else # concrete W using jacobian from `calc_J!`
# skip calculation of J if step is repeated
if repeat_step || (alg_can_repeat_jac(alg) &&
(!integrator.last_stepfail && nl_iters == 1 &&
(!integrator.last_stepfail && nl_iters < JACOBIAN_REUSE_THRESHOLD[] &&
ηold < alg.new_jac_conv_bound))
new_jac = false
else
Expand Down

0 comments on commit 580ea42

Please sign in to comment.