Difference between Materials project New and Legacy

Hello.
I have a question that’s been on my mind, so I’m posting it here in the community for the first time.

For the Material Project, there are two versions: the Legacy site and the newly revamped site. I used the Legacy site first, and while using the recently updated site, I have some questions, so I’m reaching out.

  1. How to export a primitive cell
    On the Legacy site, there was a clear button to extract the primitive cell as a cif file, but on the New site, even when I change the crystal structure to a primitive cell and click “export as,” it seems to still give me the conventional cell structure. Additionally, the crystal structures of the cells downloaded from the Legacy site and the Renewal site look slightly different. Why is that?

  2. Different Energy Above Hull
    Of course, I understand that this issue may vary depending on the calculation process and the data that has been accumulated over time.
    However, I’m generally looking to check Hull Energy as a criterion for finding a stable phase, but I’m confused because the Hull Energy differs between Legacy and New, making it hard to determine which material has a more stable phase.
    For example, in the case of Co, the Energy Above Hull for “mp-54” and “mp-102” is different in Legacy and New.
    If Energy Above Hull = 0 indicates a more stable state, then in Legacy, mp-54 shows a value of 0, making it appear more stable, while in New, mp-102 shows 0, indicating that it is more stable. I would appreciate it if you could explain the reason for these differences.

Best regards.

  1. We’re currently working on adding features to the next-gen site that were present in the legacy site, including a structure download - @ruoxiyang can hopefully comment if I’m wrong. For now, you can download primitive structures through the API as follows:
from mp_api.client import MPRester

with MPRester("your_api_key") as mpr:
    # if you only need a single structure:
    structure = mpr.get_structure_by_material_id("mp-xxxxxx")
primitive_cell = structure.get_primitive_structure()

# write to file, can do something like "structure.cif", "POSCAR", etc.
primitive_cell.to("structure.cif")

If you want to download larger batches of structures, use mpr.materials.summary.search(material_ids=[<list of MP IDs>]).

Additionally, the crystal structures of the cells downloaded from the Legacy site and the Renewal site look slightly different. Why is that?

This also partly answers your second question, but MP is in the process of recomputing all structures in our database (relaxed structures + thermodynamic + electronic properties) with a higher level of theory (r2SCAN vs. the older PBE GGA). You can find details about this here and here.

  1. The hulls in the next-gen site use a mixture of r2SCAN and PBE+U hulls (see the previous links), so they’ll differ from the legacy site. We recommend using the next-gen site for more accurate hulls/stabilities.
1 Like

Thank you for your reply.

First off, since it looks like the group still adding features to the next-gen site, it seems that downloading primitive cells isn’t possible on the site, right?
I’ll try downloading it using the API.

Next, you mentioned that the results from the next-gen site are more accurate.
In the case of Co, it’s known to undergo a phase transition from HCP structure at low temperatures to FCC structure at high temperatures around 825K [1, 2].
I believe the Hull Energy calculation method is generally conducted at 0K,
so shouldn’t the HCP structure, mp-54, show a more stable result than the FCC structure, mp-102?

Best regards.

[1] First Principles Theory of the hcp-fcc Phase Transition in Cobalt | Scientific Reports (nature.com)
[2] Cobalt - Wikipedia

First off, since it looks like the group still adding features to the next-gen site, it seems that downloading primitive cells isn’t possible on the site, right?
I’ll try downloading it using the API.

Yes please use the API for now.

I believe the Hull Energy calculation method is generally conducted at 0K,
so shouldn’t the HCP structure, mp-54, show a more stable result than the FCC structure, mp-102?

You’ve found an interesting edge case where r2SCAN actually predicts hcp Co to be dynamically unstable, and fcc Co to be stable - see p. 024102-4 of this paper by Liu et al. I wasn’t aware of this previously.

There’s no single DFT method right now that offers universal accuracy. r2SCAN is generally more accurate but not in this specific case.

1 Like

According to the paper I attached earlier, in the absence of magnetism, Co is generally expected to have a stable phase in an FCC structure [1].

I haven’t had time to read through the link you attached yet, but here’s what I’ve roughly gathered.

  1. SCAN overstabilizes the ferromagnetic (FM) state when it has a very large local magnetic moment.
  2. In r2SCAN, a different approach was introduced to address this issue.
  3. The r2SCAN calculations were performed using VASP, and spin-polarized calculations were conducted.
  4. At this time, Co was assumed to be ferromagnetic.


