{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction\n", "\n", "This notebook demonstrates how to predict likely n- and p-type dopant atoms using pymatgen. This example uses the Materials API to download the structure of interest but any `Structure` object can be used. Two methods for choosing dopants are demonstrated. The first uses a simple Shannon radii comparison, whereas the second is based on the substitution probability of two atoms calculated using the `SubstitutionPredictor` utility in pymatgen. This code requires knowledge of the oxidation state of all elements in the structure. These can be guessed using pymatgen but should be checked to ensure the validity of the results.\n", "\n", "*Author: Alex Ganose (10/06/18)*" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Uncomment the subsequent lines in this cell to install dependencies for Google Colab.\n", "# !pip install pymatgen==2022.7.19" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Imports we need for generating dopant suggestions\n", "from __future__ import annotations\n", "\n", "from pprint import pprint\n", "\n", "from pymatgen.analysis.local_env import CrystalNN\n", "from pymatgen.analysis.structure_prediction.dopant_predictor import (\n", " get_dopants_from_shannon_radii,\n", " get_dopants_from_substitution_probabilities,\n", ")\n", "from pymatgen.ext.matproj import MPRester" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Establish rester for accessing Materials API\n", "\n", "api_key = None # INSERT YOUR OWN API KEY\n", "\n", "mpr = MPRester()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we define a variable -- `num_dopants` for how many dopants you wish to explore." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "num_dopants = 5 # number of highest probability dopants you wish to see" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download a structure and add oxidation states\n", "\n", "In this section, we use the Materials API to download a structure and add information on the oxidation states of the atoms." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6824bbbb8edf4c28a90729fb01f910c7", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Retrieving MaterialsDoc documents: 0%| | 0/1 [00:00