symfc 1.2.2__tar.gz → 1.3.1__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.
- {symfc-1.2.2/src/symfc.egg-info → symfc-1.3.1}/PKG-INFO +1 -1
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/api_symfc.py +63 -4
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/basis_sets/__init__.py +1 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/basis_sets/basis_sets_O2.py +18 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/basis_sets/basis_sets_O3.py +18 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/basis_sets/basis_sets_O4.py +18 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/version.py +1 -1
- {symfc-1.2.2 → symfc-1.3.1/src/symfc.egg-info}/PKG-INFO +1 -1
- {symfc-1.2.2 → symfc-1.3.1}/tests/basis_sets/test_basis_sets_O2.py +32 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/basis_sets/test_basis_sets_O3.py +2 -86
- {symfc-1.2.2 → symfc-1.3.1}/tests/conftest.py +96 -3
- {symfc-1.2.2 → symfc-1.3.1}/tests/test_api.py +15 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_matrix_tools_O2.py +22 -0
- {symfc-1.2.2 → symfc-1.3.1}/LICENSE +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/MANIFEST.in +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/README.md +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/pyproject.toml +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/setup.cfg +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/__init__.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/basis_sets/basis_sets_O1.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/basis_sets/basis_sets_base.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/solvers/__init__.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/solvers/solver_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/solvers/solver_O2O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/solvers/solver_O2O3O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/solvers/solver_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/solvers/solver_O3O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/solvers/solver_O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/solvers/solver_base.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/spg_reps/__init__.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/spg_reps/spg_reps_O1.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/spg_reps/spg_reps_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/spg_reps/spg_reps_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/spg_reps/spg_reps_O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/spg_reps/spg_reps_base.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/__init__.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/cutoff_tools.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/eig_tools.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/matrix_tools.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/matrix_tools_O1.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/matrix_tools_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/matrix_tools_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/matrix_tools_O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/permutation_tools.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/permutation_tools_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/permutation_tools_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/permutation_tools_O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/rotation_tools_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/run_rotation_tools_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/run_rotation_tools_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/run_test_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/solver_funcs.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/utils.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/utils_O1.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/utils_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/utils_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc/utils/utils_O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc.egg-info/SOURCES.txt +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc.egg-info/dependency_links.txt +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc.egg-info/requires.txt +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/src/symfc.egg-info/top_level.txt +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/NaCl-unitcell.yaml +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/basis_sets/test_basis_sets_O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/basis_sets/test_basis_sets_base.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_GaN_222.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_GaN_442.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_NaCl_222.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_SiO2_221.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_Si_111_fc3_2.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_Si_111_fc3_3.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_Si_111_fc4_2.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_Si_111_fc4_3.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_Si_111_fc4_4.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/compact_fc_SnO2_223.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/dfset_GaN_222_rd.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/dfset_GaN_442_rd.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/dfset_NaCl_222_rd.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/dfset_SiO2_221_rd.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/dfset_Si_111_fc3_rd.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/dfset_SnO2_223_rd.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_NaCl_222.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_Si_111_fc3_2.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_Si_111_fc3_3.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_Si_111_fc4_2.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_Si_111_fc4_3.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_Si_111_fc4_4.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_Si_111_fc4_step_2.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_Si_111_fc4_step_3.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_Si_111_fc4_step_4.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/full_fc_SnO2_223.xz +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/perms_super.dat +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/phonopy_to_python.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/solvers/test_solver_utils.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/spg_reps/test_spg_reps_O1.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/spg_reps/test_spg_reps_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/spg_reps/test_spg_reps_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/spg_reps/test_spg_reps_O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/spg_reps/test_spg_reps_base.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_cutoff_tools.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_eig_tools.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_matrix_tools_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_matrix_tools_O4.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_solver_funcs.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_utils.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_utils_O1.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_utils_O2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_utils_O2_2.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_utils_O3.py +0 -0
- {symfc-1.2.2 → symfc-1.3.1}/tests/utils/test_utils_O4.py +0 -0
|
@@ -67,6 +67,11 @@ class Symfc:
|
|
|
67
67
|
self._force_constants: dict[np.ndarray] = {}
|
|
68
68
|
self._prepare_cutoff(cutoff)
|
|
69
69
|
|
|
70
|
+
@property
|
|
71
|
+
def supercell(self) -> SymfcAtoms:
|
|
72
|
+
"""Return supercell."""
|
|
73
|
+
return self._supercell
|
|
74
|
+
|
|
70
75
|
@property
|
|
71
76
|
def p2s_map(self) -> Optional[np.ndarray]:
|
|
72
77
|
"""Return indices of translationally independent atoms."""
|
|
@@ -276,12 +281,12 @@ class Symfc:
|
|
|
276
281
|
orders: list
|
|
277
282
|
Orders of force constants.
|
|
278
283
|
"""
|
|
279
|
-
|
|
280
|
-
for order in orders:
|
|
284
|
+
for order in self._check_orders(max_order, orders):
|
|
281
285
|
if order == 2:
|
|
282
286
|
basis_set_o2 = FCBasisSetO2(
|
|
283
287
|
self._supercell,
|
|
284
288
|
spacegroup_operations=self._spacegroup_operations,
|
|
289
|
+
cutoff=self._cutoff[2],
|
|
285
290
|
use_mkl=self._use_mkl,
|
|
286
291
|
log_level=self._log_level,
|
|
287
292
|
).run()
|
|
@@ -306,6 +311,60 @@ class Symfc:
|
|
|
306
311
|
self._basis_set[4] = basis_set_o4
|
|
307
312
|
return self
|
|
308
313
|
|
|
314
|
+
def estimate_basis_size(
|
|
315
|
+
self,
|
|
316
|
+
max_order: Optional[int] = None,
|
|
317
|
+
orders: Optional[list] = None,
|
|
318
|
+
) -> dict:
|
|
319
|
+
"""Estimate the size of basis set.
|
|
320
|
+
|
|
321
|
+
Parameters
|
|
322
|
+
----------
|
|
323
|
+
max_order : int
|
|
324
|
+
Maximum fc order.
|
|
325
|
+
orders: list
|
|
326
|
+
Orders of force constants.
|
|
327
|
+
|
|
328
|
+
Returns
|
|
329
|
+
-------
|
|
330
|
+
dict :
|
|
331
|
+
Estimates of basis set sizes for each order. The key of dict is the
|
|
332
|
+
order.
|
|
333
|
+
"""
|
|
334
|
+
basis_size_estimates = {}
|
|
335
|
+
for order in self._check_orders(max_order, orders):
|
|
336
|
+
if order < 2 or order > 4:
|
|
337
|
+
raise NotImplementedError(
|
|
338
|
+
"Only fc2, fc3 and fc4 basis sets are implemented."
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
if order == 2:
|
|
342
|
+
basis_size_estimates[order] = FCBasisSetO2(
|
|
343
|
+
self._supercell,
|
|
344
|
+
spacegroup_operations=self._spacegroup_operations,
|
|
345
|
+
cutoff=self._cutoff[2],
|
|
346
|
+
use_mkl=self._use_mkl,
|
|
347
|
+
log_level=self._log_level,
|
|
348
|
+
).estimate_basis_size()
|
|
349
|
+
elif order == 3:
|
|
350
|
+
basis_size_estimates[order] = FCBasisSetO3(
|
|
351
|
+
self._supercell,
|
|
352
|
+
spacegroup_operations=self._spacegroup_operations,
|
|
353
|
+
cutoff=self._cutoff[3],
|
|
354
|
+
use_mkl=self._use_mkl,
|
|
355
|
+
log_level=self._log_level,
|
|
356
|
+
).estimate_basis_size()
|
|
357
|
+
elif order == 4:
|
|
358
|
+
basis_size_estimates[order] = FCBasisSetO4(
|
|
359
|
+
self._supercell,
|
|
360
|
+
spacegroup_operations=self._spacegroup_operations,
|
|
361
|
+
cutoff=self._cutoff[4],
|
|
362
|
+
use_mkl=self._use_mkl,
|
|
363
|
+
log_level=self._log_level,
|
|
364
|
+
).estimate_basis_size()
|
|
365
|
+
|
|
366
|
+
return basis_size_estimates
|
|
367
|
+
|
|
309
368
|
def _check_orders(self, max_order: int, orders: list) -> tuple:
|
|
310
369
|
if max_order is None and orders is None:
|
|
311
370
|
raise RuntimeError("Maximum order and orders not found.")
|
|
@@ -352,9 +411,9 @@ class Symfc:
|
|
|
352
411
|
|
|
353
412
|
def _prepare_cutoff(self, cutoff):
|
|
354
413
|
if cutoff is None:
|
|
355
|
-
self._cutoff = {3: None, 4: None}
|
|
414
|
+
self._cutoff = {2: None, 3: None, 4: None}
|
|
356
415
|
else:
|
|
357
416
|
self._cutoff = cutoff
|
|
358
|
-
for order in (3, 4):
|
|
417
|
+
for order in (2, 3, 4):
|
|
359
418
|
if order not in self._cutoff:
|
|
360
419
|
self._cutoff[order] = None
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Symmetry adapted basis sets of force constants."""
|
|
2
2
|
|
|
3
3
|
from .basis_sets_base import FCBasisSetBase # noqa 401
|
|
4
|
+
from .basis_sets_O1 import FCBasisSetO1 # noqa 401
|
|
4
5
|
from .basis_sets_O2 import FCBasisSetO2 # noqa 401
|
|
5
6
|
from .basis_sets_O3 import FCBasisSetO3 # noqa 401
|
|
6
7
|
from .basis_sets_O4 import FCBasisSetO4 # noqa 401
|
|
@@ -186,3 +186,21 @@ class FCBasisSetO2(FCBasisSetBase):
|
|
|
186
186
|
self._n_a_compression_matrix = n_a_compress_mat
|
|
187
187
|
|
|
188
188
|
return self
|
|
189
|
+
|
|
190
|
+
def estimate_basis_size(self) -> int:
|
|
191
|
+
"""Estimate basis set size."""
|
|
192
|
+
if self._fc_cutoff is None:
|
|
193
|
+
n_sym, N = self._spg_reps._permutations.shape
|
|
194
|
+
basis_size_estimates = 9 * (N**2) / n_sym / 2
|
|
195
|
+
return int(np.round(basis_size_estimates).astype(int))
|
|
196
|
+
|
|
197
|
+
trans_perms = self._spg_reps.translation_permutations
|
|
198
|
+
c_pt = compr_permutation_lat_trans_O2(
|
|
199
|
+
trans_perms,
|
|
200
|
+
atomic_decompr_idx=self._atomic_decompr_idx,
|
|
201
|
+
fc_cutoff=self._fc_cutoff,
|
|
202
|
+
verbose=False,
|
|
203
|
+
)
|
|
204
|
+
n_sym_prim = len(self._spg_reps._unique_rotations)
|
|
205
|
+
basis_size_estimates = c_pt.shape[1] / n_sym_prim
|
|
206
|
+
return int(np.round(basis_size_estimates).astype(int))
|
|
@@ -250,3 +250,21 @@ class FCBasisSetO3(FCBasisSetBase):
|
|
|
250
250
|
self._n_a_compression_matrix = n_a_compress_mat
|
|
251
251
|
|
|
252
252
|
return self
|
|
253
|
+
|
|
254
|
+
def estimate_basis_size(self) -> int:
|
|
255
|
+
"""Estimate basis set size."""
|
|
256
|
+
if self._fc_cutoff is None:
|
|
257
|
+
n_sym, N = self._spg_reps._permutations.shape
|
|
258
|
+
basis_size_estimates = 27 * (N**3) / n_sym / 6
|
|
259
|
+
return int(np.round(basis_size_estimates).astype(int))
|
|
260
|
+
|
|
261
|
+
trans_perms = self._spg_reps.translation_permutations
|
|
262
|
+
c_pt = compr_permutation_lat_trans_O3(
|
|
263
|
+
trans_perms,
|
|
264
|
+
atomic_decompr_idx=self._atomic_decompr_idx,
|
|
265
|
+
fc_cutoff=self._fc_cutoff,
|
|
266
|
+
verbose=False,
|
|
267
|
+
)
|
|
268
|
+
n_sym_prim = len(self._spg_reps._unique_rotations)
|
|
269
|
+
basis_size_estimates = c_pt.shape[1] / n_sym_prim
|
|
270
|
+
return int(np.round(basis_size_estimates).astype(int))
|
|
@@ -245,3 +245,21 @@ class FCBasisSetO4(FCBasisSetBase):
|
|
|
245
245
|
self._n_a_compression_matrix = n_a_compress_mat
|
|
246
246
|
|
|
247
247
|
return self
|
|
248
|
+
|
|
249
|
+
def estimate_basis_size(self) -> int:
|
|
250
|
+
"""Estimate basis set size."""
|
|
251
|
+
if self._fc_cutoff is None:
|
|
252
|
+
n_sym, N = self._spg_reps._permutations.shape
|
|
253
|
+
basis_size_estimates = 81 * (N**4) / n_sym / 24
|
|
254
|
+
return int(np.round(basis_size_estimates).astype(int))
|
|
255
|
+
|
|
256
|
+
trans_perms = self._spg_reps.translation_permutations
|
|
257
|
+
c_pt = compr_permutation_lat_trans_O4(
|
|
258
|
+
trans_perms,
|
|
259
|
+
atomic_decompr_idx=self._atomic_decompr_idx,
|
|
260
|
+
fc_cutoff=self._fc_cutoff,
|
|
261
|
+
verbose=False,
|
|
262
|
+
)
|
|
263
|
+
n_sym_prim = len(self._spg_reps._unique_rotations)
|
|
264
|
+
basis_size_estimates = c_pt.shape[1] / n_sym_prim
|
|
265
|
+
return int(np.round(basis_size_estimates).astype(int))
|
|
@@ -45,6 +45,38 @@ def test_fc_basis_set_o2():
|
|
|
45
45
|
assert np.linalg.norm(sbs.basis_set) == pytest.approx(1.0)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
def test_fc_basis_set_o2_nacl222(cell_nacl_222: SymfcAtoms):
|
|
49
|
+
"""Test symmetry adapted basis sets of FCBasisSetO2 by nacl222."""
|
|
50
|
+
sbs = FCBasisSetO2(cell_nacl_222, log_level=1).run()
|
|
51
|
+
|
|
52
|
+
assert sbs.basis_set.shape[0] == 33
|
|
53
|
+
assert sbs.basis_set.shape[1] == 31
|
|
54
|
+
compact_basis = sbs.compact_compression_matrix @ sbs.basis_set
|
|
55
|
+
assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(0.96875)
|
|
56
|
+
|
|
57
|
+
sbs = FCBasisSetO2(cell_nacl_222, cutoff=5.0, log_level=1).run()
|
|
58
|
+
assert sbs.basis_set.shape[0] == 12
|
|
59
|
+
assert sbs.basis_set.shape[1] == 10
|
|
60
|
+
compact_basis = sbs.compact_compression_matrix @ sbs.basis_set
|
|
61
|
+
assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(0.3125)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_fc_basis_set_o2_wurtzite332(cell_wurtzite_332: SymfcAtoms):
|
|
65
|
+
"""Test symmetry adapted basis sets of FCBasisSetO2 by wurtzite332."""
|
|
66
|
+
sbs = FCBasisSetO2(cell_wurtzite_332, log_level=1).run()
|
|
67
|
+
|
|
68
|
+
assert sbs.basis_set.shape[0] == 130
|
|
69
|
+
assert sbs.basis_set.shape[1] == 126
|
|
70
|
+
compact_basis = sbs.compact_compression_matrix @ sbs.basis_set
|
|
71
|
+
assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(7)
|
|
72
|
+
|
|
73
|
+
sbs = FCBasisSetO2(cell_wurtzite_332, cutoff=5.0, log_level=1).run()
|
|
74
|
+
assert sbs.basis_set.shape[0] == 49
|
|
75
|
+
assert sbs.basis_set.shape[1] == 45
|
|
76
|
+
compact_basis = sbs.compact_compression_matrix @ sbs.basis_set
|
|
77
|
+
assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(2.5)
|
|
78
|
+
|
|
79
|
+
|
|
48
80
|
@pytest.mark.parametrize("is_compact_fc", [True, False])
|
|
49
81
|
def test_fc2_NaCl_222(
|
|
50
82
|
ph_nacl_222: tuple[SymfcAtoms, np.ndarray, np.ndarray], is_compact_fc: bool
|
|
@@ -177,93 +177,9 @@ def test_fc_basis_set_o3_diamond():
|
|
|
177
177
|
assert np.linalg.norm(compact_basis) ** 2 == pytest.approx(0.75)
|
|
178
178
|
|
|
179
179
|
|
|
180
|
-
def test_fc_basis_set_o3_wurtzite_332():
|
|
180
|
+
def test_fc_basis_set_o3_wurtzite_332(cell_wurtzite_332: SymfcAtoms):
|
|
181
181
|
"""Test symmetry adapted basis sets of FCBasisSetO3."""
|
|
182
|
-
|
|
183
|
-
[
|
|
184
|
-
[11.35855848088148, 0.0, 0.0],
|
|
185
|
-
[-5.679279240440739, 9.836800194814545, 0.0],
|
|
186
|
-
[0.0, 0.0, 12.425356538818003],
|
|
187
|
-
]
|
|
188
|
-
)
|
|
189
|
-
positions = np.array(
|
|
190
|
-
[
|
|
191
|
-
[0.111111111111111, 0.222222222222222, 0.001063232855807],
|
|
192
|
-
[0.444444444444444, 0.222222222222222, 0.001063232855807],
|
|
193
|
-
[0.777777777777778, 0.222222222222222, 0.001063232855807],
|
|
194
|
-
[0.111111111111111, 0.555555555555556, 0.001063232855807],
|
|
195
|
-
[0.444444444444444, 0.555555555555556, 0.001063232855807],
|
|
196
|
-
[0.777777777777778, 0.555555555555556, 0.001063232855807],
|
|
197
|
-
[0.111111111111111, 0.888888888888889, 0.001063232855807],
|
|
198
|
-
[0.444444444444444, 0.888888888888889, 0.001063232855807],
|
|
199
|
-
[0.777777777777778, 0.888888888888889, 0.001063232855807],
|
|
200
|
-
[0.111111111111111, 0.222222222222222, 0.501063232855807],
|
|
201
|
-
[0.444444444444444, 0.222222222222222, 0.501063232855807],
|
|
202
|
-
[0.777777777777778, 0.222222222222222, 0.501063232855807],
|
|
203
|
-
[0.111111111111111, 0.555555555555556, 0.501063232855807],
|
|
204
|
-
[0.444444444444444, 0.555555555555556, 0.501063232855807],
|
|
205
|
-
[0.777777777777778, 0.555555555555556, 0.501063232855807],
|
|
206
|
-
[0.111111111111111, 0.888888888888889, 0.501063232855807],
|
|
207
|
-
[0.444444444444444, 0.888888888888889, 0.501063232855807],
|
|
208
|
-
[0.777777777777778, 0.888888888888889, 0.501063232855807],
|
|
209
|
-
[0.222222222222222, 0.111111111111111, 0.251063232855807],
|
|
210
|
-
[0.555555555555556, 0.111111111111111, 0.251063232855807],
|
|
211
|
-
[0.888888888888889, 0.111111111111111, 0.251063232855807],
|
|
212
|
-
[0.222222222222222, 0.444444444444444, 0.251063232855807],
|
|
213
|
-
[0.555555555555556, 0.444444444444444, 0.251063232855807],
|
|
214
|
-
[0.888888888888889, 0.444444444444444, 0.251063232855807],
|
|
215
|
-
[0.222222222222222, 0.777777777777778, 0.251063232855807],
|
|
216
|
-
[0.555555555555556, 0.777777777777778, 0.251063232855807],
|
|
217
|
-
[0.888888888888889, 0.777777777777778, 0.251063232855807],
|
|
218
|
-
[0.222222222222222, 0.111111111111111, 0.751063232855807],
|
|
219
|
-
[0.555555555555556, 0.111111111111111, 0.751063232855807],
|
|
220
|
-
[0.888888888888889, 0.111111111111111, 0.751063232855807],
|
|
221
|
-
[0.222222222222222, 0.444444444444444, 0.751063232855807],
|
|
222
|
-
[0.555555555555556, 0.444444444444444, 0.751063232855807],
|
|
223
|
-
[0.888888888888889, 0.444444444444444, 0.751063232855807],
|
|
224
|
-
[0.222222222222222, 0.777777777777778, 0.751063232855807],
|
|
225
|
-
[0.555555555555556, 0.777777777777778, 0.751063232855807],
|
|
226
|
-
[0.888888888888889, 0.777777777777778, 0.751063232855807],
|
|
227
|
-
[0.111111111111111, 0.222222222222222, 0.188158257144195],
|
|
228
|
-
[0.444444444444444, 0.222222222222222, 0.188158257144195],
|
|
229
|
-
[0.777777777777778, 0.222222222222222, 0.188158257144195],
|
|
230
|
-
[0.111111111111111, 0.555555555555556, 0.188158257144195],
|
|
231
|
-
[0.444444444444444, 0.555555555555556, 0.188158257144195],
|
|
232
|
-
[0.777777777777778, 0.555555555555556, 0.188158257144195],
|
|
233
|
-
[0.111111111111111, 0.888888888888889, 0.188158257144195],
|
|
234
|
-
[0.444444444444444, 0.888888888888889, 0.188158257144195],
|
|
235
|
-
[0.777777777777778, 0.888888888888889, 0.188158257144195],
|
|
236
|
-
[0.111111111111111, 0.222222222222222, 0.688158257144195],
|
|
237
|
-
[0.444444444444444, 0.222222222222222, 0.688158257144195],
|
|
238
|
-
[0.777777777777778, 0.222222222222222, 0.688158257144195],
|
|
239
|
-
[0.111111111111111, 0.555555555555556, 0.688158257144195],
|
|
240
|
-
[0.444444444444444, 0.555555555555556, 0.688158257144195],
|
|
241
|
-
[0.777777777777778, 0.555555555555556, 0.688158257144195],
|
|
242
|
-
[0.111111111111111, 0.888888888888889, 0.688158257144195],
|
|
243
|
-
[0.444444444444444, 0.888888888888889, 0.688158257144195],
|
|
244
|
-
[0.777777777777778, 0.888888888888889, 0.688158257144195],
|
|
245
|
-
[0.222222222222222, 0.111111111111111, 0.438158257144194],
|
|
246
|
-
[0.555555555555556, 0.111111111111111, 0.438158257144194],
|
|
247
|
-
[0.888888888888889, 0.111111111111111, 0.438158257144194],
|
|
248
|
-
[0.222222222222222, 0.444444444444444, 0.438158257144194],
|
|
249
|
-
[0.555555555555556, 0.444444444444444, 0.438158257144194],
|
|
250
|
-
[0.888888888888889, 0.444444444444444, 0.438158257144194],
|
|
251
|
-
[0.222222222222222, 0.777777777777778, 0.438158257144194],
|
|
252
|
-
[0.555555555555556, 0.777777777777778, 0.438158257144194],
|
|
253
|
-
[0.888888888888889, 0.777777777777778, 0.438158257144194],
|
|
254
|
-
[0.222222222222222, 0.111111111111111, 0.938158257144194],
|
|
255
|
-
[0.555555555555556, 0.111111111111111, 0.938158257144194],
|
|
256
|
-
[0.888888888888889, 0.111111111111111, 0.938158257144194],
|
|
257
|
-
[0.222222222222222, 0.444444444444444, 0.938158257144194],
|
|
258
|
-
[0.555555555555556, 0.444444444444444, 0.938158257144194],
|
|
259
|
-
[0.888888888888889, 0.444444444444444, 0.938158257144194],
|
|
260
|
-
[0.222222222222222, 0.777777777777778, 0.938158257144194],
|
|
261
|
-
[0.555555555555556, 0.777777777777778, 0.938158257144194],
|
|
262
|
-
[0.888888888888889, 0.777777777777778, 0.938158257144194],
|
|
263
|
-
]
|
|
264
|
-
)
|
|
265
|
-
numbers = [1 for i in range(36)] + [2 for i in range(36)]
|
|
266
|
-
supercell = SymfcAtoms(cell=lattice, scaled_positions=positions, numbers=numbers)
|
|
182
|
+
supercell = cell_wurtzite_332
|
|
267
183
|
|
|
268
184
|
"""
|
|
269
185
|
sbs = FCBasisSetO3(supercell, cutoff=6.0, log_level=1).run()
|
|
@@ -78,8 +78,95 @@ def cell_gan_111() -> SymfcAtoms:
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
@pytest.fixture(scope="session")
|
|
81
|
-
def
|
|
82
|
-
"""Return
|
|
81
|
+
def cell_wurtzite_332() -> SymfcAtoms:
|
|
82
|
+
"""Return 3x3x2 supercell of wurtzite."""
|
|
83
|
+
lattice = [
|
|
84
|
+
[11.35855848088148, 0.0, 0.0],
|
|
85
|
+
[-5.679279240440739, 9.836800194814545, 0.0],
|
|
86
|
+
[0.0, 0.0, 12.425356538818003],
|
|
87
|
+
]
|
|
88
|
+
positions = [
|
|
89
|
+
[0.111111111111111, 0.222222222222222, 0.001063232855807],
|
|
90
|
+
[0.444444444444444, 0.222222222222222, 0.001063232855807],
|
|
91
|
+
[0.777777777777778, 0.222222222222222, 0.001063232855807],
|
|
92
|
+
[0.111111111111111, 0.555555555555556, 0.001063232855807],
|
|
93
|
+
[0.444444444444444, 0.555555555555556, 0.001063232855807],
|
|
94
|
+
[0.777777777777778, 0.555555555555556, 0.001063232855807],
|
|
95
|
+
[0.111111111111111, 0.888888888888889, 0.001063232855807],
|
|
96
|
+
[0.444444444444444, 0.888888888888889, 0.001063232855807],
|
|
97
|
+
[0.777777777777778, 0.888888888888889, 0.001063232855807],
|
|
98
|
+
[0.111111111111111, 0.222222222222222, 0.501063232855807],
|
|
99
|
+
[0.444444444444444, 0.222222222222222, 0.501063232855807],
|
|
100
|
+
[0.777777777777778, 0.222222222222222, 0.501063232855807],
|
|
101
|
+
[0.111111111111111, 0.555555555555556, 0.501063232855807],
|
|
102
|
+
[0.444444444444444, 0.555555555555556, 0.501063232855807],
|
|
103
|
+
[0.777777777777778, 0.555555555555556, 0.501063232855807],
|
|
104
|
+
[0.111111111111111, 0.888888888888889, 0.501063232855807],
|
|
105
|
+
[0.444444444444444, 0.888888888888889, 0.501063232855807],
|
|
106
|
+
[0.777777777777778, 0.888888888888889, 0.501063232855807],
|
|
107
|
+
[0.222222222222222, 0.111111111111111, 0.251063232855807],
|
|
108
|
+
[0.555555555555556, 0.111111111111111, 0.251063232855807],
|
|
109
|
+
[0.888888888888889, 0.111111111111111, 0.251063232855807],
|
|
110
|
+
[0.222222222222222, 0.444444444444444, 0.251063232855807],
|
|
111
|
+
[0.555555555555556, 0.444444444444444, 0.251063232855807],
|
|
112
|
+
[0.888888888888889, 0.444444444444444, 0.251063232855807],
|
|
113
|
+
[0.222222222222222, 0.777777777777778, 0.251063232855807],
|
|
114
|
+
[0.555555555555556, 0.777777777777778, 0.251063232855807],
|
|
115
|
+
[0.888888888888889, 0.777777777777778, 0.251063232855807],
|
|
116
|
+
[0.222222222222222, 0.111111111111111, 0.751063232855807],
|
|
117
|
+
[0.555555555555556, 0.111111111111111, 0.751063232855807],
|
|
118
|
+
[0.888888888888889, 0.111111111111111, 0.751063232855807],
|
|
119
|
+
[0.222222222222222, 0.444444444444444, 0.751063232855807],
|
|
120
|
+
[0.555555555555556, 0.444444444444444, 0.751063232855807],
|
|
121
|
+
[0.888888888888889, 0.444444444444444, 0.751063232855807],
|
|
122
|
+
[0.222222222222222, 0.777777777777778, 0.751063232855807],
|
|
123
|
+
[0.555555555555556, 0.777777777777778, 0.751063232855807],
|
|
124
|
+
[0.888888888888889, 0.777777777777778, 0.751063232855807],
|
|
125
|
+
[0.111111111111111, 0.222222222222222, 0.188158257144195],
|
|
126
|
+
[0.444444444444444, 0.222222222222222, 0.188158257144195],
|
|
127
|
+
[0.777777777777778, 0.222222222222222, 0.188158257144195],
|
|
128
|
+
[0.111111111111111, 0.555555555555556, 0.188158257144195],
|
|
129
|
+
[0.444444444444444, 0.555555555555556, 0.188158257144195],
|
|
130
|
+
[0.777777777777778, 0.555555555555556, 0.188158257144195],
|
|
131
|
+
[0.111111111111111, 0.888888888888889, 0.188158257144195],
|
|
132
|
+
[0.444444444444444, 0.888888888888889, 0.188158257144195],
|
|
133
|
+
[0.777777777777778, 0.888888888888889, 0.188158257144195],
|
|
134
|
+
[0.111111111111111, 0.222222222222222, 0.688158257144195],
|
|
135
|
+
[0.444444444444444, 0.222222222222222, 0.688158257144195],
|
|
136
|
+
[0.777777777777778, 0.222222222222222, 0.688158257144195],
|
|
137
|
+
[0.111111111111111, 0.555555555555556, 0.688158257144195],
|
|
138
|
+
[0.444444444444444, 0.555555555555556, 0.688158257144195],
|
|
139
|
+
[0.777777777777778, 0.555555555555556, 0.688158257144195],
|
|
140
|
+
[0.111111111111111, 0.888888888888889, 0.688158257144195],
|
|
141
|
+
[0.444444444444444, 0.888888888888889, 0.688158257144195],
|
|
142
|
+
[0.777777777777778, 0.888888888888889, 0.688158257144195],
|
|
143
|
+
[0.222222222222222, 0.111111111111111, 0.438158257144194],
|
|
144
|
+
[0.555555555555556, 0.111111111111111, 0.438158257144194],
|
|
145
|
+
[0.888888888888889, 0.111111111111111, 0.438158257144194],
|
|
146
|
+
[0.222222222222222, 0.444444444444444, 0.438158257144194],
|
|
147
|
+
[0.555555555555556, 0.444444444444444, 0.438158257144194],
|
|
148
|
+
[0.888888888888889, 0.444444444444444, 0.438158257144194],
|
|
149
|
+
[0.222222222222222, 0.777777777777778, 0.438158257144194],
|
|
150
|
+
[0.555555555555556, 0.777777777777778, 0.438158257144194],
|
|
151
|
+
[0.888888888888889, 0.777777777777778, 0.438158257144194],
|
|
152
|
+
[0.222222222222222, 0.111111111111111, 0.938158257144194],
|
|
153
|
+
[0.555555555555556, 0.111111111111111, 0.938158257144194],
|
|
154
|
+
[0.888888888888889, 0.111111111111111, 0.938158257144194],
|
|
155
|
+
[0.222222222222222, 0.444444444444444, 0.938158257144194],
|
|
156
|
+
[0.555555555555556, 0.444444444444444, 0.938158257144194],
|
|
157
|
+
[0.888888888888889, 0.444444444444444, 0.938158257144194],
|
|
158
|
+
[0.222222222222222, 0.777777777777778, 0.938158257144194],
|
|
159
|
+
[0.555555555555556, 0.777777777777778, 0.938158257144194],
|
|
160
|
+
[0.888888888888889, 0.777777777777778, 0.938158257144194],
|
|
161
|
+
]
|
|
162
|
+
numbers = [1 for i in range(36)] + [2 for i in range(36)]
|
|
163
|
+
supercell = SymfcAtoms(cell=lattice, scaled_positions=positions, numbers=numbers)
|
|
164
|
+
return supercell
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@pytest.fixture(scope="session")
|
|
168
|
+
def cell_nacl_222() -> SymfcAtoms:
|
|
169
|
+
"""Return 2x2x2 supercell of NaCl."""
|
|
83
170
|
lattice = [
|
|
84
171
|
[11.281120000000000, 0.000000000000000, 0.000000000000000],
|
|
85
172
|
[0.000000000000000, 11.281120000000000, 0.000000000000000],
|
|
@@ -218,11 +305,17 @@ def ph_nacl_222() -> tuple[SymfcAtoms, np.ndarray, np.ndarray]:
|
|
|
218
305
|
17,
|
|
219
306
|
]
|
|
220
307
|
cell = SymfcAtoms(cell=lattice, scaled_positions=points, numbers=numbers)
|
|
308
|
+
return cell
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
@pytest.fixture(scope="session")
|
|
312
|
+
def ph_nacl_222(cell_nacl_222) -> tuple[SymfcAtoms, np.ndarray, np.ndarray]:
|
|
313
|
+
"""Return NaCl-222 data."""
|
|
221
314
|
N = 20
|
|
222
315
|
dfset = np.loadtxt(cwd / "dfset_NaCl_222_rd.xz")
|
|
223
316
|
d = dfset[:, :3].reshape(N, -1, 3)
|
|
224
317
|
f = dfset[:, 3:].reshape(N, -1, 3)
|
|
225
|
-
return
|
|
318
|
+
return cell_nacl_222, d, f
|
|
226
319
|
|
|
227
320
|
|
|
228
321
|
@pytest.fixture(scope="session")
|
|
@@ -166,3 +166,18 @@ def test_api_si_111_fc4_step(
|
|
|
166
166
|
np.testing.assert_allclose(fc2_ref, fc2, atol=1e-6)
|
|
167
167
|
np.testing.assert_allclose(fc3_ref, fc3, atol=1e-6)
|
|
168
168
|
np.testing.assert_allclose(fc4_ref, fc4, atol=1e-6)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def test_api_estimate_basis_size_NaCl_222(
|
|
172
|
+
cell_nacl_222: SymfcAtoms,
|
|
173
|
+
):
|
|
174
|
+
"""Test Symfc class."""
|
|
175
|
+
symfc = Symfc(cell_nacl_222)
|
|
176
|
+
ref_estimates = {
|
|
177
|
+
2: 12,
|
|
178
|
+
3: 768,
|
|
179
|
+
4: 36864,
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
assert symfc.estimate_basis_size(orders=[2, 3, 4]) == ref_estimates
|
|
183
|
+
assert symfc.estimate_basis_size(max_order=4) == ref_estimates
|
|
@@ -5,6 +5,7 @@ import pytest
|
|
|
5
5
|
import scipy
|
|
6
6
|
|
|
7
7
|
from symfc.spg_reps import SpgRepsBase
|
|
8
|
+
from symfc.utils.cutoff_tools import FCCutoff
|
|
8
9
|
from symfc.utils.matrix_tools_O2 import (
|
|
9
10
|
N3N3_to_NNand33,
|
|
10
11
|
compressed_projector_sum_rules_O2,
|
|
@@ -59,6 +60,17 @@ def test_projector_permutation_lat_trans_O2():
|
|
|
59
60
|
proj_ref[(row, col)] = 0.5
|
|
60
61
|
np.testing.assert_allclose(proj.toarray(), proj_ref)
|
|
61
62
|
|
|
63
|
+
proj = projector_permutation_lat_trans_O2(
|
|
64
|
+
trans_perms,
|
|
65
|
+
atomic_decompr_idx,
|
|
66
|
+
fc_cutoff=FCCutoff(supercell, cutoff=1),
|
|
67
|
+
)
|
|
68
|
+
proj_ref_cutoff = np.zeros_like(proj_ref)
|
|
69
|
+
proj_ref_cutoff[0:9, 0:9] = proj_ref[0:9, 0:9]
|
|
70
|
+
assert proj.trace() == pytest.approx(6.0)
|
|
71
|
+
assert proj.shape == (18, 18)
|
|
72
|
+
np.testing.assert_allclose(proj.toarray(), proj_ref_cutoff)
|
|
73
|
+
|
|
62
74
|
|
|
63
75
|
def test_compressed_projector_sum_rules_O2():
|
|
64
76
|
"""Test compressed_projector_sum_rules_O2."""
|
|
@@ -73,3 +85,13 @@ def test_compressed_projector_sum_rules_O2():
|
|
|
73
85
|
eigvals, _ = np.linalg.eigh(proj.toarray())
|
|
74
86
|
assert proj.shape == (18, 18)
|
|
75
87
|
assert np.count_nonzero(np.isclose(eigvals, 1.0)) == 9
|
|
88
|
+
|
|
89
|
+
proj = compressed_projector_sum_rules_O2(
|
|
90
|
+
trans_perms,
|
|
91
|
+
n_a_compress_mat,
|
|
92
|
+
atomic_decompr_idx,
|
|
93
|
+
fc_cutoff=FCCutoff(supercell, cutoff=1),
|
|
94
|
+
)
|
|
95
|
+
"""If the cutoff implementation is changed, the trace value may also change."""
|
|
96
|
+
assert proj.trace() == pytest.approx(15.75)
|
|
97
|
+
assert len(proj.data) == 18
|
|
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
|
|
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
|
|
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
|
|
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
|