Skip to content

Commit d363a68

Browse files
authored
Merge pull request #373 from godardma/codac2_dev
[doc] fixed capd doc organization (peibos_capd not displayed)
2 parents 85feefd + 2af34c2 commit d363a68

2 files changed

Lines changed: 16 additions & 208 deletions

File tree

doc/manual/manual/extensions/capd/capd.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ To use CAPD with Codac, you first need to install the CAPD library. You can find
1212
Note that as CAPD is a C++ only library, the content present in this page is **only available in C++**.
1313

1414

15-
.. _subsec-extensions-capd-capd-install:
1615
Installing the ``codac-capd`` extension
1716
---------------------------------------
1817

@@ -52,6 +51,18 @@ The header of the ``codac-capd`` extension is not included by default. You need
5251
#include <codac-capd.h>
5352
#include <capd/capdlib.h>
5453

54+
Furthermore, you need to link the extension to your project, for instance by updating your ``CMakeLists.txt`` with::
55+
56+
add_executable(${PROJECT_NAME} main.cpp)
57+
target_compile_options(${PROJECT_NAME} PUBLIC ${CODAC_CXX_FLAGS})
58+
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${CODAC_INCLUDE_DIRS} ${CODAC_CAPD_INCLUDE_DIR})
59+
target_link_libraries(${PROJECT_NAME} PRIVATE
60+
${CODAC_LIBRARIES}
61+
${CODAC_CAPD_LIBRARY} # linking to the codac-capd extension
62+
capd::capd # linking to CAPD
63+
Ibex::ibex
64+
)
65+
5566
You can use the functions ``to_capd`` and ``to_codac`` to convert between CAPD and Codac objects as follows:
5667

5768
.. tabs::
@@ -200,4 +211,4 @@ The result is the following figure, with in green the initial set (:math:`t=0s`)
200211
.. figure:: img/pendulum_result.png
201212
:width: 500px
202213

203-
Result of the CAPD integration of the pendulum, enclosed in a Codac tube.
214+
Result of the CAPD integration of the pendulum, enclosed in a Codac tube.

doc/manual/manual/extensions/capd/index.rst

Lines changed: 3 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -5,210 +5,7 @@ CAPD (rigorous numerics in dynamical systems)
55

66
Main author: `Maël Godard <https://godardma.github.io>`_
77

8-
This page describes how to use the CAPD library with Codac. CAPD is a C++ library for rigorous numerics in dynamical systems.
8+
.. toctree::
99

