Skip to content

Commit d629b6c

Browse files
committed
allowing 0 callback time
1 parent 942c08a commit d629b6c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/callbacks.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ end
447447
end
448448

449449
# Evaluate condition slightly in future
450-
abst = integrator.tprev+integrator.tdir*max(abs(integrator.dt/10000),100*eps(integrator.t))
450+
abst = integrator.tprev+integrator.tdir*max(abs(integrator.dt/10000),100*eps(typeof(integrator.t)))
451451
tmp_condition = get_condition(integrator, callback, abst)
452452

453453
# Sometimes users may "switch off" the condition after crossing
@@ -525,7 +525,7 @@ end
525525
end
526526

527527
# Evaluate condition slightly in future
528-
abst = integrator.tprev+integrator.tdir*max(abs(integrator.dt/10000),100*eps(integrator.t))
528+
abst = integrator.tprev+integrator.tdir*max(abs(integrator.dt/10000),100*eps(typeof(integrator.t)))
529529
tmp_condition = get_condition(integrator, callback, abst)
530530

531531
# Sometimes users may "switch off" the condition after crossing
@@ -633,7 +633,7 @@ function find_callback_time(integrator,callback::ContinuousCallback,counter)
633633
Θ = top_t
634634
else
635635
if integrator.event_last_time == counter &&
636-
abs(zero_func(bottom_t)) < 100abs(integrator.last_event_error) &&
636+
abs(zero_func(bottom_t)) <= 100abs(integrator.last_event_error) &&
637637
prev_sign_index == 1
638638

639639
# Determined that there is an event by derivative
@@ -700,7 +700,7 @@ function find_callback_time(integrator,callback::VectorContinuousCallback,counte
700700
else
701701
if integrator.event_last_time == counter &&
702702
integrator.vector_event_last_time == event_idx &&
703-
abs(zero_func(bottom_t)) < 100abs(integrator.last_event_error) &&
703+
abs(zero_func(bottom_t)) <= 100abs(integrator.last_event_error) &&
704704
prev_sign_index == 1
705705

706706
# Determined that there is an event by derivative
@@ -754,10 +754,11 @@ function find_callback_time(integrator,callback::VectorContinuousCallback,counte
754754
end
755755

756756
function apply_callback!(integrator,callback::Union{ContinuousCallback,VectorContinuousCallback},cb_time,prev_sign,event_idx)
757-
if cb_time == zero(typeof(integrator.t))
758-
error("Event repeated at the same time. Please report this error")
759-
end
757+
760758
change_t_via_interpolation!(integrator,integrator.tprev+cb_time)
759+
if integrator.opts.adaptive
760+
integrator.dtpropose = integrator.dt/10
761+
end
761762

762763
# handle saveat
763764
_, savedexactly = savevalues!(integrator)

0 commit comments

Comments
 (0)