Query for specific stoichiometry


I would like to query all POSCAR that has stoichiometry as 1_1_5 irrespective of the type of elements (3 species in this example) that form this specific stoichiometry or the ordering (1_1_5, 1_5_1 and 5_1_1 are all needed). How can I do that? Thanks.

Hi @nitin0301, you can use a wildcard query like 1*1*5* to get all entries with elements in that ratio, e.g. try this search. For more complicated queries, pymatgen is often helpful to filter down your search results to just the materials you want.

Thanks. I was looking for something that can be done from python notebook. I looked at some example on github and tried following:

from pymatgen import MPRester
from pprint import pprint

m = MPRester(“my_api”)

pprint(m.query(criteria={“reduced_cell_formula”: “11*5”}, properties=[“structure”]))

Getting following error:
MPRestError: 115 is an invalid formula!

following is the correct entry for the pprint line that I mentioned in the previous reply:
pprint(m.query(criteria={"reduced_cell_formula": "*1*1*5"}, properties=["structure"]))

and also the error message is: MPRestError: 1*1*5 is an invalid formula!

Hmm, ok, for Jupyter use try:

from pymatgen import MPRester

with MPRester(YOUR_API_KEY_HERE) as mpr:
    docs = mpr.query(criteria={"formula_anonymous": "ABC5"},
                     properties=["task_id", "pretty_formula"])

We maintain a list of supported keys at the mapidoc.

Hope this helps!


1 Like

That works! Thanks.:slightly_smiling_face:

1 Like