Stable crystals are ones that minimize the free energy F. For example, table salt NaCl is stable partly because G(NaCl) < G(Na) + G(Cl), where Na and Cl represent pure elemental solids. However, it’s not enough to just be stable versus the elemental solids; it must also be stable versus decomposition into, for example, 1/2 Na2Cl + NaCl2. Formally, we want to minimize the total free energy of a collection of compounds.
For now, we will assume that energy is the same as free energy (this is equivalent to zero temperature, zero pressure, which is not as bad as it might sound). Materials project contains the computed energy (via density functional theory) of many compounds.
energy
: Total energy of the material.composition
: What proportion of atoms are in the materialenergy_per_atom
: Energy of the system per atom.e_above_hull
: How much energy would be gained if the crystalspacegroup
: Denotes the crystal spacegroup!pip install pymatgen
You may need to hit “restart runtime” since pymatgen has a lot of weird dependencies.
Go to materialsproject.org and make an account.
Click on API and request an API key.
from pymatgen import MPRester
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
API_KEY = "XXXXXXXXX"
Instead of XXXXXXXXX, insert the key you got from materials project. Don’t share the key with anyone.
with MPRester(API_KEY) as mpr:
print(mpr.supported_properties)
You should get a list of possible properties that you can request. The with
statement is called a context manager. It ensures your connection is closed correctly when the block ends.
Here’s a simple function that queries materials project, returning
def make_query(query):
with MPRester(API_KEY) as mpr:
return mpr.get_entries(query,
['material_id',
'pretty_formula',
'icsd_id',
'icsd_ids',
'e_above_hull',
'spacegroup',
'energy_per_atom',
'energy',
'composition'])
Try looking at the results.
make_query("C")
results = make_query("Ti-O")
Use the PhaseDiagram object to construct the convex hull. Note that you’ll need not just the Ti-O system, but also the
phase = pymatgen.analysis.phase_diagram.PhaseDiagram(results)
plotter = pymatgen.analysis.phase_diagram.PDPlotter(phase)
plotter.get_plot()
This can allow you to grab the energy above the hull from the database, since it is already pre-computed.
with MPRester(API_KEY) as mpr:
query_results=mpr.query("Ti-O",
['material_id',
'pretty_formula',
'icsd_id',
'icsd_ids',
'e_above_hull',
'spacegroup',
'energy_per_atom',
'energy',
'composition'])
df = pd.DataFrame(query_results)
Look at the energy difference between computed stable and unstable materials. Comment on what small errors in the formation energy might do to predictions of which material is thermodynamically stable.
If the entry has an ICSD ID or list of IDs, then it exists in the experimental ICSD database, so it has been observed. Plot the energy above the hull versus whether or not it’s in the ICSD. Why are we able to observe materials that are thermodynamically unstable? Think about the three pillars of materials science.