|
5 | 5 | from aviary.utils import as_dict_handler
|
6 | 6 | from aviary.wren.utils import get_aflow_label_from_spglib
|
7 | 7 | from mp_api.client import MPRester
|
| 8 | +from pymatviz import density_scatter |
8 | 9 | from tqdm import tqdm
|
9 | 10 |
|
10 | 11 | from matbench_discovery import today
|
|
19 | 20 | __author__ = "Janosh Riebesell"
|
20 | 21 | __date__ = "2022-08-13"
|
21 | 22 |
|
22 |
| - |
23 | 23 | module_dir = os.path.dirname(__file__)
|
24 | 24 |
|
25 | 25 |
|
|
33 | 33 | "structure",
|
34 | 34 | "symmetry",
|
35 | 35 | "energy_above_hull",
|
| 36 | + "decomposition_enthalpy", |
| 37 | + "energy_type", |
36 | 38 | ]
|
| 39 | + |
37 | 40 | with MPRester(use_document_model=False) as mpr:
|
38 |
| - docs = mpr.summary.search(fields=fields) |
| 41 | + docs = mpr.thermo.search(fields=fields, thermo_types=["GGA_GGA+U"]) |
39 | 42 |
|
40 | 43 | print(f"{today}: {len(docs) = :,}")
|
41 | 44 | # 2022-08-13: len(docs) = 146,323
|
| 45 | +# 2023-01-10: len(docs) = 154,718 |
42 | 46 |
|
43 | 47 |
|
44 | 48 | # %%
|
45 | 49 | df = pd.DataFrame(docs).set_index("material_id")
|
46 | 50 | df.pop("_id")
|
47 | 51 |
|
48 |
| -df["spacegroup_number"] = df.pop("symmetry").map(lambda x: x.number) |
| 52 | +df.energy_type.value_counts().plot.pie(backend="matplotlib", autopct="%1.1f%%") |
| 53 | + |
| 54 | + |
| 55 | +# %% |
| 56 | +df["spacegroup_number"] = df.pop("symmetry").map(lambda x: x["number"]) |
49 | 57 |
|
50 | 58 | df["wyckoff_spglib"] = [get_aflow_label_from_spglib(x) for x in tqdm(df.structure)]
|
51 | 59 |
|
52 | 60 | df.to_json(f"{module_dir}/{today}-mp-energies.json.gz", default_handler=as_dict_handler)
|
53 | 61 |
|
54 | 62 | # df = pd.read_json(f"{module_dir}/2022-08-13-mp-energies.json.gz")
|
| 63 | + |
| 64 | + |
| 65 | +# %% reproduce fig. 1b from https://arxiv.org/abs/2001.10591 (as data consistency check) |
| 66 | +ax = df.plot.scatter( |
| 67 | + x="formation_energy_per_atom", |
| 68 | + y="decomposition_enthalpy", |
| 69 | + alpha=0.1, |
| 70 | + backend="matplotlib", |
| 71 | + xlim=[-5, 1], |
| 72 | + ylim=[-1, 1], |
| 73 | + color=df.decomposition_enthalpy.map(lambda x: "red" if x > 0 else "blue"), |
| 74 | + title=f"{today} - {len(df):,} MP entries", |
| 75 | +) |
| 76 | +# result on 2023-01-10: plots match. no correlation between formation energy and decomposition |
| 77 | +# enthalpy. R^2 = -1.571, MAE = 1.604 |
| 78 | +ax.figure.savefig(f"{module_dir}/{today}-mp-decomp-enth-vs-e-form.png", dpi=300) |
| 79 | + |
| 80 | +ax = density_scatter( |
| 81 | + df.formation_energy_per_atom, |
| 82 | + df.decomposition_enthalpy, |
| 83 | +) |
| 84 | +ax.set(xlim=[-5, 1], ylim=[-1, 1]) |
0 commit comments