Skip to content

Inconsistency in primitive_lattice results between get_magnetic_symmetry_dataset & get_magnetic_symmetry in the Python interface #370

@singularitti

Description

@singularitti

I've discovered an inconsistency in Spglib: the primitive_lattice results from get_magnetic_symmetry_dataset and get_magnetic_symmetry do not match. Specifically, the latter's output seems to be the transpose of the former's. This issue is consistent across multiple tests, not just a single instance.

Here's a brief code example demonstrating the problem:

>>> import numpy as np
>>> from spglib import get_magnetic_symmetry_dataset, get_magnetic_symmetry
>>> lattice = np.array(
        [
            [1.06949000e01, 0.00000000e00, 0.00000000e00],
            [3.84998337e-16, 6.28750000e00, 0.00000000e00],
            [3.09590711e-16, 3.09590711e-16, 5.05600000e00],
        ]
    )
>>> positions = np.array(
        [
            [0.0, 0.0, 0.0],
            [0.5, 0.0, 0.5],
            [0.5, 0.5, 0.5],
            [0.0, 0.5, 0.0],
            [0.2794, 0.25, 0.9906],
            [0.2206, 0.75, 0.4906],
            [0.7206, 0.75, 0.0094],
            [0.7794, 0.25, 0.5094],
        ]
    )
>>> numbers = [0, 0, 0, 0, 0, 0, 0, 0]
>>> magmoms = np.array(
        [
            [3.0, 0.4, 0.0],
            [-3.0, -0.4, 0.0],
            [-3.0, 0.4, 0.0],
            [3.0, -0.4, 0.0],
            [4.5, 0.0, 0.0],
            [-4.5, 0.0, 0.0],
            [4.5, 0.0, 0.0],
            [-4.5, 0.0, 0.0],
        ]
    )
>>> dataset = get_magnetic_symmetry_dataset((lattice, positions, numbers, magmoms))
>>> symdict = get_magnetic_symmetry((lattice, positions, numbers, magmoms))
>>> dataset
{'uni_number': 544, 'msg_type': 3, 'hall_number': 292, 'tensor_rank': 1, 'n_operations': 8, 'rotations': array([[[ 1,  0,  0],
        [ 0,  1,  0],
        [ 0,  0,  1]],

       [[-1,  0,  0],
        [ 0, -1,  0],
        [ 0,  0, -1]],

       [[-1,  0,  0],
        [ 0, -1,  0],
        [ 0,  0,  1]],

       [[ 1,  0,  0],
        [ 0,  1,  0],
        [ 0,  0, -1]],

       [[ 1,  0,  0],
        [ 0, -1,  0],
        [ 0,  0, -1]],

       [[-1,  0,  0],
        [ 0,  1,  0],
        [ 0,  0,  1]],

       [[-1,  0,  0],
        [ 0,  1,  0],
        [ 0,  0, -1]],

       [[ 1,  0,  0],
        [ 0, -1,  0],
        [ 0,  0,  1]]], dtype=int32), 'translations': array([[-0.00000000e+00, -0.00000000e+00, -0.00000000e+00],
       [-0.00000000e+00, -0.00000000e+00, -0.00000000e+00],
       [ 5.00000000e-01,  0.00000000e+00,  5.00000000e-01],
       [ 5.00000000e-01,  0.00000000e+00,  5.00000000e-01],
       [ 5.00000000e-01,  5.00000000e-01,  5.00000000e-01],
       [ 5.00000000e-01,  5.00000000e-01,  5.00000000e-01],
       [ 6.16297582e-33,  5.00000000e-01,  0.00000000e+00],
       [ 6.16297582e-33,  5.00000000e-01,  0.00000000e+00]]), 'time_reversals': array([False, False, False, False,  True,  True,  True,  True]), 'n_atoms': 8, 'equivalent_atoms': array([0, 0, 0, 0, 4, 4, 4, 4], dtype=int32), 'transformation_matrix': array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]]), 'origin_shift': array([0., 0., 0.]), 'n_std_atoms': 8, 'std_lattice': array([[1.06949000e+01, 0.00000000e+00, 0.00000000e+00],
       [3.84998337e-16, 6.28750000e+00, 0.00000000e+00],
       [3.09590711e-16, 3.09590711e-16, 5.05600000e+00]]), 'std_types': array([0, 0, 0, 0, 0, 0, 0, 0], dtype=int32), 'std_positions': array([[ 1.54074396e-33,  0.00000000e+00,  0.00000000e+00],
       [ 5.00000000e-01,  0.00000000e+00,  5.00000000e-01],
       [ 5.00000000e-01,  5.00000000e-01,  5.00000000e-01],
       [-4.62223187e-33,  5.00000000e-01,  0.00000000e+00],
       [ 2.79400000e-01,  2.50000000e-01,  9.90600000e-01],
       [ 2.20600000e-01,  7.50000000e-01,  4.90600000e-01],
       [ 7.20600000e-01,  7.50000000e-01,  9.40000000e-03],
       [ 7.79400000e-01,  2.50000000e-01,  5.09400000e-01]]), 'std_tensors': array([[ 3. ,  0.4,  0. ],
       [-3. , -0.4,  0. ],
       [-3. ,  0.4,  0. ],
       [ 3. , -0.4,  0. ],
       [ 4.5,  0. ,  0. ],
       [-4.5,  0. ,  0. ],
       [ 4.5,  0. ,  0. ],
       [-4.5,  0. ,  0. ]]), 'std_rotation_matrix': array([[1.00000000e+00, 1.23259516e-32, 0.00000000e+00],
       [0.00000000e+00, 1.00000000e+00, 0.00000000e+00],
       [0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]), 'primitive_lattice': array([[-3.09590711e-16, -3.09590711e-16, -5.05600000e+00],
       [-3.84998337e-16, -6.28750000e+00, -0.00000000e+00],
       [-1.06949000e+01, -0.00000000e+00, -0.00000000e+00]])}
