# Introduction¶

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.

Written using:

• pymatgen==2018.11.Y

Author: Alex Ganose (10/06/18)

In [1]:
# Imports we need for generating dopant suggestions

from pymatgen.analysis.structure_prediction.dopant_predictor import \
from pymatgen.analysis.local_env import CrystalNN

from pymatgen import MPRester
from pprint import pprint

In [2]:
# Establish rester for accessing Materials API

api_key = None  # INSERT YOUR OWN API KEY

mpr = MPRester(api_key=api_key)


Here we define a variable -- num_dopants for how many dopants you wish to explore.

In [3]:
num_dopants = 5  # number of highest probability dopants you wish to see


In this section, we use the Materials API to download a structure and add information on the oxidation states of the atoms.

In [4]:
mp_id = 'mp-856'  # Materials Project id for rutile SnO2

structure = mpr.get_structure_by_material_id(mp_id)


The downloaded structure does not contain oxidation state information. There are two ways to add this information. The first is to specify the oxidation state of the elements manually.

In [5]:
structure.add_oxidation_state_by_element({"Sn": 4, "O": -2})


Alternatively, we can use pymatgen to guess the oxidation states. If using this method you should check that the oxidation states are what you expect.

In [6]:
structure.add_oxidation_state_by_guess()


Let's check what oxidation states pymatgen guessed.

In [7]:
species = structure.composition.elements

print(species)

[Specie O2-, Specie Sn4+]


## Finding dopants by Shannon radii¶

In this section, we use the known Shannon radii to predict likely dopants. We will prefer dopants which have the smallest difference in radius to the host atoms. As the Shannon radii depend on the coordination number of the site, we must first calculate the bonding in the structure. In this example, we do this using the CrystalNN class.

In [8]:
cnn = CrystalNN()
bonded_structure = cnn.get_bonded_structure(structure)


Pymatgen has a function to take a bonded structure with oxidation states and report the closest n- and p-type dopants, sorted by the difference in Shannon radii. Let's run this on our bonded structure:

In [9]:
dopants = get_dopants_from_shannon_radii(bonded_structure, num_dopants=num_dopants)

pprint(dopants)

{'n_type': [{'dopant_species': Specie U6+,
'original_species': Specie Sn4+,
{'dopant_species': Specie Nb5+,
'original_species': Specie Sn4+,
{'dopant_species': Specie Ta5+,
'original_species': Specie Sn4+,
{'dopant_species': Specie F-,
'original_species': Specie O2-,
{'dopant_species': Specie Np5+,
'original_species': Specie Sn4+,
'p_type': [{'dopant_species': Specie Ni2+,
'original_species': Specie Sn4+,
{'dopant_species': Specie Ru3+,
'original_species': Specie Sn4+,
{'dopant_species': Specie Ir3+,
'original_species': Specie Sn4+,
{'dopant_species': Specie Rh3+,
'original_species': Specie Sn4+,
{'dopant_species': Specie Mg2+,
'original_species': Specie Sn4+,


The most favoured n-type dopant is U on a Sn site. Unfortunately, this is not a sustainable or safe choice of dopant. The most common industrial n-type dopant for SnO2 is fluorine. While F is present in our list of suggested dopants, it found way down at suggestion number 4.

Another limitation of the Shannon radii approach to choosing dopants is that the radii depend on both the coordination number and charge state. For many elements, the radii for many charge state/coordination number combinations have not been tabulated, meaning this approach is incomplete.

Instead we should use a more robust approach to determine possible dopants.

## Finding dopants by substitution probability¶

In this section, we use the statistics provided by SubstitutionPredictor to predict likely dopants substitutions using a data-mined approach from ICSD data. Based on the species in the structure, we get a list of which species are likely to substitute in but have different charge states. The substitution prediction methodology is presented in: Hautier, G., Fischer, C., Ehrlacher, V., Jain, A., and Ceder, G. (2011) Data Mined Ionic Substitutions for the Discovery of New Compounds. Inorganic Chemistry, 50(2), 656-663. doi:10.1021/ic102031h

Here, we define a variable -- threshold for the threshold probability in making substitution/structure predictions.

In [10]:
threshold = 0.001  # probability threshold for substitution/structure predictions


Pymatgen provides a function to filter the predicted substitutions by their charge states and return a list of n- and p-type dopants. Let's run the function on the structure we downloaded earlier:

In [11]:
dopants = get_dopants_from_substitution_probabilities(
structure, num_dopants=num_dopants, threshold=threshold)

pprint(dopants)

INFO:root:87 substitutions found
INFO:root:11 substitutions found

{'n_type': [{'dopant_species': Specie F-,
'original_species': Specie O2-,
'probability': 0.06692682583342485},
{'dopant_species': Specie Cl-,
'original_species': Specie O2-,
'probability': 0.021022638288432097},
{'dopant_species': Specie Ta5+,
'original_species': Specie Sn4+,
'probability': 0.01948622124590853},
{'dopant_species': Specie Sb5+,
'original_species': Specie Sn4+,
'probability': 0.010380692735493774},
{'dopant_species': Specie Nb5+,
'original_species': Specie Sn4+,
'probability': 0.00998853178143717}],
'p_type': [{'dopant_species': Specie Co2+,
'original_species': Specie Sn4+,
'probability': 0.023398867249112974},
{'dopant_species': Specie Cd2+,
'original_species': Specie Sn4+,
'probability': 0.022644061067779383},
{'dopant_species': Specie Li+,
'original_species': Specie Sn4+,
'probability': 0.022394101830147096},
{'dopant_species': Specie Fe2+,
'original_species': Specie Sn4+,
'probability': 0.020971777662831426},
{'dopant_species': Specie Ca2+,
'original_species': Specie Sn4+,
'probability': 0.019487195581329015}]}


The function returns a list of potential dopants sorted by their substitution probability. The most likely n-type dopant is F on a O site. Fluorine doped SnO2 (FTO) is one of the most widely used transparent conducting oxides, therefore validating this approach.