{ "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": [ "" ] }, "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": [ "\n", " \n", " ASE atomic visualization\n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", "\n", "\n" ], "text/plain": [ "" ] }, "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": [ "\n", " \n", " ASE atomic visualization\n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", "\n", "\n" ], "text/plain": [ "" ] }, "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", "\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} 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", "\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": [ "" ] }, "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": [ "\n", " \n", " ASE atomic visualization\n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", "\n", "\n" ], "text/plain": [ "" ] }, "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", "\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 }