Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

Fixes #136

When solving a NoiseProblem with a NoiseGrid where the dt doesn't evenly divide the time span, floating point errors could cause the solver to report "Stepped past the defined domain for the NoiseGrid".

Root Cause

This occurred because:

  1. After many steps with dt=0.01 over tspan [0.0, 10.0], floating point errors accumulate and W.curt ends up at ~9.9999999999 instead of exactly 10.0
  2. The step_setup flag gets set to false when W.curt + dt > W.t[end]
  3. The while loop continues because W.curt < prob.tspan[2] (still slightly less due to floating point)
  4. accept_step! errors because step_setup is false

Fix

The fix adds two checks in the solve loop:

  1. If we're essentially at the end (within floating point tolerance), exit the loop
  2. If the next step would overshoot the end, take a partial final step to reach exactly the end, resetting step_setup if necessary

Test Plan

  • Added test case for the exact issue from stepping past domain #136 (dt=0.01 with grid step 0.1)
  • Added test case where dt doesn't evenly divide the time span (dt=0.03 over [0,1])
  • Added test case with scalar noise values
  • All existing tests pass (except pre-existing failure in correlated.jl which also fails on master)

cc @ChrisRackauckas

🤖 Generated with Claude Code

…ivide time span

When solving a NoiseProblem with a NoiseGrid where the dt doesn't evenly divide
the time span, floating point errors could cause the solver to report "Stepped past
the defined domain for the NoiseGrid".

This occurred because:
1. After many steps with dt=0.01 over tspan [0.0, 10.0], floating point errors
   accumulate and W.curt ends up at ~9.9999999999 instead of exactly 10.0
2. The step_setup flag gets set to false when W.curt + dt > W.t[end]
3. The while loop continues because W.curt < prob.tspan[2] (floating point)
4. accept_step! errors because step_setup is false

The fix adds two checks in the solve loop:
1. If we're essentially at the end (within floating point tolerance), exit
2. If the next step would overshoot, take a partial final step to reach exactly
   the end, resetting step_setup if necessary

Fixes SciML#136

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

stepping past domain

2 participants