Skip to content

Feature: stop time adaptivity#914

Closed
drreynolds wants to merge 579 commits into
developfrom
feature/fes-tstop-adaptivity
Closed

Feature: stop time adaptivity#914
drreynolds wants to merge 579 commits into
developfrom
feature/fes-tstop-adaptivity

Conversation

@drreynolds
Copy link
Copy Markdown
Collaborator

@drreynolds drreynolds commented Apr 16, 2026

This PR adds optional routines to the SUNDIALS time integrators so that time steps which are shortened to adhere to "stop time" requests will be disregarded from the time step and method order adaptivity processes.

This feature is disabled by default; if after extensive testing we wish to enable this by default, I recommend that this wait until the next major release.

@gardner48 gardner48 changed the title Feature/fes tstop adaptivity Feature: stop time adaptivity May 25, 2026
Comment thread doc/arkode/guide/source/Usage/User_callable.rst Outdated
.. versionadded:: 6.1.0


.. c:function:: int ARKodeSkipAdaptStopTime(void* arkode_mem, sunbooleantype skip)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this a threshold instead of a boolean? So the check would be something like the following

sunrealtype eta_stop = h_stop / h;
if (eta_stop < skip_adapt_stop_time_eta_threshold)
{ 
  skip_adapt_stop_time = SUNTRUE;
}
else 
{
  skip_adapt_stop_time = SUNFALSE;
}

so a threshold of 1 skips adaptivity if the stop time reduced the step size and 0 always adapts (the current default behavior).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a future release, I think a better default might be 1/eta_max, so any stop time step that can't return to the old step size is ignored.

Comment thread doc/shared/RecentChanges.rst Outdated
Comment thread examples/cvode/CXX_serial/cv_kpr.cpp
Comment thread src/ida/ida.c Outdated
Comment thread src/ida/ida.c Outdated
Comment thread src/ida/ida.c
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside IDAStep set tstoplimited = SUNFALSE if the step with stop time step size needs to be reattempted

Comment thread src/ida/ida_impl.h Outdated
Comment thread src/idas/idas.c
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as in IDA

@drreynolds
Copy link
Copy Markdown
Collaborator Author

In updating this PR, I updated the X_test_tstop.c unit test for each package to examine this feature, on the simplest-possible test problem y'(t) = 1, y(0)=0. Strangely, while the option indeed reduced the number of time steps with IDA, with CVODE the number of time steps was unchanged, and with ARKODE it increased. While I think that this feature is important, it is clear to me that its implementation will require more work, so I'm rescinding the PR for now. After this release, I'll try to take time to fix the implementation, and correctly add support for the threshold-based approach.

@drreynolds drreynolds closed this May 27, 2026
@gardner48 gardner48 removed this from the SUNDIALS v7.8.0 milestone May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants