From 93c93b18fa7bfe570ad7cd7b7b46410dc5b37e88 Mon Sep 17 00:00:00 2001 From: JDBetteridge Date: Wed, 9 Apr 2025 12:54:45 +0100 Subject: [PATCH 1/6] Add tape.png image --- docs/source/adjoint.rst | 20 +- docs/source/images/tape.png | 1746 +++++++++++++++++++++++++++++++++++ 2 files changed, 1756 insertions(+), 10 deletions(-) create mode 100644 docs/source/images/tape.png diff --git a/docs/source/adjoint.rst b/docs/source/adjoint.rst index e9298ae6f7..754dce1666 100644 --- a/docs/source/adjoint.rst +++ b/docs/source/adjoint.rst @@ -81,7 +81,7 @@ Consider now the function signatures of the symbols in :eq:`eq:djdm`. Here we ar only concerned with the arguments, as these determine the sizes of the resulting assembled tensors: -.. math:: +.. math:: :label: \frac{\mathrm{d}\hat{J}}{\mathrm{d}m}: M\rightarrow \mathbb{R} @@ -102,16 +102,16 @@ Instead, we define: .. math:: :label: eq:adjoint - + \lambda^*(\in V\rightarrow\mathbb{R}) = -\frac{\partial J}{\partial u}\frac{\partial f}{\partial u}^{-1}. We actually solve the adjoint to this equation. That is find `\lambda \in V` -such that: +such that: .. math:: :label: - \frac{\partial f}{\partial u}^{*}(u, m; \lambda, v) = + \frac{\partial f}{\partial u}^{*}(u, m; \lambda, v) = -\frac{\partial J}{\partial u}(u, m; v) \qquad \forall v \in V. Note that these terms include `u`, so it is first necessary to solve @@ -144,8 +144,8 @@ How Firedrake and Pyadjoint automate derivative calculation ----------------------------------------------------------- Firedrake automates the process in the preceding section using the methodology -first published in :cite:`Farrell2013` using the implementation in -`Pyadjoint `__ :cite:`Mitusch2019`. +first published in :cite:`Farrell2013` using the implementation in +`Pyadjoint `__ :cite:`Mitusch2019`. The essence of this process is: @@ -273,7 +273,7 @@ The sequence of recorded operations is stored on an object called the tape. The currently active tape can be accessed by calling :func:`~pyadjoint.get_working_tape`. The user usually has limited direct interaction with the tape, but there is some useful information which can be -extracted. +extracted. Visualising the tape ~~~~~~~~~~~~~~~~~~~~ @@ -289,11 +289,11 @@ are to be found on `the pygraphviz website .. _fig-tape: -.. figure:: images/tape.pdf +.. figure:: images/tape.png A visualisation of the Burgers equation example above shortened to a single timestep. Operations (blocks) recorded on the tape are shown as grey - rectangles, while taped variables are shown as ovals. + rectangles, while taped variables are shown as ovals. The numbered blocks in the tape visualisation are as follows: @@ -423,4 +423,4 @@ themselves with this since annotated operations will return overloaded types. :filter: False Farrell2013 - Mitusch2019 \ No newline at end of file + Mitusch2019 diff --git a/docs/source/images/tape.png b/docs/source/images/tape.png new file mode 100644 index 0000000000..d001b14fda --- /dev/null +++ b/docs/source/images/tape.png @@ -0,0 +1,1746 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e7c5e502f6e3ed0bb6e279aa719a1560475a44c5 Mon Sep 17 00:00:00 2001 From: JDBetteridge Date: Wed, 9 Apr 2025 15:06:44 +0100 Subject: [PATCH 2/6] The png was actually an svg --- docs/source/adjoint.rst | 2 +- docs/source/images/{tape.png => tape.svg} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/source/images/{tape.png => tape.svg} (100%) diff --git a/docs/source/adjoint.rst b/docs/source/adjoint.rst index 754dce1666..5dbc237ebe 100644 --- a/docs/source/adjoint.rst +++ b/docs/source/adjoint.rst @@ -289,7 +289,7 @@ are to be found on `the pygraphviz website .. _fig-tape: -.. figure:: images/tape.png +.. figure:: images/tape.svg A visualisation of the Burgers equation example above shortened to a single timestep. Operations (blocks) recorded on the tape are shown as grey diff --git a/docs/source/images/tape.png b/docs/source/images/tape.svg similarity index 100% rename from docs/source/images/tape.png rename to docs/source/images/tape.svg From 97a0c759456a128c351fee64a494e1d0f5e2af40 Mon Sep 17 00:00:00 2001 From: JDBetteridge Date: Thu, 10 Apr 2025 10:27:20 +0100 Subject: [PATCH 3/6] Add links to Devtio --- docs/source/aims_25.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/aims_25.rst b/docs/source/aims_25.rst index d3d9048a9b..bcee0b789f 100644 --- a/docs/source/aims_25.rst +++ b/docs/source/aims_25.rst @@ -22,7 +22,7 @@ reading is available on the links above. .. list-table:: - * - + * - - **Tuesday** - **Wednesday** - **Thursday** @@ -32,7 +32,7 @@ reading is available on the links above. - `Function spaces and inner products `__ - `The Ciarlet finite element `__ - `Nonlinear problems `__ - - Devito: inverse tomography + - Devito: `sympy `__, `Devito `__, `Acoustic Wave equation `__ - Software for adjoints: differentiable programming * - **Late AM** - `Our first finite element problem `__ @@ -44,7 +44,7 @@ reading is available on the links above. - Firedrake practical 1: `Helmholtz Equation `__ - `Systems with more than one variable `__ - An introduction to solvers and preconditioners - - Devito: inverse tomography + - Devito: `Full Waveform Inversion `__ - `Deep learning introduction `__, `practical `__ * - **Late PM** - Firedrake practical 2: `Dirichlet boundary conditions `__ From dae0bf66fc395848ffc35cc224f2e99e32d12b03 Mon Sep 17 00:00:00 2001 From: JDBetteridge Date: Thu, 10 Apr 2025 10:37:58 +0100 Subject: [PATCH 4/6] Update links to new branch --- docs/source/aims_25.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/aims_25.rst b/docs/source/aims_25.rst index bcee0b789f..b3e750d90a 100644 --- a/docs/source/aims_25.rst +++ b/docs/source/aims_25.rst @@ -32,7 +32,7 @@ reading is available on the links above. - `Function spaces and inner products `__ - `The Ciarlet finite element `__ - `Nonlinear problems `__ - - Devito: `sympy `__, `Devito `__, `Acoustic Wave equation `__ + - Devito: `sympy `__, `Devito `__, `Acoustic Wave equation `__ - Software for adjoints: differentiable programming * - **Late AM** - `Our first finite element problem `__ @@ -44,7 +44,7 @@ reading is available on the links above. - Firedrake practical 1: `Helmholtz Equation `__ - `Systems with more than one variable `__ - An introduction to solvers and preconditioners - - Devito: `Full Waveform Inversion `__ + - Devito: `Full Waveform Inversion `__ - `Deep learning introduction `__, `practical `__ * - **Late PM** - Firedrake practical 2: `Dirichlet boundary conditions `__ From 1f2dd711c5ee6ca8374633f9cfd45096622839c1 Mon Sep 17 00:00:00 2001 From: JDBetteridge Date: Thu, 10 Apr 2025 13:50:12 +0100 Subject: [PATCH 5/6] Remove dead links --- demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst | 5 +---- docs/source/aims_25.rst | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst b/demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst index 33c5b02d4a..33bb4100cd 100644 --- a/demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst +++ b/demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst @@ -18,9 +18,6 @@ dissipative forces. Unlike the other demo that integrated the equations forward in time, in this problem it is necessary to compute the eigenvalues and eigenfunctions for a particular differential operator. -This demo requires SLEPc and slepc4py to be installed. For instructions on how -to install them please follow `these instructions `_. - Governing PDE ~~~~~~~~~~~~~ @@ -138,7 +135,7 @@ We define the Test Function :math:`\phi` and the Trial Function To build the weak formulation of our equation we need to build two PETSc matrices in the form of a generalized eigenvalue problem, :math:`A\psi = \lambda M\psi`. This eigenproblem takes `restrict=True` to help -users to avoid convergence failures by removing eigenvalues on the +users to avoid convergence failures by removing eigenvalues on the boundary, while preserving the original function space for the eigenmodes. :: eigenproblem = LinearEigenproblem( diff --git a/docs/source/aims_25.rst b/docs/source/aims_25.rst index b3e750d90a..893b8de42c 100644 --- a/docs/source/aims_25.rst +++ b/docs/source/aims_25.rst @@ -50,7 +50,7 @@ reading is available on the links above. - Firedrake practical 2: `Dirichlet boundary conditions `__ - Firedrake practical 4: `mixed Poisson `__ - Firedrake practical 6: `solvers `__ - - Adjoint practical 1: `Burgers again `__ + - Adjoint practical 1: `Burgers again `__ - `Scientific machine learning `__, `practical `__ From 5c3eecffeeaf110d8579fbf278512176f42b0f78 Mon Sep 17 00:00:00 2001 From: JDBetteridge Date: Thu, 10 Apr 2025 13:57:54 +0100 Subject: [PATCH 6/6] Put it back... --- demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst b/demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst index 33bb4100cd..415afaee40 100644 --- a/demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst +++ b/demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst @@ -18,6 +18,9 @@ dissipative forces. Unlike the other demo that integrated the equations forward in time, in this problem it is necessary to compute the eigenvalues and eigenfunctions for a particular differential operator. +This demo requires SLEPc and slepc4py to be installed. For instructions on how +to install them please follow `these instructions `_. + Governing PDE ~~~~~~~~~~~~~