{ "cells": [ { "cell_type": "markdown", "id": "7aa81dbc", "metadata": {}, "source": [ "# Structural modeling and experiment planning" ] }, { "cell_type": "markdown", "id": "7b385d3c", "metadata": {}, "source": [ "What are the accessible structural details of a given system by phase measurements? How to perform data acquisition? Identifying proper experimental conditions is fundamental for successfully exploiting the X-ray dynamical diffraction (in its current conception).\n", "\n", "Our approach for identifying those suitable multiple-diffraction cases is by elaborating structural models and comparing their structure factor phases. So, this step-by-step tutorial will show you how to use **pyddt** to perform these tasks." ] }, { "cell_type": "markdown", "id": "abe3434c", "metadata": {}, "source": [ "## CeFe$_{4}$P$_{12}$" ] }, { "cell_type": "markdown", "id": "32611247", "metadata": {}, "source": [ "For illustrative purposes, let's consider the filled skutterudite CeFe$_{4}$P$_{12}$ and search for suitable experimental conditions to resolve the Ce oxidation state. Download its CIF on [Materials Project mp-16272](https://materialsproject.org/materials/mp-16272/).\n", "\n", "This tutorial aims to show the experiment planning performed by Morelhão, S. et al. during the investigation of vibrational dynamics of filled skutterudites. See [Phonon scattering mechanism in thermoelectric materials revised via resonant x-ray dynamical diffraction](https://link.springer.com/article/10.1557/mrc.2020.37) for a detailed reference." ] }, { "cell_type": "markdown", "id": "846f9dfa", "metadata": {}, "source": [ "### 0. Importing packages" ] }, { "cell_type": "code", "execution_count": 1, "id": "6d6c6d7c", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "5cdf1ef1f3a04ae1beb4d5364a74773b", "version_major": 2, "version_minor": 0 }, "text/plain": [] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "plt.rcParams['font.size'] = '14'\n", "\n", "import sys\n", "sys.path.append('path/to/pyddt')\n", "\n", "import pyddt" ] }, { "cell_type": "markdown", "id": "5ec905e5", "metadata": {}, "source": [ "## 1. Structural modelling" ] }, { "cell_type": "markdown", "id": "4fe9640c", "metadata": {}, "source": [ "The structural modeling within **pyddt** is based on the `Structure` class. \n", "\n", "So, in a few words, it follows what we will do in this section: after converting the CIF into a *.in* file, we will instantiate a structure. Then, carry out the desired changes in the unit cell (replace the atoms with ions, vary their B-factors) and save the resultant models." ] }, { "cell_type": "markdown", "id": "42e87098", "metadata": {}, "source": [ "### 1.1 Converting CIF into .in file" ] }, { "cell_type": "code", "execution_count": 2, "id": "590fda76", "metadata": {}, "outputs": [], "source": [ "pyddt.to_in('Ce(FeP3)4.cif')" ] }, { "cell_type": "markdown", "id": "84ca1d94", "metadata": {}, "source": [ "### 1.2 Structure object" ] }, { "cell_type": "markdown", "id": "05b00707", "metadata": {}, "source": [ "It's easy to generate a `structure` object from the *.in* file." ] }, { "cell_type": "code", "execution_count": 3, "id": "5087ffe9", "metadata": {}, "outputs": [], "source": [ "cfp = pyddt.Structure('Ce(FeP3)4.in')" ] }, { "cell_type": "markdown", "id": "1c6fe15f", "metadata": {}, "source": [ "Let's check the current oxidation states and B-factors." ] }, { "cell_type": "code", "execution_count": 4, "id": "895aef2f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['Ce', 'Ce', 'Fe', 'Fe', 'Fe', 'Fe', 'Fe', 'Fe', 'Fe', 'Fe', 'P',\n", " 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P',\n", " 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'], dtype='" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "E = np.linspace(7000, 7300, 2000) # eV\n", "\n", "fig = plt.figure(figsize=(7, 5))\n", "\n", "plt.plot(E, np.angle(ce3.Fhkl(E, [0, 0, 2]))*180/np.pi, label='Ce3+')\n", "plt.plot(E, np.angle(ce4.Fhkl(E, [0, 0, 2]))*180/np.pi, label='Ce4+')\n", "\n", "plt.xlabel('Energy (eV)')\n", "plt.ylabel('Phase (deg)')\n", "\n", "plt.legend()\n", "plt.show()" ] }, { "cell_type": "markdown", "id": "71bf6c43", "metadata": {}, "source": [ "Although the phase difference between the structural models is less than 10 degrees, the phase shift can be at 180° for just 100 eV of variation in the X-ray energy. This phenomenon allowed a multi-wavelength use of X-ray dynamical diffraction exploited by [Morelhão, S. et al](https://link.springer.com/article/10.1557/mrc.2020.37)." ] }, { "cell_type": "markdown", "id": "87a1ab33", "metadata": {}, "source": [ "### 2.3 Phase triplets" ] }, { "cell_type": "markdown", "id": "80a2a5a3", "metadata": {}, "source": [ "Until now, we selected the 002 as the primary reflection and might acquire data using X-rays in the range of 7100 and 7200 eV. \n", "\n", "Lastly, check the three-beam cases predicted to show opposite profile asymmetries on each model structure for a fixed energy." ] }, { "cell_type": "code", "execution_count": null, "id": "27f9a7b1", "metadata": {}, "outputs": [], "source": [ "E = 7150\n", "pyddt.triplet(ce3.diffraction(E), ce4.diffraction(E), [0, 0, 2])" ] }, { "cell_type": "markdown", "id": "8cd2f7ca", "metadata": {}, "source": [ "![pyddt_t2_2](https://user-images.githubusercontent.com/106104347/187935676-81303ffe-6583-427a-b885-d1ad713afd0f.png)" ] }, { "cell_type": "markdown", "id": "b68031e2", "metadata": {}, "source": [ "Again, the plotted information was saved in the current folder (filenames displayed on the screen)." ] }, { "cell_type": "markdown", "id": "2a13e52d", "metadata": {}, "source": [ "----" ] }, { "cell_type": "markdown", "id": "d265484e", "metadata": {}, "source": [ "## Summary" ] }, { "cell_type": "markdown", "id": "c660497c", "metadata": {}, "source": [ "The first part of this tutorial has shown some tools for structural modeling. However, the functions for appending or deleting atoms and changing their occupancy numbers weren't covered, as well the `visualizer_in` method. Please, check the [API documentation](../api.rst) for more details. On the other hand, the second part covered all functions usually used for experiment planning. If you develop new tools using **pyddt** classes, please contribute to the project on [GitHub](https://github.com/rafaela-felix/pyddt).\n", "\n", "In the last tutorial, we will analyze two Renninger scans and indicate how compatibility analysis is carried out using **pyddt**." ] } ], "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.10.7" } }, "nbformat": 4, "nbformat_minor": 5 }