>>> symdict
{'rotations': array([[[ 1,  0,  0],
        [ 0,  1,  0],
        [ 0,  0,  1]],

       [[-1,  0,  0],
        [ 0, -1,  0],
        [ 0,  0, -1]],

       [[-1,  0,  0],
        [ 0, -1,  0],
        [ 0,  0,  1]],

       [[ 1,  0,  0],
        [ 0,  1,  0],
        [ 0,  0, -1]],

       [[ 1,  0,  0],
        [ 0, -1,  0],
        [ 0,  0, -1]],

       [[-1,  0,  0],
        [ 0,  1,  0],
        [ 0,  0,  1]],

       [[-1,  0,  0],
        [ 0,  1,  0],
        [ 0,  0, -1]],

       [[ 1,  0,  0],
        [ 0, -1,  0],
        [ 0,  0,  1]]], dtype=int32), 'translations': array([[-0.00000000e+00, -0.00000000e+00, -0.00000000e+00],
       [-0.00000000e+00, -0.00000000e+00, -0.00000000e+00],
       [ 5.00000000e-01,  0.00000000e+00,  5.00000000e-01],
       [ 5.00000000e-01,  0.00000000e+00,  5.00000000e-01],
       [ 5.00000000e-01,  5.00000000e-01,  5.00000000e-01],
       [ 5.00000000e-01,  5.00000000e-01,  5.00000000e-01],
       [ 6.16297582e-33,  5.00000000e-01,  0.00000000e+00],
       [ 6.16297582e-33,  5.00000000e-01,  0.00000000e+00]]), 'time_reversals': array([False, False, False, False,  True,  True,  True,  True]), 'equivalent_atoms': array([0, 0, 0, 0, 4, 4, 4, 4], dtype=int32), 'primitive_lattice': array([[-3.09590711e-16, -3.84998337e-16, -1.06949000e+01],
       [-3.09590711e-16, -6.28750000e+00, -0.00000000e+00],
       [-5.05600000e+00, -0.00000000e+00, -0.00000000e+00]])}
>>> symdict['primitive_lattice'] == dataset['primitive_lattice']
array([[ True, False, False],
       [False,  True,  True],
       [False,  True,  True]])
>>> symdict['primitive_lattice'] == dataset['primitive_lattice'].T
array([[ True,  True,  True],
       [ True,  True,  True],
       [ True,  True,  True]])
>>> import spglib
>>> spglib.get_version()
(2, 1, 0)

The comparison shows that symdict['primitive_lattice'] is indeed the transpose of dataset['primitive_lattice']. This inconsistency might affect users needing accurate lattice information. I hope this information helps in resolving the issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions