-
Notifications
You must be signed in to change notification settings - Fork 873
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
only return unique point group operations #2942
Conversation
If the space group has translations, the function should not return duplicate point group operations. rot.tobytes() seems to be the fastest hashable option for the set.
Thanks @mueslo. For future reference, could you add a failing example as JSON or CIF to the PR description using <details><summary>example</summary>
<p>
hi there!
</p>
</details> |
@janosh I added some details and a minimal working example. Could you please trigger the tests? I also note that by default |
@mueslo Very sorry for the long delay! I somehow wasn't pinged about this (or missed it). Thanks for the additional details. Tests running now.
I'll defer to @shyuep on this decision who will be better informed to gauge the downstream implications. Incidentally, he just bumped |
@mueslo If this is ready to go, best remove "WIP" from PR title as that makes it more likely to receive attention. |
@mueslo The linter will be fixed if you pull in |
rename test_get_symmetry_operations() to test_get_point_group_operations()
I'll merge this for now. Feel free to open a new PR for |
Summary
SpacegroupAnalyzer.get_point_group_operations
Retains original ordering, i.e. identity operation E always stays first.
Background:
get_point_group_operations
ultimately usesspglib.get_symmetry
. However, this only returns unique tuples of (rotation, translation, time_reversal), as ofspglib v2.0.2
. So if you have n translations and m time reversals you will get your rotation symmop n*m times.This is very annoying when e.g. filling the Brillouin zone with potentially tens of thousands of k-points from the irreducible wedge, and then getting hundreds of thousands of unnecessary duplicate k-points thanks to non-unique symmetry operations
Since
SpacegroupAnalyzer._get_symmetry
only uses and returns (rotation, translation), it should actually also be made unique, however sinceis_magnetic=True
inspglib
is supposedly being deprecated, this should solve itself.Example
Input:
Output before fix
Output after fix
Speed
I found rot.tobytes() seems to be the fastest hashable option for the set. Overall, also thanks to the removed 3x3 matrix inversion and lookup instead, and the skipped SymmOp __init__s, the new function is >10% faster for both low and high counts of symmetry operations.Time taken drops further to ~5ms if not going via
self._get_symmetry()
which has unnecessary translation vector logic, but directly callingspglib.get_symmetry()
, at the cost of duplicate code. So I did not include it in this PR.Checklist
Work-in-progress pull requests are encouraged, but please put [WIP] in the pull request title.
Before a pull request can be merged, the following items must be checked: