-
Notifications
You must be signed in to change notification settings - Fork 1
Recreate structure fresh during get_primitive_cell #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
44ab862
f3bb4b1
ed840c8
d663bbd
8bcd71f
15726ec
2451152
c0d2d36
012dadd
092cd63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import ast | ||
| import dataclasses | ||
| import string | ||
| import warnings | ||
|
|
||
| import numpy as np | ||
| import spglib | ||
|
|
@@ -400,26 +401,40 @@ def get_primitive_cell( | |
| >>> symmetry = Symmetry(structure) | ||
| >>> len(symmetry.get_primitive_cell()) == len(basis) | ||
| True | ||
|
|
||
| .. warning:: | ||
| Custom arrays defined in the base structures | ||
| :attr:`ase.atoms.Atoms.arrays` and other state (.info, .calc, etc.) are not copied to the new structure! | ||
| """ | ||
| if not all(self._structure.pbc): | ||
| raise ValueError("Can only symmetrize periodic structures.") | ||
| ret = spglib.standardize_cell( | ||
| self._get_spglib_cell(use_elements=use_elements, use_magmoms=use_magmoms), | ||
| to_primitive=not standardize, | ||
| ) | ||
| if ret is None: | ||
| raise SymmetryError(spglib.error.get_error_message()) | ||
| cell, positions, indices = ret | ||
| positions = (cell.T @ positions.T).T | ||
| new_structure = self._structure.copy() | ||
| new_structure.cell = cell | ||
| new_structure = new_structure[: len(indices)] | ||
| cell, scaled_positions, indices = ret | ||
| indices_dict = { | ||
| v: k | ||
| for k, v in structuretoolkit.common.helper.get_species_indices_dict( | ||
| structure=self._structure | ||
| ).items() | ||
| } | ||
| new_structure.symbols = [indices_dict[i] for i in indices] | ||
| new_structure.positions = positions | ||
| symbols = [indices_dict[i] for i in indices] | ||
| new_structure = type(self._structure)( | ||
| symbols=symbols, | ||
| scaled_positions=scaled_positions, | ||
| cell=cell, | ||
| pbc=[True, True, True], | ||
| ) | ||
|
Comment on lines
+405
to
+430
|
||
| keys = set(self._structure.arrays) - {"numbers", "positions"} | ||
| if len(keys) > 0: | ||
| warnings.warn( | ||
| f"Custom arrays {keys} do not carry over to new structure!", | ||
| stacklevel=2, | ||
| ) | ||
|
|
||
| return new_structure | ||
|
|
||
| def get_ir_reciprocal_mesh( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.