Skip to content

Add tstops support via LSODA's tcrit mechanism#78

Merged
ChrisRackauckas merged 5 commits into
rveltz:masterfrom
ChrisRackauckas-Claude:tstops-support
Mar 25, 2026
Merged

Add tstops support via LSODA's tcrit mechanism#78
ChrisRackauckas merged 5 commits into
rveltz:masterfrom
ChrisRackauckas-Claude:tstops-support

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown

Summary

  • Replaces the tstops error with actual support using LSODA's built-in tcrit mechanism (itask=4/5)
  • Merges tstops into integration targets while tracking which times are save points, so tstops controls solver stepping without affecting output
  • Falls back to non-tcrit itask modes after all tstops are passed
  • Adds comprehensive tests for tstops with saveat, save_everystep, 2D problems, boundary filtering, and discontinuous RHS accuracy

How it works

The LSODA C library supports itask=4 (integrate to tout, don't step past tcrit) and itask=5 (one step, don't step past tcrit). This PR leverages these modes to implement tstops:

  1. tstops times are merged with saveat times into a combined list of integration targets
  2. A save_set tracks which targets should produce output (only saveat times)
  3. Before each integration segment, opt.tcrit is set to the next upcoming tstop
  4. Saves are gated on save_everystep || is_save_point

Test plan

  • Existing test suite passes (no regressions)
  • tstops with saveat produces correct save times
  • tstops with save_everystep=true includes tstop times in output
  • Multiple tstops with saveat
  • 2D problems with tstops
  • Boundary tstops (t0 and T) are filtered correctly
  • Combined save_everystep + saveat + tstops
  • Discontinuous RHS is solved accurately when tstop is placed at the discontinuity (error = 0.0 vs ~0.001 without tstops)

🤖 Generated with Claude Code

ChrisRackauckas and others added 5 commits March 25, 2026 07:04
Use itask=4/5 with opt.tcrit to prevent the solver from stepping past
user-specified tstops times. This enables correct handling of
discontinuities in the RHS without requiring callbacks.

- Merge tstops into integration targets, track save points separately
- Gate saves on save_everystep || is_save_point
- Fall back to non-tcrit itask after all tstops are passed
- Add tests for tstops with saveat, save_everystep, 2D problems,
  boundary filtering, and discontinuous RHS accuracy

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When tcrit is set to a tstop target, the solver is guaranteed not to
overstep it, so use a simpler loop without overstep/interpolation
handling. The overstep path is only needed for saveat-only targets
between tstops (itask=5 can still overshoot those).

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Always include T (end time) in tstops so the solver never steps past
  it. This eliminates the "don't overstep the last timestep" hack and
  always uses itask=4/5 with tcrit.
- Split the else branch (already past target) for tstops vs saveat:
  tstop targets just save (already there), saveat targets interpolate.
- Accept d_discontinuities kwarg and merge into tstops. Remove
  d_discontinuities from warnlist since it is now supported.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Direct mapping: dtmin → opt.hmin, dtmax → opt.hmax.
Removed dtmin/dtmax from warnlist.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
actions/checkout v2→v4, setup-julia v1→v2, actions/cache v1→v4,
codecov-action v1→v4. The v1 cache action was causing immediate CI
failures.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ChrisRackauckas ChrisRackauckas merged commit 8335965 into rveltz:master Mar 25, 2026
3 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.

2 participants