Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relaxation Runge-Kutta Methods #298

Merged
merged 123 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
5d6b64b
adding relaxation to ARKStep
gardner48 Feb 10, 2022
245685b
remove unused file
gardner48 Feb 10, 2022
a1447b1
update comments
gardner48 Feb 10, 2022
a3fe4e9
add example input option to enable/disable relaxation
gardner48 Feb 10, 2022
a928afb
fix bug with temp vector
gardner48 Feb 10, 2022
eb23896
update output
gardner48 Feb 11, 2022
4cfc0ba
add RK4
gardner48 Feb 11, 2022
0e7ff63
print relaxation value
gardner48 Feb 11, 2022
1e33087
fix indexing typo
gardner48 Feb 11, 2022
cbae50d
add more member vars
gardner48 Feb 11, 2022
f0534ac
Merge branch 'develop' into feature/relax
gardner48 Mar 10, 2022
c2c8917
get relaxation working for ERK methods
gardner48 Mar 10, 2022
753f38e
Merge branch 'develop' into feature/relax
gardner48 Aug 10, 2022
0f9b8b8
Merge branch 'develop' into feature/relax
gardner48 Sep 21, 2022
f91de2c
clean up relaxation
gardner48 Oct 17, 2022
b65b7c9
Merge branch 'develop' into feature/relax
gardner48 Oct 22, 2022
8d021e5
forgot to add new header
gardner48 Oct 24, 2022
eff781d
add plotting script
gardner48 Oct 24, 2022
611bbae
add dissipative example
gardner48 Oct 25, 2022
175b52e
ARKStep relaxation function documentation
gardner48 Oct 25, 2022
1114c6a
Merge branch 'develop' into feature/relax
gardner48 Oct 31, 2022
634abf4
Merge branch 'develop' into feature/relax
gardner48 Dec 19, 2022
9fab3e4
fix typos in docs
gardner48 Dec 19, 2022
1fccc8a
Merge branch 'develop' into feature/relax
gardner48 Jan 9, 2023
6c96ca9
documentation updates
gardner48 Jan 10, 2023
001f46e
doc updates and corrections
gardner48 Jan 10, 2023
4644bad
add relax output to PrintAllStats
gardner48 Jan 10, 2023
eff65e1
fix compiler warning
gardner48 Jan 10, 2023
8e9431d
fix build error with info logging enabled
gardner48 Jan 11, 2023
d54b53e
fix typo
gardner48 Jan 11, 2023
07fd288
unstash ERKStep updates
gardner48 Jan 11, 2023
6aed8b0
add ERKStep docs
gardner48 Jan 11, 2023
0844c41
limit max relax failures in a step
gardner48 Jan 11, 2023
2a4a302
add missing returns
gardner48 Jan 11, 2023
ddbe760
rename ARKRelaxationSolver
gardner48 Jan 11, 2023
026c44a
add versionadded to docs
gardner48 Jan 11, 2023
b35db96
clean up examples, fix error in Jac
gardner48 Jan 11, 2023
6a715f9
check for negative b values in Butcher table
gardner48 Jan 11, 2023
6579f8c
clean up examples
gardner48 Jan 11, 2023
13b94d4
fix bug in loop index
gardner48 Jan 18, 2023
f62f656
use precision specific functions
gardner48 Jan 18, 2023
7849e91
fix include order dependency
gardner48 Jan 18, 2023
6f5b6ae
add example utilites header for C examples
gardner48 Jan 18, 2023
0f63ab2
add fixed step option
gardner48 Jan 18, 2023
9188f2e
pendulum example
gardner48 Jan 18, 2023
4e33a5a
Merge branch 'develop' into feature/relax
gardner48 Apr 4, 2023
f5a4eb2
Merge branch 'develop' into feature/relax
gardner48 Jun 1, 2023
5c838f7
update submodules
gardner48 Jun 1, 2023
d6fd877
fix submodule updates
gardner48 Jun 1, 2023
e9431b7
add missing breaks
gardner48 Jun 1, 2023
3f5ef4c
fix memory leak
gardner48 Jun 1, 2023
cbf00bf
Merge branch 'develop' into feature/relax
gardner48 Jul 3, 2023
5591e5f
debugging output
gardner48 Jul 3, 2023
fa41480
simplify interface for single relaxation equation
gardner48 Jul 3, 2023
4df0f81
skeleton of Brent's method
gardner48 Jul 4, 2023
4b65a10
change tol to res_tol, update default
gardner48 Jul 4, 2023
ddb50ec
switch to better DIRK method
gardner48 Jul 5, 2023
c7557cd
add relaxation errors to failure handler
gardner48 Jul 5, 2023
d0065e6
move different_sign to impl header, add same_sign
gardner48 Jul 5, 2023
3dc7084
have RelaxResidual functions compute relaxed state
gardner48 Jul 5, 2023
7849e8e
debugging output
gardner48 Jul 5, 2023
c5848a7
unrecoverable error with fixed stepping + relaxation
gardner48 Jul 5, 2023
4ee0243
use previous gamma as initial guess
gardner48 Jul 5, 2023
84ecaeb
add Brent's method
gardner48 Jul 5, 2023
e060d42
debugging output
gardner48 Jul 5, 2023
259e1c4
Store stages for relaxation with implicit/IMEX methods
gardner48 Jul 5, 2023
e0a0995
add comment about storing stages
gardner48 Jul 5, 2023
bfe5613
remove some debugging output
gardner48 Jul 5, 2023
9423522
fix delta_e in ERKStep
gardner48 Jul 5, 2023
365801d
update table checks
gardner48 Jul 5, 2023
8cdcf97
revise math docs
gardner48 Jul 5, 2023
40b3903
revise usage docs
gardner48 Jul 5, 2023
ae99a93
revise user supplied fn doc
gardner48 Jul 5, 2023
ed0e039
sync and clean up examples
gardner48 Jul 5, 2023
e38231f
correct Norsett method
gardner48 Jul 5, 2023
0a30a27
remove new include
gardner48 Jul 5, 2023
c3d0d81
update comment
gardner48 Jul 5, 2023
43e2018
update ERK method check
gardner48 Jul 5, 2023
bb12a94
update table of constants
gardner48 Jul 6, 2023
69cbd00
remove debugging output
gardner48 Jul 6, 2023
229c0d0
reduce example output
gardner48 Jul 6, 2023
f691c65
return error if relaxation + deduce implicit RHS
gardner48 Jul 6, 2023
64dbe25
add example .out files
gardner48 Jul 6, 2023
4717f4e
update output for test machine
gardner48 Jul 6, 2023
6bd135c
remove debugging logging output
gardner48 Jul 6, 2023
4f673a0
add step length tol to Newton and tol set function
gardner48 Jul 6, 2023
ebc6158
regen Fortran interfaces
gardner48 Jul 6, 2023
bf78e13
update tarscript
gardner48 Jul 6, 2023
27c9140
fix doc typo
gardner48 Jul 6, 2023
d5f22bd
add missing file to tarscript
gardner48 Jul 6, 2023
01ea484
include current director in install tests
gardner48 Jul 6, 2023
0baf4e8
update answers commit
gardner48 Jul 6, 2023
a365711
Merge branch 'develop' into feature/relax
gardner48 Jul 11, 2023
75037f7
switch to multiple of h for accpetable relax parameter range, fix inp…
gardner48 Jul 12, 2023
df07f7e
remove fixed-point option
gardner48 Jul 12, 2023
0879758
doc updates
gardner48 Jul 12, 2023
6f12a96
regenerate f2003
gardner48 Jul 12, 2023
79f3ea5
revert change to bound factor
gardner48 Jul 12, 2023
2755dc0
Apply suggestions from code review
gardner48 Jul 13, 2023
601555b
doc updates
gardner48 Jul 12, 2023
da0e872
fix typos in comments
gardner48 Jul 13, 2023
7aee4dd
fix compiler warnings (GCC 12)
gardner48 Jul 13, 2023
81aeada
add warnings to shared utility headers
gardner48 Jul 13, 2023
aeea427
update lrw and liw
gardner48 Jul 13, 2023
8cb706b
update comment on relaxation actions
gardner48 Jul 13, 2023
28aeb86
check if N_VDotProdMultiAllReduce is provided
gardner48 Jul 13, 2023
84894cc
simplify PrintAllStats
gardner48 Jul 13, 2023
0614414
add bound fails to PrintAllStats
gardner48 Jul 13, 2023
0590610
adjust temporary vector usage
gardner48 Jul 13, 2023
08214bd
update workspace size in output files
gardner48 Jul 13, 2023
103c489
support fixed mass matrix
gardner48 Jul 13, 2023
f44dd15
save stages with fixed M to reduce mass solves
gardner48 Jul 14, 2023
2e59e75
add back missing b[i] after add M support
gardner48 Jul 14, 2023
f502c00
remove example utilities
gardner48 Jul 14, 2023
94b1133
add note about mass matrix support
gardner48 Jul 14, 2023
c0d7201
point users to references for examples
gardner48 Jul 14, 2023
194ac3d
remove example_utilties.h from CMake files
gardner48 Jul 14, 2023
6eb07bf
add back CXX example utils in CMake
gardner48 Jul 14, 2023
b66adfa
update example outputs
gardner48 Jul 14, 2023
4c86a0d
udpate answers submodule commit
gardner48 Jul 14, 2023
5322b3a
update .out file for Jenkins
gardner48 Jul 14, 2023
bc4b209
fix typo in output
gardner48 Jul 14, 2023
b574ae7
Merge branch 'develop' into feature/relax
balos1 Jul 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Changes to SUNDIALS in release 6.6.0

