Open SiLiKhon opened 1 year ago
I recently ran into the same issue, with magnetic moments this time. After querying FeNi (mp-2213) and calling SpaceGroupAnalyzer(struct).get_conventional_standard_structure(keep_site_properties=True)
on it, the magnetic moments on Ni sites are incorrect. Taking a closer look, the culprit seems to be the get_refined_structure()
, more specifically how the site_properties
are transferred at https://github.com/materialsproject/pymatgen/blob/e2b0801ea6bf5aa30b57d922395dadd729e8f122/pymatgen/symmetry/analyzer.py#L340
I won't attempt a PR at this moment but for the time being transferring the site properties some other way is probably safer.
This is a minimal repro with magnetic moments;
from mp_api.client import MPRester
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
with MPRester() as mpr:
struct = mpr.get_structure_by_material_id("mp-2213")
sga = SpacegroupAnalyzer(struct)
refined_bulk = sga.get_refined_structure(keep_site_properties=True)
where in the original structure the magnetic moments on Fe and Ni sites are 2.941 and 0.767, respectively, while in the refined structure they are both set to 2.941.
When converting a primitive cell to a conventional one with
keep_site_properties=True
(https://github.com/materialsproject/pymatgen/pull/2349), the resulting properties are incorrect.To Reproduce In this example I mark each site with a different label to find where the corresponding cite is in the resulting cell. (this is based on mp-35591)
Output:
Expected behavior Ideally, I'd expect the sites with different properties to be treated as different ones and therefore I expect the output structures to have all the labels from
a
toh
. Note that the result is incorrect even if the same-element sites are treated as equivalent ones. E.g., Er got a label that belonged to Li, and S got a label from Er.