Skip to content

Commit 8a55fa0

Browse files
Merge pull request #189 from devmotion/eps
Fix eps() for types with units
2 parents f2966ce + 7066c1c commit 8a55fa0

File tree

3 files changed

+109
-107
lines changed

3 files changed

+109
-107
lines changed

src/integrators/integrator_utils.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,10 @@ function loopfooter!(integrator)
260260
integrator.last_stepfail = false
261261
dtnew = step_accept_controller!(integrator,integrator.alg,q)
262262
integrator.tprev = integrator.t
263-
if typeof(integrator.t)<:AbstractFloat && !isempty(integrator.opts.tstops)
263+
# integrator.EEst has unitless type of integrator.t
264+
if typeof(integrator.EEst)<: AbstractFloat && !isempty(integrator.opts.tstops)
264265
tstop = top(integrator.opts.tstops)
265-
abs(ttmp - tstop) < 10eps(integrator.t) ? (integrator.t = tstop) : (integrator.t = ttmp)
266+
abs(ttmp - tstop) < 10eps(integrator.EEst)*oneunit(integrator.t) ? (integrator.t = tstop) : (integrator.t = ttmp)
266267
else
267268
integrator.t = ttmp
268269
end
@@ -271,9 +272,10 @@ function loopfooter!(integrator)
271272
end
272273
elseif !integrator.opts.adaptive #Not adaptive
273274
integrator.tprev = integrator.t
274-
if typeof(integrator.t)<:AbstractFloat && !isempty(integrator.opts.tstops)
275+
# integrator.EEst has unitless type of integrator.t
276+
if typeof(integrator.EEst)<: AbstractFloat && !isempty(integrator.opts.tstops)
275277
tstop = top(integrator.opts.tstops)
276-
abs(ttmp - tstop) < 10eps(integrator.t) ? (integrator.t = tstop) : (integrator.t = ttmp)
278+
abs(ttmp - tstop) < 10eps(integrator.EEst)*oneunit(integrator.t) ? (integrator.t = tstop) : (integrator.t = ttmp)
277279
else
278280
integrator.t = ttmp
279281
end

0 commit comments

Comments
 (0)