Added support for relaxation Runge-Kutta methods to ERKStep and ARKStep in
ARKODE.

Added the second order IMEX method from Giraldo, Kelly, and Constantinescu 2013
as the default second order IMEX method in ARKStep. The explicit table is given
by `ARKODE_ARK2_ERK_3_1_2` and the implicit table by `ARKODE_ARK2_DIRK_3_1_2`.
Expand Down
21 changes: 21 additions & 0 deletions doc/arkode/guide/source/Constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ contains the ARKODE output constants.
+---------------------------------------------+-----------------------------------------------------------+
| |
+---------------------------------------------+-----------------------------------------------------------+
| **Relaxtion module input constants** |
+---------------------------------------------+-----------------------------------------------------------+
| :index:`ARK_RELAX_BRENT` | Specifies Brent's method as the relaxation nonlinear |
| | solver. |
+---------------------------------------------+-----------------------------------------------------------+
| :index:`ARK_RELAX_NEWTON` | Specifies Newton's method as the relaxation nonlinear |
| | solver. |
+---------------------------------------------+-----------------------------------------------------------+
| |
+---------------------------------------------+-----------------------------------------------------------+
| **Explicit Butcher table specification** |
+---------------------------------------------+-----------------------------------------------------------+
| :index:`ARKODE_HEUN_EULER_2_1_2` | Use the Heun-Euler-2-1-2 ERK method. |
Expand Down Expand Up @@ -377,6 +387,17 @@ contains the ARKODE output constants.
+-------------------------------------+------+------------------------------------------------------------+
| :index:`ARK_INVALID_TABLE` | -41 | An invalid Butcher or MRI table was encountered. |
+-------------------------------------+------+------------------------------------------------------------+
| :index:`ARK_CONTEXT_ERR` | -42 | An error occurred with the SUNDIALS context object |
+-------------------------------------+------+------------------------------------------------------------+
| :index:`ARK_RELAX_FAIL` | -43 | An error occurred in computing the relaxation parameter |
+-------------------------------------+------+------------------------------------------------------------+
| :index:`ARK_RELAX_MEM_FAIL` | -44 | The relaxation memory structure is ``NULL`` |
+-------------------------------------+------+------------------------------------------------------------+
| :index:`ARK_RELAX_FUNC_FAIL` | -45 | The relaxation function returned an unrecoverable error |
+-------------------------------------+------+------------------------------------------------------------+
| :index:`ARK_RELAX_JAC_FAIL` | -46 | The relaxation Jacobian function returned an unrecoverable |
| | | error |
+-------------------------------------+------+------------------------------------------------------------+
| :index:`ARK_UNRECOGNIZED_ERROR` | -99 | An unknown error was encountered. |
+-------------------------------------+------+------------------------------------------------------------+
| |
Expand Down
5 changes: 5 additions & 0 deletions doc/arkode/guide/source/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ Changes from previous versions
Changes in v5.6.0
-----------------


