Commit 48a4bc9
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
`100eps(tstop)` snap hack that previously masked this.
Fix: for non-adaptive, dtchangeable algorithms with no user-supplied
tstops / d_discontinuities / callbacks, expand `tstops` to the range
`tspan[1]:dt:tspan[end]` whose TwicePrecision arithmetic gives exact
floating-point tstops, and inflate `dt` by 10 ulps so that
`modify_dt_for_tstops!` always takes the tstop branch and snaps `t`
exactly via `fixed_t_for_tstop_error!`.
The expansion is intentionally skipped for adaptive algorithms (even
when used with `adaptive=false`), `CompositeAlgorithm`, non-finite
tspans, and any solve with callbacks — preserving all existing
stepping semantics in those cases.
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 48a4bc9
2 files changed
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
404 | 431 | | |
405 | 432 | | |
406 | 433 | | |
| |||
| 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 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
275 | 301 | | |
276 | 302 | | |
277 | 303 | | |
| |||
0 commit comments