symfc 1.2.0__tar.gz → 1.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. {symfc-1.2.0/src/symfc.egg-info → symfc-1.2.2}/PKG-INFO +22 -3
  2. {symfc-1.2.0 → symfc-1.2.2}/README.md +20 -1
  3. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/utils.py +36 -11
  4. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/version.py +1 -1
  5. {symfc-1.2.0 → symfc-1.2.2/src/symfc.egg-info}/PKG-INFO +22 -3
  6. symfc-1.2.2/tests/utils/test_utils.py +408 -0
  7. symfc-1.2.0/tests/utils/test_utils.py +0 -73
  8. {symfc-1.2.0 → symfc-1.2.2}/LICENSE +0 -0
  9. {symfc-1.2.0 → symfc-1.2.2}/MANIFEST.in +0 -0
  10. {symfc-1.2.0 → symfc-1.2.2}/pyproject.toml +0 -0
  11. {symfc-1.2.0 → symfc-1.2.2}/setup.cfg +0 -0
  12. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/__init__.py +0 -0
  13. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/api_symfc.py +0 -0
  14. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/basis_sets/__init__.py +0 -0
  15. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/basis_sets/basis_sets_O1.py +0 -0
  16. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/basis_sets/basis_sets_O2.py +0 -0
  17. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/basis_sets/basis_sets_O3.py +0 -0
  18. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/basis_sets/basis_sets_O4.py +0 -0
  19. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/basis_sets/basis_sets_base.py +0 -0
  20. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/solvers/__init__.py +0 -0
  21. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/solvers/solver_O2.py +0 -0
  22. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/solvers/solver_O2O3.py +0 -0
  23. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/solvers/solver_O2O3O4.py +0 -0
  24. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/solvers/solver_O3.py +0 -0
  25. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/solvers/solver_O3O4.py +0 -0
  26. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/solvers/solver_O4.py +0 -0
  27. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/solvers/solver_base.py +0 -0
  28. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/spg_reps/__init__.py +0 -0
  29. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/spg_reps/spg_reps_O1.py +0 -0
  30. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/spg_reps/spg_reps_O2.py +0 -0
  31. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/spg_reps/spg_reps_O3.py +0 -0
  32. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/spg_reps/spg_reps_O4.py +0 -0
  33. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/spg_reps/spg_reps_base.py +0 -0
  34. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/__init__.py +0 -0
  35. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/cutoff_tools.py +0 -0
  36. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/eig_tools.py +0 -0
  37. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/matrix_tools.py +0 -0
  38. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/matrix_tools_O1.py +0 -0
  39. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/matrix_tools_O2.py +0 -0
  40. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/matrix_tools_O3.py +0 -0
  41. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/matrix_tools_O4.py +0 -0
  42. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/permutation_tools.py +0 -0
  43. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/permutation_tools_O2.py +0 -0
  44. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/permutation_tools_O3.py +0 -0
  45. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/permutation_tools_O4.py +0 -0
  46. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/rotation_tools_O2.py +0 -0
  47. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/run_rotation_tools_O2.py +0 -0
  48. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/run_rotation_tools_O3.py +0 -0
  49. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/run_test_O2.py +0 -0
  50. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/solver_funcs.py +0 -0
  51. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/utils_O1.py +0 -0
  52. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/utils_O2.py +0 -0
  53. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/utils_O3.py +0 -0
  54. {symfc-1.2.0 → symfc-1.2.2}/src/symfc/utils/utils_O4.py +0 -0
  55. {symfc-1.2.0 → symfc-1.2.2}/src/symfc.egg-info/SOURCES.txt +0 -0
  56. {symfc-1.2.0 → symfc-1.2.2}/src/symfc.egg-info/dependency_links.txt +0 -0
  57. {symfc-1.2.0 → symfc-1.2.2}/src/symfc.egg-info/requires.txt +0 -0
  58. {symfc-1.2.0 → symfc-1.2.2}/src/symfc.egg-info/top_level.txt +0 -0
  59. {symfc-1.2.0 → symfc-1.2.2}/tests/NaCl-unitcell.yaml +0 -0
  60. {symfc-1.2.0 → symfc-1.2.2}/tests/basis_sets/test_basis_sets_O2.py +0 -0
  61. {symfc-1.2.0 → symfc-1.2.2}/tests/basis_sets/test_basis_sets_O3.py +0 -0
  62. {symfc-1.2.0 → symfc-1.2.2}/tests/basis_sets/test_basis_sets_O4.py +0 -0
  63. {symfc-1.2.0 → symfc-1.2.2}/tests/basis_sets/test_basis_sets_base.py +0 -0
  64. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_GaN_222.xz +0 -0
  65. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_GaN_442.xz +0 -0
  66. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_NaCl_222.xz +0 -0
  67. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_SiO2_221.xz +0 -0
  68. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_Si_111_fc3_2.xz +0 -0
  69. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_Si_111_fc3_3.xz +0 -0
  70. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_Si_111_fc4_2.xz +0 -0
  71. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_Si_111_fc4_3.xz +0 -0
  72. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_Si_111_fc4_4.xz +0 -0
  73. {symfc-1.2.0 → symfc-1.2.2}/tests/compact_fc_SnO2_223.xz +0 -0
  74. {symfc-1.2.0 → symfc-1.2.2}/tests/conftest.py +0 -0
  75. {symfc-1.2.0 → symfc-1.2.2}/tests/dfset_GaN_222_rd.xz +0 -0
  76. {symfc-1.2.0 → symfc-1.2.2}/tests/dfset_GaN_442_rd.xz +0 -0
  77. {symfc-1.2.0 → symfc-1.2.2}/tests/dfset_NaCl_222_rd.xz +0 -0
  78. {symfc-1.2.0 → symfc-1.2.2}/tests/dfset_SiO2_221_rd.xz +0 -0
  79. {symfc-1.2.0 → symfc-1.2.2}/tests/dfset_Si_111_fc3_rd.xz +0 -0
  80. {symfc-1.2.0 → symfc-1.2.2}/tests/dfset_SnO2_223_rd.xz +0 -0
  81. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_NaCl_222.xz +0 -0
  82. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_Si_111_fc3_2.xz +0 -0
  83. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_Si_111_fc3_3.xz +0 -0
  84. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_Si_111_fc4_2.xz +0 -0
  85. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_Si_111_fc4_3.xz +0 -0
  86. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_Si_111_fc4_4.xz +0 -0
  87. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_Si_111_fc4_step_2.xz +0 -0
  88. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_Si_111_fc4_step_3.xz +0 -0
  89. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_Si_111_fc4_step_4.xz +0 -0
  90. {symfc-1.2.0 → symfc-1.2.2}/tests/full_fc_SnO2_223.xz +0 -0
  91. {symfc-1.2.0 → symfc-1.2.2}/tests/perms_super.dat +0 -0
  92. {symfc-1.2.0 → symfc-1.2.2}/tests/phonopy_to_python.py +0 -0
  93. {symfc-1.2.0 → symfc-1.2.2}/tests/solvers/test_solver_utils.py +0 -0
  94. {symfc-1.2.0 → symfc-1.2.2}/tests/spg_reps/test_spg_reps_O1.py +0 -0
  95. {symfc-1.2.0 → symfc-1.2.2}/tests/spg_reps/test_spg_reps_O2.py +0 -0
  96. {symfc-1.2.0 → symfc-1.2.2}/tests/spg_reps/test_spg_reps_O3.py +0 -0
  97. {symfc-1.2.0 → symfc-1.2.2}/tests/spg_reps/test_spg_reps_O4.py +0 -0
  98. {symfc-1.2.0 → symfc-1.2.2}/tests/spg_reps/test_spg_reps_base.py +0 -0
  99. {symfc-1.2.0 → symfc-1.2.2}/tests/test_api.py +0 -0
  100. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_cutoff_tools.py +0 -0
  101. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_eig_tools.py +0 -0
  102. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_matrix_tools_O2.py +0 -0
  103. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_matrix_tools_O3.py +0 -0
  104. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_matrix_tools_O4.py +0 -0
  105. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_solver_funcs.py +0 -0
  106. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_utils_O1.py +0 -0
  107. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_utils_O2.py +0 -0
  108. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_utils_O2_2.py +0 -0
  109. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_utils_O3.py +0 -0
  110. {symfc-1.2.0 → symfc-1.2.2}/tests/utils/test_utils_O4.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: symfc
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: This is the symfc module.
5
5
  Author-email: Atsuto Seko <seko@cms.mtl.kyoto-u.ac.jp>
