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.48k stars 851 forks source link

determine crystal space group error #3844

Open baigeiguai opened 3 months ago

baigeiguai commented 3 months ago

Python version

3.11.4

Pymatgen version

2023.12.18

Operating system version

Rocky Linux 9.2

Current behavior

The cif file of the crystal YUTYOC is recognized as the P/6mmm space group category when it is parsed, but the P6mm space group category is marked in the cif file.My code is following.

Expected Behavior

unknown,maybe P6mm or P/6mmm. I want to know why P/6mmm and is it right ?

Minimal example

from pymatgen.io.cif import CifParser
# before parsing the file ,I do 
#    ase convert  xxx.cif xxx.POSCAR                           
# to  transfrom the cif to poscar file 
# and then use CifParser to parse POSCAR file                         
parser = CifParser(file_path,occupancy_tolerance=100,site_tolerance=100)
structure = parser.parse_structures()[0]
print(structure)

Relevant files to reproduce this bug

YUTYOC CIF download link: https://www.ccdc.cam.ac.uk/structures/Search?Ccdcid=787088&DatabaseToSearch=Published

wladerer commented 1 month ago

I tried following your procedure and could not convert the file using ASE 3.23

  File "/home/wladerer/.local/lib/python3.10/site-packages/ase/spacegroup/spacegroup.py", line 876, in spacegroup_from_data
    spg = Spacegroup(symbol, None, datafile)
  File "/home/wladerer/.local/lib/python3.10/site-packages/ase/spacegroup/spacegroup.py", line 132, in __init__
    _read_datafile(self, spacegroup, setting, fd)
  File "/home/wladerer/.local/lib/python3.10/site-packages/ase/spacegroup/spacegroup.py", line 692, in _read_datafile
    _skip_to_blank(f, spacegroup, setting)
  File "/home/wladerer/.local/lib/python3.10/site-packages/ase/spacegroup/spacegroup.py", line 593, in _skip_to_blank
    raise SpacegroupNotFoundError(
ase.spacegroup.spacegroup.SpacegroupNotFoundError: invalid spacegroup `P6 m m m`, setting `None` not found in data base

Also, as a general note, depending on the tolerance you set for ase, pymatgen, phonopy, etc, you get a different result. If your precision is 0.001 you get P6/mmm and if your precision is 0.0001 then you get P6/m.

from pymatgen.core import Structure
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer

structure = Structure.from_file('787088.cif')

high_sym_spacegroup = SpacegroupAnalyzer(structure, symprec=0.0001).get_space_group_symbol()
low_sym_spacegroup = SpacegroupAnalyzer(structure, symprec=0.01).get_space_group_symbol()

print(high_sym_spacegroup) # P6/m
print(low_sym_spacegroup) # P6/mmm