Skip to content

Fully implemented spin-block rotation #930

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

Merged
merged 3 commits into from
Jun 8, 2025
Merged

Fully implemented spin-block rotation #930

merged 3 commits into from
Jun 8, 2025

Conversation

zerothi
Copy link
Owner

@zerothi zerothi commented Jun 8, 2025

Fixes #924.

The problem was that the rotation should be performed using the Lie group SU(2) rotation matrix.

This merge does a lot of things:

  1. extends Quaternion to return norm2, rotation_matrix rotation_matrix_su2, rotation_vector.

  2. A bug in reduction calls for sparse matrices that are complex. It had used the wrong data-type.

  3. Generalized rotation arguments to allow more, and simpler rotations. Now the rotations can be any of:

    • 3 floats: angles for each Cartesian direction
    • (float, str): angle + direction
    • (float, 3 floats): angle + vector of rotation
    • Quaternion

    Or any sequence of the above. In this, latter case,
    they will be combined into a single Quaternion.

  4. General clean-ups in the spin-align method.

  5. Added checks to ensure Hermitian matrix after rotation.

The code is relatively simple, and allows for much improved handling.

Fixes #924.

The problem was that the rotation should be performed
using the Lie group SU(2) rotation matrix.

This merge does a lot of things:

1. extends Quaternion to return norm2, rotation_matrix
    rotation_matrix_su2, rotation_vector.
2. A bug in reduction calls for sparse matrices that are
    complex. It had used the wrong data-type.
3. Generalized rotation arguments to allow more, and simpler
    rotations. Now the rotations can be any of:

    - 3 floats: angles for each Cartesian direction
    - (float, str): angle + direction
    - (float, 3 floats): angle + vector of rotation
    - Quaternion

    Or any sequence of the above. In this, latter case,
    they will be combined into a single Quaternion.

4. General clean-ups in the spin-align method.
5. Added checks to ensure Hermitian matrix after rotation.

The code is relatively simple, and allows for much improved
handling.

Signed-off-by: Nick Papior <[email protected]>
Copy link

codecov bot commented Jun 8, 2025

Codecov Report

Attention: Patch coverage is 90.20979% with 14 lines in your changes missing coverage. Please review.

Project coverage is 86.94%. Comparing base (f08db8f) to head (d177b49).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/sisl/utils/mathematics.py 80.55% 7 Missing ⚠️
src/sisl/_core/quaternion.py 72.22% 5 Missing ⚠️
src/sisl/physics/sparse.py 96.92% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #930      +/-   ##
==========================================
+ Coverage   86.86%   86.94%   +0.07%     
==========================================
  Files         412      412              
  Lines       54309    54313       +4     
==========================================
+ Hits        47176    47220      +44     
+ Misses       7133     7093      -40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zerothi zerothi merged commit b28b8de into main Jun 8, 2025
3 checks passed
@zerothi zerothi deleted the 924-rotation branch June 8, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rotating matrices cannot be back-rotated
1 participant