Added support for relaxation Runge-Kutta methods in ERKStep and ARKStep, see
:numref:`ARKODE.Mathematics.Relaxation`, :numref:`ARKODE.Usage.ERKStep.Relaxation`,
and :numref:`ARKODE.Usage.ARKStep.Relaxation` for more information.

Added the second order IMEX method from :cite:p:`giraldo2013implicit` as the
default second order IMEX method in ARKStep. The explicit table is given by
``ARKODE_ARK2_ERK_3_1_2`` (see :numref:`Butcher.ARK2_ERK`) and the implicit
Expand Down
63 changes: 63 additions & 0 deletions doc/arkode/guide/source/Mathematics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2074,3 +2074,66 @@ step attempt, or fails with the minimum step size, then the integration is halte
and an error is returned. In this case the user may need to employ other
strategies as discussed in :numref:`ARKODE.Usage.ARKStep.Tolerances` and
:numref:`ARKODE.Usage.ERKStep.Tolerances` to satisfy the inequality constraints.

.. _ARKODE.Mathematics.Relaxation:

Relaxation Methods
==================

For cases where the problem :eq:`ARKODE_IVP` is conservative or dissipative with
respect to a smooth *convex* function :math:`\xi(y(t))`, it is desirable to have
the numerical method preserve these properties. That is
:math:`\xi(y_n) = \xi(y_{n-1}) = \ldots = \xi(y_{0})` for conservative problems
and :math:`\xi(y_n) \leq \xi(y_{n-1})` for dissipative problems. To this end,
ARKODE supports relaxation methods
:cite:p:`ketcheson2019relaxation, kang2022entropy, ranocha2020relaxation`
applied to ERK, DIRK, or ARK methods to ensure dissipation or preservation of a
global function.

