Skip to content

Add DASSL-style ires backtracking with physical rejection retries (idid = -4)#53

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/extend-rhs-sub-interface
Draft

Add DASSL-style ires backtracking with physical rejection retries (idid = -4)#53
Copilot wants to merge 2 commits into
mainfrom
copilot/extend-rhs-sub-interface

Conversation

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

This change introduces DASSL-like callback semantics so fun can reject physically inadmissible trial steps without hard-stopping integration. ires = -1 now triggers step rollback + halving retry, while ires < -1 remains an interrupt path (idid = -2).

  • Solver contract and status model

    • Clarified rhs_sub callback contract in code/docs:
      • ires = 0 → normal
      • ires = -1 → reject trial step and retry with smaller step
      • ires < -1 → interrupt integration
    • Added solver exit code idid = -4 for rejection-limit termination (too many physical rejections).
  • Core integration flow (stiff3_core)

    • Added per-outer-step physical rejection counter (nphys) and retry loop.
    • Applied rejection handling at every RHS evaluation point, including accepted-step endpoint RHS evaluation.
    • On ires = -1, solver now restores pre-attempt state (y, f, df), halves h, resets icon, increments rejection stats, and retries.
    • If nphys > 10, solver exits with idid = -4 using restored safe state.
  • Stage solver propagation (sirk3)

    • Ensured internal RHS call is ires-aware (ires=0 before call).
    • Returns early on any nonzero ires so caller (stiff3_core) applies -1 retry vs <-1 interrupt semantics.
  • Tests

    • Updated existing interrupt test behavior where ires=-1 had been used as a hard interrupt signal (now uses <-1 for interrupt).
    • Added ode_phys_reject coverage for:
      • recovery after transient ires=-1 rejections (idid=0)
      • rejection-limit termination with persistent ires=-1 (idid=-4)
    • Registered new test target in test CMake list.
  • Documentation

    • Updated README callback semantics and exit-flag table to include the new ires behavior and idid=-4.
subroutine fun(n, y, f, ires)
  integer, intent(in) :: n
  real(wp), intent(in) :: y(n)
  real(wp), intent(inout) :: f(n)
  integer, intent(inout) :: ires

  f(1) = -y(1)

  ! Ask solver to reject and backtrack this trial step
  if (y(1) < 0.0_wp) ires = -1

  ! Hard interrupt remains available via ires < -1
  ! if (fatal_condition) ires = -2
end subroutine

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