Skip to content

Commit

Permalink
Fix order of primitive basis for get_magnetic_symmetry
Browse files Browse the repository at this point in the history
  • Loading branch information
lan496 committed Dec 5, 2023
1 parent 82c2a22 commit 6bbcb7d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
4 changes: 3 additions & 1 deletion python/spglib/spglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ def get_magnetic_symmetry(
"translations": np.array(translations[:num_sym], dtype="double", order="C"),
"time_reversals": time_reversals,
"equivalent_atoms": equivalent_atoms,
"primitive_lattice": primitive_lattice,
"primitive_lattice": np.array(
np.transpose(primitive_lattice), dtype="double", order="C"
),
}


Expand Down
40 changes: 39 additions & 1 deletion test/functional/python/test_magnetic_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import numpy as np

from spglib import get_magnetic_symmetry_dataset, get_symmetry_dataset
from spglib import (
get_magnetic_symmetry,
get_magnetic_symmetry_dataset,
get_symmetry_dataset,
)


class TestMagneticDataset(unittest.TestCase):
Expand Down Expand Up @@ -621,6 +625,40 @@ def test_std_rotation(self):
assert np.allclose(dataset_msg["transformation_matrix"], np.eye(3))
assert np.allclose(dataset_msg["std_rotation_matrix"], rigid_rotation.T)

def test_primitive_lattice(self):
# https://github.com/spglib/spglib/issues/370
lattice = np.array(
[
[10.6949, 0, 0],
[0, 6.2875, 0],
[0, 0, 5.056],
]
)
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],
]
)
numbers = [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],
]
)
primitive_lattice1 = get_magnetic_symmetry_dataset(
(lattice, positions, numbers, magmoms)
)["primitive_lattice"]
primitive_lattice2 = get_magnetic_symmetry(
(lattice, positions, numbers, magmoms)
)["primitive_lattice"]
assert np.allclose(primitive_lattice1, primitive_lattice2)


if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(TestMagneticDataset)
Expand Down

0 comments on commit 6bbcb7d

Please sign in to comment.