10-
To use CAPD with Codac, you first need to install the CAPD library. You can find the installation instructions on the `CAPD website <http://capd.ii.uj.edu.pl/html/capd_compilation.html>`_.
11-
12-
Note that as CAPD is a C++ only library, the content present in this page is **only available in C++**.
13-
14-
15-
Installing the ``codac-capd`` extension
16-
---------------------------------------
17-
18-
To install the ``codac-capd`` extension, you need to install the Codac library from its sources. This can be done :ref:`by using CMake <sec-install-cpp>` with the option ``WITH_CAPD=ON``. For example:
19-
20-
.. code-block:: bash
21-
22-
cmake -DCMAKE_INSTALL_PREFIX=$HOME/ibex-lib/build_install -DCMAKE_BUILD_TYPE=Release -DWITH_CAPD=ON ..
23-
24-
We highly recommend to test the installation of the library with the provided tests. To do so, you can use the following command:
25-
26-
.. code-block:: bash
27-
28-
make test
29-
30-
31-
Content
32-
-------
33-
34-
The ``codac-capd`` extension provides functions to convert CAPD objects to Codac objects and vice versa.
35-
36-
The functions are ``to_capd`` and ``to_codac``. They can be used to convert the following objects:
37-
38-
- ``capd::Interval`` :math:`\leftrightarrow` ``codac2::Interval``
39-
- ``capd::IVector`` :math:`\leftrightarrow` ``codac2::IntervalVector``
40-
- ``capd::IMatrix`` :math:`\leftrightarrow` ``codac2::IntervalMatrix``
41-
- ``capd::ITimeMap::SolutionCurve`` :math:`\rightarrow` ``codac2::SlicedTube<codac2::IntervalVector>``
42-
43-
44-
How to use
45-
----------
46-
47-
The header of the ``codac-capd`` extension is not included by default. You need to include it manually in your code, together with the CAPD library:
48-
49-
.. code-block:: c++
50-
51-
#include <codac-capd.h>
52-
#include <capd/capdlib.h>
53-
54-
Furthermore, you need to link the extension to your project, for instance by updating your ``CMakeLists.txt`` with::
55-
56-
add_executable(${PROJECT_NAME} main.cpp)
57-
target_compile_options(${PROJECT_NAME} PUBLIC ${CODAC_CXX_FLAGS})
58-
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${CODAC_INCLUDE_DIRS} ${CODAC_CAPD_INCLUDE_DIR})
59-
target_link_libraries(${PROJECT_NAME} PRIVATE
60-
${CODAC_LIBRARIES}
61-
${CODAC_CAPD_LIBRARY} # linking to the codac-capd extension
62-
capd::capd # linking to CAPD
63-
Ibex::ibex
64-
)
65-
66-
You can use the functions ``to_capd`` and ``to_codac`` to convert between CAPD and Codac objects as follows:
67-
68-
.. tabs::
69-
70-
.. code-tab:: c++
71-
72-
codac2::Interval codac_interval(0,2); // Codac interval [0, 2]
73-
capd::Interval capd_interval = to_capd(codac_interval); // convert to CAPD interval
74-
codac2::Interval codac_interval2 = to_codac(capd_interval); // convert back to Codac interval
75-
76-
77-
Example
78-
-------
79-
80-
.. image:: img/pendulum.png
81-
:alt: State variables of the pendulum
82-
:align: right
83-
:width: 130px
84-
85-
For this example we will consider the pendulum with friction.
86-
87-
The state variables of the pendulum are its angle :math:`\theta` and its angular velocity :math:`\omega`. The pendulum follows the following dynamic:
88-
89-
.. math::
90-
91-
\left(\begin{array}{c}
92-
\dot{\theta}\\
93-
\dot{\omega}
94-
\end{array}\right)=\left(\begin{array}{c}
95-
\omega\\
96-
-\sin(\theta)\cdot\frac{g}{l}-0.5\omega
97-
\end{array}\right),
98-
99-
100-
where :math:`g` is the gravity constant and :math:`l` is the length of the pendulum.
101-
102-
This equation can be passed to the CAPD library as follows:
103-
104-
.. tabs::
105-
106-
.. group-tab:: C++
107-
108-
.. literalinclude:: src.cpp
109-
:language: c++
110-
:start-after: [codac-capd-2-beg]
111-
:end-before: [codac-capd-2-end]
112-
:dedent: 2
113-
114-
To solve this ODE, an ``IOdeSolver`` object is necessary.
115-
116-
.. tabs::
117-
118-
.. group-tab:: C++
119-
120-
.. literalinclude:: src.cpp
121-
:language: c++
122-
:start-after: [codac-capd-3-beg]
123-
:end-before: [codac-capd-3-end]
124-
:dedent: 2
125-
126-
CAPD then uses an ``ITimeMap`` to make the link between a time step and the solution of the ODE at this time. The ``I`` here stands for ``Interval`` as the solution is an interval guaranteed to enclose the solution. Here we will integrate the ODE between :math:`t_0=0s` and :math:`t_f=20s`.
127-
128-
.. tabs::
129-
130-
.. group-tab:: C++
131-
132-
.. literalinclude:: src.cpp
133-
:language: c++
134-
:start-after: [codac-capd-4-beg]
135-
:end-before: [codac-capd-4-end]
136-
:dedent: 2
137-
138-
To completly define the ODE, we need to define the initial conditions. Here we will set the initial angle to :math:`\theta_0=-\frac{\pi}{2}` and the
139-
initial angular velocity to :math:`\omega_0=0`. For the purpose of this example, we will add a small uncertainty to the initial conditions. The initial conditions are then defined as follows:
140-
141-
.. tabs::
142-
143-
.. group-tab:: C++
144-
145-
.. literalinclude:: src.cpp
146-
:language: c++
147-
:start-after: [codac-capd-5-beg]
148-
:end-before: [codac-capd-5-end]
149-
:dedent: 2
150-
151-
There are then two ways to get the result of the integration depending on the use case.
152-
153-
If the desired result is the solution of the ODE at a given time (here say :math:`T=1s`), we can do as follows:
154-
155-
.. tabs::
156-
157-
.. group-tab:: C++
158-
159-
.. literalinclude:: src.cpp
160-
:language: c++
161-
:start-after: [codac-capd-6-beg]
162-
:end-before: [codac-capd-6-end]
163-
:dedent: 2
164-
165-
**Be careful, this method modifies the initial set** ``s`` **in place**.
166-
167-
If the desired result is the solution curve (or tube) of the ODE on the time domain :math:`[t_0,t_f]`, we can do as follows:
168-
169-
.. tabs::
170-
171-
.. group-tab:: C++
172-
173-
.. literalinclude:: src.cpp
174-
:language: c++
175-
:start-after: [codac-capd-7-beg]
176-
:end-before: [codac-capd-7-end]
177-
:dedent: 2
178-
179-
The variable ``solution`` is the desired solution curve (or tube). The operator ``solution(t)`` gives the solution at time :math:`t`.
180-
It can be converted into a Codac ``SlicedTube<IntervalVector>`` with the function ``to_codac``. This functions takes two arguments:
181-
182-
- the ``capd::ITimeMap::SolutionCurve`` to convert.
183-
- a ``codac2::TDomain`` object defining the temporal domain of the tube.
184-
185-
The resulting ``SlicedTube`` will have the same time domain as the one given in argument, completed with the CAPD gates. An example of conversion is :
186-
187-
.. tabs::
188-
189-
.. group-tab:: C++
190-
191-
.. literalinclude:: src.cpp
192-
:language: c++
193-
:start-after: [codac-capd-8-beg]
194-
:end-before: [codac-capd-8-end]
195-
:dedent: 2
196-
197-
A full display can be done with the following code:
198-
199-
.. tabs::
200-
201-
.. group-tab:: C++
202-
203-
.. literalinclude:: src.cpp
204-
:language: c++
205-
:start-after: [codac-capd-9-beg]
206-
:end-before: [codac-capd-9-end]
207-
:dedent: 4
208-
209-
The result is the following figure, with in green the initial set (:math:`t=0s`) and in red the final set (:math:`t=20s`). The ``SlicedTube`` is displayed in blue with a black edge for better visibility. The orange rectangles correspond to the gates (degenerate slices).
210-
211-
.. figure:: img/pendulum_result.png
212-
:width: 500px
213-
214-
Result of the CAPD integration of the pendulum, enclosed in a Codac tube.
10+
capd.rst
11+
peibos_capd.rst

0 commit comments

Comments
 (0)