Skip to content

Instantly share code, notes, and snippets.

@computron
computron / pd_example.py
Created May 8, 2014 18:33
Create, plot, and analyze Phase Diagrams using the pymatgen codebase and Materials Project database
"""
This is a basic example of how to create, plot, and analyze Phase Diagrams using the pymatgen
codebase and Materials Project database. To run this example, you should:
* have pymatgen (www.pymatgen.org) installed along with matplotlib
* obtain a Materials Project API key (https://www.materialsproject.org/open)
* paste that API key in the MAPI_KEY variable below, e.g. MAPI_KEY = "foobar1234"
For citation, see https://www.materialsproject.org/citing
For the accompanying comic book, see http://www.hackingmaterials.com/pdcomic
@computron
computron / gcpd_example.py
Last active February 27, 2022 09:47
Create, plot, and analyze OPEN (grand canonical) Phase Diagrams using the pymatgen codebase and Materials Project database
"""
This is a basic example of how to create, plot, and analyze OPEN Phase Diagrams using the pymatgen
codebase and Materials Project database. To run this example, you should:
* have pymatgen (www.pymatgen.org) installed along with matplotlib
* obtain a Materials Project API key (https://www.materialsproject.org/open)
* paste that API key in the MAPI_KEY variable below, e.g. MAPI_KEY = "foobar1234"
For citation, see https://www.materialsproject.org/citing
For the accompanying comic book, see http://www.hackingmaterials.com/pdcomic
"""
from __future__ import print_function
@computron
computron / check_stability.py
Last active August 18, 2023 16:26
Check a new material's stability using the pymatgen codebase and Materials Project database
"""
This is a basic example of how to check a new material for stability using the pymatgen
codebase and Materials Project database. It assumes that you have already calculated
the energy of your predicted compound with DFT.
It is very important to note that this code does NOT do a detailed check to make sure
your computed energies are compatible with those in the Materials Project database
(i.e., uses the same functional, +U corrections, k-point mesh, etc). You must ensure
that the energies you provide are directly comparable with those in Materials Project,
otherwise this code will give you false results!
@computron
computron / print_corrections.py
Last active August 29, 2015 14:01
Print all corrections applied on a Materials Project entry
"""
This example prints out the corrections applied by a Compatibility scheme
(e.g., MaterialsProjectCompatibility) in order to improve the accuracy of reaction energies
and phase diagrams.
To run this example, you should:
* have pymatgen (www.pymatgen.org) installed
* obtain a Materials Project API key (https://www.materialsproject.org/open)
@computron
computron / plot_bs.py
Last active July 13, 2022 23:19
plot_bandstructure
"""
This example prints out a band structure object of a Materials Project entry.
To run this example, you should:
* have pymatgen (www.pymatgen.org) installed
* obtain a Materials Project API key (https://www.materialsproject.org/open)
* paste that API key in the MAPI_KEY variable below, e.g. MAPI_KEY = "foobar1234"
as well as:
@computron
computron / print_structures.py
Created May 18, 2014 20:51
Print structures from Materials Project
"""
This example prints out structure(s) by MP id, by formula, or by chemical system
To run this example, you should:
* have pymatgen (www.pymatgen.org) installed
* obtain a Materials Project API key (https://www.materialsproject.org/open)
* paste that API key in the MAPI_KEY variable below, e.g. MAPI_KEY = "foobar1234"
as well as:
@computron
computron / create_vaspinputs.py
Created May 18, 2014 20:55
Create VASP inputs for an MP structure
"""
This example prints out VASP inputs for an MP structure.
To run this example, you should:
* have pymatgen (www.pymatgen.org) installed
* obtain a Materials Project API key (https://www.materialsproject.org/open)
* paste that API key in the MAPI_KEY variable below, e.g. MAPI_KEY = "foobar1234"
as well as:
@computron
computron / fireworks-vasp_demo.py
Created November 9, 2014 06:09
basic demo of using the fireworks-vasp codebase
from fireworks import Firework
from fireworks.core.firework import Workflow
from fireworks_vasp.tasks import WriteVaspInputTask, VaspCustodianTask, VaspAnalyzeTask
from pymatgen.matproj.rest import MPRester
"""
This demo shows how one can use the fireworks-vasp codebase. It runs only a single VASP job.
To run multiple VASP jobs in a workflow, one needs to pass the directory information between
jobs such that input files can be copied.
"""
@computron
computron / get_dos_csv.py
Created February 24, 2016 19:24
Helps convert a DOS to tab-delimited. Useful for experimentalists working in Excel
from pymatgen import MPRester, Spin, Element
def print_dos_data(dos):
print("The Fermi energy is {}".format(dos.efermi))
cols = ["energy", "total_dos", "up_dos", "down_dos"]
energies = dos.energies
total_dos = dos.get_densities() # note that you can also get smeaered densities using a different function
up_dos = dos.get_densities(Spin.up)
@computron
computron / BulkModulus.ipynb
Created November 30, 2016 19:10
Demo: Bulk modulus prediction with MatMiner
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.