How to get crystal structures and then get lattice constants and atomic radius and atomic numbers?

hello everyone, here is the code, idk how to use new API to do such things, and I didn’t find the way to solve it in the doc.
I want to get lattice constant, atomic radius, atomic number for several elements.
could you help me to find the errors? thx!!!

from mp_api.client import MPRester
from pymatgen.core.periodic_table import Element
import pandas as pd

api_key = "xxx"
elements = [
    "Cs", "Rb", "K", "Ba", "Sr", "Eu", "Yb", "Ca", "La", "Na",
    "Sm", "Nd", "Pr", "Ho", "Li", "Er", "Tm", "Gd", "Ce", "Tb",
    "Dy", "Y", "Lu", "Sc", "Ti", "Hf", "Mg", "Zr", "In", "Ga",
    "Zn", "Al", "Bi", "Sn", "V", "Cr", "Mo", "Nb", "Ta", "Sb",
    "Fe", "Mn", "Ge", "As", "W", "Te", "Co", "Cu", "B", "Si",
    "Be", "Ni", "O"
]

mpr = MPRester(api_key)

lattice_constants = []
atomic_radii = []
atomic_numbers = []

for element in elements:
    result = mpr.summary.search(chemsys= element, properties= structure)

    structure = result[0]["structure"]
    lattice_constants.append(structure.lattice.a)
    element_obj = Element(element)
    atomic_radii.append(element_obj.atomic_radius)
    atomic_numbers.append(element_obj.atomic_number)

df = pd.DataFrame({
    "Element": elements,
    "Lattice Constants": lattice_constants,
    "Atomic Radii": atomic_radii,
    "Atomic Numbers": atomic_numbers
})

df.head()

csv_file_path = 'materials_data_with_properties.csv'
df.to_csv(csv_file_path, index=False)
print(f'Data with lattice constants, atomic radii, and atomic numbers saved to {csv_file_path}')

Could you provide an actual error message or describe the problem you’re running into?

Thx for the reply, I’ve solved the problem.
However, still have a question, could you tell me how to get the melting point data? Does MP have that data? I didn’t find how to do it in api docs.
Best regards.

We have some contributed melting point data in MPContribs: https://contribs.materialsproject.org/projects/melting_points. See the docs at https://mpcontribs.org for details on how to retrieve that data. @mattmcdermott is one of the contributors of that dataset and might be able to help with the details.

Thx, I’ll have a try.

I’m sorry to bother you again.
This website https://contribs.materialsproject.org/projects/melting_points is not available now, it seems the data go into the new generation mp database, however, IDK which database provides the melting point data, the one that seems like will have those data is called Experimental Thermochemistry Database. But I don’t see the melting point data in it. Could you please help me to take a look?

Hi @Roberto_Baggio , I understand that the name 'Experimental Thermochemistry" might make it sound like there is melting point data in there, but that is not the case. That particular MPContribs dataset only contains formation energies and enthalpies; no melting points.

It sounds like the best way to get melting point data is to query the MPContribs collection that you linked.

thx for helping!

Sure, the link you provided: https://contribs.materialsproject.org/projects/melting_points, it seems will directly go to the database with the melting point, is that correct?

What I see is when I open the site, it says: “We are in the process of moving this portal to the new MPContribs Explorer on our next-gen website. It will stay available and functional until the new explorer is feature-complete. Both sites are interfaces to the same data and can be used interchangably.
Project ‘melting_points’ not found or access denied! Try to log in.”

I checked both of the link you sent and the data in the next-generation MP, still haven’t found such data.

@mattmcdermott I’m sorry to bother you, could you please give me your dataset in MPContribs collection?

Best regards.

Thanks for following up. It indeed looks like the authors never made that project public. I just published it and you should be able to access it at https://contribs.materialsproject.org/projects/melting_points. Instructions to download MPContribs projects are here:

Yea! Now I can see those data, thank you very much!
Have a good day :grin:

@Roberto_Baggio we just added the full set of 155k melting points to the MPContribs project: https://contribs.materialsproject.org/projects/melting_points. @mattmcdermott can help with question if needed.

Sorry for bother again :joy:
I tried to download those data using the below code, but it doesn’t work, and the doc doesn’t tell me the way to save the data from MPContribs, could you do me a favor?
@mattmcdermott

from mpcontribs.client import Client
client = Client(apikey="my api", project="melting_points")
# print(client.available_query_params())
query = {}
client.download_contributions(query=query, include=[“tables”])

Best regards.

@Roberto_Baggio Please try to be as specific as possible when describing your issue. “it doesn’t work” unfortunately doesn’t give us any indicators as to how to help you.

query/download_contributions() both return a list of dictionaries. So assign the output of those functions to a variable and use it as input to your code or convert/write it to the format you need.

Thx! Now I have already corrected the code and got all the data. Much appreciation!