If the magnetic calculations are accurate, should we consider that the difference between the paper I presented and the one you suggested might be due to the fact that, as you mentioned earlier,

There’s no single DFT method right now that offers universal accuracy. r2SCAN is generally more accurate but not in this specific case.

there isn’t a single DFT method that provides universal accuracy, which could mean one of them might not have had an accurate calculation?

[1] First Principles Theory of the hcp-fcc Phase Transition in Cobalt | Scientific Reports (nature.com)

Hey.
I’d like to get some primitive cell data of Cobalt binary metals.

So I tried structure = mpr.materials.summary.search like below.

But this code threw an error like this.

It worked fine when outputting the primitive cell of a single substance.

Can you tell me how I can quickly extract the primitive cell data for multiple substances?
Even I read the MP public docs, I didn’t get it as well.
Where can I find the whole codes and option list?

Thank you.

mpr.materials.summary.search() returns a list of structures. Run .get_primitive_structure() on the list element(s) by using an index or for loop.

1 Like

Hi.
Thanks for your advise.

You mean, I should make an array of whole materials by using mpr.materials.summary.search(), and print out those structure’s primitive cell with loop?

If so, can you please tell me is the code I wrote right?

import os
from mp_api.client import MPRester

with MPRester("My API") as mpr:
    structures = mpr.materials.summary.search(
                elements = ["Co"],
                chemsys = "Co-*",
                energy_above_hull = (0, 0),
                is_metal = True,
                is_stable = True
)

with open("2test.txt", "w") as file:
    # count number of doc.
    file.write(f"Number of documents: {len(structures)}\n\n")

    if not structures:  # if nothing searched
        file.write("No results found.\n")
    else:
	for idx, structure_summary in enumerate(structures):
            # bring structure informations
            structure = mpr.get_structure_by_material_id(material_id)
            # extract primitive cell data
            primitive_cell = structure.get_primitive_structure() 

            # Save material_id and primitive cell information into test.txt file
            file.write(f"--- Document {idx + 1} ---\n")
            file.write(f"Primitive Structure:\n{primitive_cell}\n")
            file.write('-' * 40 + "\n")
            file.write("\n\n")

And my output is like below.

2test.txt

Number of documents: 110

— Document 1 —
Primitive Structure:
Full Formula (Zr6 Co23)
Reduced Formula: Zr6Co23
abc : 8.115843 8.115850 8.115907
angles: 59.999331 59.999260 59.999416
pbc : True True True
Sites (29)

SP a b c magmom


0 Zr 0.788177 0.211827 0.211805 -0.373
1 Zr 0.788195 0.788182 0.211813 -0.373
2 Zr 0.211832 0.211812 0.788177 -0.373
3 Zr 0.788179 0.211826 0.788191 -0.373
4 Zr 0.21183 0.788176 0.211802 -0.373
5 Zr 0.211829 0.788179 0.788191 -0.373
6 Co 0.499995 0.499998 0.500003 2.083
7 Co 0.500002 -3e-06 -5e-06 1.806
8 Co -7e-06 -8e-06 0.500007 1.806
9 Co 0.5 0.500003 -1e-06 1.806
10 Co -3e-06 0.500005 0.500006 1.806
11 Co -4e-06 0.500005 -8e-06 1.806
12 Co 0.500001 -1e-06 0.500005 1.806
13 Co 0.377919 0.377919 0.377934 1.63
14 Co 0.622079 0.622082 0.133761 1.63
15 Co 0.133757 0.622087 0.622077 1.63
16 Co 0.622088 0.133757 0.622078 1.63
17 Co 0.866229 0.377914 0.377928 1.63
18 Co 0.377908 0.866239 0.377926 1.63
19 Co 0.377922 0.377918 0.866226 1.63
20 Co 0.62208 0.622081 0.622079 1.629
21 Co 0.173961 0.173958 0.173965 1.457
22 Co 0.82603 0.826037 0.521902 1.457
23 Co 0.521903 0.826037 0.826028 1.457
24 Co 0.826038 0.521894 0.826032 1.457
25 Co 0.478102 0.173962 0.173971 1.457
26 Co 0.173959 0.478118 0.173964 1.457
27 Co 0.173963 0.173961 0.478113 1.457
28 Co 0.826035 0.826037 0.826029 1.457

— Document 2 —
Primitive Structure:
Full Formula (Zr6 Co23)
Reduced Formula: Zr6Co23
abc : 8.115843 8.115850 8.115907
angles: 59.999331 59.999260 59.999416
pbc : True True True
Sites (29)

SP a b c magmom


0 Zr 0.788177 0.211827 0.211805 -0.373
1 Zr 0.788195 0.788182 0.211813 -0.373
2 Zr 0.211832 0.211812 0.788177 -0.373
3 Zr 0.788179 0.211826 0.788191 -0.373
4 Zr 0.21183 0.788176 0.211802 -0.373
5 Zr 0.211829 0.788179 0.788191 -0.373
6 Co 0.499995 0.499998 0.500003 2.083
7 Co 0.500002 -3e-06 -5e-06 1.806
8 Co -7e-06 -8e-06 0.500007 1.806
9 Co 0.5 0.500003 -1e-06 1.806
10 Co -3e-06 0.500005 0.500006 1.806
11 Co -4e-06 0.500005 -8e-06 1.806
12 Co 0.500001 -1e-06 0.500005 1.806
13 Co 0.377919 0.377919 0.377934 1.63
14 Co 0.622079 0.622082 0.133761 1.63
15 Co 0.133757 0.622087 0.622077 1.63
16 Co 0.622088 0.133757 0.622078 1.63
17 Co 0.866229 0.377914 0.377928 1.63
18 Co 0.377908 0.866239 0.377926 1.63
19 Co 0.377922 0.377918 0.866226 1.63
20 Co 0.62208 0.622081 0.622079 1.629
21 Co 0.173961 0.173958 0.173965 1.457
22 Co 0.82603 0.826037 0.521902 1.457
23 Co 0.521903 0.826037 0.826028 1.457
24 Co 0.826038 0.521894 0.826032 1.457
25 Co 0.478102 0.173962 0.173971 1.457
26 Co 0.173959 0.478118 0.173964 1.457
27 Co 0.173963 0.173961 0.478113 1.457
28 Co 0.826035 0.826037 0.826029 1.457

… etc.

But I have no idea how should I make them with .cif file.

primitive_cell.to("2test.cif")

My lack of coding skill lead to be unable to make progress.
Is there any good idea?

Best regards.

Umm… thanks for the GPT… I mad it.

import os
from mp_api.client import MPRester

with MPRester("My_API") as mpr:
#    structure = mpr.get_structure_by_material_id("mp-149")
    structures = mpr.materials.summary.search(
#               material_ids = ["mp-149", "mp-2241"])     #for multiple structure
                elements = ["Co"],
                chemsys = "Co-*",
#               formula = "AB"
#               band_gap = (0.5, 1.0),
                energy_above_hull = (0, 0),
                is_metal = True,
                is_stable = True
)


with open("test.txt", "w") as file:
    file.write(f"Number of documents: {len(structures)}\n\n")

    if not structures:
        file.write("No results found.\n")
    else:
	for idx, structure_summary in enumerate(structures):
            material_id = structure_summary.material_id
            formula = structure_summary.formula_pretty
#            E_Hull = structure_summary.energy_above_hull
#            Is_Metal = structure_summary.is_metal
#            stable = structure_summary.is_stable
#            crystal = structure_summary.structure
            sym = structure_summary.symmetry

            structure = mpr.get_structure_by_material_id(material_id)
            primitive_cell = structure.get_primitive_structure()

            cif_filename = f"{formula}.cif"
            primitive_cell.to(filename = cif_filename)

            file.write(f"--- Document {idx + 1} ---\n")
            file.write(f"Material ID: {material_id}\n")
#            file.write(f"Chemical Formula: {formula}\n")
#            file.write(f"Energy Above Hull: {E_Hull}\n")
#            file.write(f"Is Metal: {Is_Metal}\n")
#            file.write(f"Stable: {stable}\n")
#            file.write(f"Crystal: {structure}\n")
            file.write(f"Symmetry: {sym}\n")
            file.write(f"Primitive Structure:\n{primitive_cell}\n")
            file.write('-' * 40 + "\n")
            file.write("\n\n")

First of all, I’ve written it this way, but if there are any good options for optimization, please let me know.

And there is another question.
There is another option to figure out the cell data.

crystal = structure_summary.structure

When I use this option, the variable “crystal” include whole materials data.
It seems that the structure_summary.structure is same as structure.get_primitive_structure().

Can you tell me if I right?

   for idx, structure_summary in enumerate(structures):
           material_id = structure_summary.material_id
           formula = structure_summary.formula_pretty
           sym = structure_summary.symmetry
           structure = mpr.get_structure_by_material_id(material_id)
           primitive_cell = structure.get_primitive_structure()
           file.write(f"--- Document {idx + 1} ---\n")
           file.write(f"Material ID: {material_id}\n")
           file.write(f"Symmetry: {sym}\n")
           file.write(f"Primitive Structure:\n{primitive_cell}\n")
           file.write('-' * 40 + "\n")
           file.write("\n\n")
output by `structure.get_primitive_structure()`

Number of documents: 110

— Document 1 —
Material ID: mp-9945
Symmetry: crystal_system=<CrystalSystem.ortho: ‘Orthorhombic’> symbol=‘Pnnm’ number=58 point_group=‘mmm’ symprec=0.1 version=‘2.0.2’
Primitive Structure:
Full Formula (Co2 Te4)
Reduced Formula: CoTe2
abc : 3.936121 5.322096 6.390892
angles: 90.001887 90.000000 90.000000
pbc : True True True
Sites (6)

SP a b c magmom


0 Co -0 -0 0 1.161
1 Co 0.5 0.5 0.5 1.16
2 Te -0 0.21977 0.365541 -0.052
3 Te -0 0.78023 0.634459 -0.052
4 Te 0.5 0.719763 0.134487 -0.052
5 Te 0.5 0.280237 0.865513 -0.052

— Document 2 —
Material ID: mp-284
Symmetry: crystal_system=<CrystalSystem.cubic: ‘Cubic’> symbol=‘Pm-3m’ number=221 point_group=‘m-3m’ symprec=0.1 version=‘2.0.2’
Primitive Structure:
Full Formula (Al1 Co1)
Reduced Formula: AlCo
abc : 2.819403 2.819403 2.819403
angles: 90.000000 90.000000 90.000000
pbc : True True True
Sites (2)

SP a b c magmom


0 Al -0 -0 -0 0
1 Co 0.5 0.5 0.5 -0

        for idx, structure_summary in enumerate(structures):
            material_id = structure_summary.material_id
            sym = structure_summary.symmetry
            crystal = structure_summary.structure
            file.write(f"--- Document {idx + 1} ---\n")
            file.write(f"Material ID: {material_id}\n")
            file.write(f"Symmetry: {sym}\n")
            file.write(f"Crystal: {crystal}\n")
            file.write('-' * 40 + "\n")
            file.write("\n\n")
output by `structure_summary.structure`

Number of documents: 110

— Document 1 —
Material ID: mp-9945
Symmetry: crystal_system=<CrystalSystem.ortho: ‘Orthorhombic’> symbol=‘Pnnm’ number=58 point_group=‘mmm’ symprec=0.1 version=‘2.0.2’
Crystal: Full Formula (Co2 Te4)
Reduced Formula: CoTe2
abc : 3.936121 5.322096 6.390892
angles: 90.001887 90.000000 90.000000
pbc : True True True
Sites (6)

SP a b c magmom


0 Co -0 -0 0 1.161
1 Co 0.5 0.5 0.5 1.16
2 Te -0 0.21977 0.365541 -0.052
3 Te -0 0.78023 0.634459 -0.052
4 Te 0.5 0.719763 0.134487 -0.052
5 Te 0.5 0.280237 0.865513 -0.052

— Document 2 —
Material ID: mp-284
Symmetry: crystal_system=<CrystalSystem.cubic: ‘Cubic’> symbol=‘Pm-3m’ number=221 point_group=‘m-3m’ symprec=0.1 version=‘2.0.2’
Crystal: Full Formula (Al1 Co1)
Reduced Formula: AlCo
abc : 2.819403 2.819403 2.819403
angles: 90.000000 90.000000 90.000000
pbc : True True True
Sites (2)

SP a b c magmom


0 Al -0 -0 -0 0
1 Co 0.5 0.5 0.5 -0

Couple of things to consider:

  • If you’re retrieving a lot of structures or repeatedly have to run the same queries, it’s much more performant to download all structures, save them to disk and post-filter (see here for a start)
  • You don’t need to call mpr.get_structure_by_material_id(). The structure should already be in your structures list and accessible via structure_summary.structure.

HTH

1 Like

Thank you so much for your response.
And I’m sorry for checking late and replying now.
Somehow, I managed to successfully extract the data.

I’m sorry for keeps asking, but I still don’t really get it and there are parts that keep confusing me…

  • You don’t need to call mpr.get_structure_by_material_id(). The structure should already be in your structures list and accessible via structure_summary.structure
  • Does this mean that since structure data is already inside structures, we don’t need to call structure = mpr.get_structure_by_material_id(material_id) again?
  • So, does that mean I can just use structures = mpr.materials.summary.search(~) to extract the data without necessarily using primitive_cell = structure.get_primitive_structure(), and it will still give me the primitive cell structure?
  • I’m asking if just using the second piece of code I posted above can extract the primitive cell.

Here I have a few more questions. Regarding the indicators provided by the materials project, are the sorting results for predicted stable and Energy above Hull the same?
I looked into the cases of Cu, Ru, and Co, and for metallic compounds (alloys), it seems that if Energy above Hull = 0, they are all considered predicted stable.

I know that generally, a state with Energy above Hull = 0 is thought as the most stable state. However, I’m wondering if there’s a specific reason for having those two options split into different columns.
Additionally, could you please direct me to detailed explanations for each column elements (synthesizable, is metal, predicted stable, formation energy, etc.)? I recall finding explanations for those criteria on the site before, but now I cannot locate them.

+ Is there any way to plot the cohesive energy of each materials?
I referred to dwinston’s answer and added the items below. (For MPRester, I’m just using the mp_api.client as it is.)

from pymatgen.ext.matproj import MPRester
mpr = MPRester()
mpr.get_cohesive_energy('mp-721988', per_atom=True) # 6.73 eV/atom

My python file is below.

import os  
from mp_api.client import MPRester  

with MPRester("ZiWsNasQOf0xOblqHoCg97K6Cu2kWk7B") as mpr:  
    structures = mpr.materials.summary.search(  
                elements = ["Co"],  
                chemsys = "Co-*",  
                energy_above_hull = (0, 0),  
                is_metal = True,  
                is_stable = True  
)  

with open("test.txt", "w") as file:  
    file.write(f"Number of documents: {len(structures)}\n\n")  

    if not structures:  
        file.write("No results found.\n")  
    else:  
        for idx, structure_summary in enumerate(structures):  
            material_id = structure_summary.material_id  
            formula = structure_summary.formula_pretty  
            sym = structure_summary.symmetry  

            structure = mpr.get_structure_by_material_id(material_id)  
#            cohesive = mpr.get_cohesive_energy_by_material_id(material_id, per_atom = True)  
            cohesive = mpr.get_cohesive_energy(material_id, per_atom = True)  
            primitive_cell = structure.get_primitive_structure()  

            cif_filename = f"{formula}.cif"  
            primitive_cell.to(filename = cif_filename)  

            file.write(f"--- Document {idx + 1} ---\n")  
            file.write(f"Material ID: {material_id}\n")  
            file.write(f"Symmetry: {sym}\n")  
            file.write(f"Cohesive: {cohesive}\n")  
            file.write(f"Primitive Structure:\n{primitive_cell}\n")  
            file.write('-' * 40 + "\n")  
            file.write("\n\n")

However, the following error occurs. Is it not possible to use mpr.get_cohesive in our mp_api.client as referenced above?

Traceback (most recent call last):
File “/home/-/MP_API/API/Test_Cohesive.py”, line 35, in
cohesive = mpr.get_cohesive_energy(material_id, per_atom = True)
^^^^^^^^^^^^^^^^^^^^^^^
File “/home/-/anaconda3/lib/python3.11/site-packages/mp_api/client/mprester.py”, line 399, in getattr
raise AttributeError(
AttributeError: ‘MPRester’ object has no attribute ‘get_cohesive_energy’

Best regards.

Hello,

I tried downloading the entire data as you mentioned in the form of documentation (mp_docs.json), but I’m not sure how to sort using the .json file. When I open this file itself, the capacity is too large (almost 2GB) and there’s an issue where the shell itself stops.

Moreover, even if I try to extract the file to Windows for post-processing, it’s difficult because the file size is too large. Can you explain again exactly how to sort using the json file?