How can I extract all the entries of perovskite structure from Materials Project?

I attempted to search for all the structures of type ABC3, but found that it was not comprehensive.Because there are some perovskite compounds whose chemical formulas cannot be simply summarized as ABC₃. Such as Cs3Sb2I9.

Hey @Chuanxi-cairen, there are a couple options: if you have a list of anonoymized formulae (ABC3, A3B2C9, etc.) you can query directly for those.

Otherwise, you can search by crystal prototype using the robocrystallographer documents and manually-assigned provenance:

from mp_api.client import MPRester

with MPRester() as mpr:
    robocrys_docs = mpr.materials.robocrys.search(
        keywords=["perovskite"]
    )
    prov_docs = mpr.materials.provenance.search(
         fields=["material_id","remarks","tags"]
    )

robo_perov_mpids = [doc.material_id for doc in robocrys_docs]
possible_perov = [
    doc.material_id for doc in prov_docs
    if any("perovskite" in tag.lower()
    for tag in (doc.tags+doc.remarks))
]

likely_perovskite_mpids = list(
    set(robo_perov_mpids).union(possible_perov)
)
2 Likes

Thanks!I extracted 4266 likely materials project id of perovskite. When I ran this code, I found that

possible_perov = [
    doc.material_id for doc in prov_docs
    if any("perovskite" in tag.lower()
    for tag in (doc.tags+doc.remarks))
]

should be changed to

possible_perov = [
    doc.get("material_id") for doc in prov_docs
    if any("perovskite" in tag.lower()
    for tag in (doc.get("tags", []) + doc.get("remarks", [])))
]

as prov_docs is a dictionary.

prov_docs should be a list of dictionaries if you use MPRester(use_document_model=False), but the default behavior should give you python objects (the pydantic document models)

1 Like

I did use “use_document_model=False”. Thank you very much for clearing up my confusion.