Commit 2ad6f5a
committed
Fix spurious tiny final step for fixed-dt methods
When solving with a fixed-dt method (e.g. `solve(prob, Euler(); dt = 0.1)`),
the accumulated `t + dt + dt + ...` drifts past `tspan[end]` by one ulp,
producing a spurious trailing micro-step. PR #2869 removed the old
`100eps(tstop)` snap in `fixed_t_for_floatingpoint_error!` that masked this.
Fix: add a floating-point tolerance (`100 * eps(max(|t|, |tstop|))`) to
the `dt < distance_to_tstop` comparison in `modify_dt_for_tstops!`.
When `dt ≈ distance` within rounding the integrator now takes the tstop
branch, and `fixed_t_for_tstop_error!` snaps `t` to the exact tstop
value — eliminating the extra step.
Adds a regression test covering forward, reverse, and non-evenly-
dividing `dt` on `tspan = (0.0, 1.0)`.
Fixes the PositiveIntegrators.jl CI failure noted in
NumericalMathematics/PositiveIntegrators.jl#192.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>1 parent ba0dfa2 commit 2ad6f5a
2 files changed
Lines changed: 36 additions & 2 deletions
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
184 | 195 | | |
185 | | - | |
| 196 | + | |
186 | 197 | | |
187 | 198 | | |
188 | 199 | | |
| |||
198 | 209 | | |
199 | 210 | | |
200 | 211 | | |
201 | | - | |
| 212 | + | |
202 | 213 | | |
203 | 214 | | |
204 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
275 | 298 | | |
276 | 299 | | |
277 | 300 | | |
| |||
0 commit comments