How to get magnetic moment of each atom using the Materials Project API?

Dear users and developers,

I’d like to get magnetic properties, magnetic moment of each atom.

I already know How to get “total magnetization”, but magnetic moment of each atom should be needed.

Is there way to gather magnetic properties of each atom in each material?

Sincerely

Hi @11112,

We’ve recently added this information :slight_smile:

At the moment, the easiest way is to use the MPRester interface in pymatgen. You should find that most structures now have magmom site properties attached with the site-projected magnetic moments.

We’re working on making this information easier to obtain via the API and also on the website, and also making sure that all structures have this information (currently, only a subset have site-projected magnetic moments attached).

Best,

Matt

Dear Matt

Thank you let me knowing the magmom site properties using MPRester

but, I want to know the detailed command

I used the following command, but it didn`t work

import pymatgen
from pymatgen import MPRester

mpr = MPRester(MY_API_KEY)
mag = mpr.get_data(“mp-2662”)[0][“magmom”]

Sincerely

No problem. Unfortunately, mp-2662 specifically is a structure that does not have this information yet, but to take another MnP example that does have this information:

from pymatgen import MPRester

mpr = MPRester(YOUR_API_KEY_HERE)
structure = mpr.get_structure_by_material_id('mp-999516')
print(structure)
magmoms = structure.site_properties['magmom']
print(magmoms)

This will output:

Full Formula (Mn2 P2)
Reduced Formula: MnP
abc   :   3.339203   3.339494   5.369199
angles:  90.000000  90.000000 119.997123
Sites (4)
  #  SP           a        b     c    magmom
---  ----  --------  -------  ----  --------
  0  Mn    0         0        0.5      1.981
  1  Mn    0         0        0        1.982
  2  P     0.333305  0.66661  0.25    -0.082
  3  P     0.666695  0.33339  0.75    -0.082
[1.981, 1.982, -0.082, -0.082]

(In general, it is the older materials on the Materials Project that do not yet have site-projected magnetic moments. All newer materials should have them.)