{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7e31b322-df55-44ed-9f29-6f6efa71eafe",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "# Activity 1: Getting started\n",
    "\n",
    "MsSpec is a Fortran code with two components: Phagen (Written by R. Natoli) and Spec (written by D. Sébilleau). Phagen computes the phase shifts of the electronic wave propagating in the matter on a spherical harmonics basis. Spec uses those phase shifts to compute the multiple scattering process and simulate the intensity of different electronic spectroscopies.\n",
    "\n",
    "In the most recent version of MsSpec, the program is interfaced with python (https://msspec.cnrs.fr/), allowing for much more flexibility and interplay with other simulation techniques.\n",
    "\n",
    "## Building atomic systems\n",
    "\n",
    "MsSpec works in the *cluster* approach. Building such a cluster for a calculation is a fundamental step.\n",
    "We use the [python Atomic Simulation Environment (ASE)](https://wiki.fysik.dtu.dk/ase/) for this.\n",
    "\n",
    "ASE is a set of tools and Python modules for setting up, manipulating, running, visualizing and analyzing atomistic simulations.\n",
    "Building atomic systems, structures... is pretty straightforward:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "07a04c8c-a268-481a-8f1b-14878ed771b5",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Popen: returncode: None args: ['/home/stricot/msspec_py3.11.13/bin/python',...>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# To build a molecule with ASE\n",
    "from ase.build import molecule\n",
    "# To view\n",
    "from ase.visualize import view\n",
    "\n",
    "# Create a water molecule\n",
    "water = molecule('H2O')\n",
    "# Display it\n",
    "view(water)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e09c7d97-eb35-49a7-b74a-9fb21a9a3aaf",
   "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 3.052956\">\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.119262\">\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.763239 -0.477047\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"1.0 1.0 1.0\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"0.31\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 -0.763239 -0.477047\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"1.0 1.0 1.0\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"0.31\"/>\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": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view(water, viewer='x3d')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94b690a2-52f0-43e4-953d-6e7519ac4e9c",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "## Barebone script for MsSpec\n",
    "\n",
    "MsSpec can simulate different electronic spectroscopies like PED, AED, LEED, EXAFS, APECS and more will be included in the forthcoming version. However, it is really well-suited for PhotoElectron Diffraction simulation, and the python interface is only fully available for it at the moment. Since PED covers all the MsSpec features and concepts, we will focus on this technique.\n",
    "\n",
    "There are typically 3 steps to follow to get a result with MsSpec:\n",
    "\n",
    "1. Create a *cluster*\n",
    "2. Create an ASE *calculator*\n",
    "3. Run the simulation\n",
    "\n",
    "### PED polar scan for Cu(001)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "da96a735-a028-4fe8-89ac-96f707323ae9",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "```{literalinclude} cu.py\n",
    ":end-before: The \"emitter\"\n",
    ":linenos:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6ddd72a9-8f32-484f-9a3e-9ab3a85945a4",
   "metadata": {
    "editable": true,
    "scrolled": 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 28.8\">\n",
       "    <group/>\n",
       "  </viewpoint>\n",
       "  <transform translation=\"-7.2 -7.2 -3.6\">\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 14.4 0.0 0.0 14.4 14.4 0.0 0.0 14.4 0.0 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 0.0 7.2\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0 0 0\"/>\n",
       "            </appearance>\n",
       "            <lineset vertexCount=\"5\">\n",
       "              <coordinate point=\"0 0 0 14.4 0.0 0.0 14.4 14.4 0.0 0.0 14.4 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 14.4 0.0 0.0 14.4 0.0 7.2 0.0 0.0 7.2 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 14.4 0.0\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0 0 0\"/>\n",
       "            </appearance>\n",
       "            <lineset vertexCount=\"5\">\n",
       "              <coordinate point=\"0 0 0 14.4 0.0 0.0 14.4 0.0 7.2 0.0 0.0 7.2 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "      </group>\n",
       "      <group>\n",
       "        <transform translation=\"3.6 7.2 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"3.6 7.2 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"5.400000000000002 5.400000000000002 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 3.5999999999999988 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 5.400000000000002 0.8999999999999997\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"5.400000000000002 5.400000000000002 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 3.5999999999999988 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 5.400000000000002 4.5\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"5.400000000000002 7.2 0.8999999999999997\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"5.400000000000002 8.999999999999998 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 7.2 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 8.999999999999998 0.8999999999999997\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"5.400000000000002 7.2 4.5\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"5.400000000000002 8.999999999999998 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 7.2 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 8.999999999999998 4.5\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 10.800000000000004 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"7.2 10.800000000000004 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"8.999999999999998 5.400000000000002 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"8.999999999999998 5.400000000000002 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"8.999999999999998 7.2 0.8999999999999997\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"8.999999999999998 8.999999999999998 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"10.800000000000004 7.2 2.700000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"8.999999999999998 7.2 4.5\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"8.999999999999998 8.999999999999998 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"10.800000000000004 7.2 6.300000000000001\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\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": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from ase.io import read\n",
    "from ase.visualize import view\n",
    "from msspec.calculator import MSSPEC\n",
    "\n",
    "\n",
    "cluster = read('copper.cif')\n",
    "# view the cluster\n",
    "view(cluster, viewer='x3d')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a51b9284-ce53-48e2-bd4b-65fe3998cc33",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "```{literalinclude} cu.py\n",
    ":start-at: The \"emitter\"\n",
    ":lineno-match:\n",
    "```\n",
    ":::{figure-md} Cu-XPD\n",
    "<img src=\"fig1.png\" width=\"600px\" align=\"center\">\n",
    "\n",
    "Cu(2p) polar scan for the copper cluster above\n",
    ":::"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "85c7dcac-9f0e-4a56-8077-c96f89865dcb",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "## Shaping a cluster"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff63b7cb-5e31-44f8-b81b-d05bf0c775c0",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "::::{tab-set}\n",
    "\n",
    ":::{tab-item} <i class=\"fa-solid fa-circle-question\"></i> Quiz\n",
    "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",
    "As the cluster will contain fewer atoms, the emitter index will be different\n",
    "```\n",
    "\n",
    "What do you conclude ?\n",
    ":::\n",
    "\n",
    "::::"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1590cc49-8788-4a7b-a051-74ce1168e744",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "```{toggle}\n",
    "\n",
    ":::{figure-md} Cu-4planes3planes\n",
    "<img src=\"fig2.png\" width=\"600px\" align=\"center\">\n",
    "\n",
    "Comparison between 4 and 3 planes for an emitter in the 3{sup}`rd` plane.\n",
    ":::\n",
    "\n",
    "Not all atoms contribute equally to the total signal. Some of them can be removed to save computation time and memory.\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "102bfad0-f8ed-44ab-990f-9fb2eb5662b0",
   "metadata": {
    "editable": true,
    "scrolled": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "hide-input"
    ]
   },
   "source": [
    "The number of atoms used for the calculation greatly impact the calculation time and memory. Most of the time, a cluster is shaped as an hemisphere to minimize the number of atoms to take into account"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f7ecc1d0-097d-4199-822a-c564e9e94337",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "remove-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Popen: returncode: None args: ['/home/stricot/msspec_py3.11.13/bin/python',...>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from msspec.calculator import MSSPEC\n",
    "from msspec.utils import hemispherical_cluster, get_atom_index\n",
    "from ase.build import bulk\n",
    "from ase.visualize import view\n",
    "\n",
    "copper = bulk('Cu', cubic=True)\n",
    "cluster = hemispherical_cluster(copper, planes=3, emitter_plane=2)\n",
    "cluster.emitter = get_atom_index(cluster, 0,0,0)\n",
    "\n",
    "view(cluster)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "076f617d-599f-483d-b22c-38cebf41b28a",
   "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 14.440000000000001\">\n",
       "    <group/>\n",
       "  </viewpoint>\n",
       "  <transform translation=\"-1.805 -1.805 -1.805\">\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 3.61 0.0 0.0 3.61 3.61 0.0 0.0 3.61 0.0 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 0.0 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0 0 0\"/>\n",
       "            </appearance>\n",
       "            <lineset vertexCount=\"5\">\n",
       "              <coordinate point=\"0 0 0 3.61 0.0 0.0 3.61 3.61 0.0 0.0 3.61 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 3.61 0.0 0.0 3.61 0.0 3.61 0.0 0.0 3.61 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 3.61 0.0\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0 0 0\"/>\n",
       "            </appearance>\n",
       "            <lineset vertexCount=\"5\">\n",
       "              <coordinate point=\"0 0 0 3.61 0.0 0.0 3.61 0.0 3.61 0.0 0.0 3.61 0 0 0\"/>\n",
       "            </lineset>\n",
       "          </shape>\n",
       "        </transform>\n",
       "      </group>\n",
       "      <group>\n",
       "        <transform translation=\"-3.610000000000001 0.0 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"-1.8049999999999997 -1.8049999999999997 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"-1.8049999999999997 0.0 1.8050000000000002\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"-1.8049999999999997 1.8049999999999997 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 -3.6099999999999994 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 0.0 4.440892098500626e-16\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 -1.8049999999999997 1.8050000000000002\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 0.0 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"1.8049999999999997 -1.8049999999999997 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"1.8049999999999997 0.0 1.8050000000000002\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 1.8049999999999997 1.8050000000000002\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"0.0 3.6099999999999994 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"1.8049999999999997 1.8049999999999997 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\n",
       "          </shape>\n",
       "        </transform>\n",
       "        <transform translation=\"3.6099999999999994 0.0 3.61\">\n",
       "          <shape>\n",
       "            <appearance>\n",
       "              <material diffuseColor=\"0.784 0.502 0.2\"/>\n",
       "            </appearance>\n",
       "            <sphere radius=\"1.32\"/>\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": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view(cluster, viewer='x3d')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a71c734-8c73-49a2-9f27-12157841405c",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    ":::{figure-md} Cu-hemi\n",
    "<img src=\"fig3.png\" width=\"600px\" align=\"center\">\n",
    "\n",
    "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": {
  "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.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
