From 7ac82b1cc29e4f8673ae939807d5acc394b983d4 Mon Sep 17 00:00:00 2001 From: Sylvain Tricot Date: Tue, 22 Jul 2025 18:25:07 +0200 Subject: [PATCH] Change toggle to dropdown admonition --- msspecbook/Activity01/Activity01.ipynb | 32 +++++---- msspecbook/Activity02/Activity02.ipynb | 8 ++- msspecbook/Activity03/Activity03.ipynb | 14 ++-- msspecbook/Activity04/Activity04.ipynb | 20 +++++- msspecbook/Activity05/Activity05.ipynb | 90 ++++++++++++++------------ msspecbook/Activity06/Activity06.ipynb | 16 +++-- msspecbook/Activity07/Activity07.ipynb | 57 ++++++++++++---- msspecbook/Activity08/Activity08.ipynb | 34 ++++++++-- msspecbook/Activity09/Activity09.ipynb | 54 +++++++++++++--- msspecbook/Activity10/Activity10.ipynb | 31 +++++++-- 10 files changed, 253 insertions(+), 103 deletions(-) diff --git a/msspecbook/Activity01/Activity01.ipynb b/msspecbook/Activity01/Activity01.ipynb index 1f18d31..e71953e 100644 --- a/msspecbook/Activity01/Activity01.ipynb +++ b/msspecbook/Activity01/Activity01.ipynb @@ -208,7 +208,15 @@ "2. Create an ASE *calculator*\n", "3. Run the simulation\n", "\n", - "### PED polar scan for Cu(001)" + "### PED polar scan for Cu(001)\n", + "\n", + "download the [cu.py](cu.py \"download\") python script and the [copper.cif](copper.cif \"download\") file. Put those files in the same folder. You can run your first MsSpec calculation by typing in a terminal:\n", + "\n", + "```shell\n", + "$ python cu.py\n", + "```\n", + "\n", + "Here is the content of the script file:" ] }, { @@ -597,6 +605,8 @@ "Based on the previous *.cif file, create a new cluster without the deepest plane and run the same calculation for the same emitter\n", "\n", "```{note}\n", + "Use the `cluster.edit()` method to interactively remove atoms...\n", + "\n", "As the cluster will contain fewer atoms, the emitter index will be different\n", "```\n", "\n", @@ -617,7 +627,9 @@ "tags": [] }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{figure-md} Cu-4planes3planes\n", "\n", @@ -913,20 +925,6 @@ "Cu(2p) polar scan for the hemispherical cluster.\n", ":::" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e86ab1b3-fcf3-46e7-9cc7-f5e80becea9d", - "metadata": { - "editable": true, - "slideshow": { - "slide_type": "" - }, - "tags": [] - }, - "outputs": [], - "source": [] } ], "metadata": { @@ -945,7 +943,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.13" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/msspecbook/Activity02/Activity02.ipynb b/msspecbook/Activity02/Activity02.ipynb index ff2f9b1..c4afc51 100644 --- a/msspecbook/Activity02/Activity02.ipynb +++ b/msspecbook/Activity02/Activity02.ipynb @@ -42,7 +42,7 @@ "\n", "### Building the cluster\n", "\n", - "Let's start by building the cluster" + "Let's start by building the cluster. You can copy/paste directly the code from this page to your text editor or you can download the script [SbAg.py](SbAg.py \"download\"). You will also need the [data.txt](data.txt \"download\") file." ] }, { @@ -1164,7 +1164,9 @@ "tags": [] }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{figure-md} SbAg-fig2\n", "\n", @@ -1200,7 +1202,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.13" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/msspecbook/Activity03/Activity03.ipynb b/msspecbook/Activity03/Activity03.ipynb index 69a7c50..c44ab25 100644 --- a/msspecbook/Activity03/Activity03.ipynb +++ b/msspecbook/Activity03/Activity03.ipynb @@ -62,7 +62,7 @@ "::::{tab-set}\n", "\n", ":::{tab-item} Quiz\n", - "By using the `Atoms` class of the `ase` package, try to build a O-Rh chain where atoms are 4 Å apart. Here is the begining of the script. Try to complete the line of code and view your two-atoms chain.\n", + "By using the [`Atoms`](https://wiki.fysik.dtu.dk/ase/ase/atoms.html#ase.Atoms) class of the `ase` package, try to build a O-Rh chain where atoms are 4 Å apart. Here is the begining of the script. Try to complete the line of code and view your two-atoms chain.\n", "\n", "```python\n", "from ase import Atoms\n", @@ -266,7 +266,9 @@ "tags": [] }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{literalinclude} RhO_sf.py\n", ":start-at: Compute\n", @@ -333,7 +335,7 @@ "::::{tab-set}\n", "\n", ":::{tab-item} Quiz\n", - "Complete the script below to compute the ($\\theta,\\phi$) scan of the photodiffraction of O(1s) adsorbed on a *fcc* site on Rh(111) surface.\n", + "Complete the [script below](RhO_tofill.py \"download\") to compute the ($\\theta,\\phi$) scan of the photodiffraction of O(1s) adsorbed on a *fcc* site on Rh(111) surface.\n", "\n", "```{literalinclude} RhO_tofill.py\n", ":lineno-match:\n", @@ -358,7 +360,9 @@ "tags": [] }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{literalinclude} RhO_completed.py\n", ":lineno-match:\n", @@ -409,7 +413,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.13" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/msspecbook/Activity04/Activity04.ipynb b/msspecbook/Activity04/Activity04.ipynb index 22d2654..7ce3972 100644 --- a/msspecbook/Activity04/Activity04.ipynb +++ b/msspecbook/Activity04/Activity04.ipynb @@ -97,7 +97,13 @@ { "cell_type": "markdown", "id": "3ed73f46-c12f-452f-a584-00d142f2e133", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "```{admonition} *Solution...*\n", ":class: tip\n", @@ -136,7 +142,13 @@ { "cell_type": "markdown", "id": "626708d9-c421-4bf0-bd70-f32113360f9c", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "```{admonition} *Solution...*\n", ":class: tip\n", @@ -150,6 +162,10 @@ "Polar scan of a Ni chain of 2-5 atoms for single and full mutliple scattering.\n", ":::\n", "\n", + ":::{literalinclude} Ni_chain2.py\n", + ":linenos: true\n", + ":::\n", + "\n", "```" ] } diff --git a/msspecbook/Activity05/Activity05.ipynb b/msspecbook/Activity05/Activity05.ipynb index a7fe237..993f94c 100644 --- a/msspecbook/Activity05/Activity05.ipynb +++ b/msspecbook/Activity05/Activity05.ipynb @@ -181,12 +181,12 @@ "::::{tab-set}\n", "\n", ":::{tab-item} Quiz\n", - "Complete the code snipet provided below to create a small TiSe{sub}`2` cluster with Ti emitter in the 2{sup}`nd` plane:\n", + "Complete the code snipet provided below (or [here](TiSe2_1_tofill.py \"download\")) to create a small TiSe{sub}`2` cluster with Ti emitter in the 2{sup}`nd` plane:\n", "\n", "```{literalinclude} TiSe2_1_tofill.py\n", - ":start-at: from\n", - ":end-before: Create a calculator\n", - ":lineno-match:\n", + ":lines: 1-29\n", + ":linenos:\n", + ":emphasize-lines: 7,11,15,26 \n", "```\n", "\n", ":::\n", @@ -195,53 +195,32 @@ ] }, { - "cell_type": "code", - "execution_count": 14, - "id": "b65b569e-242b-4fe9-9c87-ea90d80d9b44", + "cell_type": "markdown", + "id": "1f2e014f-8963-4ae6-bbf5-7f4ebde3b16a", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, - "tags": [ - "hide-cell" - ] + "tags": [] }, - "outputs": [], "source": [ - "from ase.build import mx2\n", - "from ase.visualize import view\n", - "from msspec.calculator import MSSPEC\n", - "from msspec.utils import hemispherical_cluster, get_atom_index\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", - "# Some usefull constants (a, c, d, D) for defining the structure\n", - "a=3.535;c=6.004;d=3.450;D=2.554\n", + ":::{literalinclude} TiSe2_1_completed.py\n", + ":linenos: true\n", + ":lines: 1-18\n", + ":::\n", "\n", - "# Create the TiSe2 trilayer\n", - "# use ase help for this function\n", - "TiSe2 = mx2(formula='TiSe2', kind='1T', a=a, thickness=d, size=(1, 1, 1), vacuum=None)\n", - "\n", - "# The preious cell is 2D, let's define the c-axis to take into account \n", - "# the Van der Waals gap between trilayers\n", - "TiSe2.cell[2] = [0, 0, c]\n", - "\n", - "# To be aligned like in the paper\n", - "TiSe2.rotate(60, 'z', rotate_cell=True)\n", - "\n", - "# Since the material is multi-elements, \"tag\" each inequivalent atom \n", - "# of the unit cell with a number. The \"Ti\" atom is tagged 0 and \"Se\" \n", - "# atoms are 1 and 2.\n", - "for i in range(3): \n", - " TiSe2[i].tag = i\n", - "\n", - "cluster = hemispherical_cluster(TiSe2, emitter_tag=0, emitter_plane=1, planes=5)\n", - "cluster.emitter = get_atom_index(cluster, 0, 0, 0)" + "```" ] }, { "cell_type": "code", - "execution_count": 15, - "id": "515064d0-3751-4fae-af0c-c4b15ea221b3", + "execution_count": 1, + "id": "b65b569e-242b-4fe9-9c87-ea90d80d9b44", "metadata": { "editable": true, "slideshow": { @@ -777,12 +756,39 @@ "" ] }, - "execution_count": 15, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ + "from ase.build import mx2\n", + "from ase.visualize import view\n", + "from msspec.calculator import MSSPEC\n", + "from msspec.utils import hemispherical_cluster, get_atom_index\n", + "\n", + "# Some usefull constants (a, c, d, D) for defining the structure\n", + "a=3.535;c=6.004;d=3.450;D=2.554\n", + "\n", + "# Create the TiSe2 trilayer\n", + "# use ase help for this function\n", + "TiSe2 = mx2(formula='TiSe2', kind='1T', a=a, thickness=d, size=(1, 1, 1), vacuum=None)\n", + "\n", + "# The preious cell is 2D, let's define the c-axis to take into account \n", + "# the Van der Waals gap between trilayers\n", + "TiSe2.cell[2] = [0, 0, c]\n", + "\n", + "# To be aligned like in the paper\n", + "TiSe2.rotate(60, 'z', rotate_cell=True)\n", + "\n", + "# Since the material is multi-elements, \"tag\" each inequivalent atom \n", + "# of the unit cell with a number. The \"Ti\" atom is tagged 0 and \"Se\" \n", + "# atoms are 1 and 2.\n", + "for i in range(3): \n", + " TiSe2[i].tag = i\n", + "\n", + "cluster = hemispherical_cluster(TiSe2, emitter_tag=0, emitter_plane=1, planes=5)\n", + "cluster.emitter = get_atom_index(cluster, 0, 0, 0)\n", "view(cluster, viewer='x3d')" ] }, @@ -847,7 +853,9 @@ ] }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{figure-md} results-completed-fig\n", "\n", @@ -878,7 +886,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.13" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/msspecbook/Activity06/Activity06.ipynb b/msspecbook/Activity06/Activity06.ipynb index a95699d..7a06cfd 100644 --- a/msspecbook/Activity06/Activity06.ipynb +++ b/msspecbook/Activity06/Activity06.ipynb @@ -3,7 +3,13 @@ { "cell_type": "markdown", "id": "c0a860db-0f72-4785-81f4-831e48b3a49f", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "# Activity 6: Effect of the temperature\n", "\n", @@ -73,7 +79,7 @@ "\n", ":::{tab-item} Quiz\n", "With the help of the [MsSpec documentation](https://msspec.cnrs.fr/parameters.html) and the second paragraph p6791 of the [article cited above](#msd-paper),\n", - "complete the hilighted lines in the following script to compute the anisotropy of Cu(2p) $\\phi$-scans for polar angle $\\theta$=45° and 83°.\n", + "complete the hilighted lines in the [following script](Cu_temperature.py \"download\") to compute the anisotropy of Cu(2p) $\\phi$-scans for polar angle $\\theta$=45° and 83°.\n", "\n", "How is varying the anisotropy versus the temperature. How can you qualitatively explain this variation ?\n", "\n", @@ -98,7 +104,9 @@ "tags": [] }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{literalinclude} Cu_temperature_completed.py\n", ":lineno-match:\n", @@ -133,7 +141,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.13" + "version": "3.11.3" } }, "nbformat": 4, diff --git a/msspecbook/Activity07/Activity07.ipynb b/msspecbook/Activity07/Activity07.ipynb index 29d05a8..ffb6f1a 100644 --- a/msspecbook/Activity07/Activity07.ipynb +++ b/msspecbook/Activity07/Activity07.ipynb @@ -3,7 +3,13 @@ { "cell_type": "markdown", "id": "42cfa8b1-20d2-47e4-a1f0-161c4517df2c", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "(path-filtering)=\n", "# Activity 7: Large clusters and path filtering" @@ -42,7 +48,13 @@ { "cell_type": "markdown", "id": "0f78af28-335e-4f6b-9b98-929f9e6965f8", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "::::{tab-set}\n", "\n", @@ -66,16 +78,24 @@ { "cell_type": "markdown", "id": "a83ee1b8-dc25-4db9-a3bd-c5ba8443f758", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ - ":::{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", "To get the total number of paths generated by a cluster of $N$ atoms up to order $M$, use the following formula:\n", "\n", - "```{math}\n", + ":::{math}\n", ":label: eq-nbpaths\n", "\\sum_{i=0}^{i=M} (N-1)^i\n", - "```\n", + ":::\n", "\n", ":::{figure-md} nbpaths-fig\n", "\"path\n", @@ -83,7 +103,7 @@ "The time for computing all scattering path for increasing cluster size and scattering order (up to 6{sup}`th` order with 739 atoms. (One path is assumed to be calculated within 1 µs)\n", ":::\n", "\n", - ":::" + "```" ] }, { @@ -110,7 +130,13 @@ { "cell_type": "markdown", "id": "28aae2f7-2af9-4630-b89d-ab634725ad79", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "## Application to a deep plane in a Si(001) sample\n", "\n", @@ -129,7 +155,7 @@ "\n", ":::{tab-item} Quiz\n", "\n", - "The following script is almost completed, try to define path filtering options (no backscattering, accept all paths with forward angles < 40° and reject paths longer than the diameter of the cluster).\n", + "The [following script](Si001.py \"download\") is almost completed, try to define path filtering options (no backscattering, accept all paths with forward angles < 40° and reject paths longer than the diameter of the cluster).\n", "\n", "```{literalinclude} Si001.py\n", ":lineno-match:\n", @@ -148,9 +174,18 @@ { "cell_type": "markdown", "id": "19fbd486-b0c1-450c-a00d-79984945aefd", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", + "\n", "The calculation took few seconds and the result is very close to the calculation with all scattering paths.\n", "\n", "Only 0.01% of 3{sup}`rd` order paths were actually taken into account\n", diff --git a/msspecbook/Activity08/Activity08.ipynb b/msspecbook/Activity08/Activity08.ipynb index 658c800..49a80aa 100644 --- a/msspecbook/Activity08/Activity08.ipynb +++ b/msspecbook/Activity08/Activity08.ipynb @@ -3,7 +3,13 @@ { "cell_type": "markdown", "id": "2ff5929f-c066-496f-b078-0bbc2ab49428", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "# Activity 8: Inequivalent emitters and the XPD of a substrate" ] @@ -92,9 +98,17 @@ { "cell_type": "markdown", "id": "8a3a48ef-196f-435a-b342-3a73e62160f8", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ - ":::{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{figure-md} AlN-fig3\n", "\"AlN\n", @@ -102,7 +116,7 @@ "Number of different clusters to build for Al(2p) and N(1s) in 3 planes\n", ":::\n", "\n", - ":::" + "```" ] }, { @@ -123,9 +137,17 @@ { "cell_type": "markdown", "id": "abc64fdb-5895-4112-a987-66b3420d78eb", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{figure-md} AlN-fig4\n", "\"AlN\n", diff --git a/msspecbook/Activity09/Activity09.ipynb b/msspecbook/Activity09/Activity09.ipynb index e72a966..2b35a1c 100644 --- a/msspecbook/Activity09/Activity09.ipynb +++ b/msspecbook/Activity09/Activity09.ipynb @@ -4,7 +4,13 @@ "attachments": {}, "cell_type": "markdown", "id": "aa43e0e7-0c18-4750-9e2b-3a48f106d2ca", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "(RFactor)=\n", "# Activity 9: Comparing simulation and experiment with R-factors\n", @@ -33,7 +39,13 @@ { "cell_type": "markdown", "id": "91c03801-b46b-4844-8c89-655700419063", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "::::{tab-set}\n", "\n", @@ -61,9 +73,18 @@ { "cell_type": "markdown", "id": "d1be5047-fb75-4e98-a6a2-fc6f678e68ff", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", + "\n", "Here is the code of the `create_cluster` function\n", "\n", ":::{literalinclude} COFe_completed.py\n", @@ -98,9 +119,18 @@ { "cell_type": "markdown", "id": "670cbd24-efd4-4c51-89e2-f1d96c53908d", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", + "\n", "Here are the code of the nested *for loops*\n", "\n", ":::{literalinclude} COFe_completed.py\n", @@ -144,9 +174,17 @@ { "cell_type": "markdown", "id": "aa8d2dc4-286a-441d-9c21-dab6bac8145c", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", "6 R-factors out of 12 do agree that *variable set n°30* gives the best agreement. The set n°30 corresponds to\n", "$\\theta=55°$ and $\\phi=0°$.\n", diff --git a/msspecbook/Activity10/Activity10.ipynb b/msspecbook/Activity10/Activity10.ipynb index 2f822d0..9f9ce29 100644 --- a/msspecbook/Activity10/Activity10.ipynb +++ b/msspecbook/Activity10/Activity10.ipynb @@ -3,7 +3,13 @@ { "cell_type": "markdown", "id": "38d3e621-e866-43e1-9c92-f473d1e755c0", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "# Activity 10: Parallelization and multi-processing in MsSpec" ] @@ -11,7 +17,13 @@ { "cell_type": "markdown", "id": "1dccb5e3-1cd3-4732-a7ba-81a8a94c89dc", - "metadata": {}, + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ "As you can see from the previous examples, a complete simulation may require several multiple scattering calculations, for instance to calculate the total intensity of a substrate or to optimize the geometry of a system. As the calculations are often time consuming, it can be useful to distribute these tasks over several processors to make the most of hardware resources.\n", "Although MsSpec is not fully parallelized, the code does offer a number of features, which we will explore here.\n", @@ -67,10 +79,18 @@ }, { "cell_type": "markdown", - "id": "0a1fabce-c42d-4cb4-9720-bcd21ff0cd09", - "metadata": {}, + "id": "3833a4c3-2d47-49e8-b78d-5c97dad47716", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, "source": [ - "```{toggle}\n", + "```{admonition} *Solution...*\n", + ":class: tip\n", + ":class: dropdown\n", "\n", ":::{literalinclude} COFe_mp_completed.py\n", ":lineno-start: 63\n", @@ -79,7 +99,6 @@ ":emphasize-lines: 6,7, 9,10, 18\n", ":::\n", "\n", - "\n", "```" ] }