The wrong space group type given by spglib. #514
Replies: 3 comments 1 reply
-
On the other hand, I also tried to use ase and pymatgen to do the same thing as follows:
In [15]: import numpy as np
...: from ase.io import read
...: from ase.spacegroup import get_spacegroup
...:
...: def analyze_space_group_ase(filename):
...: """Analyze space group using ASE with different tolerances."""
...: # Read the CIF file
...: atoms = read(filename)
...:
...: # Define tolerances to test
...: tolerances = [1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7]
...:
...: print(f"Analysis for file: {filename}")
...: print(f"Cell parameters:\n{atoms.cell}")
...: print(f"Number of atoms: {len(atoms)}")
...: print(f"Atom types: {set(atoms.get_chemical_symbols())}")
...:
...: for tol in tolerances:
...: spacegroup = get_spacegroup(atoms, symprec=tol)
...: print(f"Tolerance {tol:.1e}: {spacegroup.symbol} ({spacegroup.no})")
...:
...: if __name__ == "__main__":
...: cif_file = "ICSD_CollCode262928.cif"
...: analyze_space_group_ase(cif_file)
...:
Analysis for file: ICSD_CollCode262928.cif
Cell parameters:
Cell([[3.3717, 0.0, 0.0], [-1.6858499999999994, 2.9199778539399923, 0.0], [0.0, 0.0, 5.3855]])
Number of atoms: 4
Atom types: {'Mn', 'O'}
Tolerance 1.0e-01: P 63 m c (186)
Tolerance 1.0e-02: P 63 m c (186)
Tolerance 1.0e-03: P 63 m c (186)
Tolerance 1.0e-04: P 63 m c (186)
Tolerance 1.0e-05: C m c 21 (36)
Tolerance 1.0e-06: C m c 21 (36)
Tolerance 1.0e-07: C m c 21 (36) About this problem, I've posted here for further discussion.
In [16]: from pymatgen.core import Structure
...: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
...:
...: def analyze_space_group_pymatgen(filename):
...: """Analyze space group using pymatgen with different tolerances."""
...: # Read the CIF file
...: structure = Structure.from_file(filename)
...:
...: # Define tolerances to test
...: tolerances = [1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7]
...:
...: print(f"Analysis for file: {filename}")
...: print(f"Lattice parameters: {structure.lattice.abc}")
...: print(f"Lattice angles: {structure.lattice.angles}")
...: print(f"Number of sites: {len(structure)}")
...: print(f"Element types: {set(structure.species)}")
...:
...: for tol in tolerances:
...: analyzer = SpacegroupAnalyzer(structure, symprec=tol)
...: spacegroup = analyzer.get_space_group_symbol()
...: spacegroup_number = analyzer.get_space_group_number()
...: print(f"Tolerance {tol:.1e}: {spacegroup} ({spacegroup_number})")
...:
...: # Additional analysis
...: print("\nDetailed symmetry analysis:")
...: analyzer = SpacegroupAnalyzer(structure)
...: print(f"Refined structure:\n{analyzer.get_refined_structure()}")
...: print(f"Symmetry dataset:\n{analyzer.get_symmetry_dataset()}")
...:
...: if __name__ == "__main__":
...: cif_file = "ICSD_CollCode262928.cif"
...: analyze_space_group_pymatgen(cif_file)
...:
/home/werner/Public/repo/github.com/materialsproject/pymatgen.git/src/pymatgen/io/cif.py:1285: UserWarning: Issues encountered while parsing CIF: 4 fractional coordinates rounded to ideal values to avoid issues with finite precision.
warnings.warn("Issues encountered while parsing CIF: " + "\n".join(self.warnings))
Analysis for file: ICSD_CollCode262928.cif
Lattice parameters: (3.3717, 3.3717, 5.3855)
Lattice angles: (90.0, 90.0, 119.99999999999999)
Number of sites: 4
Element types: {Species O2-, Species Mn2+}
Tolerance 1.0e-01: P6_3mc (186)
Tolerance 1.0e-02: P6_3mc (186)
Tolerance 1.0e-03: P6_3mc (186)
Tolerance 1.0e-04: P6_3mc (186)
Tolerance 1.0e-05: P6_3mc (186)
Tolerance 1.0e-06: P6_3mc (186)
Tolerance 1.0e-07: P6_3mc (186)
Detailed symmetry analysis:
Refined structure:
Full Formula (Mn2 O2)
Reduced Formula: MnO
abc : 3.371700 3.371700 5.385500
angles: 90.000000 90.000000 120.000000
pbc : True True True
Sites (4)
# SP a b c
--- ---- -------- -------- -------
0 Mn2+ 0.666667 0.333333 0.51096
1 Mn2+ 0.333333 0.666667 0.01096
2 O2- 0.666667 0.333333 0.87547
3 O2- 0.333333 0.666667 0.37547
Symmetry dataset:
SpglibDataset(number=186, hall_number=480, international='P6_3mc', hall='P 6c -2c', choice='', transformation_matrix=array([[1.00000000e+00, 5.55111512e-17, 0.00000000e+00],
[0.00000000e+00, 1.00000000e+00, 0.00000000e+00],
[0.00000000e+00, 6.16297582e-33, 1.00000000e+00]]), origin_shift=array([1.11022302e-16, 1.11022302e-16, 0.00000000e+00]), rotations=array([[[ 1, 0, 0],
[ 0, 1, 0],
[ 0, 0, 1]],
[[ 1, -1, 0],
[ 1, 0, 0],
[ 0, 0, 1]],
[[ 0, -1, 0],
[ 1, -1, 0],
[ 0, 0, 1]],
[[-1, 0, 0],
[ 0, -1, 0],
[ 0, 0, 1]],
[[-1, 1, 0],
[-1, 0, 0],
[ 0, 0, 1]],
[[ 0, 1, 0],
[-1, 1, 0],
[ 0, 0, 1]],
[[ 0, 1, 0],
[ 1, 0, 0],
[ 0, 0, 1]],
[[ 1, 0, 0],
[ 1, -1, 0],
[ 0, 0, 1]],
[[ 1, -1, 0],
[ 0, -1, 0],
[ 0, 0, 1]],
[[ 0, -1, 0],
[-1, 0, 0],
[ 0, 0, 1]],
[[-1, 0, 0],
[-1, 1, 0],
[ 0, 0, 1]],
[[-1, 1, 0],
[ 0, 1, 0],
[ 0, 0, 1]]], dtype=int32), translations=array([[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
[-1.11022302e-16, 0.00000000e+00, 5.00000000e-01],
[-2.22044605e-16, -1.11022302e-16, -6.84227766e-49],
[-2.22044605e-16, -2.22044605e-16, 5.00000000e-01],
[-1.11022302e-16, -2.22044605e-16, -1.36845553e-48],
[-6.16297582e-33, -1.11022302e-16, 5.00000000e-01],
[ 0.00000000e+00, 0.00000000e+00, 5.00000000e-01],
[-6.16297582e-33, -1.11022302e-16, -6.84227766e-49],
[-1.11022302e-16, -2.22044605e-16, 5.00000000e-01],
[-2.22044605e-16, -2.22044605e-16, -1.36845553e-48],
[-2.22044605e-16, -1.11022302e-16, 5.00000000e-01],
[-1.11022302e-16, 0.00000000e+00, 0.00000000e+00]]), wyckoffs=['b', 'b', 'b', 'b'], site_symmetry_symbols=['3m.', '3m.', '3m.', '3m.'], crystallographic_orbits=array([0, 0, 2, 2], dtype=int32), equivalent_atoms=array([0, 0, 2, 2], dtype=int32), primitive_lattice=array([[ 3.37170000e+00, 0.00000000e+00, 2.06457081e-16],
[-1.68585000e+00, 2.91997785e+00, 2.06457081e-16],
[ 0.00000000e+00, 0.00000000e+00, 5.38550000e+00]]), mapping_to_primitive=array([0, 1, 2, 3], dtype=int32), std_lattice=array([[ 3.3717 , 0. , 0. ],
[-1.68585 , 2.91997785, 0. ],
[ 0. , 0. , 5.3855 ]]), std_positions=array([[0.66666667, 0.33333333, 0.51096 ],
[0.33333333, 0.66666667, 0.01096 ],
[0.66666667, 0.33333333, 0.87547 ],
[0.33333333, 0.66666667, 0.37547 ]]), std_types=array([1, 1, 2, 2], dtype=int32), std_rotation_matrix=array([[ 1.00000000e+00, 0.00000000e+00, 6.12323400e-17],
[-6.49415036e-33, 1.00000000e+00, 1.06057524e-16],
[-6.12323400e-17, -1.06057524e-16, 1.00000000e+00]]), std_mapping_to_primitive=array([0, 1, 2, 3], dtype=int32), pointgroup='6mm') As you can see, under different tolerances, only pymatgen gave all the correct results. I don't know why this happened. |
Beta Was this translation helpful? Give feedback.
-
I think this is not (yet) a question about spglib. We will be able to answer only the questions whose crystal structures are provided in the format given here https://spglib.readthedocs.io/en/stable/python-interface.html#crystal-structure-cell. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your tip. Now it gives the correct result as shown below: import numpy as np
import spglib
# Lattice parameters
a = 3.3717
c = 5.3855
# Lattice matrix
lattice = [
[a, 0, 0],
[-a/2, a*np.sqrt(3)/2, 0],
[0, 0, c]
]
# Atomic positions (fractional coordinates)
positions = [
[2/3, 1/3, 0.51096],
[1/3, 2/3, 0.01096],
[2/3, 1/3, 0.87547],
[1/3, 2/3, 0.37547]
]
# Atomic numbers (25 for Mn, 8 for O)
numbers = [25, 25, 8, 8]
# Create the cell tuple
cell = (lattice, positions, numbers)
def get_spacegroup(cell, symprec):
dataset = spglib.get_symmetry_dataset(cell, symprec=symprec)
if dataset is not None:
return dataset.number, dataset.international
return None, None
# Try different symprec values
print("Space group determination for different symprec values:")
for symprec in [1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8]:
sg_number, sg_symbol = get_spacegroup(cell, symprec)
print(f"symprec = {symprec:.1e}: Space group {sg_number} ({sg_symbol})")
# Attempt to standardize the cell
print("\nAttempting to standardize the cell:")
try:
cell_std = spglib.standardize_cell(cell, to_primitive=False, no_idealize=True)
sg_number, sg_symbol = get_spacegroup(cell_std, symprec=1e-5)
print(f"Standardized cell: Space group {sg_number} ({sg_symbol})")
except Exception as e:
print(f"Error in standardizing cell: {e}") The result of the above code:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Dear spglib Development Team,
I try to obtain the space group type by spglib using a cif file as shown below:
After running the above script, I obtained the following results:
These results show that spglib consistently determines the space group as P6mm (183) across all tested symmetry tolerances, which differs from P6_3mc (186) given in the cif file.
I'm very puzzled by the wrong results given by spglib. Any hints/comments will be appreciated.
ICSD_CollCode262928.cif.zip
See here for the related discussion.
Regards,
Zhao
Beta Was this translation helpful? Give feedback.
All reactions