Created
May 18, 2014 20:51
-
-
Save computron/8acc53ef995064163a73 to your computer and use it in GitHub Desktop.
Print structures from Materials Project
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
""" | |
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: | |
* change QUERY to either an mp-id, a formula, or a chemical system | |
For citation, see https://www.materialsproject.org/citing | |
""" | |
from pymatgen import MPRester | |
if __name__ == "__main__": | |
MAPI_KEY = None # You must change this to your Materials API key! (or set MAPI_KEY env variable) | |
QUERY = "mp-1203" # change this to the mp-id of your compound of interest | |
# QUERY = "TiO" # change this to a formula of interest | |
# QUERY = "Ti-O" # change this to a chemical system of interest | |
mpr = MPRester(MAPI_KEY) # object for connecting to MP Rest interface | |
structures = mpr.get_structures(QUERY) | |
for s in structures: | |
print s |
I practice similarly with the above example and saved it as "structures.py" in jupyter notebook:
**from pymatgen import MPRester
if name == "main":
MAPI_KEY = "..." # I use my key
QUERY = "TiO"
mpr = MPRester(MAPI_KEY)
structures = mpr.get_structures(QUERY)
for s in structures:
print s**
However, when I run in Anaconda Prompt, I got this error:
(base) C:\Users\Owner>python structures.py
File "structures.py", line 10
print m.get_materials_id_references('mp-568')
^
SyntaxError: invalid syntax
Anyone please help me. I am just a beginner.
Thanks a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MAPI_KEY = "your key"