Skip to content

Fix PeriodicCallback with Rational Δt (DE #878) - #328

Merged
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:cr/periodic-rational-dt
Jul 24, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:cr/periodic-rational-dt

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

  • PeriodicCallback condition used exact t == t0 + index*Δt.
  • With Δt::Rational and t::Float64, equality is always false after t0 (Float64(3//10) == 3//10 is false), so the callback never re-fires.
  • Convert period targets and scheduled tstops into the integrator time type.

Fixes SciML/DifferentialEquations.jl#878

This PR should be ignored until reviewed by @ChrisRackauckas.

Test plan

  • Local: Rational 1//10 fires ~10 times on [0,1] (was 1)
  • Local: Float64 periods still work
  • CI: periodic_tests.jl

Exact equality `t == t0 + index*Δt` fails when integrator time is
Float64 and Δt is Rational (`Float64(3//10) == 3//10` is false).
Convert period targets and tstops into the integrator's time type so
Rational periods fire every step.

Fixes SciML/DifferentialEquations.jl#878

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 24, 2026 06:13
@ChrisRackauckas
ChrisRackauckas merged commit 5256ab3 into SciML:master Jul 24, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PeriodicCallback not triggering with Rational numbers

2 participants