Open lopsided opened 5 months ago
The complete bug reproduction code snippet is shown below:
In [12]: from pymatgen.symmetry.groups import SpaceGroup, PointGroup
...:
...: # Create an instance of the SpaceGroup for 'P212121'
...: sg = SpaceGroup('P212121')
...:
...: # Fetch the point group symbol from the space group
...: point_group_symbol = sg.point_group
...:
...: # Display the space group and its point group symbol
...: print(f"Space Group: {sg.symbol}")
...: print(f"Point Group Symbol: {point_group_symbol}")
...:
...: # Now let's try creating the PointGroup.
...: try:
...: pg = PointGroup(point_group_symbol)
...: print(f"Processed Point Group: {pg}")
...: except Exception as e:
...: print(f"Error: {e}")
...:
Space Group: P212121
Point Group Symbol: D2^4
Error: 'D2^4'
Python version
Python 3.9.18
Pymatgen version
2024.2.8
Operating system version
Fedora 38
Current behavior
Loading the SpaceGroup
P212121
works fine, but thepoint_group
symbol it reports (D2^4
) is not recognised. I believe it should be222
. The issue appears to be here: https://github.com/materialsproject/pymatgen/blob/81dc677462d164182115903e28318cb5cf2ea804/pymatgen/symmetry/groups.py#L223 as the symbolP212121
is not inSpaceGroup.sg_encoding
- instead it appears there with the underscoresP2_12_12_1
and the correct pointgroup (222
). As it can't find it here it uses theschoenflies
entry of the spacegroup (D2^4
) instead. I don't know what this is, or how to use it to find the 222 space group..?At the top of this class some effort is made to duplicate entries for the
SG_SYMBOLS
so they also contain copies without underscores. If this was also done for thesg_encoding
then the problem would be fixed, but I don't know if that is a reasonable thing to do or if it would cause other problems?Expected Behavior
I should be able to instantiate a PointGroup from a SpaceGroup by using the associated point_group symbol
Minimal example
Relevant files to reproduce this bug
No response