Hello!
I’m tring to calculate energy above hull (EAH) from formation energy.
Recently, I’ve been confused because a program that I wrote for verification outputs values different from the Materials Project’s(MP) EAH values for certain compounds.
The case for mp-3213581 (EAH in MP is 0.0099 eV/atom)is shown below;
import itertools
from mp_api.client import MPRester
from pymatgen.analysis.phase_diagram import PhaseDiagram
from pymatgen.entries.computed_entries import ComputedEntry
with MPRester(API) as mpr:
docs = mpr.summary.search(material_ids="mp-3213581")
composition = docs[0].composition
elements = [str(el) for el in composition.elements]
all_chemsyses = []
for i in range(len(elements)):
for els in itertools.combinations(elements, i + 1):
all_chemsyses.append("-".join(sorted(els)))
with MPRester(API) as m:
materials = m.materials.summary.search(chemsys=all_chemsyses,
fields=["composition",
"formation_energy_per_atom"])
entries = []
for material in materials:
comp = material.composition
formation_energy_per_atom = material.formation_energy_per_atom
num_atoms = comp.num_atoms
if formation_energy_per_atom is not None:
entry = ComputedEntry(composition=comp,
energy=formation_energy_per_atom*num_atoms)
entries.append(entry)
# remove mp-3213581([-1]) for testing
entries.pop()
target_entry = ComputedEntry(composition=composition,
energy = eform*composition.num_atoms)
entries.append(target_entry)
phase = PhaseDiagram(entries)
target_eah = phase.get_e_above_hull(target_entry)
target_eform = phase.get_form_energy_per_atom(target_entry)
EAH from this program is 0.2663 eV/atom.(Instead, formation energy value is same as MP.)
This does not work for all compounds; for example, mp-1370479 outputs the same EAH value as MP.
Please teach me why mp-3213581 is not going well and what is the difference between mp-3213581 and mp-1370479.
This has to do with the corrections scheme used to mix energy data from different DFT functionals, as well as mp-1370479 having only PBE GGA+U calculations, and mp-3213581 having only r2SCAN calculations
For mp-3213581, you will need to specifically retrieve the entries that are only computed with r2SCAN:
from mp_api.client import MPRester
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.analysis.phase_diagram import PhaseDiagram
with MPRester() as mpr:
mat_doc = mpr.materials.summary.search(material_ids=["mp-3213581"],fields=["composition","energy_per_atom"])[0]
chemsys = mat_doc.composition.chemical_system
entries = mpr.get_entries_in_chemsys(chemsys,additional_criteria = {"thermo_types": ["R2SCAN"]})
target_entry = ComputedEntry(
composition=mat_doc.composition,
energy=mat_doc.energy_per_atom*mat_doc.composition.num_atoms
)
pd = PhaseDiagram(entries + [target_entry])
print(pd.get_e_above_hull(target_entry))
>>> 0.009926182854936627
Also note that the API client has a method to directly get the stability of an entry for you:
I believe the GGA/GGA+U/r2SCAN mixing scheme was developed to deal with the limited availability of r2SCAN-calculated data. You mentioned that the compound having only r2SCAN calculations, the phase diagram should be constructed using only r2SCAN data. Would this phase diagram be considered accurate?
I think phase diagram should be constructed by energy applied for GGA/GGA+U/r2SCAN mixing scheme. I think queried formation energy from MP already applied for this scheme, so I don’t understand why formation energies calculated by GGA and r2SCAN must not be mixed.
I confirmed the case of mp-29447(having only r2SCAN calculations) outputs the same EAH value as MP. What is the difference between mp-3213581 and mp-29447.
In MP, there are a lot of compounds having both GGA and r2SCAN calculations. How should I do toward these data.
The GGA / GGA+U / r2SCAN mixing scheme is only applied for entries with thermo_type = GGA_GGA_U_R2SCAN. The thermo_type = GGA_GGA_U hull does not use this scheme, and the thermo_type = R2SCAN hull uses no corrections scheme
Not sure what you’re asking sorry! mp-29447 has GGA, GGA+U, and r2SCAN calculations, mp-3213581 has only r2SCAN. mp-3213581 is also a GNoME material, for which we have not released full thermodynamic data, hence no GGA_GGA_U_R2SCAN mixed hull
You should directly query the thermo endpoint which has the formation energy and energy above hull computed for you. Make sure to use a consistent thermo_type