Skip to content

Instantly share code, notes, and snippets.

@computron
Created May 18, 2014 20:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save computron/7ef25bec7afa1d39b6b9 to your computer and use it in GitHub Desktop.
Save computron/7ef25bec7afa1d39b6b9 to your computer and use it in GitHub Desktop.
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:
* change MP_ID to a Materials Project id
For citation, see https://www.materialsproject.org/citing
"""
from pymatgen import MPRester
from pymatgen.io.vaspio_set import MPVaspInputSet
if __name__ == "__main__":
MAPI_KEY = None # You must change this to your Materials API key! (or set MAPI_KEY env variable)
MP_ID = "mp-24972" # change this to the mp-id of your compound of interest
mpr = MPRester(MAPI_KEY) # object for connecting to MP Rest interface
user_incar_settings = {} # provide user incar settings, e.g. {"EDIFF": 0.00001}
hubbard_off = False # set True if you never want to use +U
vis = MPVaspInputSet(user_incar_settings=user_incar_settings, hubbard_off=hubbard_off) # chooses default INCAR, kpoints, etc
structure = mpr.get_structure_by_material_id(MP_ID)
print vis.get_incar(structure)
print vis.get_poscar(structure)
print vis.get_kpoints(structure)
# print vis.get_potcar(structure) # requires VASP_PSP_DIR env variable set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment