@@ -29,8 +29,7 @@ function SciMLBase.__init(
29
29
! default_linear_interpolation (prob, alg),
30
30
calck = (callback != = nothing && callback != = CallbackSet ()) ||
31
31
(dense) || ! isempty (saveat), # and no dense output
32
- dt = isdiscretealg (alg) && isempty (tstops) ?
33
- eltype (prob. tspan)(1 ) : eltype (prob. tspan)(0 ),
32
+ dt = nothing ,
34
33
dtmin = eltype (prob. tspan)(0 ),
35
34
dtmax = eltype (prob. tspan)((prob. tspan[end ] - prob. tspan[1 ])),
36
35
force_dtmin = false ,
@@ -127,7 +126,7 @@ function SciMLBase.__init(
127
126
if (((! (alg isa OrdinaryDiffEqAdaptiveAlgorithm) &&
128
127
! (alg isa OrdinaryDiffEqCompositeAlgorithm) &&
129
128
! (alg isa DAEAlgorithm)) || ! adaptive || ! isadaptive (alg)) &&
130
- dt == tType ( 0 ) && isempty (tstops)) && dt_required (alg)
129
+ isnothing (dt ) && isempty (tstops)) && dt_required (alg)
131
130
throw (ArgumentError (" Fixed timestep methods require a choice of dt or choosing the tstops" ))
132
131
end
133
132
if ! isadaptive (alg) && adaptive
@@ -343,7 +342,7 @@ function SciMLBase.__init(
343
342
alg_choice = _alg isa CompositeAlgorithm ? Int[] : nothing
344
343
345
344
if (! adaptive || ! isadaptive (_alg)) && save_everystep && tspan[2 ] - tspan[1 ] != Inf
346
- if dt == 0
345
+ if isnothing (dt)
347
346
steps = length (tstops)
348
347
else
349
348
# For fixed dt, the only time dtmin makes sense is if it's smaller than eps().
@@ -400,14 +399,16 @@ function SciMLBase.__init(
400
399
else
401
400
uprev2 = uprev
402
401
end
403
-
402
+
403
+ _dt = isdiscretealg (alg) && isempty (tstops) ?
404
+ eltype (prob. tspan)(1 ) : eltype (prob. tspan)(0 )
404
405
if prob isa DAEProblem
405
406
cache = alg_cache (_alg, du, u, res_prototype, rate_prototype, uEltypeNoUnits,
406
- uBottomEltypeNoUnits, tTypeNoUnits, uprev, uprev2, f, t, dt ,
407
+ uBottomEltypeNoUnits, tTypeNoUnits, uprev, uprev2, f, t, _dt ,
407
408
reltol_internal, p, calck, Val (isinplace (prob)))
408
409
else
409
410
cache = alg_cache (_alg, u, rate_prototype, uEltypeNoUnits, uBottomEltypeNoUnits,
410
- tTypeNoUnits, uprev, uprev2, f, t, dt , reltol_internal, p, calck,
411
+ tTypeNoUnits, uprev, uprev2, f, t, _dt , reltol_internal, p, calck,
411
412
Val (isinplace (prob)))
412
413
end
413
414
@@ -494,8 +495,8 @@ function SciMLBase.__init(
494
495
# we don't want to differentiate through eigenvalue estimation
495
496
eigen_est = inv (one (tType))
496
497
tprev = t
497
- dtcache = tType (dt )
498
- dtpropose = tType (dt )
498
+ dtcache = tType (_dt )
499
+ dtpropose = tType (_dt )
499
500
iter = 0
500
501
kshortsize = 0
501
502
reeval_fsal = false
@@ -530,7 +531,7 @@ function SciMLBase.__init(
530
531
typeof (opts), typeof (fsalfirst),
531
532
typeof (last_event_error), typeof (callback_cache),
532
533
typeof (initializealg), typeof (differential_vars)}(
533
- sol, u, du, k, t, tType (dt ), f, p,
534
+ sol, u, du, k, t, tType (_dt ), f, p,
534
535
uprev, uprev2, duprev, tprev,
535
536
_alg, dtcache, dtchangeable,
536
537
dtpropose, tdir, eigen_est, EEst,
@@ -596,7 +597,7 @@ function SciMLBase.__init(
596
597
end
597
598
end
598
599
599
- handle_dt! (integrator)
600
+ handle_dt! (integrator, dt )
600
601
integrator
601
602
end
602
603
632
633
633
634
# Helpers
634
635
635
- function handle_dt! (integrator)
636
- if iszero (integrator . dt) && integrator. opts. adaptive
636
+ function handle_dt! (integrator, dt )
637
+ if isnothing ( dt) && integrator. opts. adaptive
637
638
auto_dt_reset! (integrator)
638
639
if sign (integrator. dt) != integrator. tdir && ! iszero (integrator. dt) &&
639
640
! isnan (integrator. dt)
0 commit comments