Phase stability using the Materials API + pymatgen.
#!/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() |
#!/usr/bin/env python | |
__author__ = "Shyue Ping Ong" | |
__maintainer__ = "Shyue Ping Ong" | |
__email__ = "shyue@mit.edu" | |
__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) |
This comment has been minimized.
This comment has been minimized.
Dear researcher, |
This comment has been minimized.
This comment has been minimized.
Dear pymatgen users, It seems the library 'pdanalyzer' no longer exists, since I face to error while using 'from pymatgen.phasediagram.pdanalyzer import PDAnalyzer'. Any comment from where to import this library? Regards |
This comment has been minimized.
This comment has been minimized.
It is now integrated into the PhaseDiagram class |
This comment has been minimized.
This comment has been minimized.
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
This comment has been minimized.
I am happy to find you at Git. Because I'm in china, where Twitter&Google is shielded, so that it is not convenient to get access to you by the other routht.
Pymatgen looks like very powerful, so I wonder to know if pymaten can be used for steel-making, for some calculations for the equilibrium between steel(Fe,C,Si,Mn,P,S....) and slag (CaO,SiO2,MgO....).
There is already a software named FactSage that contains professional database for oxides, But the price is too high. Thus I have an idea to build functions with python myself, but I know some others must have done some work. so I find pymatgen and come here。