Matbench Perovskite Dataset¶
Exploratory Data Analysis (EDA). MPContribs link
Matbench v0.1 dataset for predicting formation energy from crystal structure with 18,928 entries, adapted from an original dataset by Castelli et al.
The target is the heat of formation of the entire 5-atom perovskite cell in eV as calculated by RPBE GGA-DFT. The oxygen reference state was computed from oxygen's chemical potential in water vapor, not as oxygen molecules, to reflect the application these perovskites were studied for.
# make-assets supplies matminer
%pip install "pymatviz[make-assets]"
import kemio
import pandas as pd
from matminer.datasets import load_dataset
from tqdm import tqdm
import pymatviz as pmv
__author__ = "Janosh Riebesell"
__date__ = "2022-03-19"
df_perov = load_dataset("matbench_perovskites")
moyo_spg_num_key = "moyopy_spg_num"
df_perov[moyo_spg_num_key] = [
struct.get_symmetry_dataset(backend="moyopy", return_raw_dataset=True).number
for struct in tqdm(df_perov["structure"])
]
df_perov["volume"] = df_perov["structure"].map(lambda struct: struct.volume)
df_perov["formula"] = df_perov["structure"].map(lambda cryst: cryst.formula)
df_perov["crystal_system"] = df_perov[moyo_spg_num_key].map(kemio.crystal_system)
pmv.widget_grid(
{
idx: pmv.structure(structure=struct)
for idx, struct in df_perov["structure"].iloc[:12].items()
},
n_cols=4,
)
# Matbench Perovskites Formation Energy Distribution
widget = pmv.histogram(
df_perov["e_form"], bins=300, x_axis={"label": "Formation Energy (eV/atom)"}
)
widget.ref_lines = [
{"type": "vertical", "x": 0, "style": {"color": "black", "width": 2, "dash": "4 4"}}
]
widget
widget = pmv.ptable_heatmap(
df_perov["formula"],
exclude_elements=["O"],
heat_mode="percent",
color_bar={"title": "Elements in Matbench Perovskites dataset"},
)
widget.show()
# Crystal systems in Matbench Perovskites
crys_sys_counts = df_perov["crystal_system"].value_counts()
pmv.bar_plot(
[{"x": crys_sys_counts.index.astype(str).to_list(), "y": crys_sys_counts}],
x_axis={"label": "Crystal System"},
y_axis={"label": "Count"},
)
# Matbench Perovskites Formation Energy vs. Volume
pmv.scatter_plot(
[
{
"x": df_perov["volume"],
"y": df_perov["e_form"],
"color_values": df_perov[moyo_spg_num_key],
"markers": "points",
}
],
x_axis={"label": "Volume (ų)"},
y_axis={"label": "Formation Energy (eV/atom)"},
color_bar={"title": "Space group number"},
)
pmv.spacegroup_sunburst(df_perov[moyo_spg_num_key], label_text="label+percent")
# originally generated with aviary calling out to Aflow CLI, takes ~6h when running
# uninterrupted. see https://github.com/CompRhys/aviary/blob/14b2ab204ec/aviary/wren/utils.py#L158
# rows follow the Matbench dataset order, to_numpy raises if the lengths differ
aflow_protostructure_key = "aflow_wyckoff"
df_perov[aflow_protostructure_key] = pd.read_csv(
# 2022-05-17-matbench_perovskites_aflow_labels.csv
"https://docs.google.com/spreadsheets/d/"
"1Mhk5t3Ac_aHOTWMjZ1DL4LtUBIB21nWt7oy2t3M-fQU/export?format=csv"
)[aflow_protostructure_key].to_numpy()
extract spacegroups and crystal systems from Aflow Wyckoff labels
aflow_spg_num_key = "aflow_spg_num"
df_perov[aflow_spg_num_key] = (
df_perov[aflow_protostructure_key].str.split("_").str[2].astype(int)
)
df_perov["aflow_crys_sys"] = df_perov[aflow_spg_num_key].map(kemio.crystal_system)
Compare the spacegroups and crystal systems assigned by moyopy and AFLOW.
AFLOW uses an adaptive symmetry algorithm, so its assignments can differ from moyopy.
for moyo_col, aflow_col in (
(moyo_spg_num_key, aflow_spg_num_key),
("crystal_system", "aflow_crys_sys"),
):
df_compare = df_perov[[moyo_col, aflow_col]].set_axis(["Moyopy", "AFLOW"], axis=1)
pmv.sankey(df_compare, "Moyopy", "AFLOW").show()