Skip to content

Instantly share code, notes, and snippets.

@computron
Last active March 2, 2018 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save computron/939af8c774a7737f0d5f69401722454f to your computer and use it in GitHub Desktop.
Save computron/939af8c774a7737f0d5f69401722454f to your computer and use it in GitHub Desktop.
estimate oxidative stability of a compound using Materials Project data. The higher (less negative) the maximum chemical potential of oxygen that is tolerated, the more stable.
from pymatgen import Composition, Element, MPRester
from pymatgen.analysis.phase_diagram import PhaseDiagram
if __name__ == "__main__":
# stuff the user needs to set
MAPI_KEY = None
FORMULA = "FeP2"
OPEN_ELEMENT = "O"
# automatic from here on down!
# add oxygen to list of elements if formula doesn't have it
comp = Composition(FORMULA)
elements = [str(x) for x in comp.elements]
if OPEN_ELEMENT not in elements:
elements.append(OPEN_ELEMENT)
# get the profile of evolution for the open element
mpr = MPRester(MAPI_KEY) # object for connecting to MP Rest interface
entries = mpr.get_entries_in_chemsys(elements, compatible_only=True)
pd = PhaseDiagram(entries)
profile = pd.get_element_profile(Element(OPEN_ELEMENT), comp)
# determine the maximum chemical potential in which the open element is not evolved/produced.
max_chempot = -float("inf")
for x in profile:
if round(x["evolution"], 5) == 0 and x["chempot"] > max_chempot:
max_chempot = x["chempot"]
print(FORMULA, max_chempot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment