{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2aebc88d-0bb4-4d56-b7f6-977a66814229",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "# Activity 3: Adsorbates and the single scattering approach\n",
    "\n",
    "Photoelectron diffraction is widely used to study the adsorption of atoms or molecules on a crystalline surface. Photoelectrons from adsorbates are scattered by the underlying surface, carrying information about the adsorption site, bond length and/or molecule orientation…. Thanks to a simulation, such information becomes quantitative with a high degree of accuracy.\n",
    "\n",
    "Calculations of the multiple scattering using matrix inversion have the great advantage of being exact, including all scattering paths. On the other hand, memory consumption soon becomes a problem as the kinetic energy and number of atoms to be considered increase. As an approximation, it is possible to only consider a single scattering from the emitter to any atom in the cluster. This approximation is extremely computationally fast and can give satisfactory results for adsorbates. We’ll see later that this approach is rather too simplistic for most cases.\n",
    "\n",
    "## Oxygen on Rh(001)\n",
    "In a paper published in 1998, T. Gerber *et al.* used the quite high backscattering factor of Rhodium atoms to probe the distance of Oxygen atoms adsorbed on a Rhodium surface. Some electrons coming from Oxygen atoms are ejected toward the Rhodium surface. They are then backscattered and interfere with the direct signal comming from Oxygen atoms (see the figure below). They demonstrated both experimentally and numerically with a sinle scattering computation that this lead to a very accurate probe of adsorbed species that can be sensitive to bond length changes of the order of {math}`\\pm 0.02 \\mathring{A}`.\n",
    "\n",
    ":::{seealso}\n",
    "based on this paper from T. Greber *et al.* [Phys. Rev. Lett. **81**(8) p1654 (1998)](https://doi.org/10.1103/PhysRevLett.81.1654)\n",
    ":::"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4cd32cd-b480-44b5-af38-b38e5979ce00",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    ":::{figure-md} RhO-fig\n",
    "<img src=\"RhO_fig0.jpg\" alt=\"RhO\" width=\"300px\" align=\"center\">\n",
    "\n",
    "Interferences produced by the backscattering effect\n",
    ":::"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f6bcc08-a54c-424a-a20c-cbdd0ce13ae2",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "### Computing the scattering factor\n",
    "\n",
    "To illustrate that photoelectrons emitted by Oxygen adsorbates towards the Rhodium surface can be backscattered, we will start by computing the scattering factor for both O and Rh atoms.\n",
    "\n",
    "::::{tab-set}\n",
    "\n",
    ":::{tab-item} <i class=\"fa-solid fa-circle-question\"></i> 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",
    "\n",
    "```python\n",
    "from ase import Atoms\n",
    "from ase.visualize import view\n",
    "\n",
    "# Create an atomic chain O-Rh\n",
    "cluster = Atoms(... # Fill this line\n",
    "```\n",
    ":::\n",
    "\n",
    "::::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "55929980-7394-4a60-b554-376adce57dbf",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "hide-cell"
    ]
   },
   "outputs": [],
   "source": [
    "from ase import Atoms\n",
    "from ase.visualize import view\n",
    "\n",
    "# Create an atomic chain O-Rh\n",
    "cluster = Atoms(['O', 'Rh'], positions = [(0,0,0), (0,0,4.)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2f296e2c-2a34-4266-98a8-362ede072659",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "remove-input"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\n",
       "    <head>\n",
       "        <title>ASE atomic visualization</title>\n",
       "        <link rel=\"stylesheet\" type=\"text/css\"             href=\"https://www.x3dom.org/release/x3dom.css\"></link>\n",
       "        <script type=\"text/javascript\"             src=\"https://www.x3dom.org/release/x3dom.js\"></script>\n",
       "    </head>\n",
       "    <body>\n",
       "        <X3D width=\"400px\"; height=\"300px\";>\n",
       "\n",
       "<!--Inserting Generated X3D Scene-->\n",
       "<scene>\n",
       "  <viewpoint position=\"0 0 8.0\">\n",
       "    <group/>\n",
       "  </viewpoint>\n",
       "  <transform translation=\"-0.0 -0.0 -0.0\">\n",
       "    <group>\n",
       "      <group>\n",
       "        <transform translation=\"0 0 0\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0 0 0\"/>\n",
       "            </appearance>\n",
       "            <lineset vertexCount=\"5\">\n",
       "              <coordinate point=\"0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 0.0 0.0\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0 0 0\"/>\n",
       "            </appearance>\n",
       "            <lineset vertexCount=\"5\">\n",
       "              <coordinate point=\"0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0 0 0\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0 0 0\"/>\n",
       "            </appearance>\n",
       "            <lineset vertexCount=\"5\">\n",
       "              <coordinate point=\"0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 0.0 0.0\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0 0 0\"/>\n",
       "            </appearance>\n",
       "            <lineset vertexCount=\"5\">\n",
       "              <coordinate point=\"0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "      </group>\n",
       "      <group>\n",
       "        <transform translation=\"0.0 0.0 0.0\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"1.0 0.051 0.051\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"0.66\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 0.0 4.0\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.039 0.49 0.549\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.42\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "      </group>\n",
       "    </group>\n",
       "  </transform>\n",
       "</scene>\n",
       "<!--End of Inserted Scene-->\n",
       "\n",
       "        </X3D>\n",
       "    </body>\n",
       "</html>\n",
       "\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view(cluster, viewer='x3d')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "736d6d08-930e-4b4f-a3fd-599ef8463035",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "As previously, we create a calculator, we attach our 2 atoms cluster to this calculator and we define the first atom in the chain as the emitter\n",
    "\n",
    ":::{literalinclude} RhO_sf.py\n",
    ":start-at: calc =\n",
    ":end-at: emitter =\n",
    ":::"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21763c63-9bd1-4e80-944a-9cf313894b89",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "::::{tab-set}\n",
    "\n",
    ":::{tab-item} <i class=\"fa-solid fa-circle-question\"></i> Quiz\n",
    "We use the `get_scattering_factors` method [(see its documentation)](https://msspec.cnrs.fr/modules/calculator.html#calculator._PED.get_scattering_factors) to compute the scattering factors at 723 eV.\n",
    "\n",
    "How large is the backscattering factor of Rhodium with respect to that of Oxygen ?\n",
    ":::\n",
    "\n",
    "::::"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "14d39e21-eee0-411b-8347-25e932075c83",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "```{toggle}\n",
    "\n",
    ":::{literalinclude} RhO_sf.py\n",
    ":start-at: Compute\n",
    ":::\n",
    "\n",
    ":::{figure-md} SF-fig\n",
    "<img src=\"RhO_fig1.jpg\" alt=\"Scattering factors\" width=\"600px\" align=\"center\">\n",
    "\n",
    "Polar representation of the scattering factor\n",
    ":::\n",
    "\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e7da60a3-b4e3-45ec-9d0e-62cb592f0687",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "### Interferences due to backscattering\n",
    "\n",
    "Let an Oxygen atom (in red) being adsorbed at a distance $z_0$ of an *fcc* site of the Rh(111) surface."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68048f33-318d-400e-a815-769660f2b6c5",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "remove-input"
    ]
   },
   "source": [
    ":::{figure-md} Rho-fig2a\n",
    "<img src=\"RhO_fig2a.jpg\" width=\"600px\" align=\"center\">\n",
    "\n",
    "Small cluster used for the calculation.\n",
    ":::"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d6145250-5548-49a6-8b50-0bb7c5b454da",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "We will compute  for different values of the adsorption height $z_0$.\n",
    "\n",
    "::::{tab-set}\n",
    "\n",
    ":::{tab-item} <i class=\"fa-solid fa-circle-question\"></i> 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",
    "\n",
    "```{literalinclude} RhO_tofill.py\n",
    ":lineno-match:\n",
    ":emphasize-lines: 6,8,12,13\n",
    "```\n",
    "\n",
    "As proposed in the comments, add a loop to vary the adsorption height of Oxygen between 1.10 and 1.65 Å.\n",
    "What is the bond length difference between to intensity maxima ?\n",
    ":::\n",
    "\n",
    "::::"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ff0c14f-b2f6-47c6-91f4-9edc7ee7260d",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "```{toggle}\n",
    "\n",
    ":::{literalinclude} RhO_completed.py\n",
    ":lineno-match:\n",
    ":emphasize-lines: 6,8,12,13\n",
    ":::\n",
    "\n",
    ":::{figure-md} stereo-fig\n",
    "<img src=\"RhO_fig2b.gif\" alt=\"Scattering factors\" width=\"600px\" align=\"center\">\n",
    "\n",
    "Stereographic projections of O(1s) emission at {math}`E_0` = 723 eV for an oxygen atom \n",
    "on top of a fcc site of 3 Rh atoms at various altitudes {math}`z_0`\n",
    ":::\n",
    "\n",
    "\n",
    "You can see on the stereographic projection 3 bright circles representing fringes of constructive interference between the direct O(1s) photoelectron wave and that backscattered by the Rhodium atoms. The center of these annular shapes changes from bright to dark due to the variation of the Oxygen atom height above the surface which changes the path difference.\n",
    "\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3621c545-3e3a-439c-ab91-a76202cf2644",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