6
6
  Maintainer-email: Atsushi Togo <atztogo@gmail.com>
@@ -62,4 +62,23 @@ factors such as numerical noise or approximations used. Symfc is a software
62
62
  designed to compute force constants from displacement-force datasets in the
63
63
  supercell approach, ensuring they meet the required symmetry constraints.
64
64
 
65
- For more detail, please refer https://arxiv.org/abs/2403.03588.
65
+ ## Citation of symfc
66
+
67
+ "Projector-based efficient estimation of force constants", A. Seko and A. Togo,
68
+ Phys. Rev. B, **110**, 214302 (2024)
69
+ [[doi](https://doi.org/10.1103/PhysRevB.110.214302)]
70
+ [[arxiv](https://arxiv.org/abs/2403.03588)].
71
+
72
+ ```
73
+ @article{PhysRevB.110.214302,
74
+ title = {Projector-based efficient estimation of force constants},
75
+ author = {Seko, Atsuto and Togo, Atsushi},
76
+ journal = {Phys. Rev. B},
77
+ volume = {110},
78
+ issue = {21},
79
+ pages = {214302},
80
+ numpages = {18},
81
+ year = {2024},
82
+ month = {Dec},
83
+ }
84
+ ```
@@ -19,4 +19,23 @@ factors such as numerical noise or approximations used. Symfc is a software
19
19
  designed to compute force constants from displacement-force datasets in the
20
20
  supercell approach, ensuring they meet the required symmetry constraints.
21
21
 
22
- For more detail, please refer https://arxiv.org/abs/2403.03588.
22
+ ## Citation of symfc
23
+
24
+ "Projector-based efficient estimation of force constants", A. Seko and A. Togo,
25
+ Phys. Rev. B, **110**, 214302 (2024)
26
+ [[doi](https://doi.org/10.1103/PhysRevB.110.214302)]
27
+ [[arxiv](https://arxiv.org/abs/2403.03588)].
28
+
29
+ ```
30
+ @article{PhysRevB.110.214302,
31
+ title = {Projector-based efficient estimation of force constants},
32
+ author = {Seko, Atsuto and Togo, Atsushi},
33
+ journal = {Phys. Rev. B},
34
+ volume = {110},
35
+ issue = {21},
36
+ pages = {214302},
37
+ numpages = {18},
38
+ year = {2024},
39
+ month = {Dec},
40
+ }
41
+ ```
@@ -34,7 +34,7 @@ def get_indep_atoms_by_lat_trans(trans_perms: np.ndarray) -> np.ndarray:
34
34
  return np.array(unique_atoms, dtype=int)
35
35
 
36
36
 
37
- def round_positions(positions, tol=1e-13, decimals=5):
37
+ def round_positions(positions: np.ndarray, tol: float = 1e-13, decimals: int = 5):
38
38
  """Round fractional coordinates of positions (-0.5 <= p < 0.5)."""
39
39
  positions_rint = positions - np.rint(positions)
40
40
  positions_rint[np.abs(positions_rint - 0.5) < tol] = -0.5
@@ -42,15 +42,27 @@ def round_positions(positions, tol=1e-13, decimals=5):
42
42
  return positions_rint
43
43
 
44
44
 
45
- def argsort_positions(positions, tol=1e-13, decimals=5):
45
+ def argsort_positions(positions: np.ndarray, tol: float = 1e-13, decimals: int = 5):
46
46
  """Round and sort fractional coordinates of positions (-0.5 <= p < 0.5)."""
47
- positions_rint = round_positions(positions, tol=tol, decimals=decimals)
48
- """Not needed part?"""
49
- positions_rint *= 10**decimals
47
+ positions_round = round_positions(positions, tol=tol, decimals=decimals)
48
+ # Not needed part?
49
+ positions_rint = 10**decimals * positions_round
50
50
  positions_rint = [tuple(p) for p in positions_rint.astype(int)]
51
- """Not needed part? (end)"""
51
+ # Not needed part? (end)
52
52
  sorted_ids = sorted(range(positions.shape[0]), key=positions_rint.__getitem__)
53
- return sorted_ids
53
+ sorted_positions = positions_round[sorted_ids]
54
+ return sorted_ids, sorted_positions
55
+
56
+
57
+ def _find_optimal_decimals(positions: np.ndarray, tol: float = 1e-13):
58
+ """Find optimal value of decimals used for sorting atoms."""
59
+ n_atom = positions.shape[0]
60
+ for decimals in range(3, 15):
61
+ positions_round = round_positions(positions, tol=tol, decimals=decimals)
62
+ n_atom_uniq = len(set([tuple(pos) for pos in positions_round]))
63
+ if n_atom_uniq == n_atom:
64
+ return decimals
65
+ raise RuntimeError("Optimal decimals not found.")
54
66
 
55
67
 
56
68
  def compute_sg_permutations(
@@ -91,13 +103,26 @@ def compute_sg_permutations(
91
103
  trans_perms = []
92
104
  pure_trans = []
93
105
  n_atom = positions.shape[0]
94
- decimals = int(-np.log10(symprec))
95
- sorted_ids = argsort_positions(positions, decimals=decimals)
106
+ decimals = _find_optimal_decimals(positions)
107
+ sorted_ids, sorted_positions = argsort_positions(positions, decimals=decimals)
96
108
  for r, t in zip(rotations, translations):
97
109
  if (r != np.eye(3, dtype=int)).any():
98
110
  continue
99
- tp = np.zeros(n_atom, dtype=int)
100
- tp[sorted_ids] = argsort_positions(positions + t, decimals=decimals)
111
+ trans_positions = positions + t
112
+ sorted_trans_ids, sorted_trans_positions = argsort_positions(
113
+ trans_positions,
114
+ decimals=decimals,
115
+ )
116
+ if np.allclose(sorted_trans_positions - sorted_positions, 0.0):
117
+ tp = np.zeros(n_atom, dtype=int)
118
+ tp[sorted_trans_ids] = sorted_ids
119
+ else:
120
+ diffs = positions[None, :, :] - trans_positions[:, None, :]
121
+ diffs -= np.rint(diffs)
122
+ dists = np.linalg.norm(diffs @ lattice.T, axis=2)
123
+ rows, cols = np.where(dists < symprec)
124
+ assert len(positions) == len(np.unique(rows)) == len(np.unique(cols))
125
+ tp = cols[np.argsort(rows)]
101
126
  trans_perms.append(tp)
102
127
  pure_trans.append(t)
103
128
  trans_perms = np.array(trans_perms, dtype=int)
@@ -1,3 +1,3 @@
1
1
  """Version number of the package."""
2
2
 
3
- __version__ = "1.2.0"
3
+ __version__ = "1.2.2"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: symfc
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: This is the symfc module.
5
5
  Author-email: Atsuto Seko <seko@cms.mtl.kyoto-u.ac.jp>
6
6
  Maintainer-email: Atsushi Togo <atztogo@gmail.com>
@@ -62,4 +62,23 @@ factors such as numerical noise or approximations used. Symfc is a software
62
62
  designed to compute force constants from displacement-force datasets in the
63
63
  supercell approach, ensuring they meet the required symmetry constraints.
64
64
 
65
- For more detail, please refer https://arxiv.org/abs/2403.03588.
65
+ ## Citation of symfc
66
+
67
+ "Projector-based efficient estimation of force constants", A. Seko and A. Togo,
68
+ Phys. Rev. B, **110**, 214302 (2024)
69
+ [[doi](https://doi.org/10.1103/PhysRevB.110.214302)]
70
+ [[arxiv](https://arxiv.org/abs/2403.03588)].
71
+
72
+ ```
73
+ @article{PhysRevB.110.214302,
74
+ title = {Projector-based efficient estimation of force constants},
75
+ author = {Seko, Atsuto and Togo, Atsushi},
76
+ journal = {Phys. Rev. B},
77
+ volume = {110},
78
+ issue = {21},
79
+ pages = {214302},
80
+ numpages = {18},
81
+ year = {2024},
82
+ month = {Dec},
83
+ }
84
+ ```
@@ -0,0 +1,408 @@
1
+ """Tests of matrix manipulating functions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ import numpy as np
8
+ import pytest
9
+
10
+ from symfc.spg_reps import SpgRepsBase
11
+ from symfc.utils.utils import (
12
+ SymfcAtoms,
13
+ compute_sg_permutations,
14
+ compute_sg_permutations_stable,
15
+ get_indep_atoms_by_lat_trans,
16
+ )
17
+
18
+ cwd = Path(__file__).parent
19
+
20
+
21
+ def test_get_indep_atoms_by_lattice_translation(
22
+ ph_nacl_222: tuple[SymfcAtoms, np.ndarray, np.ndarray],
23
+ ):
24
+ """Test of get_indep_atoms_by_lattice_translation."""
25
+ supercell, _, _ = ph_nacl_222
26
+ sym_op_reps = SpgRepsBase(supercell)
27
+ trans_perms = sym_op_reps.translation_permutations
28
+ assert trans_perms.shape == (32, 64)
29
+ indep_atoms = get_indep_atoms_by_lat_trans(trans_perms)
30
+ np.testing.assert_array_equal(indep_atoms, [0, 32])
31
+
32
+
33
+ def test_compute_sg_permutations(
34
+ ph_gan_222: tuple[SymfcAtoms, np.ndarray, np.ndarray], cell_gan_111: SymfcAtoms
35
+ ):
36
+ """Test compute_sg_permutations."""
37
+ pytest.importorskip("spglib", minversion="2.5")
38
+ from spglib import spglib
39
+
40
+ supercell, _, _ = ph_gan_222
41
+ primitive = cell_gan_111
42
+ dataset = spglib.get_symmetry_dataset(supercell.totuple())
43
+ primitive_dataset = spglib.get_symmetry_dataset(primitive.totuple())
44
+ perms = compute_sg_permutations(
45
+ primitive.scaled_positions,
46
+ primitive_dataset.rotations,
47
+ primitive_dataset.translations,
48
+ primitive.cell,
49
+ )
50
+ ref_perms = [
51
+ [0, 1, 2, 3],
52
+ [1, 0, 3, 2],
53
+ [0, 1, 2, 3],
54
+ [1, 0, 3, 2],
55
+ [0, 1, 2, 3],
56
+ [1, 0, 3, 2],
57
+ [1, 0, 3, 2],
58
+ [0, 1, 2, 3],
59
+ [1, 0, 3, 2],
60
+ [0, 1, 2, 3],
61
+ [1, 0, 3, 2],
62
+ [0, 1, 2, 3],
63
+ ]
64
+ np.testing.assert_array_equal(ref_perms, perms)
65
+
66
+ perms_super = compute_sg_permutations(
67
+ supercell.scaled_positions,
68
+ dataset.rotations,
69
+ dataset.translations,
70
+ supercell.cell,
71
+ )
72
+ # np.savetxt("perms_super.dat", perms_super, fmt="%d")
73
+ perms_super_ref = np.loadtxt(cwd / ".." / "perms_super.dat", dtype=int)
74
+ np.testing.assert_array_equal(perms_super_ref, perms_super)
75
+
76
+
77
+ def test_compute_sg_permutations_compare_stable():
78
+ """Test compute_sg_permutations and compare with compute_sg_permutations_stable."""
79
+ pytest.importorskip("spglib", minversion="2.5")
80
+ from spglib import spglib
81
+
82
+ axis = np.array([[0.0, 1.0, 1.0], [7.0, 6.0, 7.0], [8.0, 8.0, 8.0]])
83
+ positions = np.array(
84
+ [
85
+ [0.000000000000000, 0.000000000000000, 0.000000000000000],
86
+ [0.000000000000000, 0.000000000000000, 0.125000000000000],
87
+ [0.000000000000000, 0.000000000000000, 0.250000000000000],
88
+ [0.000000000000000, 0.000000000000000, 0.375000000000000],
89
+ [0.000000000000000, 0.000000000000000, 0.500000000000000],
90
+ [0.000000000000000, 0.000000000000000, 0.625000000000000],
91
+ [0.000000000000000, 0.000000000000000, 0.750000000000000],
92
+ [0.000000000000000, 0.000000000000000, 0.875000000000000],
93
+ ]
94
+ )
95
+ types = np.zeros(8, dtype=int)
96
+
97
+ cell = axis, positions, types
98
+ dataset = spglib.get_symmetry_dataset(cell)
99
+ perms = compute_sg_permutations(
100
+ positions,
101
+ dataset.rotations,
102
+ dataset.translations,
103
+ axis,
104
+ )
105
+ perms_stable = compute_sg_permutations_stable(
106
+ positions,
107
+ dataset.rotations,
108
+ dataset.translations,
109
+ axis,
110
+ )
111
+ ref_perms = [
112
+ [0, 1, 2, 3, 4, 5, 6, 7],
113
+ [0, 7, 6, 5, 4, 3, 2, 1],
114
+ [0, 7, 6, 5, 4, 3, 2, 1],
115
+ [0, 1, 2, 3, 4, 5, 6, 7],
116
+ [0, 1, 2, 3, 4, 5, 6, 7],
117
+ [0, 7, 6, 5, 4, 3, 2, 1],
118
+ [0, 7, 6, 5, 4, 3, 2, 1],
119
+ [0, 1, 2, 3, 4, 5, 6, 7],
120
+ [0, 7, 6, 5, 4, 3, 2, 1],
121
+ [0, 1, 2, 3, 4, 5, 6, 7],
122
+ [0, 1, 2, 3, 4, 5, 6, 7],
123
+ [0, 7, 6, 5, 4, 3, 2, 1],
124
+ [1, 2, 3, 4, 5, 6, 7, 0],
125
+ [1, 0, 7, 6, 5, 4, 3, 2],
126
+ [1, 0, 7, 6, 5, 4, 3, 2],
127
+ [1, 2, 3, 4, 5, 6, 7, 0],
128
+ [1, 2, 3, 4, 5, 6, 7, 0],
129
+ [1, 0, 7, 6, 5, 4, 3, 2],
130
+ [1, 0, 7, 6, 5, 4, 3, 2],
131
+ [1, 2, 3, 4, 5, 6, 7, 0],
132
+ [1, 0, 7, 6, 5, 4, 3, 2],
133
+ [1, 2, 3, 4, 5, 6, 7, 0],
134
+ [1, 2, 3, 4, 5, 6, 7, 0],
135
+ [1, 0, 7, 6, 5, 4, 3, 2],
136
+ [2, 3, 4, 5, 6, 7, 0, 1],
137
+ [2, 1, 0, 7, 6, 5, 4, 3],
138
+ [2, 1, 0, 7, 6, 5, 4, 3],
139
+ [2, 3, 4, 5, 6, 7, 0, 1],
140
+ [2, 3, 4, 5, 6, 7, 0, 1],
141
+ [2, 1, 0, 7, 6, 5, 4, 3],
142
+ [2, 1, 0, 7, 6, 5, 4, 3],
143
+ [2, 3, 4, 5, 6, 7, 0, 1],
144
+ [2, 1, 0, 7, 6, 5, 4, 3],
145
+ [2, 3, 4, 5, 6, 7, 0, 1],
146
+ [2, 3, 4, 5, 6, 7, 0, 1],
147
+ [2, 1, 0, 7, 6, 5, 4, 3],
148
+ [3, 4, 5, 6, 7, 0, 1, 2],
149
+ [3, 2, 1, 0, 7, 6, 5, 4],
150
+ [3, 2, 1, 0, 7, 6, 5, 4],
151
+ [3, 4, 5, 6, 7, 0, 1, 2],
152
+ [3, 4, 5, 6, 7, 0, 1, 2],
153
+ [3, 2, 1, 0, 7, 6, 5, 4],
154
+ [3, 2, 1, 0, 7, 6, 5, 4],
155
+ [3, 4, 5, 6, 7, 0, 1, 2],
156
+ [3, 2, 1, 0, 7, 6, 5, 4],
157
+ [3, 4, 5, 6, 7, 0, 1, 2],
158
+ [3, 4, 5, 6, 7, 0, 1, 2],
159
+ [3, 2, 1, 0, 7, 6, 5, 4],
160
+ [4, 5, 6, 7, 0, 1, 2, 3],
161
+ [4, 3, 2, 1, 0, 7, 6, 5],
162
+ [4, 3, 2, 1, 0, 7, 6, 5],
163
+ [4, 5, 6, 7, 0, 1, 2, 3],
164
+ [4, 5, 6, 7, 0, 1, 2, 3],
165
+ [4, 3, 2, 1, 0, 7, 6, 5],
166
+ [4, 3, 2, 1, 0, 7, 6, 5],
167
+ [4, 5, 6, 7, 0, 1, 2, 3],
168
+ [4, 3, 2, 1, 0, 7, 6, 5],
169
+ [4, 5, 6, 7, 0, 1, 2, 3],
170
+ [4, 5, 6, 7, 0, 1, 2, 3],
171
+ [4, 3, 2, 1, 0, 7, 6, 5],
172
+ [5, 6, 7, 0, 1, 2, 3, 4],
173
+ [5, 4, 3, 2, 1, 0, 7, 6],
174
+ [5, 4, 3, 2, 1, 0, 7, 6],
175
+ [5, 6, 7, 0, 1, 2, 3, 4],
176
+ [5, 6, 7, 0, 1, 2, 3, 4],
177
+ [5, 4, 3, 2, 1, 0, 7, 6],
178
+ [5, 4, 3, 2, 1, 0, 7, 6],
179
+ [5, 6, 7, 0, 1, 2, 3, 4],
180
+ [5, 4, 3, 2, 1, 0, 7, 6],
181
+ [5, 6, 7, 0, 1, 2, 3, 4],
182
+ [5, 6, 7, 0, 1, 2, 3, 4],
183
+ [5, 4, 3, 2, 1, 0, 7, 6],
184
+ [6, 7, 0, 1, 2, 3, 4, 5],
185
+ [6, 5, 4, 3, 2, 1, 0, 7],
186
+ [6, 5, 4, 3, 2, 1, 0, 7],
187
+ [6, 7, 0, 1, 2, 3, 4, 5],
188
+ [6, 7, 0, 1, 2, 3, 4, 5],
189
+ [6, 5, 4, 3, 2, 1, 0, 7],
190
+ [6, 5, 4, 3, 2, 1, 0, 7],
191
+ [6, 7, 0, 1, 2, 3, 4, 5],
192
+ [6, 5, 4, 3, 2, 1, 0, 7],
193
+ [6, 7, 0, 1, 2, 3, 4, 5],
194
+ [6, 7, 0, 1, 2, 3, 4, 5],
195
+ [6, 5, 4, 3, 2, 1, 0, 7],
196
+ [7, 0, 1, 2, 3, 4, 5, 6],
197
+ [7, 6, 5, 4, 3, 2, 1, 0],
198
+ [7, 6, 5, 4, 3, 2, 1, 0],
199
+ [7, 0, 1, 2, 3, 4, 5, 6],
200
+ [7, 0, 1, 2, 3, 4, 5, 6],
201
+ [7, 6, 5, 4, 3, 2, 1, 0],
202
+ [7, 6, 5, 4, 3, 2, 1, 0],
203
+ [7, 0, 1, 2, 3, 4, 5, 6],
204
+ [7, 6, 5, 4, 3, 2, 1, 0],
205
+ [7, 0, 1, 2, 3, 4, 5, 6],
206
+ [7, 0, 1, 2, 3, 4, 5, 6],
207
+ [7, 6, 5, 4, 3, 2, 1, 0],
208
+ ]
209
+ np.testing.assert_array_equal(perms, perms_stable)
210
+ np.testing.assert_array_equal(perms, ref_perms)
211
+
212
+
213
+ def test_compute_sg_permutations_compare_stable_nacl(
214
+ ph_nacl_222: tuple[SymfcAtoms, np.ndarray, np.ndarray],
215
+ ):
216
+ """Test of compute_sg_permutations for NaCl."""
217
+ pytest.importorskip("spglib", minversion="2.5")
218
+ from spglib import spglib
219
+
220
+ supercell, _, _ = ph_nacl_222
221
+ dataset = spglib.get_symmetry_dataset(supercell.totuple())
222
+ perms = compute_sg_permutations(
223
+ supercell.scaled_positions,
224
+ dataset.rotations,
225
+ dataset.translations,
226
+ supercell.cell,
227
+ )
228
+ perms_stable = compute_sg_permutations_stable(
229
+ supercell.scaled_positions,
230
+ dataset.rotations,
231
+ dataset.translations,
232
+ supercell.cell,
233
+ )
234
+ np.testing.assert_array_equal(perms, perms_stable)
235
+
236
+
237
+ def test_compute_sg_permutations_compare_stable_sio2(
238
+ ph_sio2_221: tuple[SymfcAtoms, np.ndarray, np.ndarray],
239
+ ):
240
+ """Test of compute_sg_permutations for SiO2."""
241
+ pytest.importorskip("spglib", minversion="2.5")
242
+ from spglib import spglib
243
+
244
+ supercell, _, _ = ph_sio2_221
245
+ dataset = spglib.get_symmetry_dataset(supercell.totuple())
246
+ perms = compute_sg_permutations(
247
+ supercell.scaled_positions,
248
+ dataset.rotations,
249
+ dataset.translations,
250
+ supercell.cell,
251
+ )
252
+ perms_stable = compute_sg_permutations_stable(
253
+ supercell.scaled_positions,
254
+ dataset.rotations,
255
+ dataset.translations,
256
+ supercell.cell,
257
+ )
258
+ np.testing.assert_array_equal(perms, perms_stable)
259
+
260
+
261
+ def test_compute_sg_permutations_compare_stable_baal2o4():
262
+ """Test compute_sg_permutations for BaAl2O4."""
263
+ pytest.importorskip("spglib", minversion="2.5")
264
+ from spglib import spglib
265
+
266
+ types = np.zeros(8, dtype=int)
267
+ axis = np.array(
268
+ [
269
+ [10.4020522437529994, 0.0000000000000000, 0.0000000000000000],
270
+ [-5.2010261218764997, 9.0084414945829998, 0.0000000000000000],
271
+ [0.00000000000000000, 0.0000000000000000, 17.8057491600000013],
272
+ ]
273
+ )
274
+ types = np.hstack(
275
+ [np.zeros(16, dtype=int), np.ones(32, dtype=int), np.ones(64, dtype=int) * 2]
276
+ )
277
+ positions = np.array(
278
+ [
279
+ [0.0000000000000000, 0.0000000000000000, 0.1250000000000000],
280
+ [0.5000000000000000, 0.0000000000000000, 0.1250000000000000],
281
+ [0.0000000000000050, 0.5000000000000000, 0.1250000000000000],
282
+ [0.4999999999999950, 0.5000000000000000, 0.1250000000000000],
283
+ [0.0000000000000000, 0.0000000000000000, 0.6250000000000000],
284
+ [0.5000000000000000, 0.0000000000000000, 0.6250000000000000],
285
+ [0.0000000000000050, 0.5000000000000000, 0.6250000000000000],
286
+ [0.4999999999999950, 0.5000000000000000, 0.6250000000000000],
287
+ [0.0000000000000000, 0.0000000000000000, 0.3750000000000000],
288
+ [0.5000000000000000, 0.0000000000000000, 0.3750000000000000],
289
+ [0.0000000000000050, 0.5000000000000000, 0.3750000000000000],
290
+ [0.4999999999999950, 0.5000000000000000, 0.3750000000000000],
291
+ [0.0000000000000000, 0.0000000000000000, 0.8750000000000000],
292
+ [0.5000000000000000, 0.0000000000000000, 0.8750000000000000],
293
+ [0.0000000000000050, 0.5000000000000000, 0.8750000000000000],
294
+ [0.4999999999999950, 0.5000000000000000, 0.8750000000000000],
295
+ [0.1666666666666690, 0.3333333333333370, 0.2768253700000010],
296
+ [0.6666666666666690, 0.3333333333333370, 0.2768253700000010],
297
+ [0.1666666666666730, 0.8333333333333370, 0.2768253700000010],
298
+ [0.6666666666666640, 0.8333333333333370, 0.2768253700000010],
299
+ [0.1666666666666690, 0.3333333333333370, 0.7768253699999890],
300
+ [0.6666666666666690, 0.3333333333333370, 0.7768253699999890],
301
+ [0.1666666666666730, 0.8333333333333370, 0.7768253699999890],
302
+ [0.6666666666666640, 0.8333333333333370, 0.7768253699999890],
303
+ [0.3333333333333270, 0.1666666666666630, 0.0268253700000010],
304
+ [0.8333333333333270, 0.1666666666666630, 0.0268253700000010],
305
+ [0.3333333333333320, 0.6666666666666630, 0.0268253700000010],
306
+ [0.8333333333333310, 0.6666666666666630, 0.0268253700000010],
307
+ [0.3333333333333270, 0.1666666666666630, 0.5268253700000010],
308
+ [0.8333333333333270, 0.1666666666666630, 0.5268253700000010],
309
+ [0.3333333333333320, 0.6666666666666630, 0.5268253700000010],
310
+ [0.8333333333333310, 0.6666666666666630, 0.5268253700000010],
311
+ [0.3333333333333270, 0.1666666666666630, 0.2231746299999990],
312
+ [0.8333333333333270, 0.1666666666666630, 0.2231746299999990],
313
+ [0.3333333333333320, 0.6666666666666630, 0.2231746299999990],
314
+ [0.8333333333333310, 0.6666666666666630, 0.2231746299999990],
315
+ [0.3333333333333270, 0.1666666666666630, 0.7231746300000110],
316
+ [0.8333333333333270, 0.1666666666666630, 0.7231746300000110],
317
+ [0.3333333333333320, 0.6666666666666630, 0.7231746300000110],
318
+ [0.8333333333333310, 0.6666666666666630, 0.7231746300000110],
319
+ [0.1666666666666690, 0.3333333333333370, 0.4731746299999990],
320
+ [0.6666666666666690, 0.3333333333333370, 0.4731746299999990],
321
+ [0.1666666666666730, 0.8333333333333370, 0.4731746299999990],
322
+ [0.6666666666666640, 0.8333333333333370, 0.4731746299999990],
323
+ [0.1666666666666690, 0.3333333333333370, 0.9731746300000110],
324
+ [0.6666666666666690, 0.3333333333333370, 0.9731746300000110],
325
+ [0.1666666666666730, 0.8333333333333370, 0.9731746300000110],
326
+ [0.6666666666666640, 0.8333333333333370, 0.9731746300000110],
327
+ [0.1749127449999990, 0.1749127449999980, 0.2500000000000000],
328
+ [0.6749127449999970, 0.1749127449999980, 0.2500000000000000],
329
+ [0.1749127450000020, 0.6749127449999980, 0.2500000000000000],
330
+ [0.6749127450000020, 0.6749127449999980, 0.2500000000000000],
331
+ [0.1749127449999990, 0.1749127449999980, 0.7500000000000000],
332
+ [0.6749127449999970, 0.1749127449999980, 0.7500000000000000],
333
+ [0.1749127450000020, 0.6749127449999980, 0.7500000000000000],
334
+ [0.6749127450000020, 0.6749127449999980, 0.7500000000000000],
335
+ [0.0000000000000030, 0.3250872550000020, 0.2500000000000000],
336
+ [0.5000000000000030, 0.3250872550000020, 0.2500000000000000],
337
+ [0.9999999999999990, 0.8250872550000020, 0.2500000000000000],
338
+ [0.5000000000000010, 0.8250872550000020, 0.2500000000000000],
339
+ [0.0000000000000030, 0.3250872550000020, 0.7500000000000000],
340
+ [0.5000000000000030, 0.3250872550000020, 0.7500000000000000],
341
+ [0.9999999999999990, 0.8250872550000020, 0.7500000000000000],
342
+ [0.5000000000000010, 0.8250872550000020, 0.7500000000000000],
343
+ [0.9999999999999990, 0.1749127449999980, 0.0000000000000000],
344
+ [0.5000000000000010, 0.1749127449999980, 0.0000000000000000],
345
+ [0.9999999999999970, 0.6749127449999980, 0.0000000000000000],
346
+ [0.4999999999999970, 0.6749127449999980, 0.0000000000000000],
347
+ [0.9999999999999990, 0.1749127449999980, 0.5000000000000000],
348
+ [0.5000000000000010, 0.1749127449999980, 0.5000000000000000],
349
+ [0.9999999999999970, 0.6749127449999980, 0.5000000000000000],
350
+ [0.4999999999999970, 0.6749127449999980, 0.5000000000000000],
351
+ [0.1666666666666690, 0.3333333333333370, 0.3750000000000000],
352
+ [0.6666666666666690, 0.3333333333333370, 0.3750000000000000],
353
+ [0.1666666666666730, 0.8333333333333370, 0.3750000000000000],
354
+ [0.6666666666666640, 0.8333333333333370, 0.3750000000000000],
355
+ [0.1666666666666690, 0.3333333333333370, 0.8750000000000000],
356
+ [0.6666666666666690, 0.3333333333333370, 0.8750000000000000],
357
+ [0.1666666666666730, 0.8333333333333370, 0.8750000000000000],
358
+ [0.6666666666666640, 0.8333333333333370, 0.8750000000000000],
359
+ [0.3250872549999980, 0.3250872550000020, 0.0000000000000000],
360
+ [0.8250872549999980, 0.3250872550000020, 0.0000000000000000],
361
+ [0.3250872550000010, 0.8250872550000020, 0.0000000000000000],
362
+ [0.8250872550000030, 0.8250872550000020, 0.0000000000000000],
363
+ [0.3250872549999980, 0.3250872550000020, 0.5000000000000000],
364
+ [0.8250872549999980, 0.3250872550000020, 0.5000000000000000],
365
+ [0.3250872550000010, 0.8250872550000020, 0.5000000000000000],
366
+ [0.8250872550000030, 0.8250872550000020, 0.5000000000000000],
367
+ [0.3250872550000040, 0.0000000000000000, 0.2500000000000000],
368
+ [0.8250872550000040, 0.0000000000000000, 0.2500000000000000],
369
+ [0.3250872550000020, 0.5000000000000000, 0.2500000000000000],
370
+ [0.8250872550000000, 0.5000000000000000, 0.2500000000000000],
371
+ [0.3250872550000040, 0.0000000000000000, 0.7500000000000000],
372
+ [0.8250872550000040, 0.0000000000000000, 0.7500000000000000],
373
+ [0.3250872550000020, 0.5000000000000000, 0.7500000000000000],
374
+ [0.8250872550000000, 0.5000000000000000, 0.7500000000000000],
375
+ [0.3333333333333270, 0.1666666666666630, 0.1250000000000000],
376
+ [0.8333333333333270, 0.1666666666666630, 0.1250000000000000],
377
+ [0.3333333333333320, 0.6666666666666630, 0.1250000000000000],
378
+ [0.8333333333333310, 0.6666666666666630, 0.1250000000000000],
379
+ [0.3333333333333270, 0.1666666666666630, 0.6250000000000000],
380
+ [0.8333333333333270, 0.1666666666666630, 0.6250000000000000],
381
+ [0.3333333333333320, 0.6666666666666630, 0.6250000000000000],
382
+ [0.8333333333333310, 0.6666666666666630, 0.6250000000000000],
383
+ [0.1749127449999960, 0.0000000000000000, 0.0000000000000000],
384
+ [0.6749127449999960, 0.0000000000000000, 0.0000000000000000],
385
+ [0.1749127449999980, 0.5000000000000000, 0.0000000000000000],
386
+ [0.6749127450000000, 0.5000000000000000, 0.0000000000000000],
387
+ [0.1749127449999960, 0.0000000000000000, 0.5000000000000000],
388
+ [0.6749127449999960, 0.0000000000000000, 0.5000000000000000],
389
+ [0.1749127449999980, 0.5000000000000000, 0.5000000000000000],
390
+ [0.6749127450000000, 0.5000000000000000, 0.5000000000000000],
391
+ ]
392
+ )
393
+
394
+ cell = axis, positions, types
395
+ dataset = spglib.get_symmetry_dataset(cell)
396
+ perms = compute_sg_permutations(
397
+ positions,
398
+ dataset.rotations,
399
+ dataset.translations,
400
+ axis,
401
+ )
402
+ perms_stable = compute_sg_permutations_stable(
403
+ positions,
404
+ dataset.rotations,
405
+ dataset.translations,
406
+ axis,
407
+ )
408
+ np.testing.assert_array_equal(perms, perms_stable)
@@ -1,73 +0,0 @@
1
- """Tests of matrix manipulating functions."""
2
-
3
- from __future__ import annotations
4
-
5
- from pathlib import Path
6
-
7
- import numpy as np
8
- import pytest
9
-
10
- from symfc.spg_reps import SpgRepsBase
11
- from symfc.utils.utils import (
12
- SymfcAtoms,
13
- compute_sg_permutations,
14
- get_indep_atoms_by_lat_trans,
15
- )
16
-
17
- cwd = Path(__file__).parent
18
-
19
-
20
- def test_get_indep_atoms_by_lattice_translation(
21
- ph_nacl_222: tuple[SymfcAtoms, np.ndarray, np.ndarray],
22
- ):
23
- """Test of get_indep_atoms_by_lattice_translation."""
24
- supercell, _, _ = ph_nacl_222
25
- sym_op_reps = SpgRepsBase(supercell)
26
- trans_perms = sym_op_reps.translation_permutations
27
- assert trans_perms.shape == (32, 64)
28
- indep_atoms = get_indep_atoms_by_lat_trans(trans_perms)
29
- np.testing.assert_array_equal(indep_atoms, [0, 32])
30
-
31
-
32
- def test_compute_sg_permutations(
33
- ph_gan_222: tuple[SymfcAtoms, np.ndarray, np.ndarray], cell_gan_111: SymfcAtoms
34
- ):
35
- """Test compute_sg_permutations."""
36
- pytest.importorskip("spglib", minversion="2.5")
37
- from spglib import spglib
38
-
39
- supercell, _, _ = ph_gan_222
40
- primitive = cell_gan_111
41
- dataset = spglib.get_symmetry_dataset(supercell.totuple())
42
- primitive_dataset = spglib.get_symmetry_dataset(primitive.totuple())
43
- perms = compute_sg_permutations(
44
- primitive.scaled_positions,
45
- primitive_dataset.rotations,
46
- primitive_dataset.translations,
47
- primitive.cell,
48
- )
49
- ref_perms = [
50
- [0, 1, 2, 3],
51
- [1, 0, 3, 2],
52
- [0, 1, 2, 3],
53
- [1, 0, 3, 2],
54
- [0, 1, 2, 3],
55
- [1, 0, 3, 2],
56
- [1, 0, 3, 2],
57
- [0, 1, 2, 3],
58
- [1, 0, 3, 2],
59
- [0, 1, 2, 3],
60
- [1, 0, 3, 2],
61
- [0, 1, 2, 3],
62
- ]
63
- np.testing.assert_array_equal(ref_perms, perms)
64
-
65
- perms_super = compute_sg_permutations(
66
- supercell.scaled_positions,
67
- dataset.rotations,
68
- dataset.translations,
69
- supercell.cell,
70
- )
71
- # np.savetxt("perms_super.dat", perms_super, fmt="%d")
72
- perms_super_ref = np.loadtxt(cwd / ".." / "perms_super.dat", dtype=int)
73
- np.testing.assert_array_equal(perms_super_ref, perms_super)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes