I am trying to get magnetic ordering (e.g. NM, FM, AFM, ). I tried the code below to get material properties.
from pymatgen.analysis.magnetism.analyzer import Ordering
mpids = ['mp-13']
with MPRester(api_key) as mpr:
fields = ["material_id", "energy_above_hull", "formation_energy_per_atom", 'band_gap', 'magnetic_ordering']
materials_to_fetch = mat_input
for i, mpid in tqdm(enumerate(mpids), desc="Processing"):
pstruct = mpr.get_structure_by_material_id(mpid)
summary = mpr.summary.get_data_by_id(mpid, fields=fields)
Using the code above, I can get materials property, such as energy band gap summary.band_gap
. However, I get an error with summary.magnetic_ordering
, saying AttributeError: 'MPDataDoc' object has no attribute 'magnetic_ordering'
. Does anybody know how I can get magnetic ordering for each material=id?
reference:
https://materialsproject.github.io/api/_autosummary/mp_api.client.routes.materials.summary.SummaryRester.html#mp_api.client.routes.materials.summary.SummaryRester.get_data_by_id
@Ryotaro_Okabe, two things. You can use mpr.materials.summary.search(material_ids=mpids)
instead of iterating and calling get_data_by_id
. This helps our servers and will be more efficient for you. Second, you can access the magnetic ordering on the summary doc with summary.ordering
.
– Jason
Thanks for your reply. Now I run the code with mpr.materials.summary.search
.
I have tried summary.ordering
. That code did not give error, but the output is None. I have tried materials which I can find magnetic order from MP website (e.g. mp-13, mp-30), but I always see None is returned. Hope to know how I can get Ordering class (or just string objects like ‘NM’, ‘FM’ are fine too).
I just uesd that to get magnetic ordering, actually, it may work with just “ordering”
1 Like
@Ryotaro_Okabe @suk_chen
Yup, you can also query for a specific ordering in the search()
method with ordering=...
– Jason
1 Like