Created
September 1, 2012 11:23
-
-
Save shyuep/3570304 to your computer and use it in GitHub Desktop.
Phase stability using the Materials API + pymatgen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from pymatgen.matproj.rest import MPRester | |
from pymatgen.phasediagram.pdmaker import PhaseDiagram | |
from pymatgen.phasediagram.plotter import PDPlotter | |
#This initializes the REST adaptor. Put your own API key in. | |
a = MPRester("YOUR_API_KEY") | |
#Entries are the basic unit for thermodynamic and other analyses in pymatgen. | |
#This gets all entries belonging to the Ca-C-O system. | |
entries = a.get_entries_in_chemsys(['Ca', 'C', 'O']) | |
#With entries, you can do many sophisticated analyses, like creating phase diagrams. | |
pd = PhaseDiagram(entries) | |
plotter = PDPlotter(pd) | |
plotter.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
__author__ = "Shyue Ping Ong" | |
__maintainer__ = "Shyue Ping Ong" | |
__email__ = "[email protected]" | |
__status__ = "Production" | |
__version__ = "1.0" | |
__date__ = "Sep 21, 2012" | |
import argparse | |
import sys | |
from pymatgen.matproj.rest import MPRester | |
from pymatgen.phasediagram.pdmaker import PhaseDiagram | |
from pymatgen.apps.borg.hive import VaspToComputedEntryDrone | |
from pymatgen.phasediagram.pdanalyzer import PDAnalyzer | |
from pymatgen.entries.compatibility import MaterialsProjectCompatibility | |
def calculate_phase_stability(args): | |
#This initializes the REST adaptor. | |
a = MPRester(args.api_key) | |
drone = VaspToComputedEntryDrone() | |
entry = drone.assimilate(args.directory) | |
compat = MaterialsProjectCompatibility() | |
entry = compat.process_entry(entry) | |
if not entry: | |
print "Calculation parameters are not consistent with Materials " + \ | |
"Project parameters." | |
sys.exit() | |
syms = [el.symbol for el in entry.composition.elements] | |
#This gets all entries belonging to the relevant system. | |
entries = a.get_entries_in_chemsys(syms) | |
entries.append(entry) | |
#Process entries with Materials Project compatibility. | |
entries = compat.process_entries(entries) | |
pd = PhaseDiagram(entries) | |
analyzer = PDAnalyzer(pd) | |
ehull = analyzer.get_e_above_hull(entry) * 1000 | |
print "Run contains formula {} with corrected energy {:.3f} eV.".format( | |
entry.composition, entry.energy | |
) | |
print "Energy above convex hull = {:.1f} meV".format(ehull) | |
if ehull < 1: | |
print "Entry is stable." | |
elif ehull < 30: | |
print "Entry is metastable and could be stable at finite temperatures." | |
elif ehull < 50: | |
print "Entry has a low probability of being stable." | |
else: | |
print "Entry is very unlikely to be stable." | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description=""" | |
This is a simple phase stability estimation script which utilizes the | |
Materials API and pymatgen to calculate the phase stability of a single | |
material.""", | |
epilog=""" | |
Author: Shyue Ping Ong | |
Version: {} | |
Last updated: {}""".format(__version__, __date__)) | |
parser.add_argument("directory", metavar="dir", type=str, | |
help="directory containing vasp run to process") | |
parser.add_argument("-k", "--key", dest="api_key", type=str, required=True, | |
help="User's Materials API key.") | |
args = parser.parse_args() | |
calculate_phase_stability(args) |
aziziph
commented
Jun 19, 2019
via email
Thank you!
…On Wed, Jun 19, 2019 at 10:51 AM Shyue Ping Ong ***@***.***> wrote:
It is now integrated into the PhaseDiagram class
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/3570304?email_source=notifications&email_token=AMMMUQGAZ7PEHCWNLJFOI6LP3HGAPA5CNFSM4HZGHY72YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFT5NU#gistcomment-2947802>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMMMUQG4K7HXDSNBDT6VJ33P3HGAPANCNFSM4HZGHY7Q>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment