Skip to content

Commit

Permalink
add docs for the generic classes from other branch and update
Browse files Browse the repository at this point in the history
  • Loading branch information
balos1 committed Aug 28, 2024
1 parent a0348a2 commit 53c9bcc
Show file tree
Hide file tree
Showing 10 changed files with 420 additions and 76 deletions.
43 changes: 38 additions & 5 deletions doc/arkode/guide/source/Usage/ARKStep/ASA.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,53 @@
Adjoint Sensitivity Analysis
============================

The previous sections discuss using ARKStep for the intergation of forward ODE models.
This section discusses how to use ARKStep for adjoint sensitivity analysis as introduced
in :numref:`ARKODE.Mathematics.ASA`. To use ARKStep for ASA, users simply setup the forward
integration as usual (following :numref:`ARKODE.Usage.Skeleton`) with one exception:
a :c:type:`SUNAdjointCheckpointScheme` object must be provided to the forward ARKStep stepper
creating a :c:type:`SUNAdjointCheckpointScheme` object and then calling
:c:func:`ARKodeSetAdjointCheckpointScheme` before the call to the :c:func:`ARKodeEvolve`
function. After the forward model integration code, a :c:type:`SUNAdjointStepper` object
can be created for the adjoint model integration by calling :c:func:`ARKStepCreateAdjointStepper`.
The code snippet below demonstrates these steps in brief and the example code
``examples/arkode/C_serial/ark_lotka_volterra_asa.c`` demonstrates these steps in detail.

.. code-block:: C
// 1. Create a SUNAdjointCheckpointScheme object
// 2. Setup ARKStep for forward integration
// 3. Attach the SUNAdjointCheckpointScheme
// 4. Evolve the forward model
// 5. Create the SUNAdjointStepper
// 6. Setup the adjoint model
// 7. Evolve the adjoint model
// 8. Cleanup
User Callable Functions
-----------------------

This section describes ARKStep-specific user-callable functions for performing
adjoint sensitivity analysis with methods with ARKStep.


.. c:function:: int ARKStepCreateAdjointStepper(void* arkode_mem, N_Vector sf, SUNAdjointStepper* adj_stepper_ptr)
Creates a :c:type:`SUNAdjointStepper` object compatible with the provided ARKStep instance for
Creates a :c:type:`SUNAdjointStepper` object compatible with the provided ARKStep instance for
integrating the adjoint sensitivity system :eq:`ARKODE_ADJOINT_ODE`.
:param arkode_mem: a pointer to the ARKStep memory block.
:param sf: the sensitivity vector holding the adjoint system terminal condition.
This must be an instance of the ManyVector ``N_Vector`` implementation with two subvectors.
The first subvector must hold :math:`\partial g/\partial y |_{t=t_f} \in \mathbb{R}^N` and the second subvector must
hold :math:`\partial g / \partial p |_{t=t_f} \in \mathbb{R}^d`.
This must be an instance of the ManyVector ``N_Vector`` implementation with two subvectors.
The first subvector must hold :math:`\partial g/\partial y |_{t=t_f} \in \mathbb{R}^N` and the second subvector must hold :math:`\partial g / \partial p |_{t=t_f} \in \mathbb{R}^d`.
:param adj_stepper_ptr: the newly created :c:type:`SUNAdjointStepper` object.

:return:
Expand Down
3 changes: 2 additions & 1 deletion doc/arkode/guide/source/sunadjoint/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
SUNDIALS Copyright End
----------------------------------------------------------------

.. _SUNAdaptController:
.. _SUNAdjoint:

###########################
Adjoint Sensitivty Analysis
Expand All @@ -24,6 +24,7 @@ sensitivity analysis (ASA). The API itself does not implement ASA, but it provid
interface for ASA capabilties implemented in the SUNDIALS packages. Right now it supports :ref:`the
ASA capabilties in ARKODE <ARKODE.Mathematics.ASA>`, while the ASA capabilities in :ref:`CVODES
<CVODES.Mathematics.ASA>` and :ref:`IDAS <IDAS.Mathematics.ASA>` must be used directly.
*Users should read the package specific sections on ASA capabiltiies before this section.*

.. toctree::
:maxdepth: 1
Expand Down
17 changes: 0 additions & 17 deletions doc/shared/sunadjoint/SUNAdjointCheckpointScheme.rst

This file was deleted.

17 changes: 0 additions & 17 deletions doc/shared/sunadjoint/SUNAdjointStepper.rst

This file was deleted.

Loading

0 comments on commit 53c9bcc

Please sign in to comment.