Getting different catalyst structures & atomic positions from website and api (cif, poscar, everything)

Hello,

I am getting a completely different structure and atomic positions when I query for the structure in pymatgen and the new mp-api than when I download the same files from the website from catalysis explorer for the bulk material. For example, mp-30811. The ones on the website seem to have more atoms and detail which is what I want. How do I get these files from the api as well? Thanks for any help, I am new to this stuff :slight_smile:
Here is the code I had so far:

from mp_api.client import MPRester
m = MPRester(api_key=“api key”)

#Open the file and iterate over each line, each line has an mp-id
with open(‘top1k.txt’, ‘r’) as file:
for line in file:
x = line.strip()
structure = m.get_structure_by_material_id(x)
print(structure)
cif_data = structure.to(fmt=“json”)
fn = x + “.json”
with open(fn, “w”) as f:
f.write(cif_data)

Thanks.

@Abhinav_Maru that looks good. Are you looking for the conventional cell instead of the primitive one? If so, you can use the code below to download it directly to a CIF file:

m = MPRester(api_key=“api key”)

with open(‘top1k.txt’, ‘r’) as file:
for line in file:
    x = line.strip()
    structure = m.get_structure_by_material_id(x, conventional_unit_cell=True)
    cif_data = structure.to(filename=f“{x}.cif”) # Dumps to a file in current dir

– Jason

The data behind the Catalysis Explorer on our website is from the Open Catalyst Project on MPContribs, see

The structures used on the website are from the structures and/or attachments components in the above MPContribs project. See Query and Download Contributed Data - Materials Project Documentation for details on how to download data from MPContribs.

Hello Jason,

This was exactly what I was looking for and I think I can make these cifs work. However I was wondering out of curiosity what to do to get a cif of the interactive model on the website as well? It is not necessary for my project but I was just wondering if you knew.

Thanks.

@Abhinav_Maru the interactive structure on the main details pages is accessible with the code I provided.

– Jason

Is there a way to get the cartesian coordinates instead of the fractional coordinates from the MPContribs api? If not, is there an easy way to turn the fractional coordinates into cartesian for a 500+ structures at once?

Sorry if I am bothering everyone with questions, I am still a little new to the api and the field in general. Thanks for any help!

-Abhinav

When you use the query/download_contributions() functions in mpcontribs-client, the structures are returned as pymatgen objects. Any pymatgen structure object has a cart_coords attribute that should give you the cartesian coordinates for a structure. Please refer to the pymatgen documentation for more info. The structure object in Jason’s code snippet is a pymatgen Structure, too. HTH.

Thank you!