目前Materials Project已经启用新的网站(新的Materials Project网站),并且采用新的api_key进行访问它们的数据库。
以下是新旧API的对比:
新的api_key需要安装mp-api:pip install mp-api#https://matsci.org/t/new-mp-api-fails-in-jupyter/42967/4
1. 通过Materials Project IDs搜索材料
from mp_api.client import MPResterwith MPRester("your_api_key_here") as mpr:docs = mpr.summary.search(material_ids=["mp-149", "mp-13", "mp-22526"])
example_doc = docs[0]mpid = example_doc.material_idformula = example_doc.formula_prettyprint(mpid)print(formula)
mp-149Si
2. 限定特定元素和特定带隙搜索材料
from mp_api.client import MPResterwith MPRester("your_api_key_here") as mpr:docs = mpr.summary.search(elements=["Si", "O"],band_gap=(0.5, 1.0),fields=["material_id","band_gap","volume", "formula_pretty"])
example_doc = docs[0]mpid = example_doc.material_id # a Materials Project IDformula = example_doc.formula_pretty # a formulavolume = example_doc.volume # a volume#example_doc.fields_not_requested # list of unrequested fieldsprint(mpid, formula, volume)
mp-1293053 MgMnSiO5 335.42577089080943. 搜索稳定且带隙大于一定值的材料
from mp_api.client import MPResterwith MPRester("your_api_key_here") as mpr:## -- Alternative directly using energy above hull:docs = mpr.summary.search(band_gap=(3,None),energy_above_hull=(0,0),fields=["material_id"])stable_mpids = [doc.material_id for doc in docs]print(stable_mpids[0])
mp-1195170参考资料:
https://docs.materialsproject.org/downloading-data/using-the-api/querying-data
https://docs.materialsproject.org/downloading-data/using-the-api/examples
| 留言与评论(共有 0 条评论) “” |