API mp-id query structure, get the unexpected structure


#1

Hi MP manager,

I met a problem when I was trying to get the conventional cell from materials project by using API (ID: mp-37). I have two ways to get conventional cell and they return me different structures by using the same mp-id.

First way:
m = MPRester(“xxx”)
entry = m.get_entry_by_material_id(material_id=“mp-37”,
compatible_only=True,
inc_structure=True,
property_data=None,
conventional_unit_cell=True)
print(entry.structure)

Full Formula (Th2)
Reduced Formula: Th
abc : 2.822000 2.822000 4.411000
angles: 90.000000 90.000000 90.000000
Sites (2)

SP a b c


0 Th 0 0 0
1 Th 0.5 0.5 0.5

Second way:
m = MPRester(“xxx”)
Th = m.get_structure_by_material_id(“mp-37”, final=True, conventional_unit_cell=True)
print(Th)

Full Formula (Th4)
Reduced Formula: Th
abc : 5.041217 5.041217 5.041217
angles: 90.000000 90.000000 90.000000
Sites (4)

SP a b c


0 Th 0 0 0
1 Th 0 0.5 0.5
2 Th 0.5 0 0.5
3 Th 0.5 0.5 0

The second way returns same structure by downloading from the MP website, which is the structure I expected. While by using the first way, the conventional structure I got is expected, not fcc.

Thank you for your concern!

Best,
Tina


#2

Hi Tina,

Thanks for the explicit description of the problem. I’m looking through the code, and it looks like the inc_structure flag has to be set to “final” to include the optimized structure as the included structure in the entry returned by MPRester.get_entry_by_material_id, e. g.

from pymatgen import MPRester
m = MPRester()
entry = m.get_entry_by_material_id(material_id="mp-37",
                                   compatible_only=True,
                                   inc_structure="final",
                                   property_data=None,
                                   conventional_unit_cell=True)
print(entry.structure)

This seems counterintuitive to me, since the “final” or optimized structure is the one that the entry energy actually corresponds to, so I’ll submit a pull request to pymatgen to have this changed.


#3

Just to follow up, this will be changed in the next release to pymatgen. inc_structure=True will default to returning the final structure.


#4

Hi Joseph,

Thank you very much for your prompt reply and solutions!

I got it, and thank you for the updates!

Best,
Tina