Skip to content

Draft: restore BDF step size after tstop truncation#2

Draft
dpastoor wants to merge 1 commit into
mainfrom
draft/bdf-tstop-restore-step-size
Draft

Draft: restore BDF step size after tstop truncation#2
dpastoor wants to merge 1 commit into
mainfrom
draft/bdf-tstop-restore-step-size

Conversation

@dpastoor

Copy link
Copy Markdown
Member

Summary

  • Track the BDF step size before set_stop_time truncates a step to land exactly on tstop.
  • When TstopReached is returned, rescale the BDF difference history back to the pre-truncation step size so the truncated stop interval does not become the next proposed step size.
  • Add a focused regression test and a runnable reproducer.

Why draft

This preserves the documented TstopReached behavior that state.t == tstop, but it changes the meaning of state.h immediately after a stop: after TstopReached, state.h is the restored proposed next step size rather than the just-used truncated interval. That may be the right behavior for checkpoint/restart, but it is worth maintainer review before treating this as the final API contract.

This branch is independent of #1. It intentionally does not include the n_equal_steps checkpoint-state change.

Reproducer

Command:

cargo run -p diffsol --example bdf_tstop_reproducer

Output from this branch:

BDF tstop checkpoint/restart reproducer
ODE: dy/dt = -0.1 y, t in [0, 10], 100 output targets
rtol=0.000001, atol=0.00000001, h0=0.001

single sweep                                    55
cold restart at each target                     2100
checkpoint/restart + set_stop_time              320
checkpoint/restart + overshoot/interpolate      268

The set_stop_time row remains above the single sweep because this branch does not include #1. The key behavior tested here is that stop-time truncation no longer pins the checkpointed/proposed step size to the dense output spacing.

Tests

  • cargo test -p diffsol bdf_tstop_restores_pre_truncation_step_size -- --nocapture
  • cargo test -p diffsol test_tstop_bdf -- --nocapture
  • cargo check -p diffsol --examples
  • cargo run -p diffsol --example bdf_tstop_reproducer

@dpastoor dpastoor force-pushed the draft/bdf-tstop-restore-step-size branch from d8f8b19 to 23137c0 Compare June 12, 2026 02:19
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.

1 participant