The relaxed solution is given by

.. math::
y_r = y_{n-1} + r d = r y_n + (1 - r) y_{n - 1}
:label: ARKODE_RELAX_SOL

where :math:`d \equiv h_n \sum_{i=1}^{s}(b^E_i f^E_i + b^I_i f^I_i)` is the
update direction and the relaxation factor, :math:`r`, is selected to ensure
conservation or dissipation. Given an ERK, DIRK, or ARK method of at least
second order with non-negative solution weights (i.e., :math:`b_i \geq 0` for
ERKStep or :math:`b^E_i \geq 0` and :math:`b^I_i \geq 0` for ARKStep), the
factor :math:`r` is computed by solving the auxiliary scalar nonlinear system

.. math::
F(r) = \xi(y_{n-1} + r d) - \xi(y_{n-1}) - r e = 0
:label: ARKODE_RELAX_NLS

at the end of each time step. The estimated change in :math:`\xi` is given by
:math:`e \equiv h_n \sum_{i=1}^{s} \langle \xi'(z_i), b^E_i f^E_i + b^I_i f^I_i \rangle`
where :math:`\xi'` is the Jacobian of :math:`\xi`.

Two iterative methods are provided for solving :eq:`ARKODE_RELAX_NLS`, Newton's
method and Brent's method. When using Newton's method (the default), the
iteration is halted either when the residual tolerance is met,
:math:`F(r^{(k)}) < \epsilon_{\mathrm{relax\_res}}`, or when the difference
between successive iterates satisfies the relative and absolute tolerances,
:math:`|\delta_r^{(k)}| = |r^{(k)} - r^{(k-1)}| < \epsilon_{\mathrm{relax\_rtol}} |r^{(k-1)}| + \epsilon_{\mathrm{relax\_atol}}`.
Brent's method applies the same residual tolerance check and additionally halts
when the bisection update satisfies the relative and absolute tolerances,
:math:`|0.5 (r_c - r^{k})| < \epsilon_{\mathrm{relax\_rtol}} |r^{(k)}| + 0.5 \epsilon_{\mathrm{relax\_atol}}`
where :math:`r_c` and :math:`r^{(k)}` bound the root.

If the nonlinear solve fails to meet the specified tolerances within the maximum
allowed number of iterations, the step size is reduced by the factor
:math:`\eta_\mathrm{rf}` (default 0.25) and the step is repeated. Additionally,
the solution of :eq:`ARKODE_RELAX_NLS` should be
:math:`r = 1 + \mathcal{O}(h_n^{q - 1})` for a method of order :math:`q`
:cite:p:`ranocha2020relaxation`. As such, limits are imposed on the range of
relaxation values allowed (i.e., limiting the maximum change in step size due to
relaxation). A relaxation value greater than :math:`r_\text{max}` (default 1.2)
or less than :math:`r_\text{min}` (default 0.8), is considered as a failed
relaxation application and the step will is repeated with the step size reduced
by :math:`\eta_\text{rf}`.

For more information on utilizing relaxation Runge--Kutta methods, see
:numref:`ARKODE.Usage.ERKStep.Relaxation` and
:numref:`ARKODE.Usage.ARKStep.Relaxation`.
Loading