materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.45k stars 842 forks source link

[Bug]: Inconsistent behaviour with `get_symmetrized_structure` #3340

Open kavanase opened 10 months ago

kavanase commented 10 months ago

Email (Optional)

sean.kavanagh.19@ucl.ac.uk

Version

v2023.9.2

Which OS(es) are you using?

What happened?

When using SpacegroupAnalyzer.get_symmetrized_structure(), I noticed some odd behavior. If the input structure is a non-diagonal supercell of the primitive structure, the space group symmetry of the material is correctly determined (and returns the correct primitive structure), but the SymmetrizedStructure differs from that obtained when inputting the primitive structure. In the example case below, this now outputs additional 'inequivalent' sites, which are in fact equivalent in the primitive structure. I've witnessed this now in a couple of different material systems, with non-diagonal supercells.

I'm not sure if this is the desired behaviour, but I wouldn't have guessed so. Notebook and PDF attached below.

pymatgen_symm_structure_PR.pdf

pymatgen_symm_structure_PR.ipynb.zip

Code snippet

No response

Log output

No response

Code of Conduct

amkrajewski commented 8 months ago

Hi @kavanase! It seems that your supercell is quite large and if you are saving it as a POSCAR with default settings you may be running into numerical precision issues. I suggest you look into either (1) increasing export accuracy or (2) playing with the SpacegroupAnalyzer's symprec parameter, to allow for larger basis distortions from ideal positions. Good luck!

mkhorton commented 8 months ago

It might also be worth talking to the developers of spglib if it might seem like a legitimate bug in symmetry determination, rather than a precision issue (of course, they would need a minimal reproducible example using spglib directly rather than pymatgen—the easiest way to do this is typically to add a print statement before the spglib call inside pymatgen to see the exact values passed to spglib).

For symmetry issues, it’s also worth trying some different versions of spglib just in case there’s been a regression etc.

lan496 commented 8 months ago

As spglib developer side, I think it may be possible that spglib returns another space group for a supercell than that for the primitive structure. Spglib only returns rotation matrices with integers. So if the supercell matrix breaks the symmetry, corresponding result may change. I am also wondering what space group types does spglib return for this issue's structure.